Coverage Report

Created: 2026-04-01 07:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavformat/g728dec.c
Line
Count
Source
1
/*
2
 * G.728 raw demuxer
3
 *
4
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with FFmpeg; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20
21
#include "avformat.h"
22
#include "demux.h"
23
#include "internal.h"
24
25
static int g728_read_header(AVFormatContext *s)
26
839
{
27
839
    AVStream *st = avformat_new_stream(s, NULL);
28
839
    if (!st)
29
0
        return AVERROR(ENOMEM);
30
31
839
    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
32
839
    st->codecpar->codec_id    = ffifmt(s->iformat)->raw_codec_id;
33
839
    st->codecpar->sample_rate = 8000;
34
839
    st->codecpar->bit_rate    = 16000;
35
839
    st->codecpar->block_align = 5;
36
839
    st->codecpar->ch_layout   = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
37
839
    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
38
39
839
    return 0;
40
839
}
41
42
static int g728_read_packet(AVFormatContext *s, AVPacket *pkt)
43
61.7k
{
44
61.7k
    int ret = av_get_packet(s->pb, pkt, 1020); // a size similar to RAW_PACKET_SIZE divisible by 5
45
61.7k
    pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
46
61.7k
    pkt->duration = (pkt->size / 5) * 20;
47
61.7k
    return ret;
48
61.7k
}
49
50
const FFInputFormat ff_g728_demuxer = {
51
    .p.name         = "g728",
52
    .p.long_name    = NULL_IF_CONFIG_SMALL("raw G.728"),
53
    .p.extensions   = "g728",
54
    .p.flags        = AVFMT_GENERIC_INDEX,
55
    .read_header    = g728_read_header,
56
    .read_packet    = g728_read_packet,
57
    .raw_codec_id   = AV_CODEC_ID_G728,
58
};