Browse code

mpeg4videodec: move use_intra_dc_vlc from MpegEncContext to Mpeg4DecContext

Anton Khirnov authored on 2013/11/26 22:34:52
Showing 3 changed files
... ...
@@ -83,6 +83,7 @@ typedef struct Mpeg4DecContext {
83 83
     int new_pred;
84 84
     int enhancement_type;
85 85
     int scalability;
86
+    int use_intra_dc_vlc;
86 87
 
87 88
     /* bug workarounds */
88 89
     int divx_version;
... ...
@@ -925,9 +925,10 @@ int ff_mpeg4_decode_partitions(Mpeg4DecContext *ctx)
925 925
  * Decode a block.
926 926
  * @return <0 if an error occurred
927 927
  */
928
-static inline int mpeg4_decode_block(MpegEncContext *s, int16_t *block,
928
+static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
929 929
                                      int n, int coded, int intra, int rvlc)
930 930
 {
931
+    MpegEncContext *s = &ctx->m;
931 932
     int level, i, last, run, qmul, qadd, dc_pred_dir;
932 933
     RLTable *rl;
933 934
     RL_VLC_ELEM *rl_vlc;
... ...
@@ -936,7 +937,7 @@ static inline int mpeg4_decode_block(MpegEncContext *s, int16_t *block,
936 936
     // Note intra & rvlc should be optimized away if this is inlined
937 937
 
938 938
     if (intra) {
939
-        if (s->use_intra_dc_vlc) {
939
+        if (ctx->use_intra_dc_vlc) {
940 940
             /* DC coef */
941 941
             if (s->partitioned_frame) {
942 942
                 level = s->dc_val[0][s->block_index[n]];
... ...
@@ -1151,7 +1152,7 @@ static inline int mpeg4_decode_block(MpegEncContext *s, int16_t *block,
1151 1151
 
1152 1152
 not_coded:
1153 1153
     if (intra) {
1154
-        if (!s->use_intra_dc_vlc) {
1154
+        if (!ctx->use_intra_dc_vlc) {
1155 1155
             block[0] = ff_mpeg4_pred_dc(s, n, block[0], &dc_pred_dir, 0);
1156 1156
 
1157 1157
             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])
1178 1178
     mb_type = s->current_picture.mb_type[xy];
1179 1179
     cbp     = s->cbp_table[xy];
1180 1180
 
1181
-    s->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
1181
+    ctx->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
1182 1182
 
1183 1183
     if (s->current_picture.qscale_table[xy] != s->qscale)
1184 1184
         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])
1228 1228
         s->dsp.clear_blocks(s->block[0]);
1229 1229
         /* decode each block */
1230 1230
         for (i = 0; i < 6; i++) {
1231
-            if (mpeg4_decode_block(s, block[i], i, cbp & 32, s->mb_intra, ctx->rvlc) < 0) {
1231
+            if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, s->mb_intra, ctx->rvlc) < 0) {
1232 1232
                 av_log(s->avctx, AV_LOG_ERROR,
1233 1233
                        "texture corrupted at %d %d %d\n",
1234 1234
                        s->mb_x, s->mb_y, s->mb_intra);
... ...
@@ -1576,7 +1577,7 @@ intra:
1576 1576
         }
1577 1577
         cbp = (cbpc & 3) | (cbpy << 2);
1578 1578
 
1579
-        s->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
1579
+        ctx->use_intra_dc_vlc = s->qscale < s->intra_dc_threshold;
1580 1580
 
1581 1581
         if (dquant)
1582 1582
             ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
... ...
@@ -1587,7 +1588,7 @@ intra:
1587 1587
         s->dsp.clear_blocks(s->block[0]);
1588 1588
         /* decode each block */
1589 1589
         for (i = 0; i < 6; i++) {
1590
-            if (mpeg4_decode_block(s, block[i], i, cbp & 32, 1, 0) < 0)
1590
+            if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 1, 0) < 0)
1591 1591
                 return -1;
1592 1592
             cbp += cbp;
1593 1593
         }
... ...
@@ -1596,7 +1597,7 @@ intra:
1596 1596
 
1597 1597
     /* decode each block */
1598 1598
     for (i = 0; i < 6; i++) {
1599
-        if (mpeg4_decode_block(s, block[i], i, cbp & 32, 0, 0) < 0)
1599
+        if (mpeg4_decode_block(ctx, block[i], i, cbp & 32, 0, 0) < 0)
1600 1600
             return -1;
1601 1601
         cbp += cbp;
1602 1602
     }
... ...
@@ -593,7 +593,6 @@ typedef struct MpegEncContext {
593 593
     int vo_type;
594 594
     int vol_control_parameters;      ///< does the stream contain the low_delay flag, used to workaround buggy encoders
595 595
     int intra_dc_threshold;          ///< QP above whch the ac VLC should be used for intra dc
596
-    int use_intra_dc_vlc;
597 596
     PutBitContext tex_pb;            ///< used for data partitioned VOPs
598 597
     PutBitContext pb2;               ///< used for data partitioned VOPs
599 598
     int mpeg_quant;