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

Function decode_chunks

libavcodec/mpeg12.c:2275–2484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2273}
2274
2275static int decode_chunks(AVCodecContext *avctx,
2276 AVFrame *picture, int *data_size,
2277 const uint8_t *buf, int buf_size)
2278{
2279 Mpeg1Context *s = avctx->priv_data;
2280 MpegEncContext *s2 = &s->mpeg_enc_ctx;
2281 const uint8_t *buf_ptr = buf;
2282 const uint8_t *buf_end = buf + buf_size;
2283 int ret, input_size;
2284 int last_code= 0;
2285
2286 for(;;) {
2287 /* find next start code */
2288 uint32_t start_code = -1;
2289 buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code);
2290 if (start_code > 0x1ff){
2291 if(s2->pict_type != FF_B_TYPE || avctx->skip_frame <= AVDISCARD_DEFAULT){
2292 if(avctx->thread_count > 1){
2293 int i;
2294
2295 avctx->execute(avctx, slice_decode_thread, &s2->thread_context[0], NULL, s->slice_count, sizeof(void*));
2296 for(i=0; i<s->slice_count; i++)
2297 s2->error_count += s2->thread_context[i]->error_count;
2298 }
2299
2300 if (CONFIG_MPEG_VDPAU_DECODER && avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
2301 ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count);
2302
2303 if (slice_end(avctx, picture)) {
2304 if(s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice
2305 *data_size = sizeof(AVPicture);
2306 }
2307 }
2308 s2->pict_type= 0;
2309 return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index);
2310 }
2311
2312 input_size = buf_end - buf_ptr;
2313
2314 if(avctx->debug & FF_DEBUG_STARTCODE){
2315 av_log(avctx, AV_LOG_DEBUG, "%3X at %td left %d\n", start_code, buf_ptr-buf, input_size);
2316 }
2317
2318 /* prepare data for next start code */
2319 switch(start_code) {
2320 case SEQ_START_CODE:
2321 if(last_code == 0){
2322 mpeg1_decode_sequence(avctx, buf_ptr,
2323 input_size);
2324 s->sync=1;
2325 }else{
2326 av_log(avctx, AV_LOG_ERROR, "ignoring SEQ_START_CODE after %X\n", last_code);
2327 }
2328 break;
2329
2330 case PICTURE_START_CODE:
2331 if(last_code == 0 || last_code == SLICE_MIN_START_CODE){
2332 if(mpeg_decode_postinit(avctx) < 0){

Callers 1

mpeg_decode_frameFunction · 0.85

Calls 15

ff_find_start_codeFunction · 0.85
slice_endFunction · 0.85
av_logFunction · 0.85
mpeg1_decode_sequenceFunction · 0.85
mpeg_decode_postinitFunction · 0.85
mpeg1_decode_pictureFunction · 0.85
init_get_bitsFunction · 0.85
get_bitsFunction · 0.85

Tested by

no test coverage detected