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

Function mpegaudio_parse

libavcodec/mpegaudio_parser.c:81–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81static int mpegaudio_parse(AVCodecParserContext *s1,
82 AVCodecContext *avctx,
83 const uint8_t **poutbuf, int *poutbuf_size,
84 const uint8_t *buf, int buf_size)
85{
86 MpegAudioParseContext *s = s1->priv_data;
87 ParseContext *pc = &s->pc;
88 uint32_t state= pc->state;
89 int i;
90 int next= END_NOT_FOUND;
91
92 for(i=0; i<buf_size; ){
93 if(s->frame_size){
94 int inc= FFMIN(buf_size - i, s->frame_size);
95 i += inc;
96 s->frame_size -= inc;
97
98 if(!s->frame_size){
99 next= i;
100 break;
101 }
102 }else{
103 while(i<buf_size){
104 int ret, sr, channels, bit_rate, frame_size;
105
106 state= (state<<8) + buf[i++];
107
108 ret = ff_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate);
109 if (ret < 4) {
110 s->header_count= -2;
111 } else {
112 if((state&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header)
113 s->header_count= -3;
114 s->header= state;
115 s->header_count++;
116 s->frame_size = ret-4;
117
118 if(s->header_count > 1){
119 avctx->sample_rate= sr;
120 avctx->channels = channels;
121 avctx->frame_size = frame_size;
122 avctx->bit_rate = bit_rate;
123 }
124 break;
125 }
126 }
127 }
128 }
129
130 pc->state= state;
131 if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
132 *poutbuf = NULL;
133 *poutbuf_size = 0;
134 return buf_size;
135 }
136
137 *poutbuf = buf;
138 *poutbuf_size = buf_size;

Callers

nothing calls this directly

Calls 2

ff_mpa_decode_headerFunction · 0.85
ff_combine_frameFunction · 0.85

Tested by

no test coverage detected