aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vulkan/rangecoder.comp
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2025-05-02 11:52:17 +0200
committerLynne <dev@lynne.ee>2025-05-20 19:53:00 +0900
commit69f83bafd1faa69f3b05c87615c098eb0173d35f (patch)
tree8e040997b9bfec6f4f957c86f4a171097fe76f87 /libavcodec/vulkan/rangecoder.comp
parenta4078abd739a79390fdb8aefa1d5c3aa84d843e6 (diff)
downloadffmpeg-69f83bafd1faa69f3b05c87615c098eb0173d35f.tar.gz
ffv1enc_vulkan: get rid of temporary data for the setup shader
Diffstat (limited to 'libavcodec/vulkan/rangecoder.comp')
-rw-r--r--libavcodec/vulkan/rangecoder.comp28
1 files changed, 17 insertions, 11 deletions
diff --git a/libavcodec/vulkan/rangecoder.comp b/libavcodec/vulkan/rangecoder.comp
index 256b5f0e79..1db42e1dc9 100644
--- a/libavcodec/vulkan/rangecoder.comp
+++ b/libavcodec/vulkan/rangecoder.comp
@@ -91,15 +91,13 @@ void renorm_encoder(inout RangeCoder c)
bs[i].v = fill;
}
-void put_rac_norenorm(inout RangeCoder c, uint64_t state, bool bit)
+void put_rac_direct(inout RangeCoder c, uint8_t state, bool bit)
{
- u8buf sb = u8buf(state);
- uint val = uint(sb.v);
- int range1 = uint16_t((c.range * val) >> 8);
+ int range1 = uint16_t((c.range * state) >> 8);
#ifdef DEBUG
- if (val == 0)
- debugPrintfEXT("Error: state is zero (addr: 0x%lx)", uint64_t(sb));
+ if (state == 0)
+ debugPrintfEXT("Error: state is zero");
if (range1 >= c.range)
debugPrintfEXT("Error: range1 >= c.range");
if (range1 <= 0)
@@ -113,13 +111,21 @@ void put_rac_norenorm(inout RangeCoder c, uint64_t state, bool bit)
} else {
c.range = diff;
}
+}
- sb.v = zero_one_state[(uint(bit) << 8) + val];
+void put_rac_norenorm(inout RangeCoder c, uint64_t state, bool bit)
+{
+ put_rac_direct(c, u8buf(state).v, bit);
-#ifdef DEBUG
- if (sb.v == 0)
- debugPrintfEXT("Error: inserted zero state from tab %i idx %i", bit, val);
-#endif
+ u8buf(state).v = zero_one_state[(uint(bit) << 8) + u8buf(state).v];
+}
+
+void put_rac(inout RangeCoder c, inout uint8_t state, bool bit)
+{
+ put_rac_direct(c, state, bit);
+ if (c.range < 0x100)
+ renorm_encoder_full(c);
+ state = zero_one_state[(uint(bit) << 8) + state];
}
/* Equiprobable bit */