Commit a5d752c168 for ffmpeg
commit a5d752c168047c3fcd0eeabf8dbcd07723c545a1
Author: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun Nov 22 12:47:30 2026 +0100
avcodec/vc1: Shrink VC1Context.blocks
Only one block is needed, as the effective lifetime of each block
is so short that the lifetimes of different blocks don't overlap.
Reviewed-by: Forgejo_Fairy
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index d3b9f7c103..3d55130298 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -404,8 +404,8 @@ typedef struct VC1Context{
int resync_marker; ///< could this stream contain resync markers
// FIXME: The 4x4 and 4x8 LASX and 4x8 MSA inverse transform DSP functions
- // overread the (offsetted) input block, hence the padding with another block.
- DECLARE_ALIGNED_32(int16_t, blocks)[6 + (HAVE_LASX || HAVE_MSA)][64];
+ // overread the (offsetted) input block, hence the padding.
+ DECLARE_ALIGNED_32(int16_t, blk)[64 + 4 * (HAVE_LASX || HAVE_MSA)];
} VC1Context;
/**
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index a84c853b6f..fb727cc56f 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -1949,22 +1949,22 @@ static int vc1_decode_b_mb(VC1Context *v)
if (i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[s->block_index[i] - 1];
- ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
+ ret = vc1_decode_intra_block(v, v->blk, i, val, mquant,
(i & 4) ? v->codingset2 : v->codingset);
if (ret < 0)
return ret;
if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
continue;
- v->vc1dsp.vc1_inv_trans_8x8(v->blocks[i]);
+ v->vc1dsp.vc1_inv_trans_8x8(v->blk);
if (v->rangeredfrm)
for (j = 0; j < 64; j++)
- v->blocks[i][j] *= 2;
- s->idsp.put_signed_pixels_clamped(v->blocks[i],
+ v->blk[j] *= 2;
+ s->idsp.put_signed_pixels_clamped(v->blk,
s->dest[dst_idx] + off,
i & 4 ? s->uvlinesize
: s->linesize);
} else if (val) {
- int pat = vc1_decode_p_block(v, v->blocks[i], i, mquant, ttmb,
+ int pat = vc1_decode_p_block(v, v->blk, i, mquant, ttmb,
first_block, s->dest[dst_idx] + off,
(i & 4) ? s->uvlinesize : s->linesize,
CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), NULL);
@@ -2030,18 +2030,18 @@ static int vc1_decode_b_mb_intfi(VC1Context *v)
if (i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[s->block_index[i] - 1];
- ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
+ ret = vc1_decode_intra_block(v, v->blk, i, val, mquant,
(i & 4) ? v->codingset2 : v->codingset);
if (ret < 0)
return ret;
if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
continue;
- v->vc1dsp.vc1_inv_trans_8x8(v->blocks[i]);
+ v->vc1dsp.vc1_inv_trans_8x8(v->blk);
if (v->rangeredfrm)
for (j = 0; j < 64; j++)
- v->blocks[i][j] <<= 1;
+ v->blk[j] <<= 1;
off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
- s->idsp.put_signed_pixels_clamped(v->blocks[i],
+ s->idsp.put_signed_pixels_clamped(v->blk,
s->dest[dst_idx] + off,
(i & 4) ? s->uvlinesize
: s->linesize);
@@ -2128,7 +2128,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v)
val = ((cbp >> (5 - i)) & 1);
off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
if (val) {
- pat = vc1_decode_p_block(v, v->blocks[i], i, mquant, ttmb,
+ pat = vc1_decode_p_block(v, v->blk, i, mquant, ttmb,
first_block, s->dest[dst_idx] + off,
(i & 4) ? s->uvlinesize : s->linesize,
CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
@@ -2226,13 +2226,13 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
if (i == 1 || i == 3 || s->mb_x)
v->c_avail = v->mb_type[s->block_index[i] - 1];
- ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
+ ret = vc1_decode_intra_block(v, v->blk, i, val, mquant,
(i & 4) ? v->codingset2 : v->codingset);
if (ret < 0)
return ret;
if (CONFIG_GRAY && i > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
continue;
- v->vc1dsp.vc1_inv_trans_8x8(v->blocks[i]);
+ v->vc1dsp.vc1_inv_trans_8x8(v->blk);
if (i < 4) {
stride_y = s->linesize << fieldtx;
off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;
@@ -2240,7 +2240,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
stride_y = s->uvlinesize;
off = 0;
}
- s->idsp.put_signed_pixels_clamped(v->blocks[i],
+ s->idsp.put_signed_pixels_clamped(v->blk,
s->dest[dst_idx] + off,
stride_y);
}
@@ -2429,7 +2429,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v)
else
off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
if (val) {
- pat = vc1_decode_p_block(v, v->blocks[i], i, mquant, ttmb,
+ pat = vc1_decode_p_block(v, v->blk, i, mquant, ttmb,
first_block, s->dest[dst_idx] + off,
(i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 0336c1848e..98b8b3377a 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -423,7 +423,7 @@ static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
return AVERROR(ENOMEM);
}
- ret = ff_intrax8_common_init(s->avctx, &v->x8, v->blocks[0],
+ ret = ff_intrax8_common_init(s->avctx, &v->x8, v->blk,
s->mb_width, s->mb_height);
if (ret < 0)
return ret;