MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_mpa_decode_header

Function ff_mpa_decode_header

libavcodec/mpegaudio_parser.c:44–79  ·  view source on GitHub ↗

useful helper to get mpeg audio stream infos. Return -1 if error in header, otherwise the coded frame size in bytes */

Source from the content-addressed store, hash-verified

42/* useful helper to get mpeg audio stream infos. Return -1 if error in
43 header, otherwise the coded frame size in bytes */
44int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate)
45{
46 MPADecodeHeader s1, *s = &s1;
47
48 if (ff_mpa_check_header(head) != 0)
49 return -1;
50
51 if (ff_mpegaudio_decode_header(s, head) != 0) {
52 return -1;
53 }
54
55 switch(s->layer) {
56 case 1:
57 avctx->codec_id = CODEC_ID_MP1;
58 *frame_size = 384;
59 break;
60 case 2:
61 avctx->codec_id = CODEC_ID_MP2;
62 *frame_size = 1152;
63 break;
64 default:
65 case 3:
66 avctx->codec_id = CODEC_ID_MP3;
67 if (s->lsf)
68 *frame_size = 576;
69 else
70 *frame_size = 1152;
71 break;
72 }
73
74 *sample_rate = s->sample_rate;
75 *channels = s->nb_channels;
76 *bit_rate = s->bit_rate;
77 avctx->sub_id = s->layer;
78 return s->frame_size;
79}
80
81static int mpegaudio_parse(AVCodecParserContext *s1,
82 AVCodecContext *avctx,

Callers 2

mp3_read_probeFunction · 0.85
mpegaudio_parseFunction · 0.85

Calls 2

ff_mpa_check_headerFunction · 0.85

Tested by

no test coverage detected