mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-11-06 05:17:42 +00:00
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>
This commit is contained in:
1 parent
0a83847313
commit
5a26a9ffa1
3 files changed
+7
-6
No files matched your search
+2
-2
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user