Commit bbcfe0aa52 for ffmpeg
commit bbcfe0aa52a0a7752404993cf86a1c9f7a3c0939
Author: Lynne <dev@lynne.ee>
Date: Sat Nov 7 13:33:42 2026 +0800
prores_raw: don't use the proresdsp iDCT permutation
Since 3b3be6e58f, proresdsp selects FF_IDCT_PERM_TRANSPOSE for 12 bits
on AVX2 CPUs, to match its new SIMD idct_put. The decoder permuted its
scan and quantization matrix with it, but only uses idct_put_bayer,
which has no SIMD version and takes coefficients in natural order. Every
8x8 block of a software decode on such CPUs was therefore transposed.
Use the scan and quantization matrix in natural order, and drop the
undoing of the permutation in the Vulkan hwaccel. Also remove a comment
describing the iDCT as 12-bit, out of date since faa7c882cb.
Fixes: 3b3be6e58fb07c8177ef6aa4fe28ebbb7b57eaa1
Fixes: #25461
Reported-by: Hyperlite-Media
diff --git a/libavcodec/prores_raw.c b/libavcodec/prores_raw.c
index 36c3879f73..fb43fa44e5 100644
--- a/libavcodec/prores_raw.c
+++ b/libavcodec/prores_raw.c
@@ -36,7 +36,6 @@
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
-#include "idctdsp.h"
#include "proresdata.h"
#include "thread.h"
#include "hwconfig.h"
@@ -58,12 +57,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->pix_fmt = AV_PIX_FMT_NONE;
ff_blockdsp_init(&s->bdsp);
- /* Coefficients and the iDCT are 12-bit, the linearization curve then
- * expands the result to the 16-bit linear output range. */
ff_proresdsp_init(&s->prodsp, 12);
- ff_permute_scantable(s->scan, ff_prores_interlaced_scan, s->prodsp.idct_permutation);
-
return 0;
}
@@ -168,7 +163,7 @@ static int decode_comp(AVCodecContext *avctx, TileContext *tile,
int16_t rn_codebook = 0;
int16_t ln_codebook = 66;
- const uint8_t *scan = s->scan;
+ const uint8_t *scan = ff_prores_interlaced_scan;
GetBitContext gb;
if (component > 1)
@@ -473,7 +468,7 @@ static int decode_frame(AVCodecContext *avctx,
memcpy(s->lin_curve, default_lin_curve, sizeof(s->lin_curve));
}
- ff_permute_scantable(s->qmat, s->prodsp.idct_permutation, qmat);
+ memcpy(s->qmat, qmat, sizeof(s->qmat));
int tw16 = (w + 15) >> 4;
s->nb_tw = (tw16 >> align) + av_popcount(~(-1 * (1 << align)) & tw16);
diff --git a/libavcodec/prores_raw.h b/libavcodec/prores_raw.h
index 1e7fee435e..86c2805c57 100644
--- a/libavcodec/prores_raw.h
+++ b/libavcodec/prores_raw.h
@@ -52,7 +52,6 @@ typedef struct ProResRAWContext {
int version;
- DECLARE_ALIGNED(32, uint8_t, scan)[64];
DECLARE_ALIGNED(32, uint8_t, qmat)[64];
/* 8-point combined linearization curve
diff --git a/libavcodec/vulkan_prores_raw.c b/libavcodec/vulkan_prores_raw.c
index 45936b68a4..ce2dc814aa 100644
--- a/libavcodec/vulkan_prores_raw.c
+++ b/libavcodec/vulkan_prores_raw.c
@@ -226,10 +226,7 @@ static int vk_prores_raw_end_frame(AVCodecContext *avctx)
DecodePushData pd_decode = (DecodePushData) {
.pkt_data = slices_buf->address,
};
- /* The decoder permutes the quantization matrix to match the layout
- * expected by its IDCT, undo it here. */
- for (int i = 0; i < 64; i++)
- pd_decode.qmat[prr->prodsp.idct_permutation[i]] = prr->qmat[i];
+ memcpy(pd_decode.qmat, prr->qmat, sizeof(pd_decode.qmat));
memcpy(pd_decode.lin_curve, prr->lin_curve, sizeof(pd_decode.lin_curve));
ff_vk_shader_update_push_const(&ctx->s, exec, decode_shader,
VK_SHADER_STAGE_COMPUTE_BIT,