1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/proresdec: Remove grayscale hack

This was introduced in commit 9c43703, to support a codec "extension"
in the prores_aw encoder.
This removes the chroma fill loop, and instead performs the inverse
transform on null coefficients, which achieves the same result and
fixes an off-by-one in the chroma values produced.

Updated test to reflect this change.
This commit is contained in:
averne
2025-07-31 16:42:35 +02:00
committed by Lynne
parent 2b522f537f
commit a49108fd29
2 changed files with 11 additions and 23 deletions

View File

@ -572,12 +572,15 @@ static int decode_slice_chroma(AVCodecContext *avctx, SliceContext *slice,
for (i = 0; i < blocks_per_slice; i++) for (i = 0; i < blocks_per_slice; i++)
ctx->bdsp.clear_block(blocks+(i<<6)); ctx->bdsp.clear_block(blocks+(i<<6));
/* Some encodes have empty chroma scans to simulate grayscale */
if (buf_size) {
init_get_bits(&gb, buf, buf_size << 3); init_get_bits(&gb, buf, buf_size << 3);
if ((ret = decode_dc_coeffs(&gb, blocks, blocks_per_slice)) < 0) if ((ret = decode_dc_coeffs(&gb, blocks, blocks_per_slice)) < 0)
return ret; return ret;
if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0) if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0)
return ret; return ret;
}
block = blocks; block = blocks;
for (i = 0; i < slice->mb_count; i++) { for (i = 0; i < slice->mb_count; i++) {
@ -638,7 +641,6 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
LOCAL_ALIGNED_16(int16_t, qmat_chroma_scaled,[64]); LOCAL_ALIGNED_16(int16_t, qmat_chroma_scaled,[64]);
int mb_x_shift; int mb_x_shift;
int ret; int ret;
uint16_t val_no_chroma;
slice->ret = -1; slice->ret = -1;
//av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n", //av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n",
@ -702,7 +704,7 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
if (ret < 0) if (ret < 0)
return ret; return ret;
if (!(avctx->flags & AV_CODEC_FLAG_GRAY) && (u_data_size + v_data_size) > 0) { if (!(avctx->flags & AV_CODEC_FLAG_GRAY)) {
ret = decode_slice_chroma(avctx, slice, (uint16_t*)dest_u, chroma_stride, ret = decode_slice_chroma(avctx, slice, (uint16_t*)dest_u, chroma_stride,
buf + y_data_size, u_data_size, buf + y_data_size, u_data_size,
qmat_chroma_scaled, log2_chroma_blocks_per_mb); qmat_chroma_scaled, log2_chroma_blocks_per_mb);
@ -715,20 +717,6 @@ static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
else {
size_t mb_max_x = slice->mb_count << (mb_x_shift - 1);
size_t i, j;
if (avctx->bits_per_raw_sample == 10) {
val_no_chroma = 511;
} else { /* 12b */
val_no_chroma = 511 * 4;
}
for (i = 0; i < 16; ++i)
for (j = 0; j < mb_max_x; ++j) {
*(uint16_t*)(dest_u + (i * chroma_stride) + (j << 1)) = val_no_chroma;
*(uint16_t*)(dest_v + (i * chroma_stride) + (j << 1)) = val_no_chroma;
}
}
/* decode alpha plane if available */ /* decode alpha plane if available */
if (ctx->alpha_info && pic->data[3] && a_data_size) { if (ctx->alpha_info && pic->data[3] && a_data_size) {

View File

@ -8,8 +8,8 @@
#codec_id 1: pcm_s16le #codec_id 1: pcm_s16le
#sample_rate 1: 48000 #sample_rate 1: 48000
#channel_layout_name 1: stereo #channel_layout_name 1: stereo
0, 0, 0, 1, 1658880, 0x43d9c9e2 0, 0, 0, 1, 1658880, 0x365613b9
1, 0, 0, 1024, 4096, 0x543c9a17 1, 0, 0, 1024, 4096, 0x543c9a17
1, 1024, 1024, 1024, 4096, 0x9aedadd1 1, 1024, 1024, 1024, 4096, 0x9aedadd1
0, 1, 1, 1, 1658880, 0xa2a72f9b 0, 1, 1, 1, 1658880, 0x95247963
1, 2048, 2048, 1024, 4096, 0xa0c9cd55 1, 2048, 2048, 1024, 4096, 0xa0c9cd55