History

avcodec/mpegutils: Don't use MB_TYPE_L[01] for mpegvideo

MB_TYPE_L[01] is based upon H.264 terminology (it stands for list); yet the mpegvideo based decoders don't have lists of reference frames, they have at most one forward and one backward reference. So use terminology based upon this. This also has a second advantage: MB_TYPE_L[01] is actually an OR of two flags (which are set independently for H.264, but aren't for mpegvideo). Switching to different flags makes the flags fit into an int16_t, which will be useful in future commits. The only downside to this is a very small amount of code in error_resilience.c and mpegutils.c (the only code shared between the H.264 decoder and mpegvideo).

Andreas Rheinhardt committed 2 years ago

Commit f5d5b801 parent 07ae09b12 files · +123 −111Browse files

Unified · Split

12 files
  1. libavcodec/error_resilience.c +4 −4
  2. libavcodec/h261dec.c +2 −2
  3. libavcodec/ituh263dec.c +22 −22
  4. libavcodec/ituh263enc.c +2 −2
  5. libavcodec/mpeg12dec.c +22 −22
  6. libavcodec/mpeg4video.c +3 −3
  7. libavcodec/mpeg4videodec.c +25 −28
  8. libavcodec/mpegutils.c +14 −9
  9. libavcodec/mpegutils.h +10 −0
  10. libavcodec/msmpeg4dec.c +4 −4
  11. libavcodec/rv34.c +9 −9
  12. libavcodec/wmv2dec.c +6 −6
libavcodec/error_resilience.c+4−4
@@ -902,6 +902,7 @@ void ff_er_frame_end(ERContext *s, int *decode_error_flags) · 901 unmodified lines
902 int threshold = 50;902 int threshold = 50;
903 int is_intra_likely;903 int is_intra_likely;
904 int size = s->b8_stride * 2 * s->mb_height;904 int size = s->b8_stride * 2 * s->mb_height;
905 int guessed_mb_type;
905 906
906 /* We do not support ER of field pictures yet,907 /* We do not support ER of field pictures yet,
907 * though it should not crash if enabled. */908 * though it should not crash if enabled. */
@@ -1117,16 +1118,15 @@ void ff_er_frame_end(ERContext *s, int *decode_error_flags) · 209 unmodified lines
1117 is_intra_likely = is_intra_more_likely(s);1118 is_intra_likely = is_intra_more_likely(s);
1118 1119
1119 /* set unknown mb-type to most likely */1120 /* set unknown mb-type to most likely */
1121 guessed_mb_type = is_intra_likely ? MB_TYPE_INTRA4x4 :
1122 (MB_TYPE_16x16 | (s->avctx->codec_id == AV_CODEC_ID_H264 ? MB_TYPE_L0 : MB_TYPE_FORWARD_MV));
1120 for (i = 0; i < s->mb_num; i++) {1123 for (i = 0; i < s->mb_num; i++) {
1121 const int mb_xy = s->mb_index2xy[i];1124 const int mb_xy = s->mb_index2xy[i];
1122 int error = s->error_status_table[mb_xy];1125 int error = s->error_status_table[mb_xy];
1123 if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))1126 if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))
1124 continue;1127 continue;
1125 1128
1126 if (is_intra_likely)1129 s->cur_pic.mb_type[mb_xy] = guessed_mb_type;
1127 s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
1128 else
1129 s->cur_pic.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;
1130 }1130 }
1131 1131
1132 // change inter to intra blocks if no reference frames are available1132 // change inter to intra blocks if no reference frames are available
libavcodec/h261dec.c+2−2
@@ -232,7 +232,7 @@ static int h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2) · 231 unmodified lines
232 232
233 s->mv_dir = MV_DIR_FORWARD;233 s->mv_dir = MV_DIR_FORWARD;
234 s->mv_type = MV_TYPE_16X16;234 s->mv_type = MV_TYPE_16X16;
235 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;235 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
236 s->mv[0][0][0] = 0;236 s->mv[0][0][0] = 0;
237 s->mv[0][0][1] = 0;237 s->mv[0][0][1] = 0;
238 s->mb_skipped = 1;238 s->mb_skipped = 1;
@@ -460,7 +460,7 @@ static int h261_decode_mb(H261DecContext *h) · 221 unmodified lines
460 //set motion vectors460 //set motion vectors
461 s->mv_dir = MV_DIR_FORWARD;461 s->mv_dir = MV_DIR_FORWARD;
462 s->mv_type = MV_TYPE_16X16;462 s->mv_type = MV_TYPE_16X16;
463 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;463 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
464 s->mv[0][0][0] = h->current_mv_x * 2; // gets divided by 2 in motion compensation464 s->mv[0][0][0] = h->current_mv_x * 2; // gets divided by 2 in motion compensation
465 s->mv[0][0][1] = h->current_mv_y * 2;465 s->mv[0][0][1] = h->current_mv_y * 2;
466 466
libavcodec/ituh263dec.c+22−22
@@ -60,18 +60,18 @@ · 59 unmodified lines
60#define CBPC_B_VLC_BITS 360#define CBPC_B_VLC_BITS 3
61 61
62static const int h263_mb_type_b_map[15]= {62static const int h263_mb_type_b_map[15]= {
63 MB_TYPE_DIRECT2 | MB_TYPE_L0L1,63 MB_TYPE_DIRECT2 | MB_TYPE_BIDIR_MV,
64 MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP,64 MB_TYPE_DIRECT2 | MB_TYPE_BIDIR_MV | MB_TYPE_CBP,
65 MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT,65 MB_TYPE_DIRECT2 | MB_TYPE_BIDIR_MV | MB_TYPE_CBP | MB_TYPE_QUANT,
66 MB_TYPE_L0 | MB_TYPE_16x16,66 MB_TYPE_FORWARD_MV | MB_TYPE_16x16,
67 MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_16x16,67 MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_16x16,
68 MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,68 MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
69 MB_TYPE_L1 | MB_TYPE_16x16,69 MB_TYPE_BACKWARD_MV | MB_TYPE_16x16,
70 MB_TYPE_L1 | MB_TYPE_CBP | MB_TYPE_16x16,70 MB_TYPE_BACKWARD_MV | MB_TYPE_CBP | MB_TYPE_16x16,
71 MB_TYPE_L1 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,71 MB_TYPE_BACKWARD_MV | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
72 MB_TYPE_L0L1 | MB_TYPE_16x16,72 MB_TYPE_BIDIR_MV | MB_TYPE_16x16,
73 MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_16x16,73 MB_TYPE_BIDIR_MV | MB_TYPE_CBP | MB_TYPE_16x16,
74 MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,74 MB_TYPE_BIDIR_MV | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
75 0, //stuffing75 0, //stuffing
76 MB_TYPE_INTRA4x4 | MB_TYPE_CBP,76 MB_TYPE_INTRA4x4 | MB_TYPE_CBP,
77 MB_TYPE_INTRA4x4 | MB_TYPE_CBP | MB_TYPE_QUANT,77 MB_TYPE_INTRA4x4 | MB_TYPE_CBP | MB_TYPE_QUANT,
@@ -363,7 +363,7 @@ static void preview_obmc(MpegEncContext *s){ · 285 unmodified lines
363 mot_val[1 ]= mot_val[3 ]=363 mot_val[1 ]= mot_val[3 ]=
364 mot_val[1+stride]= mot_val[3+stride]= 0;364 mot_val[1+stride]= mot_val[3+stride]= 0;
365 365
366 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;366 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
367 goto end;367 goto end;
368 }368 }
369 cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);369 cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 2);
@@ -382,7 +382,7 @@ static void preview_obmc(MpegEncContext *s){ · 12 unmodified lines
382 }382 }
383 383
384 if ((cbpc & 16) == 0) {384 if ((cbpc & 16) == 0) {
385 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;385 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
386 /* 16x16 motion prediction */386 /* 16x16 motion prediction */
387 mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);387 mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
388 if (s->umvplus)388 if (s->umvplus)
@@ -400,7 +400,7 @@ static void preview_obmc(MpegEncContext *s){ · 11 unmodified lines
400 mot_val[1 ]= mot_val[3 ]=400 mot_val[1 ]= mot_val[3 ]=
401 mot_val[1+stride]= mot_val[3+stride]= my;401 mot_val[1+stride]= mot_val[3+stride]= my;
402 } else {402 } else {
403 s->cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;403 s->cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
404 for(i=0;i<4;i++) {404 for(i=0;i<4;i++) {
405 mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);405 mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
406 if (s->umvplus)406 if (s->umvplus)
@@ -763,7 +763,7 @@ static int set_direct_mv(MpegEncContext *s) · 356 unmodified lines
763 s->mv_type = MV_TYPE_8X8;763 s->mv_type = MV_TYPE_8X8;
764 for (i = 0; i < 4; i++)764 for (i = 0; i < 4; i++)
765 set_one_direct_mv(s, p, i);765 set_one_direct_mv(s, p, i);
766 return MB_TYPE_DIRECT2 | MB_TYPE_8x8 | MB_TYPE_L0L1;766 return MB_TYPE_DIRECT2 | MB_TYPE_8x8 | MB_TYPE_BIDIR_MV;
767 } else {767 } else {
768 set_one_direct_mv(s, p, 0);768 set_one_direct_mv(s, p, 0);
769 s->mv[0][1][0] =769 s->mv[0][1][0] =
@@ -780,7 +780,7 @@ static int set_direct_mv(MpegEncContext *s) · 10 unmodified lines
780 s->mv[1][3][1] = s->mv[1][0][1];780 s->mv[1][3][1] = s->mv[1][0][1];
781 s->mv_type = MV_TYPE_8X8;781 s->mv_type = MV_TYPE_8X8;
782 // Note see prev line782 // Note see prev line
783 return MB_TYPE_DIRECT2 | MB_TYPE_16x16 | MB_TYPE_L0L1;783 return MB_TYPE_DIRECT2 | MB_TYPE_16x16 | MB_TYPE_BIDIR_MV;
784 }784 }
785}785}
786 786
@@ -803,7 +803,7 @@ int ff_h263_decode_mb(MpegEncContext *s, · 16 unmodified lines
803 s->block_last_index[i] = -1;803 s->block_last_index[i] = -1;
804 s->mv_dir = MV_DIR_FORWARD;804 s->mv_dir = MV_DIR_FORWARD;
805 s->mv_type = MV_TYPE_16X16;805 s->mv_type = MV_TYPE_16X16;
806 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;806 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
807 s->mv[0][0][0] = 0;807 s->mv[0][0][0] = 0;
808 s->mv[0][0][1] = 0;808 s->mv[0][0][1] = 0;
809 s->mb_skipped = !(s->obmc | s->loop_filter);809 s->mb_skipped = !(s->obmc | s->loop_filter);
@@ -841,7 +841,7 @@ int ff_h263_decode_mb(MpegEncContext *s, · 31 unmodified lines
841 841
842 s->mv_dir = MV_DIR_FORWARD;842 s->mv_dir = MV_DIR_FORWARD;
843 if ((cbpc & 16) == 0) {843 if ((cbpc & 16) == 0) {
844 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;844 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
845 /* 16x16 motion prediction */845 /* 16x16 motion prediction */
846 s->mv_type = MV_TYPE_16X16;846 s->mv_type = MV_TYPE_16X16;
847 ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);847 ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
@@ -866,7 +866,7 @@ int ff_h263_decode_mb(MpegEncContext *s, · 18 unmodified lines
866 if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)866 if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
867 skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */867 skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
868 } else {868 } else {
869 s->cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;869 s->cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
870 s->mv_type = MV_TYPE_8X8;870 s->mv_type = MV_TYPE_8X8;
871 for(i=0;i<4;i++) {871 for(i=0;i<4;i++) {
872 mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);872 mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
@@ -952,7 +952,7 @@ int ff_h263_decode_mb(MpegEncContext *s, · 79 unmodified lines
952 s->mv_type= MV_TYPE_16X16;952 s->mv_type= MV_TYPE_16X16;
953//FIXME UMV953//FIXME UMV
954 954
955 if(USES_LIST(mb_type, 0)){955 if (HAS_FORWARD_MV(mb_type)) {
956 int16_t *mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);956 int16_t *mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
957 s->mv_dir = MV_DIR_FORWARD;957 s->mv_dir = MV_DIR_FORWARD;
958 958
@@ -979,7 +979,7 @@ int ff_h263_decode_mb(MpegEncContext *s, · 20 unmodified lines
979 mot_val[1 ]= mot_val[3 ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;979 mot_val[1 ]= mot_val[3 ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
980 }980 }
981 981
982 if(USES_LIST(mb_type, 1)){982 if (HAS_BACKWARD_MV(mb_type)) {
983 int16_t *mot_val= ff_h263_pred_motion(s, 0, 1, &pred_x, &pred_y);983 int16_t *mot_val= ff_h263_pred_motion(s, 0, 1, &pred_x, &pred_y);
984 s->mv_dir |= MV_DIR_BACKWARD;984 s->mv_dir |= MV_DIR_BACKWARD;
985 985
libavcodec/ituh263enc.c+2−2
@@ -697,11 +697,11 @@ void ff_h263_update_mb(MpegEncContext *s) · 696 unmodified lines
697 s->cur_pic.mbskip_table[mb_xy] = s->mb_skipped;697 s->cur_pic.mbskip_table[mb_xy] = s->mb_skipped;
698 698
699 if (s->mv_type == MV_TYPE_8X8)699 if (s->mv_type == MV_TYPE_8X8)
700 s->cur_pic.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_8x8;700 s->cur_pic.mb_type[mb_xy] = MB_TYPE_FORWARD_MV | MB_TYPE_8x8;
701 else if(s->mb_intra)701 else if(s->mb_intra)
702 s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA;702 s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA;
703 else703 else
704 s->cur_pic.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_16x16;704 s->cur_pic.mb_type[mb_xy] = MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
705 705
706 ff_h263_update_motion_val(s);706 ff_h263_update_motion_val(s);
707}707}
libavcodec/mpeg12dec.c+22−22
@@ -97,26 +97,26 @@ typedef struct Mpeg1Context { · 96 unmodified lines
97 97
98static const uint32_t ptype2mb_type[7] = {98static const uint32_t ptype2mb_type[7] = {
99 MB_TYPE_INTRA,99 MB_TYPE_INTRA,
100 MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,100 MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
101 MB_TYPE_L0,101 MB_TYPE_FORWARD_MV,
102 MB_TYPE_L0 | MB_TYPE_CBP,102 MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
103 MB_TYPE_QUANT | MB_TYPE_INTRA,103 MB_TYPE_QUANT | MB_TYPE_INTRA,
104 MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,104 MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
105 MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,105 MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
106};106};
107 107
108static const uint32_t btype2mb_type[11] = {108static const uint32_t btype2mb_type[11] = {
109 MB_TYPE_INTRA,109 MB_TYPE_INTRA,
110 MB_TYPE_L1,110 MB_TYPE_BACKWARD_MV,
111 MB_TYPE_L1 | MB_TYPE_CBP,111 MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
112 MB_TYPE_L0,112 MB_TYPE_FORWARD_MV,
113 MB_TYPE_L0 | MB_TYPE_CBP,113 MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
114 MB_TYPE_L0L1,114 MB_TYPE_BIDIR_MV,
115 MB_TYPE_L0L1 | MB_TYPE_CBP,115 MB_TYPE_BIDIR_MV | MB_TYPE_CBP,
116 MB_TYPE_QUANT | MB_TYPE_INTRA,116 MB_TYPE_QUANT | MB_TYPE_INTRA,
117 MB_TYPE_QUANT | MB_TYPE_L1 | MB_TYPE_CBP,117 MB_TYPE_QUANT | MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
118 MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,118 MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
119 MB_TYPE_QUANT | MB_TYPE_L0L1 | MB_TYPE_CBP,119 MB_TYPE_QUANT | MB_TYPE_BIDIR_MV | MB_TYPE_CBP,
120};120};
121 121
122/* as H.263, but only 17 codes */122/* as H.263, but only 17 codes */
@@ -438,7 +438,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 315 unmodified lines
438 if (s->pict_type == AV_PICTURE_TYPE_P) {438 if (s->pict_type == AV_PICTURE_TYPE_P) {
439 s->mb_skipped = 1;439 s->mb_skipped = 1;
440 s->cur_pic.mb_type[s->mb_x + s->mb_y * s->mb_stride] =440 s->cur_pic.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
441 MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;441 MB_TYPE_SKIP | MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
442 } else {442 } else {
443 int mb_type;443 int mb_type;
444 444
@@ -579,7 +579,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 134 unmodified lines
579 s->mv[0][0][0] = 0;579 s->mv[0][0][0] = 0;
580 s->mv[0][0][1] = 0;580 s->mv[0][0][1] = 0;
581 } else {581 } else {
582 av_assert2(mb_type & MB_TYPE_L0L1);582 av_assert2(mb_type & MB_TYPE_BIDIR_MV);
583 // FIXME decide if MBs in field pictures are MB_TYPE_INTERLACED583 // FIXME decide if MBs in field pictures are MB_TYPE_INTERLACED
584 /* get additional motion vector type */584 /* get additional motion vector type */
585 if (s->picture_structure == PICT_FRAME && s->frame_pred_frame_dct) {585 if (s->picture_structure == PICT_FRAME && s->frame_pred_frame_dct) {
@@ -594,7 +594,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 8 unmodified lines
594 s->qscale = mpeg_get_qscale(s);594 s->qscale = mpeg_get_qscale(s);
595 595
596 /* motion vectors */596 /* motion vectors */
597 s->mv_dir = (mb_type >> 13) & 3;597 s->mv_dir = MB_TYPE_MV_2_MV_DIR(mb_type);
598 ff_tlog(s->avctx, "motion_type=%d\n", motion_type);598 ff_tlog(s->avctx, "motion_type=%d\n", motion_type);
599 switch (motion_type) {599 switch (motion_type) {
600 case MT_FRAME: /* or MT_16X8 */600 case MT_FRAME: /* or MT_16X8 */
@@ -602,7 +602,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 1 unmodified line
602 mb_type |= MB_TYPE_16x16;602 mb_type |= MB_TYPE_16x16;
603 s->mv_type = MV_TYPE_16X16;603 s->mv_type = MV_TYPE_16X16;
604 for (i = 0; i < 2; i++) {604 for (i = 0; i < 2; i++) {
605 if (USES_LIST(mb_type, i)) {605 if (HAS_MV(mb_type, i)) {
606 /* MT_FRAME */606 /* MT_FRAME */
607 s->mv[i][0][0] =607 s->mv[i][0][0] =
608 s->last_mv[i][0][0] =608 s->last_mv[i][0][0] =
@@ -625,7 +625,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 16 unmodified lines
625 mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;625 mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
626 s->mv_type = MV_TYPE_16X8;626 s->mv_type = MV_TYPE_16X8;
627 for (i = 0; i < 2; i++) {627 for (i = 0; i < 2; i++) {
628 if (USES_LIST(mb_type, i)) {628 if (HAS_MV(mb_type, i)) {
629 /* MT_16X8 */629 /* MT_16X8 */
630 for (j = 0; j < 2; j++) {630 for (j = 0; j < 2; j++) {
631 s->field_select[i][j] = get_bits1(&s->gb);631 s->field_select[i][j] = get_bits1(&s->gb);
@@ -645,7 +645,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 13 unmodified lines
645 if (s->picture_structure == PICT_FRAME) {645 if (s->picture_structure == PICT_FRAME) {
646 mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;646 mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
647 for (i = 0; i < 2; i++) {647 for (i = 0; i < 2; i++) {
648 if (USES_LIST(mb_type, i)) {648 if (HAS_MV(mb_type, i)) {
649 for (j = 0; j < 2; j++) {649 for (j = 0; j < 2; j++) {
650 s->field_select[i][j] = get_bits1(&s->gb);650 s->field_select[i][j] = get_bits1(&s->gb);
651 val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],651 val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
@@ -665,7 +665,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 13 unmodified lines
665 av_assert0(!s->progressive_sequence);665 av_assert0(!s->progressive_sequence);
666 mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;666 mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
667 for (i = 0; i < 2; i++) {667 for (i = 0; i < 2; i++) {
668 if (USES_LIST(mb_type, i)) {668 if (HAS_MV(mb_type, i)) {
669 s->field_select[i][0] = get_bits1(&s->gb);669 s->field_select[i][0] = get_bits1(&s->gb);
670 for (k = 0; k < 2; k++) {670 for (k = 0; k < 2; k++) {
671 val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],671 val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
@@ -685,7 +685,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) · 13 unmodified lines
685 }685 }
686 s->mv_type = MV_TYPE_DMV;686 s->mv_type = MV_TYPE_DMV;
687 for (i = 0; i < 2; i++) {687 for (i = 0; i < 2; i++) {
688 if (USES_LIST(mb_type, i)) {688 if (HAS_MV(mb_type, i)) {
689 int dmx, dmy, mx, my, m;689 int dmx, dmy, mx, my, m;
690 const int my_shift = s->picture_structure == PICT_FRAME;690 const int my_shift = s->picture_structure == PICT_FRAME;
691 691
libavcodec/mpeg4video.c+3−3
@@ -141,7 +141,7 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my) · 140 unmodified lines
141 s->mv_type = MV_TYPE_8X8;141 s->mv_type = MV_TYPE_8X8;
142 for (i = 0; i < 4; i++)142 for (i = 0; i < 4; i++)
143 ff_mpeg4_set_one_direct_mv(s, mx, my, i);143 ff_mpeg4_set_one_direct_mv(s, mx, my, i);
144 return MB_TYPE_DIRECT2 | MB_TYPE_8x8 | MB_TYPE_L0L1;144 return MB_TYPE_DIRECT2 | MB_TYPE_8x8 | MB_TYPE_BIDIR_MV;
145 } else if (IS_INTERLACED(colocated_mb_type)) {145 } else if (IS_INTERLACED(colocated_mb_type)) {
146 s->mv_type = MV_TYPE_FIELD;146 s->mv_type = MV_TYPE_FIELD;
147 for (i = 0; i < 2; i++) {147 for (i = 0; i < 2; i++) {
@@ -169,7 +169,7 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my) · 21 unmodified lines
169 (time_pb - time_pp) / time_pp;169 (time_pb - time_pp) / time_pp;
170 }170 }
171 return MB_TYPE_DIRECT2 | MB_TYPE_16x8 |171 return MB_TYPE_DIRECT2 | MB_TYPE_16x8 |
172 MB_TYPE_L0L1 | MB_TYPE_INTERLACED;172 MB_TYPE_BIDIR_MV | MB_TYPE_INTERLACED;
173 } else {173 } else {
174 ff_mpeg4_set_one_direct_mv(s, mx, my, 0);174 ff_mpeg4_set_one_direct_mv(s, mx, my, 0);
175 s->mv[0][1][0] =175 s->mv[0][1][0] =
@@ -190,6 +190,6 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my) · 14 unmodified lines
190 else190 else
191 s->mv_type = MV_TYPE_8X8;191 s->mv_type = MV_TYPE_8X8;
192 // Note see prev line192 // Note see prev line
193 return MB_TYPE_DIRECT2 | MB_TYPE_16x16 | MB_TYPE_L0L1;193 return MB_TYPE_DIRECT2 | MB_TYPE_16x16 | MB_TYPE_BIDIR_MV;
194 }194 }
195}195}
libavcodec/mpeg4videodec.c+25−28
@@ -68,10 +68,10 @@ static VLCElem studio_chroma_dc[528]; · 67 unmodified lines
68static const uint8_t mpeg4_block_count[4] = { 0, 6, 8, 12 };68static const uint8_t mpeg4_block_count[4] = { 0, 6, 8, 12 };
69 69
70static const int mb_type_b_map[4] = {70static const int mb_type_b_map[4] = {
71 MB_TYPE_DIRECT2 | MB_TYPE_L0L1,71 MB_TYPE_DIRECT2 | MB_TYPE_BIDIR_MV,
72 MB_TYPE_L0L1 | MB_TYPE_16x16,72 MB_TYPE_BIDIR_MV | MB_TYPE_16x16,
73 MB_TYPE_L1 | MB_TYPE_16x16,73 MB_TYPE_BACKWARD_MV | MB_TYPE_16x16,
74 MB_TYPE_L0 | MB_TYPE_16x16,74 MB_TYPE_FORWARD_MV | MB_TYPE_16x16,
75};75};
76 76
77static void gmc1_motion(MpegEncContext *s, const Mpeg4DecContext *ctx,77static void gmc1_motion(MpegEncContext *s, const Mpeg4DecContext *ctx,
@@ -1010,13 +1010,13 @@ try_again: · 932 unmodified lines
1010 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |1010 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |
1011 MB_TYPE_16x16 |1011 MB_TYPE_16x16 |
1012 MB_TYPE_GMC |1012 MB_TYPE_GMC |
1013 MB_TYPE_L0;1013 MB_TYPE_FORWARD_MV;
1014 mx = get_amv(ctx, 0);1014 mx = get_amv(ctx, 0);
1015 my = get_amv(ctx, 1);1015 my = get_amv(ctx, 1);
1016 } else {1016 } else {
1017 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |1017 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |
1018 MB_TYPE_16x16 |1018 MB_TYPE_16x16 |
1019 MB_TYPE_L0;1019 MB_TYPE_FORWARD_MV;
1020 mx = my = 0;1020 mx = my = 0;
1021 }1021 }
1022 mot_val[0] =1022 mot_val[0] =
@@ -1081,13 +1081,13 @@ try_again: · 58 unmodified lines
1081 if (my >= 0xffff)1081 if (my >= 0xffff)
1082 return AVERROR_INVALIDDATA;1082 return AVERROR_INVALIDDATA;
1083 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 |1083 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 |
1084 MB_TYPE_L0;1084 MB_TYPE_FORWARD_MV;
1085 } else {1085 } else {
1086 mx = get_amv(ctx, 0);1086 mx = get_amv(ctx, 0);
1087 my = get_amv(ctx, 1);1087 my = get_amv(ctx, 1);
1088 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 |1088 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 |
1089 MB_TYPE_GMC |1089 MB_TYPE_GMC |
1090 MB_TYPE_L0;1090 MB_TYPE_FORWARD_MV;
1091 }1091 }
1092 1092
1093 mot_val[0] =1093 mot_val[0] =
@@ -1101,7 +1101,7 @@ try_again: · 7 unmodified lines
1101 } else {1101 } else {
1102 int i;1102 int i;
1103 s->cur_pic.mb_type[xy] = MB_TYPE_8x8 |1103 s->cur_pic.mb_type[xy] = MB_TYPE_8x8 |
1104 MB_TYPE_L0;1104 MB_TYPE_FORWARD_MV;
1105 for (i = 0; i < 4; i++) {1105 for (i = 0; i < 4; i++) {
1106 int16_t *mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);1106 int16_t *mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
1107 mx = ff_h263_decode_motion(s, pred_x, s->f_code);1107 mx = ff_h263_decode_motion(s, pred_x, s->f_code);
@@ -1675,16 +1675,15 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 567 unmodified lines
1675 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |1675 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |
1676 MB_TYPE_GMC |1676 MB_TYPE_GMC |
1677 MB_TYPE_16x16 |1677 MB_TYPE_16x16 |
1678 MB_TYPE_L0;1678 MB_TYPE_FORWARD_MV;
1679 s->mcsel = 1;1679 s->mcsel = 1;
1680 s->mv[0][0][0] = get_amv(ctx, 0);1680 s->mv[0][0][0] = get_amv(ctx, 0);
1681 s->mv[0][0][1] = get_amv(ctx, 1);1681 s->mv[0][0][1] = get_amv(ctx, 1);
1682 s->cur_pic.mbskip_table[xy] = 0;1682 s->cur_pic.mbskip_table[xy] = 0;
1683 s->mb_skipped = 0;1683 s->mb_skipped = 0;
1684 } else {1684 } else {
1685 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |1685 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 |
1686 MB_TYPE_16x16 |1686 MB_TYPE_FORWARD_MV;
1687 MB_TYPE_L0;
1688 s->mcsel = 0;1687 s->mcsel = 0;
1689 s->mv[0][0][0] = 0;1688 s->mv[0][0][0] = 0;
1690 s->mv[0][0][1] = 0;1689 s->mv[0][0][1] = 0;
@@ -1729,9 +1728,8 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 38 unmodified lines
1729 s->mv_dir = MV_DIR_FORWARD;1728 s->mv_dir = MV_DIR_FORWARD;
1730 if ((cbpc & 16) == 0) {1729 if ((cbpc & 16) == 0) {
1731 if (s->mcsel) {1730 if (s->mcsel) {
1732 s->cur_pic.mb_type[xy] = MB_TYPE_GMC |1731 s->cur_pic.mb_type[xy] = MB_TYPE_GMC | MB_TYPE_16x16 |
1733 MB_TYPE_16x16 |1732 MB_TYPE_FORWARD_MV;
1734 MB_TYPE_L0;
1735 /* 16x16 global motion prediction */1733 /* 16x16 global motion prediction */
1736 s->mv_type = MV_TYPE_16X16;1734 s->mv_type = MV_TYPE_16X16;
1737 mx = get_amv(ctx, 0);1735 mx = get_amv(ctx, 0);
@@ -1739,8 +1737,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 1 unmodified line
1739 s->mv[0][0][0] = mx;1737 s->mv[0][0][0] = mx;
1740 s->mv[0][0][1] = my;1738 s->mv[0][0][1] = my;
1741 } else if ((!s->progressive_sequence) && get_bits1(&s->gb)) {1739 } else if ((!s->progressive_sequence) && get_bits1(&s->gb)) {
1742 s->cur_pic.mb_type[xy] = MB_TYPE_16x8 |1740 s->cur_pic.mb_type[xy] = MB_TYPE_16x8 | MB_TYPE_FORWARD_MV |
1743 MB_TYPE_L0 |
1744 MB_TYPE_INTERLACED;1741 MB_TYPE_INTERLACED;
1745 /* 16x8 field motion prediction */1742 /* 16x8 field motion prediction */
1746 s->mv_type = MV_TYPE_FIELD;1743 s->mv_type = MV_TYPE_FIELD;
@@ -1763,7 +1760,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 16 unmodified lines
1763 s->mv[0][i][1] = my;1760 s->mv[0][i][1] = my;
1764 }1761 }
1765 } else {1762 } else {
1766 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;1763 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
1767 /* 16x16 motion prediction */1764 /* 16x16 motion prediction */
1768 s->mv_type = MV_TYPE_16X16;1765 s->mv_type = MV_TYPE_16X16;
1769 ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);1766 ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
@@ -1780,7 +1777,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 10 unmodified lines
1780 s->mv[0][0][1] = my;1777 s->mv[0][0][1] = my;
1781 }1778 }
1782 } else {1779 } else {
1783 s->cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;1780 s->cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_FORWARD_MV;
1784 s->mv_type = MV_TYPE_8X8;1781 s->mv_type = MV_TYPE_8X8;
1785 for (i = 0; i < 4; i++) {1782 for (i = 0; i < 4; i++) {
1786 int16_t *mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);1783 int16_t *mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
@@ -1832,14 +1829,14 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 45 unmodified lines
1832 s->mv[1][0][1] = 0;1829 s->mv[1][0][1] = 0;
1833 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |1830 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP |
1834 MB_TYPE_16x16 |1831 MB_TYPE_16x16 |
1835 MB_TYPE_L0;1832 MB_TYPE_FORWARD_MV;
1836 goto end;1833 goto end;
1837 }1834 }
1838 1835
1839 modb1 = get_bits1(&s->gb);1836 modb1 = get_bits1(&s->gb);
1840 if (modb1) {1837 if (modb1) {
1841 // like MB_TYPE_B_DIRECT but no vectors coded1838 // like MB_TYPE_B_DIRECT but no vectors coded
1842 mb_type = MB_TYPE_DIRECT2 | MB_TYPE_SKIP | MB_TYPE_L0L1;1839 mb_type = MB_TYPE_DIRECT2 | MB_TYPE_SKIP | MB_TYPE_BIDIR_MV;
1843 cbp = 0;1840 cbp = 0;
1844 } else {1841 } else {
1845 modb2 = get_bits1(&s->gb);1842 modb2 = get_bits1(&s->gb);
@@ -1869,11 +1866,11 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 23 unmodified lines
1869 mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;1866 mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
1870 mb_type &= ~MB_TYPE_16x16;1867 mb_type &= ~MB_TYPE_16x16;
1871 1868
1872 if (USES_LIST(mb_type, 0)) {1869 if (HAS_FORWARD_MV(mb_type)) {
1873 s->field_select[0][0] = get_bits1(&s->gb);1870 s->field_select[0][0] = get_bits1(&s->gb);
1874 s->field_select[0][1] = get_bits1(&s->gb);1871 s->field_select[0][1] = get_bits1(&s->gb);
1875 }1872 }
1876 if (USES_LIST(mb_type, 1)) {1873 if (HAS_BACKWARD_MV(mb_type)) {
1877 s->field_select[1][0] = get_bits1(&s->gb);1874 s->field_select[1][0] = get_bits1(&s->gb);
1878 s->field_select[1][1] = get_bits1(&s->gb);1875 s->field_select[1][1] = get_bits1(&s->gb);
1879 }1876 }
@@ -1884,7 +1881,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 4 unmodified lines
1884 if ((mb_type & (MB_TYPE_DIRECT2 | MB_TYPE_INTERLACED)) == 0) {1881 if ((mb_type & (MB_TYPE_DIRECT2 | MB_TYPE_INTERLACED)) == 0) {
1885 s->mv_type = MV_TYPE_16X16;1882 s->mv_type = MV_TYPE_16X16;
1886 1883
1887 if (USES_LIST(mb_type, 0)) {1884 if (HAS_FORWARD_MV(mb_type)) {
1888 s->mv_dir = MV_DIR_FORWARD;1885 s->mv_dir = MV_DIR_FORWARD;
1889 1886
1890 mx = ff_h263_decode_motion(s, s->last_mv[0][0][0], s->f_code);1887 mx = ff_h263_decode_motion(s, s->last_mv[0][0][0], s->f_code);
@@ -1897,7 +1894,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 6 unmodified lines
1897 s->mv[0][0][1] = my;1894 s->mv[0][0][1] = my;
1898 }1895 }
1899 1896
1900 if (USES_LIST(mb_type, 1)) {1897 if (HAS_BACKWARD_MV(mb_type)) {
1901 s->mv_dir |= MV_DIR_BACKWARD;1898 s->mv_dir |= MV_DIR_BACKWARD;
1902 1899
1903 mx = ff_h263_decode_motion(s, s->last_mv[1][0][0], s->b_code);1900 mx = ff_h263_decode_motion(s, s->last_mv[1][0][0], s->b_code);
@@ -1912,7 +1909,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 8 unmodified lines
1912 } else if (!IS_DIRECT(mb_type)) {1909 } else if (!IS_DIRECT(mb_type)) {
1913 s->mv_type = MV_TYPE_FIELD;1910 s->mv_type = MV_TYPE_FIELD;
1914 1911
1915 if (USES_LIST(mb_type, 0)) {1912 if (HAS_FORWARD_MV(mb_type)) {
1916 s->mv_dir = MV_DIR_FORWARD;1913 s->mv_dir = MV_DIR_FORWARD;
1917 1914
1918 for (i = 0; i < 2; i++) {1915 for (i = 0; i < 2; i++) {
@@ -1924,7 +1921,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 5 unmodified lines
1924 }1921 }
1925 }1922 }
1926 1923
1927 if (USES_LIST(mb_type, 1)) {1924 if (HAS_BACKWARD_MV(mb_type)) {
1928 s->mv_dir |= MV_DIR_BACKWARD;1925 s->mv_dir |= MV_DIR_BACKWARD;
1929 1926
1930 for (i = 0; i < 2; i++) {1927 for (i = 0; i < 2; i++) {
libavcodec/mpegutils.c+14−9
@@ -104,7 +104,9 @@ void ff_draw_horiz_band(AVCodecContext *avctx, · 103 unmodified lines
104 y, picture_structure, h);104 y, picture_structure, h);
105}105}
106 106
107static char get_type_mv_char(int mb_type)107#define HAS_MV_EXT(mb_type, flags, dir) ((mb_type) & flags[(dir)])
108
109static char get_type_mv_char(int mb_type, const int mb_type_mv_flags[2])
108{110{
109 // Type & MV direction111 // Type & MV direction
110 if (IS_PCM(mb_type))112 if (IS_PCM(mb_type))
@@ -125,12 +127,12 @@ static char get_type_mv_char(int mb_type) · 14 unmodified lines
125 return 'G';127 return 'G';
126 else if (IS_SKIP(mb_type))128 else if (IS_SKIP(mb_type))
127 return 'S';129 return 'S';
128 else if (!USES_LIST(mb_type, 1))130 else if (!HAS_MV_EXT(mb_type, 1, mb_type_mv_flags))
129 return '>';131 return '>';
130 else if (!USES_LIST(mb_type, 0))132 else if (!HAS_MV_EXT(mb_type, 0, mb_type_mv_flags))
131 return '<';133 return '<';
132 else {134 else {
133 av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));135 av_assert2(HAS_MV_EXT(mb_type, 0, mb_type_mv_flags) && HAS_MV_EXT(mb_type, 1, mb_type_mv_flags));
134 return 'X';136 return 'X';
135 }137 }
136}138}
@@ -162,12 +164,15 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, · 25 unmodified lines
162 const int8_t *qscale_table, int16_t (*const motion_val[2])[2],164 const int8_t *qscale_table, int16_t (*const motion_val[2])[2],
163 int mb_width, int mb_height, int mb_stride, int quarter_sample)165 int mb_width, int mb_height, int mb_stride, int quarter_sample)
164{166{
167 const int is_h264 = avctx->codec_id == AV_CODEC_ID_H264;
168 const int mb_type_mv_flags[2] = { is_h264 ? MB_TYPE_L0 : MB_TYPE_FORWARD_MV,
169 is_h264 ? MB_TYPE_L1 : MB_TYPE_BACKWARD_MV };
170
165 if ((avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) && mbtype_table && motion_val[0]) {171 if ((avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) && mbtype_table && motion_val[0]) {
166 const int shift = 1 + quarter_sample;172 const int shift = 1 + quarter_sample;
167 const int scale = 1 << shift;173 const int scale = 1 << shift;
168 const int mv_sample_log2 = avctx->codec_id == AV_CODEC_ID_H264 ? 2 : 1;174 const int mv_sample_log2 = is_h264 ? 2 : 1;
169 const int mv_stride = (mb_width << mv_sample_log2) +175 const int mv_stride = (mb_width << mv_sample_log2) + !is_h264;
170 (avctx->codec->id == AV_CODEC_ID_H264 ? 0 : 1);
171 int mb_x, mb_y, mbcount = 0;176 int mb_x, mb_y, mbcount = 0;
172 177
173 /* size is width * height * 2 * 4 where 2 is for directions and 4 is178 /* size is width * height * 2 * 4 where 2 is for directions and 4 is
@@ -180,7 +185,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, · 6 unmodified lines
180 for (mb_x = 0; mb_x < mb_width; mb_x++) {185 for (mb_x = 0; mb_x < mb_width; mb_x++) {
181 int i, direction, mb_type = mbtype_table[mb_x + mb_y * mb_stride];186 int i, direction, mb_type = mbtype_table[mb_x + mb_y * mb_stride];
182 for (direction = 0; direction < 2; direction++) {187 for (direction = 0; direction < 2; direction++) {
183 if (!USES_LIST(mb_type, direction))188 if (!HAS_MV_EXT(mb_type, direction, mb_type_mv_flags))
184 continue;189 continue;
185 if (IS_8X8(mb_type)) {190 if (IS_8X8(mb_type)) {
186 for (i = 0; i < 4; i++) {191 for (i = 0; i < 4; i++) {
@@ -299,7 +304,7 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, · 112 unmodified lines
299 int mb_type = mbtype_table[x + y * mb_stride];304 int mb_type = mbtype_table[x + y * mb_stride];
300 305
301 av_bprintf(&buf, "%c%c%c",306 av_bprintf(&buf, "%c%c%c",
302 get_type_mv_char(mb_type),307 get_type_mv_char(mb_type, mb_type_mv_flags),
303 get_segmentation_char(mb_type),308 get_segmentation_char(mb_type),
304 get_interlacement_char(mb_type));309 get_interlacement_char(mb_type));
305 }310 }
libavcodec/mpegutils.h+10−0
@@ -47,6 +47,10 @@ · 46 unmodified lines
47#define MB_TYPE_DIRECT2 (1 << 8) // FIXME47#define MB_TYPE_DIRECT2 (1 << 8) // FIXME
48#define MB_TYPE_CBP (1 << 10)48#define MB_TYPE_CBP (1 << 10)
49#define MB_TYPE_QUANT (1 << 11)49#define MB_TYPE_QUANT (1 << 11)
50#define MB_TYPE_FORWARD_MV (1 << 12)
51#define MB_TYPE_BACKWARD_MV (1 << 13)
52#define MB_TYPE_BIDIR_MV (MB_TYPE_FORWARD_MV | MB_TYPE_BACKWARD_MV)
53// MB_TYPE_P[01]L[01], MB_TYPE_L[01] and MB_TYPE_L0L1 are H.264 only.
50#define MB_TYPE_P0L0 (1 << 12)54#define MB_TYPE_P0L0 (1 << 12)
51#define MB_TYPE_P1L0 (1 << 13)55#define MB_TYPE_P1L0 (1 << 13)
52#define MB_TYPE_P0L1 (1 << 14)56#define MB_TYPE_P0L1 (1 << 14)
@@ -90,6 +94,12 @@ · 37 unmodified lines
90#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * (list))))94#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * (list))))
91 95
92#define HAS_CBP(a) ((a) & MB_TYPE_CBP)96#define HAS_CBP(a) ((a) & MB_TYPE_CBP)
97#define HAS_FORWARD_MV(a) ((a) & MB_TYPE_FORWARD_MV)
98#define HAS_BACKWARD_MV(a) ((a) & MB_TYPE_BACKWARD_MV)
99// dir == 0 means forward, dir == 1 is backward
100#define HAS_MV(a, dir) ((a) & (MB_TYPE_FORWARD_MV << (dir)))
101
102#define MB_TYPE_MV_2_MV_DIR(a) (((a) >> 12) & (MV_DIR_FORWARD | MV_DIR_BACKWARD))
93 103
94/**104/**
95 * Draw a horizontal band if supported.105 * Draw a horizontal band if supported.
libavcodec/msmpeg4dec.c+4−4
@@ -120,7 +120,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 119 unmodified lines
120 s->mv[0][0][0] = 0;120 s->mv[0][0][0] = 0;
121 s->mv[0][0][1] = 0;121 s->mv[0][0][1] = 0;
122 s->mb_skipped = 1;122 s->mb_skipped = 1;
123 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;123 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
124 return 0;124 return 0;
125 }125 }
126 }126 }
@@ -170,7 +170,7 @@ static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 43 unmodified lines
170 s->mv_type = MV_TYPE_16X16;170 s->mv_type = MV_TYPE_16X16;
171 s->mv[0][0][0] = mx;171 s->mv[0][0][0] = mx;
172 s->mv[0][0][1] = my;172 s->mv[0][0][1] = my;
173 *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;173 *mb_type_ptr = MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
174 } else {174 } else {
175 int v;175 int v;
176 if (s->msmpeg4_version == MSMP4_V2) {176 if (s->msmpeg4_version == MSMP4_V2) {
@@ -226,7 +226,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 49 unmodified lines
226 s->mv[0][0][0] = 0;226 s->mv[0][0][0] = 0;
227 s->mv[0][0][1] = 0;227 s->mv[0][0][1] = 0;
228 s->mb_skipped = 1;228 s->mb_skipped = 1;
229 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;229 *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
230 230
231 return 0;231 return 0;
232 }232 }
@@ -265,7 +265,7 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64]) · 32 unmodified lines
265 s->mv_type = MV_TYPE_16X16;265 s->mv_type = MV_TYPE_16X16;
266 s->mv[0][0][0] = mx;266 s->mv[0][0][0] = mx;
267 s->mv[0][0][1] = my;267 s->mv[0][0][1] = my;
268 *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;268 *mb_type_ptr = MB_TYPE_FORWARD_MV | MB_TYPE_16x16;
269 } else {269 } else {
270 ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,270 ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
271 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),271 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
libavcodec/rv34.c+9−9
@@ -59,16 +59,16 @@ static inline void ZERO8x2(void* dst, int stride) · 58 unmodified lines
59static const int rv34_mb_type_to_lavc[12] = {59static const int rv34_mb_type_to_lavc[12] = {
60 MB_TYPE_INTRA,60 MB_TYPE_INTRA,
61 MB_TYPE_INTRA16x16 | MB_TYPE_SEPARATE_DC,61 MB_TYPE_INTRA16x16 | MB_TYPE_SEPARATE_DC,
62 MB_TYPE_16x16 | MB_TYPE_L0,62 MB_TYPE_16x16 | MB_TYPE_FORWARD_MV,
63 MB_TYPE_8x8 | MB_TYPE_L0,63 MB_TYPE_8x8 | MB_TYPE_FORWARD_MV,
64 MB_TYPE_16x16 | MB_TYPE_L0,64 MB_TYPE_16x16 | MB_TYPE_FORWARD_MV,
65 MB_TYPE_16x16 | MB_TYPE_L1,65 MB_TYPE_16x16 | MB_TYPE_BACKWARD_MV,
66 MB_TYPE_SKIP,66 MB_TYPE_SKIP,
67 MB_TYPE_DIRECT2 | MB_TYPE_16x16,67 MB_TYPE_DIRECT2 | MB_TYPE_16x16,
68 MB_TYPE_16x8 | MB_TYPE_L0,68 MB_TYPE_16x8 | MB_TYPE_FORWARD_MV,
69 MB_TYPE_8x16 | MB_TYPE_L0,69 MB_TYPE_8x16 | MB_TYPE_FORWARD_MV,
70 MB_TYPE_16x16 | MB_TYPE_L0L1,70 MB_TYPE_16x16 | MB_TYPE_BIDIR_MV,
71 MB_TYPE_16x16 | MB_TYPE_L0 | MB_TYPE_SEPARATE_DC71 MB_TYPE_16x16 | MB_TYPE_FORWARD_MV | MB_TYPE_SEPARATE_DC
72};72};
73 73
74 74
@@ -568,7 +568,7 @@ static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir) · 493 unmodified lines
568 int mx, my;568 int mx, my;
569 int i, j;569 int i, j;
570 MPVWorkPicture *cur_pic = &s->cur_pic;570 MPVWorkPicture *cur_pic = &s->cur_pic;
571 const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0;571 const int mask = dir ? MB_TYPE_BACKWARD_MV : MB_TYPE_FORWARD_MV;
572 int type = cur_pic->mb_type[mb_pos];572 int type = cur_pic->mb_type[mb_pos];
573 573
574 if((r->avail_cache[6-1] & type) & mask){574 if((r->avail_cache[6-1] & type) & mask){
libavcodec/wmv2dec.c+6−6
@@ -112,7 +112,7 @@ static int parse_mb_skip(WMV2DecContext *w) · 111 unmodified lines
112 for (mb_y = 0; mb_y < s->mb_height; mb_y++)112 for (mb_y = 0; mb_y < s->mb_height; mb_y++)
113 for (mb_x = 0; mb_x < s->mb_width; mb_x++)113 for (mb_x = 0; mb_x < s->mb_width; mb_x++)
114 mb_type[mb_y * s->mb_stride + mb_x] =114 mb_type[mb_y * s->mb_stride + mb_x] =
115 MB_TYPE_16x16 | MB_TYPE_L0;115 MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
116 break;116 break;
117 case SKIP_TYPE_MPEG:117 case SKIP_TYPE_MPEG:
118 if (get_bits_left(&s->gb) < s->mb_height * s->mb_width)118 if (get_bits_left(&s->gb) < s->mb_height * s->mb_width)
@@ -120,7 +120,7 @@ static int parse_mb_skip(WMV2DecContext *w) · 1 unmodified line
120 for (mb_y = 0; mb_y < s->mb_height; mb_y++)120 for (mb_y = 0; mb_y < s->mb_height; mb_y++)
121 for (mb_x = 0; mb_x < s->mb_width; mb_x++)121 for (mb_x = 0; mb_x < s->mb_width; mb_x++)
122 mb_type[mb_y * s->mb_stride + mb_x] =122 mb_type[mb_y * s->mb_stride + mb_x] =
123 (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;123 (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
124 break;124 break;
125 case SKIP_TYPE_ROW:125 case SKIP_TYPE_ROW:
126 for (mb_y = 0; mb_y < s->mb_height; mb_y++) {126 for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
@@ -129,11 +129,11 @@ static int parse_mb_skip(WMV2DecContext *w) · 2 unmodified lines
129 if (get_bits1(&s->gb)) {129 if (get_bits1(&s->gb)) {
130 for (mb_x = 0; mb_x < s->mb_width; mb_x++)130 for (mb_x = 0; mb_x < s->mb_width; mb_x++)
131 mb_type[mb_y * s->mb_stride + mb_x] =131 mb_type[mb_y * s->mb_stride + mb_x] =
132 MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;132 MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
133 } else {133 } else {
134 for (mb_x = 0; mb_x < s->mb_width; mb_x++)134 for (mb_x = 0; mb_x < s->mb_width; mb_x++)
135 mb_type[mb_y * s->mb_stride + mb_x] =135 mb_type[mb_y * s->mb_stride + mb_x] =
136 (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;136 (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
137 }137 }
138 }138 }
139 break;139 break;
@@ -144,11 +144,11 @@ static int parse_mb_skip(WMV2DecContext *w) · 4 unmodified lines
144 if (get_bits1(&s->gb)) {144 if (get_bits1(&s->gb)) {
145 for (mb_y = 0; mb_y < s->mb_height; mb_y++)145 for (mb_y = 0; mb_y < s->mb_height; mb_y++)
146 mb_type[mb_y * s->mb_stride + mb_x] =146 mb_type[mb_y * s->mb_stride + mb_x] =
147 MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;147 MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
148 } else {148 } else {
149 for (mb_y = 0; mb_y < s->mb_height; mb_y++)149 for (mb_y = 0; mb_y < s->mb_height; mb_y++)
150 mb_type[mb_y * s->mb_stride + mb_x] =150 mb_type[mb_y * s->mb_stride + mb_x] =
151 (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;151 (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
152 }152 }
153 }153 }
154 break;154 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t