Commit 6debe8042e for ffmpeg
commit 6debe8042e64aee6ae452d736c625cd1c3f8b1da
Author: Lynne <dev@lynne.ee>
Date: Sat Sep 26 16:36:05 2026 +0900
vulkan_ffv1: specialise the line decoder on the extended lookup
Whether the quant table has an extended lookup is known when the slice
starts, so the line decoder is instantiated once for each case instead
of testing it per sample.
Decoding a 6464x4852 16-bit RGB frame with 1024 slices on an RX 6900
XT, with the bitstream in VRAM, goes from 53.5/45.2/44.7 ms to
53.1/43.8/43.2 ms with context model 1/0/2.
diff --git a/libavcodec/vulkan/ffv1_dec.comp.glsl b/libavcodec/vulkan/ffv1_dec.comp.glsl
index 6ad7f3846b..c7559e6e15 100644
--- a/libavcodec/vulkan/ffv1_dec.comp.glsl
+++ b/libavcodec/vulkan/ffv1_dec.comp.glsl
@@ -74,7 +74,7 @@ void decode_line_pcm(ivec2 sp, int w, int y, int p)
void decode_line(ivec2 sp, int w,
int y, int p, int bits, uint state_off,
- uint8_t quant_table_idx, int run_index)
+ uint8_t quant_table_idx, int run_index, bool ext)
{
#ifndef RGB
if (p > 0 && p < 3) {
@@ -83,7 +83,6 @@ void decode_line(ivec2 sp, int w,
}
#endif
- bool ext = extend_lookup[quant_table_idx];
linecache_load(dec[p], sp, y, 0);
ivec3 top = subgroupBroadcast(get_pred_top(dec[p], sp, ivec2(0, y), 0, w,
@@ -188,7 +187,7 @@ void golomb_init(void)
void decode_line(ivec2 sp, int w,
int y, int p, int bits, uint state_off,
- uint8_t quant_table_idx, inout int run_index)
+ uint8_t quant_table_idx, inout int run_index, bool ext)
{
#ifndef RGB
if (p > 0 && p < 3) {
@@ -206,7 +205,7 @@ void decode_line(ivec2 sp, int w,
ivec2 pos = sp + ivec2(x, y);
int diff;
ivec2 pr = get_pred(dec[p], sp, ivec2(x, y), 0, w,
- quant_table_idx, extend_lookup[quant_table_idx]);
+ quant_table_idx, ext);
uint vlc_off = state_off + abs(pr[0]);
@@ -256,6 +255,15 @@ void decode_line(ivec2 sp, int w,
}
#endif
+void decode_plane_line(ivec2 sp, int w, int y, int p, int bits, uint state_off,
+ uint8_t quant_table_idx, inout int run_index)
+{
+ if (has_extend_lookup && extend_lookup[quant_table_idx])
+ decode_line(sp, w, y, p, bits, state_off, quant_table_idx, run_index, true);
+ else
+ decode_line(sp, w, y, p, bits, state_off, quant_table_idx, run_index, false);
+}
+
#ifdef BAYER
void writeout_bayer(uint slice_idx, in SliceContext sc, ivec2 sp, int w, int y)
{
@@ -433,8 +441,8 @@ void decode_slice(in SliceContext sc, uint slice_idx)
int run_index = 0;
for (int y = 0; y < bayer_h; y++) {
for (int p = 0; p < 4; p++)
- decode_line(sp, w, y, p, bits[p],
- slice_state_off[p], quant_table_idx[p], run_index);
+ decode_plane_line(sp, w, y, p, bits[p], slice_state_off[p],
+ quant_table_idx[p], run_index);
writeout_bayer(slice_idx, sc, sp, w, y);
}
@@ -442,8 +450,8 @@ void decode_slice(in SliceContext sc, uint slice_idx)
int run_index = 0;
for (int y = 0; y < sc.slice_dim.y; y++) {
for (int p = 0; p < color_planes; p++)
- decode_line(sp, w, y, p, bits[p],
- slice_state_off[p], quant_table_idx[p], run_index);
+ decode_plane_line(sp, w, y, p, bits[p], slice_state_off[p],
+ quant_table_idx[p], run_index);
writeout_rgb(slice_idx, sc, sp, w, y, true);
}
@@ -455,8 +463,8 @@ void decode_slice(in SliceContext sc, uint slice_idx)
int run_index = 0;
for (int y = 0; y < h; y++)
- decode_line(sp, w, y, p, bits[p],
- slice_state_off[p], quant_table_idx[p], run_index);
+ decode_plane_line(sp, w, y, p, bits[p], slice_state_off[p],
+ quant_table_idx[p], run_index);
}
#endif
}