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

Function mpeg_decode_mb

libavcodec/mpeg12dec.c:406–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404#define MT_DMV 3
405
406static int mpeg_decode_mb(Mpeg12SliceContext *const s, int *mb_skip_run)
407{
408 int i, j, k, cbp, val, mb_type, motion_type;
409 const int mb_block_count = 4 + (1 << s->c.chroma_format);
410 int ret;
411
412 ff_tlog(s->c.avctx, "decode_mb: x=%d y=%d\n", s->c.mb_x, s->c.mb_y);
413
414 av_assert2(s->c.mb_skipped == 0);
415
416 if ((*mb_skip_run)-- != 0) {
417 if (s->c.pict_type == AV_PICTURE_TYPE_P) {
418 s->c.mb_skipped = 1;
419 s->c.cur_pic.mb_type[s->c.mb_x + s->c.mb_y * s->c.mb_stride] =
420 MB_TYPE_SKIP | MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
421 } else {
422 int mb_type;
423
424 if (s->c.mb_x)
425 mb_type = s->c.cur_pic.mb_type[s->c.mb_x + s->c.mb_y * s->c.mb_stride - 1];
426 else
427 // FIXME not sure if this is allowed in MPEG at all
428 mb_type = s->c.cur_pic.mb_type[s->c.mb_width + (s->c.mb_y - 1) * s->c.mb_stride - 1];
429 if (IS_INTRA(mb_type)) {
430 av_log(s->c.avctx, AV_LOG_ERROR, "skip with previntra\n");
431 return AVERROR_INVALIDDATA;
432 }
433 s->c.cur_pic.mb_type[s->c.mb_x + s->c.mb_y * s->c.mb_stride] =
434 mb_type | MB_TYPE_SKIP;
435
436 if ((s->c.mv[0][0][0] | s->c.mv[0][0][1] | s->c.mv[1][0][0] | s->c.mv[1][0][1]) == 0)
437 s->c.mb_skipped = 1;
438 }
439
440 return 0;
441 }
442
443 switch (s->c.pict_type) {
444 default:
445 case AV_PICTURE_TYPE_I:
446 if (get_bits1(&s->gb) == 0) {
447 if (get_bits1(&s->gb) == 0) {
448 av_log(s->c.avctx, AV_LOG_ERROR,
449 "Invalid mb type in I-frame at %d %d\n",
450 s->c.mb_x, s->c.mb_y);
451 return AVERROR_INVALIDDATA;
452 }
453 mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
454 } else {
455 mb_type = MB_TYPE_INTRA;
456 }
457 break;
458 case AV_PICTURE_TYPE_P:
459 mb_type = get_vlc2(&s->gb, ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 1);
460 if (mb_type < 0) {
461 av_log(s->c.avctx, AV_LOG_ERROR,
462 "Invalid mb type in P-frame at %d %d\n", s->c.mb_x, s->c.mb_y);
463 return AVERROR_INVALIDDATA;

Callers 1

mpeg_decode_sliceFunction · 0.85

Calls 13

av_logFunction · 0.85
get_bits1Function · 0.85
get_vlc2Function · 0.85
mpeg_get_qscaleFunction · 0.85
skip_bits1Function · 0.85
mpeg_decode_motionFunction · 0.85
check_markerFunction · 0.85
mpeg2_decode_block_intraFunction · 0.85
get_dmvFunction · 0.85
mpeg1_decode_block_interFunction · 0.85

Tested by

no test coverage detected