FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/aac_parser.c
Date: 2024-04-19 17:50:32
Exec Total Coverage
Lines: 13 13 100.0%
Functions: 2 2 100.0%
Branches: 2 2 100.0%

Line Branch Exec Source
1 /*
2 * Audio and Video frame extraction
3 * Copyright (c) 2003 Fabrice Bellard
4 * Copyright (c) 2003 Michael Niedermayer
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "parser.h"
24 #include "aac_ac3_parser.h"
25 #include "adts_header.h"
26 #include "adts_parser.h"
27 #include "get_bits.h"
28 #include "mpeg4audio.h"
29
30 40999 static int aac_sync(uint64_t state, int *need_next_header, int *new_frame_start)
31 {
32 GetBitContext bits;
33 AACADTSHeaderInfo hdr;
34 int size;
35 union {
36 uint64_t u64;
37 uint8_t u8[8 + AV_INPUT_BUFFER_PADDING_SIZE];
38 } tmp;
39
40 40999 tmp.u64 = av_be2ne64(state);
41 40999 init_get_bits(&bits, tmp.u8 + 8 - AV_AAC_ADTS_HEADER_SIZE,
42 AV_AAC_ADTS_HEADER_SIZE * 8);
43
44
2/2
✓ Branch 1 taken 35142 times.
✓ Branch 2 taken 5857 times.
40999 if ((size = ff_adts_header_parse(&bits, &hdr)) < 0)
45 35142 return 0;
46 5857 *need_next_header = 0;
47 5857 *new_frame_start = 1;
48 5857 return size;
49 }
50
51 157 static av_cold int aac_parse_init(AVCodecParserContext *s1)
52 {
53 157 AACAC3ParseContext *s = s1->priv_data;
54 157 s->header_size = AV_AAC_ADTS_HEADER_SIZE;
55 157 s->sync = aac_sync;
56 157 return 0;
57 }
58
59
60 const AVCodecParser ff_aac_parser = {
61 .codec_ids = { AV_CODEC_ID_AAC },
62 .priv_data_size = sizeof(AACAC3ParseContext),
63 .parser_init = aac_parse_init,
64 .parser_parse = ff_aac_ac3_parse,
65 .parser_close = ff_parse_close,
66 };
67