FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/g728dec.c
Date: 2025-08-19 23:55:23
Exec Total Coverage
Lines: 16 17 94.1%
Functions: 2 2 100.0%
Branches: 1 2 50.0%

Line Branch Exec 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 1 static int g728_read_header(AVFormatContext *s)
26 {
27 1 AVStream *st = avformat_new_stream(s, NULL);
28
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!st)
29 return AVERROR(ENOMEM);
30
31 1 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
32 1 st->codecpar->codec_id = ffifmt(s->iformat)->raw_codec_id;
33 1 st->codecpar->sample_rate = 8000;
34 1 st->codecpar->bit_rate = 16000;
35 1 st->codecpar->block_align = 5;
36 1 st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
37 1 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
38
39 1 return 0;
40 }
41
42 4 static int g728_read_packet(AVFormatContext *s, AVPacket *pkt)
43 {
44 4 int ret = av_get_packet(s->pb, pkt, 1020); // a size similar to RAW_PACKET_SIZE divisible by 5
45 4 pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
46 4 pkt->duration = (pkt->size / 5) * 20;
47 4 return ret;
48 }
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 };
59