Merge commit 'a4d0c6e0503562d4cc8f9f6d02d84d7b32583b15'
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 4 Jan 2014 02:03:02 +0000 (03:03 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 4 Jan 2014 02:03:02 +0000 (03:03 +0100)
* commit 'a4d0c6e0503562d4cc8f9f6d02d84d7b32583b15':
  mpegvideo: move dct_unquantize functions up to avoid forward declarations

Conflicts:
libavcodec/mpegvideo.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/mpegvideo.c

@@@ -123,6 -108,224 +108,213 @@@ const enum AVPixelFormat ff_pixfmt_list
      AV_PIX_FMT_NONE
  };
  
 -    if (n < 4)
 -        block[0] = block[0] * s->y_dc_scale;
 -    else
 -        block[0] = block[0] * s->c_dc_scale;
+ static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
+                                    int16_t *block, int n, int qscale)
+ {
+     int i, level, nCoeffs;
+     const uint16_t *quant_matrix;
+     nCoeffs= s->block_last_index[n];
 -    if (n < 4)
 -        block[0] = block[0] * s->y_dc_scale;
 -    else
 -        block[0] = block[0] * s->c_dc_scale;
++    block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
+     /* XXX: only mpeg1 */
+     quant_matrix = s->intra_matrix;
+     for(i=1;i<=nCoeffs;i++) {
+         int j= s->intra_scantable.permutated[i];
+         level = block[j];
+         if (level) {
+             if (level < 0) {
+                 level = -level;
+                 level = (int)(level * qscale * quant_matrix[j]) >> 3;
+                 level = (level - 1) | 1;
+                 level = -level;
+             } else {
+                 level = (int)(level * qscale * quant_matrix[j]) >> 3;
+                 level = (level - 1) | 1;
+             }
+             block[j] = level;
+         }
+     }
+ }
+ static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s,
+                                    int16_t *block, int n, int qscale)
+ {
+     int i, level, nCoeffs;
+     const uint16_t *quant_matrix;
+     nCoeffs= s->block_last_index[n];
+     quant_matrix = s->inter_matrix;
+     for(i=0; i<=nCoeffs; i++) {
+         int j= s->intra_scantable.permutated[i];
+         level = block[j];
+         if (level) {
+             if (level < 0) {
+                 level = -level;
+                 level = (((level << 1) + 1) * qscale *
+                          ((int) (quant_matrix[j]))) >> 4;
+                 level = (level - 1) | 1;
+                 level = -level;
+             } else {
+                 level = (((level << 1) + 1) * qscale *
+                          ((int) (quant_matrix[j]))) >> 4;
+                 level = (level - 1) | 1;
+             }
+             block[j] = level;
+         }
+     }
+ }
+ static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s,
+                                    int16_t *block, int n, int qscale)
+ {
+     int i, level, nCoeffs;
+     const uint16_t *quant_matrix;
+     if(s->alternate_scan) nCoeffs= 63;
+     else nCoeffs= s->block_last_index[n];
 -    if (n < 4)
 -        block[0] = block[0] * s->y_dc_scale;
 -    else
 -        block[0] = block[0] * s->c_dc_scale;
++    block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
+     quant_matrix = s->intra_matrix;
+     for(i=1;i<=nCoeffs;i++) {
+         int j= s->intra_scantable.permutated[i];
+         level = block[j];
+         if (level) {
+             if (level < 0) {
+                 level = -level;
+                 level = (int)(level * qscale * quant_matrix[j]) >> 3;
+                 level = -level;
+             } else {
+                 level = (int)(level * qscale * quant_matrix[j]) >> 3;
+             }
+             block[j] = level;
+         }
+     }
+ }
+ static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s,
+                                    int16_t *block, int n, int qscale)
+ {
+     int i, level, nCoeffs;
+     const uint16_t *quant_matrix;
+     int sum=-1;
+     if(s->alternate_scan) nCoeffs= 63;
+     else nCoeffs= s->block_last_index[n];
 -    assert(s->block_last_index[n]>=0);
++    block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
++    sum += block[0];
+     quant_matrix = s->intra_matrix;
+     for(i=1;i<=nCoeffs;i++) {
+         int j= s->intra_scantable.permutated[i];
+         level = block[j];
+         if (level) {
+             if (level < 0) {
+                 level = -level;
+                 level = (int)(level * qscale * quant_matrix[j]) >> 3;
+                 level = -level;
+             } else {
+                 level = (int)(level * qscale * quant_matrix[j]) >> 3;
+             }
+             block[j] = level;
+             sum+=level;
+         }
+     }
+     block[63]^=sum&1;
+ }
+ static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s,
+                                    int16_t *block, int n, int qscale)
+ {
+     int i, level, nCoeffs;
+     const uint16_t *quant_matrix;
+     int sum=-1;
+     if(s->alternate_scan) nCoeffs= 63;
+     else nCoeffs= s->block_last_index[n];
+     quant_matrix = s->inter_matrix;
+     for(i=0; i<=nCoeffs; i++) {
+         int j= s->intra_scantable.permutated[i];
+         level = block[j];
+         if (level) {
+             if (level < 0) {
+                 level = -level;
+                 level = (((level << 1) + 1) * qscale *
+                          ((int) (quant_matrix[j]))) >> 4;
+                 level = -level;
+             } else {
+                 level = (((level << 1) + 1) * qscale *
+                          ((int) (quant_matrix[j]))) >> 4;
+             }
+             block[j] = level;
+             sum+=level;
+         }
+     }
+     block[63]^=sum&1;
+ }
+ static void dct_unquantize_h263_intra_c(MpegEncContext *s,
+                                   int16_t *block, int n, int qscale)
+ {
+     int i, level, qmul, qadd;
+     int nCoeffs;
 -        if (n < 4)
 -            block[0] = block[0] * s->y_dc_scale;
 -        else
 -            block[0] = block[0] * s->c_dc_scale;
++    av_assert2(s->block_last_index[n]>=0 || s->h263_aic);
+     qmul = qscale << 1;
+     if (!s->h263_aic) {
 -    assert(s->block_last_index[n]>=0);
++        block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale;
+         qadd = (qscale - 1) | 1;
+     }else{
+         qadd = 0;
+     }
+     if(s->ac_pred)
+         nCoeffs=63;
+     else
+         nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
+     for(i=1; i<=nCoeffs; i++) {
+         level = block[i];
+         if (level) {
+             if (level < 0) {
+                 level = level * qmul - qadd;
+             } else {
+                 level = level * qmul + qadd;
+             }
+             block[i] = level;
+         }
+     }
+ }
+ static void dct_unquantize_h263_inter_c(MpegEncContext *s,
+                                   int16_t *block, int n, int qscale)
+ {
+     int i, level, qmul, qadd;
+     int nCoeffs;
++    av_assert2(s->block_last_index[n]>=0);
+     qadd = (qscale - 1) | 1;
+     qmul = qscale << 1;
+     nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
+     for(i=0; i<=nCoeffs; i++) {
+         level = block[i];
+         if (level) {
+             if (level < 0) {
+                 level = level * qmul - qadd;
+             } else {
+                 level = level * qmul + qadd;
+             }
+             block[i] = level;
+         }
+     }
+ }
  static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
                                int (*mv)[2][4][2],
                                int mb_x, int mb_y, int mb_intra, int mb_skipped)