From 3fd55d952efe421908a93d689aa0caf5523b5158 Mon Sep 17 00:00:00 2001 From: averne Date: Tue, 12 Aug 2025 14:31:00 +0200 Subject: [PATCH] avcodec/proresdec: save slice width parameter in codec context Save the log2_desired_slice_size_in_mb syntax element in the codec context. Required by the Vulkan hwaccel to compute slice widths and positions. --- libavcodec/proresdec.c | 9 ++++++--- libavcodec/proresdec.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c index 578d87f815..0b6556107f 100644 --- a/libavcodec/proresdec.c +++ b/libavcodec/proresdec.c @@ -335,6 +335,9 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons return AVERROR_INVALIDDATA; } + ctx->slice_mb_width = 1 << log2_slice_mb_width; + ctx->slice_mb_height = 1 << log2_slice_mb_height; + ctx->mb_width = (avctx->width + 15) >> 4; if (ctx->frame_type) ctx->mb_height = (avctx->height + 31) >> 5; @@ -344,7 +347,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons // QT ignores the written value // slice_count = AV_RB16(buf + 5); slice_count = ctx->mb_height * ((ctx->mb_width >> log2_slice_mb_width) + - av_popcount(ctx->mb_width & (1 << log2_slice_mb_width) - 1)); + av_popcount(ctx->mb_width & ctx->slice_mb_width - 1)); if (ctx->slice_count != slice_count || !ctx->slices) { av_freep(&ctx->slices); @@ -367,7 +370,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons index_ptr = buf + hdr_size; data_ptr = index_ptr + slice_count*2; - slice_mb_count = 1 << log2_slice_mb_width; + slice_mb_count = ctx->slice_mb_width; mb_x = 0; mb_y = 0; @@ -392,7 +395,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons mb_x += slice_mb_count; if (mb_x == ctx->mb_width) { - slice_mb_count = 1 << log2_slice_mb_width; + slice_mb_count = ctx->slice_mb_width; mb_x = 0; mb_y++; } diff --git a/libavcodec/proresdec.h b/libavcodec/proresdec.h index d15e5b2c1d..d33eab149b 100644 --- a/libavcodec/proresdec.h +++ b/libavcodec/proresdec.h @@ -52,6 +52,8 @@ typedef struct { int slice_count; ///< number of slices in the current picture unsigned mb_width; ///< width of the current picture in mb unsigned mb_height; ///< height of the current picture in mb + unsigned slice_mb_width; ///< maximum width of a slice in mb + unsigned slice_mb_height; ///< maximum height of a slice in mb uint8_t progressive_scan[64]; uint8_t interlaced_scan[64]; const uint8_t *scan;