From ceb1d54f3dfcd283d6e523bc8e6ced4a551779cc Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Date: Fri, 7 Mar 2025 02:16:10 +0100 Subject: [PATCH 4/9] avcodec/intrax8: Stop setting write-only block_last_index These values are only used by the mpegvideo unquantize functions, yet these are not active when intrax is in use. Furthermore, given that ff_intrax8_decode_picture() decodes multiple macroblocks in a given call, it makes no sense to return any value (that was in practice the maximum of the indices of all the macroblocks decoded). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/intrax8.c | 12 ------------ libavcodec/intrax8.h | 3 --- libavcodec/vc1dec.c | 3 +-- libavcodec/wmv2dec.c | 3 +-- 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index f1dce86a50..684f15d904 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec/intrax8.c @@ -480,24 +480,18 @@ static void x8_ac_compensation(IntraX8Context *const w, const int direction, t = T(1084); // g B(1, 1) += t; - - w->block_last_index[0] = FFMAX(w->block_last_index[0], 7 * 8); break; case 1: B(0, 1) -= T(6269); B(0, 3) -= T(708); B(0, 5) -= T(172); B(0, 7) -= T(73); - - w->block_last_index[0] = FFMAX(w->block_last_index[0], 7 * 8); break; case 2: B(1, 0) -= T(6269); B(3, 0) -= T(708); B(5, 0) -= T(172); B(7, 0) -= T(73); - - w->block_last_index[0] = FFMAX(w->block_last_index[0], 7); break; } #undef B @@ -599,10 +593,7 @@ static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma) w->block[0][scantable[pos]] = level; } while (!final); - - w->block_last_index[0] = pos; } else { // DC only - w->block_last_index[0] = 0; if (w->flat_dc && ((unsigned) (dc_level + 1)) < 3) { // [-1; 1] int32_t divide_quant = !chroma ? w->divide_quant_dc_luma : w->divide_quant_dc_chroma; @@ -633,7 +624,6 @@ static int x8_decode_intra_mb(IntraX8Context *const w, const int chroma) * -> 01'10' 10'10' 00'00' 00'01' 01'11' 11'00 => 0x6A017C */ direction = (0x6A017C >> (w->orient * 2)) & 3; if (direction != 3) { - // modify block_last[] x8_ac_compensation(w, direction, w->block[0][0]); } } @@ -689,7 +679,6 @@ static void x8_init_block_index(IntraX8Context *w, AVFrame *frame) av_cold int ff_intrax8_common_init(AVCodecContext *avctx, IntraX8Context *w, int16_t (*block)[64], - int block_last_index[12], int mb_width, int mb_height) { static AVOnce init_static_once = AV_ONCE_INIT; @@ -698,7 +687,6 @@ av_cold int ff_intrax8_common_init(AVCodecContext *avctx, w->mb_width = mb_width; w->mb_height = mb_height; w->block = block; - w->block_last_index = block_last_index; // two rows, 2 blocks per cannon mb w->prediction_table = av_mallocz(w->mb_width * 2 * 2); diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h index b9f8c4250b..38ad09c837 100644 --- a/libavcodec/intrax8.h +++ b/libavcodec/intrax8.h @@ -38,7 +38,6 @@ typedef struct IntraX8Context { WMV2DSPContext wdsp; uint8_t idct_permutation[64]; AVCodecContext *avctx; - int *block_last_index; ///< last nonzero coefficient in block int16_t (*block)[64]; // set by the caller codec @@ -77,7 +76,6 @@ typedef struct IntraX8Context { * @param avctx pointer to AVCodecContext * @param w pointer to IntraX8Context * @param block pointer to block array - * @param block_last_index pointer to index array * @param mb_width macroblock width * @param mb_height macroblock height * @return 0 on success, a negative AVERROR value on error @@ -85,7 +83,6 @@ typedef struct IntraX8Context { int ff_intrax8_common_init(AVCodecContext *avctx, IntraX8Context *w, int16_t (*block)[64], - int block_last_index[12], int mb_width, int mb_height); /** diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index d92a7da8ab..b9ca38d20d 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -422,8 +422,7 @@ static av_cold int vc1_decode_init_alloc_tables(VC1Context *v) return AVERROR(ENOMEM); } - ret = ff_intrax8_common_init(s->avctx, &v->x8, - s->block, s->block_last_index, + ret = ff_intrax8_common_init(s->avctx, &v->x8, s->block, s->mb_width, s->mb_height); if (ret < 0) return ret; diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c index 677467ccc2..7f43a5c0ba 100644 --- a/libavcodec/wmv2dec.c +++ b/libavcodec/wmv2dec.c @@ -575,8 +575,7 @@ static av_cold int wmv2_decode_init(AVCodecContext *avctx) decode_ext_header(w); - return ff_intrax8_common_init(avctx, &w->x8, - w->s.block, w->s.block_last_index, + return ff_intrax8_common_init(avctx, &w->x8, w->s.block, w->s.mb_width, w->s.mb_height); } -- 2.45.2