]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg4videodec.c
build: Let the iac decoder depend on the imc decoder
[ffmpeg] / libavcodec / mpeg4videodec.c
index 115fae403fb0f783a1075533e3825f36ca707097..b6925ac66421be1d16224dd3566e2d8e77ad51c0 100644 (file)
@@ -925,9 +925,10 @@ int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
  * Decode a block.
  * @return <0 if an error occurred
  */
-static inline int mpeg4_decode_block(MpegEncContext *s, int16_t *block,
+static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
                                      int n, int coded, int intra, int rvlc)
 {
+    MpegEncContext *s = &ctx->m;
     int level, i, last, run, qmul, qadd, dc_pred_dir;
     RLTable *rl;
     RL_VLC_ELEM *rl_vlc;
@@ -936,7 +937,7 @@ static inline int mpeg4_decode_block(MpegEncContext *s, int16_t *block,
     // Note intra & rvlc should be optimized away if this is inlined
 
     if (intra) {
-        if (s->use_intra_dc_vlc) {
+        if (ctx->use_intra_dc_vlc) {
             /* DC coef */
             if (s->partitioned_frame) {
                 level = s->dc_val[0][s->block_index[n]];
@@ -1151,7 +1152,7 @@ static inline int mpeg4_decode_block(MpegEncContext *s, int16_t *block,
 
 not_coded:
     if (intra) {
-        if (!s->use_intra_dc_vlc) {
+        if (!ctx->use_intra_dc_vlc) {
             block[0] = ff_mpeg4_pred_dc(s, n, block[0], &dc_pred_dir, 0);
 
             i -= i >> 31;  // if (i == -1) i = 0;
@@ -1178,7 +1179,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
     mb_type = s->current_picture.mb_type[xy];
     cbp     = s->cbp_table[xy];
 
-    s->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
+    ctx->use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold;
 
     if (s->current_picture.qscale_table[xy] != s->qscale)
         ff_set_qscale(s, s->current_picture.qscale_table[xy]);
@@ -1228,7 +1229,7 @@ static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
         s->dsp.clear_blocks(s->block[0]);
         /* decode each block */
         for (i = 0; i < 6; i++) {
-            if (mpeg4_decode_block(s, block[i], i, cbp & 32, s->mb_intra, ctx->rvlc) < 0) {
+            if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, s->mb_intra, ctx->rvlc) < 0) {
                 av_log(s->avctx, AV_LOG_ERROR,
                        "texture corrupted at %d %d %d\n",
                        s->mb_x, s->mb_y, s->mb_intra);
@@ -1576,7 +1577,7 @@ intra:
         }
         cbp = (cbpc & 3) | (cbpy << 2);
 
-        s->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
+        ctx->use_intra_dc_vlc = s->qscale < ctx->intra_dc_threshold;
 
         if (dquant)
             ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
@@ -1587,7 +1588,7 @@ intra:
         s->dsp.clear_blocks(s->block[0]);
         /* decode each block */
         for (i = 0; i < 6; i++) {
-            if (mpeg4_decode_block(s, block[i], i, cbp & 32, 1, 0) < 0)
+            if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 1, 0) < 0)
                 return -1;
             cbp += cbp;
         }
@@ -1596,7 +1597,7 @@ intra:
 
     /* decode each block */
     for (i = 0; i < 6; i++) {
-        if (mpeg4_decode_block(s, block[i], i, cbp & 32, 0, 0) < 0)
+        if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 0, 0) < 0)
             return -1;
         cbp += cbp;
     }
@@ -2015,10 +2016,10 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb)
         ctx->divx_version = ver;
         ctx->divx_build   = build;
         s->divx_packed  = e == 3 && last == 'p';
-        if (s->divx_packed && !s->showed_packed_warning) {
+        if (s->divx_packed && !ctx->showed_packed_warning) {
             av_log(s->avctx, AV_LOG_WARNING,
                    "Invalid and inefficient vfw-avi packed B frames detected\n");
-            s->showed_packed_warning = 1;
+            ctx->showed_packed_warning = 1;
         }
     }
 
@@ -2043,6 +2044,35 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb)
     if (e == 1)
         ctx->xvid_build = build;
 
+    if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1) {
+        if (s->stream_codec_tag == AV_RL32("XVID") ||
+            s->codec_tag        == AV_RL32("XVID") ||
+            s->codec_tag        == AV_RL32("XVIX") ||
+            s->codec_tag        == AV_RL32("RMP4") ||
+            s->codec_tag        == AV_RL32("ZMP4") ||
+            s->codec_tag        == AV_RL32("SIPP"))
+            ctx->xvid_build = 0;
+    }
+
+    if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1)
+        if (s->codec_tag == AV_RL32("DIVX") && s->vo_type == 0 &&
+            s->vol_control_parameters == 0)
+            ctx->divx_version = 400;  // divx 4
+
+    if (ctx->xvid_build >= 0 && ctx->divx_version >= 0) {
+        ctx->divx_version =
+        ctx->divx_build   = -1;
+    }
+
+#if HAVE_MMX
+    if (ctx->xvid_build >= 0                &&
+        s->avctx->idct_algo == FF_IDCT_AUTO &&
+        (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
+        s->avctx->idct_algo = FF_IDCT_XVIDMMX;
+        ff_dct_common_init(s);
+    }
+#endif
+
     return 0;
 }
 
@@ -2179,7 +2209,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
         if (s->pict_type == AV_PICTURE_TYPE_B)
             skip_bits_long(gb, ctx->cplx_estimation_trash_b);
 
-        s->intra_dc_threshold = ff_mpeg4_dc_threshold[get_bits(gb, 3)];
+        ctx->intra_dc_threshold = ff_mpeg4_dc_threshold[get_bits(gb, 3)];
         if (!s->progressive_sequence) {
             s->top_field_first = get_bits1(gb);
             s->alternate_scan  = get_bits1(gb);
@@ -2244,7 +2274,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
                    s->data_partitioning, ctx->resync_marker,
                    ctx->num_sprite_warping_points, s->sprite_warping_accuracy,
                    1 - s->no_rounding, s->vo_type,
-                   s->vol_control_parameters ? " VOLC" : " ", s->intra_dc_threshold,
+                   s->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold,
                    ctx->cplx_estimation_trash_i, ctx->cplx_estimation_trash_p,
                    ctx->cplx_estimation_trash_b);
         }
@@ -2404,26 +2434,6 @@ end:
         s->low_delay = 1;
     s->avctx->has_b_frames = !s->low_delay;
 
-    if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1) {
-        if (s->stream_codec_tag == AV_RL32("XVID") ||
-            s->codec_tag        == AV_RL32("XVID") ||
-            s->codec_tag        == AV_RL32("XVIX") ||
-            s->codec_tag        == AV_RL32("RMP4") ||
-            s->codec_tag        == AV_RL32("ZMP4") ||
-            s->codec_tag        == AV_RL32("SIPP"))
-            ctx->xvid_build = 0;
-    }
-
-    if (ctx->xvid_build == -1 && ctx->divx_version == -1 && ctx->lavc_build == -1)
-        if (s->codec_tag == AV_RL32("DIVX") && s->vo_type == 0 &&
-            s->vol_control_parameters == 0)
-            ctx->divx_version = 400;  // divx 4
-
-    if (ctx->xvid_build >= 0 && ctx->divx_version >= 0) {
-        ctx->divx_version =
-        ctx->divx_build   = -1;
-    }
-
     if (s->workaround_bugs & FF_BUG_AUTODETECT) {
         if (s->codec_tag == AV_RL32("XVIX"))
             s->workaround_bugs |= FF_BUG_XVID_ILACE;
@@ -2474,15 +2484,6 @@ end:
             s->workaround_bugs |= FF_BUG_HPEL_CHROMA;
     }
 
-#if HAVE_MMX
-    if (s->codec_id == AV_CODEC_ID_MPEG4 && ctx->xvid_build >= 0 &&
-        s->avctx->idct_algo == FF_IDCT_AUTO &&
-        (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
-        s->avctx->idct_algo = FF_IDCT_XVIDMMX;
-        ff_dct_common_init(s);
-        s->picture_number = 0;
-    }
-#endif
 
     if (s->avctx->debug & FF_DEBUG_BUGS)
         av_log(s->avctx, AV_LOG_DEBUG,