[FFmpeg-devel] [PATCH] avcodec/mpegvideo: remove redundant workaround to recalculate last nonzero coefficient
Ramiro Polla
ramiro.polla at gmail.com
Thu Aug 22 02:24:54 EEST 2024
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.
---
libavcodec/mpegvideo.c | 9 +++------
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(
--
2.39.2
More information about the ffmpeg-devel
mailing list