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

Function mpeg_decode_frame

libavcodec/mpeg12.c:2223–2273  ·  view source on GitHub ↗

handle buffering and image synchronisation */

Source from the content-addressed store, hash-verified

2221
2222/* handle buffering and image synchronisation */
2223static int mpeg_decode_frame(AVCodecContext *avctx,
2224 void *data, int *data_size,
2225 AVPacket *avpkt)
2226{
2227 const uint8_t *buf = avpkt->data;
2228 int buf_size = avpkt->size;
2229 Mpeg1Context *s = avctx->priv_data;
2230 AVFrame *picture = data;
2231 MpegEncContext *s2 = &s->mpeg_enc_ctx;
2232 dprintf(avctx, "fill_buffer\n");
2233
2234 if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
2235 /* special case for last picture */
2236 if (s2->low_delay==0 && s2->next_picture_ptr) {
2237 *picture= *(AVFrame*)s2->next_picture_ptr;
2238 s2->next_picture_ptr= NULL;
2239
2240 *data_size = sizeof(AVFrame);
2241 }
2242 return buf_size;
2243 }
2244
2245 if(s2->flags&CODEC_FLAG_TRUNCATED){
2246 int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
2247
2248 if( ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
2249 return buf_size;
2250 }
2251
2252#if 0
2253 if (s->repeat_field % 2 == 1) {
2254 s->repeat_field++;
2255 //fprintf(stderr,"\nRepeating last frame: %d -> %d! pict: %d %d", avctx->frame_number-1, avctx->frame_number,
2256 // s2->picture_number, s->repeat_field);
2257 if (avctx->flags & CODEC_FLAG_REPEAT_FIELD) {
2258 *data_size = sizeof(AVPicture);
2259 goto the_end;
2260 }
2261 }
2262#endif
2263
2264 if(s->mpeg_enc_ctx_allocated==0 && avctx->codec_tag == AV_RL32("VCR2"))
2265 vcr2_init_sequence(avctx);
2266
2267 s->slice_count= 0;
2268
2269 if(avctx->extradata && !avctx->frame_number)
2270 decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size);
2271
2272 return decode_chunks(avctx, picture, data_size, buf, buf_size);
2273}
2274
2275static int decode_chunks(AVCodecContext *avctx,
2276 AVFrame *picture, int *data_size,

Callers

nothing calls this directly

Calls 6

ff_mpeg1_find_frame_endFunction · 0.85
ff_combine_frameFunction · 0.85
vcr2_init_sequenceFunction · 0.85
decode_chunksFunction · 0.85
AV_RB32Function · 0.50
AV_RL32Function · 0.50

Tested by

no test coverage detected