Commit 5a26a9ffa1 for ffmpeg
commit 5a26a9ffa17cb1eed95c0020bb71c5078f378b96
Author: Niklas Haas <git@haasn.dev>
Date: Tue Oct 20 23:45:05 2026 +0200
swscale/ops_internal: make pack decoding helper take the pattern directly
Allows reusing it for SwsPackUOp, which has the same pattern layout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
diff --git a/libswscale/ops.c b/libswscale/ops.c
index 6b8ec400ca..2660d66d06 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -209,14 +209,14 @@ void ff_sws_apply_op_q(const SwsOp *op, AVRational64 x[4])
case SWS_OP_WRITE:
return;
case SWS_OP_UNPACK: {
- ff_sws_pack_op_decode(op, mask, shift);
+ ff_sws_pack_decode(op->pack.pattern, mask, shift);
unsigned val = x[0].num;
for (int i = 0; i < 4; i++)
x[i] = Q((val >> shift[i]) & mask[i]);
return;
}
case SWS_OP_PACK: {
- ff_sws_pack_op_decode(op, mask, shift);
+ ff_sws_pack_decode(op->pack.pattern, mask, shift);
unsigned val = 0;
for (int i = 0; i < 4; i++)
val |= (x[i].num & mask[i]) << shift[i];
diff --git a/libswscale/ops_internal.h b/libswscale/ops_internal.h
index b9e070e81b..e956c34eb0 100644
--- a/libswscale/ops_internal.h
+++ b/libswscale/ops_internal.h
@@ -28,13 +28,14 @@
#define Q(N) ((AVRational64) { N, 1 })
-static inline void ff_sws_pack_op_decode(const SwsOp *op, uint64_t mask[4], int shift[4])
+static inline void ff_sws_pack_decode(const uint8_t pattern[4],
+ uint64_t mask[4], int shift[4])
{
int size = 0;
for (int i = 0; i < 4; i++)
- size += op->pack.pattern[i];
+ size += pattern[i];
for (int i = 0; i < 4; i++) {
- const int bits = op->pack.pattern[i];
+ const int bits = pattern[i];
mask[i] = (UINT64_C(1) << bits) - 1;
shift[i] = (i ? shift[i - 1] : size) - bits;
}
diff --git a/libswscale/vulkan/ops.c b/libswscale/vulkan/ops.c
index 910aac11e3..5a840b788d 100644
--- a/libswscale/vulkan/ops.c
+++ b/libswscale/vulkan/ops.c
@@ -568,7 +568,7 @@ static void define_shader_consts(SwsContext *sws, const SwsOpList *ops,
case SWS_OP_UNPACK: {
uint64_t mask[4];
int shift[4], tmp[4];
- ff_sws_pack_op_decode(op, mask, shift);
+ ff_sws_pack_decode(op->pack.pattern, mask, shift);
for (int i = 0; i < 4; i++)
tmp[i] = spi_OpConstantUInt(spi, u32_type, shift[i]);
oid->pack.shift = spi_OpConstantComposite(spi, id->u32vec4_type,