diff options
author | Ramiro Polla <ramiro.polla@gmail.com> | 2024-08-22 01:24:54 +0200 |
---|---|---|
committer | Ramiro Polla <ramiro.polla@gmail.com> | 2024-09-03 17:14:24 +0200 |
commit | 4f7aeffd8c3607aea6464a20eba4cc9106173c52 (patch) | |
tree | 57c1d3b3b54a371bbfe2b46cb19b214ddb2549b2 | |
parent | b6f7271fa914e425142023a7cedff682183a6bf8 (diff) | |
download | ffmpeg-4f7aeffd8c3607aea6464a20eba4cc9106173c52.tar.gz |
avcodec/mpegvideo: remove redundant workaround to recalculate last nonzero coefficient
The x86 optimized dct_quantize only calculates the last nonzero
coefficient correctly if the zigzag scan order is used. For the
alternate scan order, this value is incorrect.
To work around this, the dct_unquantize functions process the entire
block if the alternate scan order is used.
But a second workaround (bb198e198ab) was added that recalculates the
last nonzero coefficient after dct_quantize is called if the alternate
scan order is used.
This commit removes the first workaround, which became redundant.
-rw-r--r-- | libavcodec/mpegvideo.c | 9 | ||||
-rw-r--r-- | libavcodec/x86/mpegvideo.c | 6 |
2 files changed, 5 insertions, 10 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index b9a0469335..01e310e483 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -110,8 +110,7 @@ static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; else qscale <<= 1; - if(s->alternate_scan) nCoeffs= 63; - else nCoeffs= s->block_last_index[n]; + nCoeffs= s->block_last_index[n]; block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; quant_matrix = s->intra_matrix; @@ -141,8 +140,7 @@ static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; else qscale <<= 1; - if(s->alternate_scan) nCoeffs= 63; - else nCoeffs= s->block_last_index[n]; + nCoeffs= s->block_last_index[n]; block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; sum += block[0]; @@ -175,8 +173,7 @@ static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; else qscale <<= 1; - if(s->alternate_scan) nCoeffs= 63; - else nCoeffs= s->block_last_index[n]; + nCoeffs= s->block_last_index[n]; quant_matrix = s->inter_matrix; for(i=0; i<=nCoeffs; i++) { diff --git a/libavcodec/x86/mpegvideo.c b/libavcodec/x86/mpegvideo.c index 73967cafda..9878607a81 100644 --- a/libavcodec/x86/mpegvideo.c +++ b/libavcodec/x86/mpegvideo.c @@ -312,8 +312,7 @@ static void dct_unquantize_mpeg2_intra_mmx(MpegEncContext *s, if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; else qscale <<= 1; - if(s->alternate_scan) nCoeffs= 63; //FIXME - else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; + nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; if (n < 4) block0 = block[0] * s->y_dc_scale; @@ -380,8 +379,7 @@ static void dct_unquantize_mpeg2_inter_mmx(MpegEncContext *s, if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; else qscale <<= 1; - if(s->alternate_scan) nCoeffs= 63; //FIXME - else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; + nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; quant_matrix = s->inter_matrix; __asm__ volatile( |