mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
vulkan/ffv1: improve compiler hints
Don't unroll unless needed, don't use const in function arguments, don't use expect unless actually needed.
This commit is contained in:
@@ -151,7 +151,7 @@ const uint32_t log2_run[41] = {
|
||||
ivec2 get_pred(readonly uimage2D pred, ivec2 sp, ivec2 off,
|
||||
uint comp, int sw, uint8_t quant_table_idx, bool extend_lookup)
|
||||
{
|
||||
const ivec2 yoff_border1 = expectEXT(off.x == 0, false) ? off + ivec2(1, -1) : off;
|
||||
ivec2 yoff_border1 = expectEXT(off.x == 0, false) ? off + ivec2(1, -1) : off;
|
||||
|
||||
/* Thanks to the same coincidence as below, we can skip checking if off == 0, 1 */
|
||||
VTYPE3 top = VTYPE3(TYPE(imageLoad(pred, sp + LADDR(yoff_border1 + ivec2(-1, -1)))[comp]),
|
||||
@@ -170,7 +170,7 @@ ivec2 get_pred(readonly uimage2D pred, ivec2 sp, ivec2 off,
|
||||
if (has_extend_lookup && extend_lookup) {
|
||||
TYPE cur2 = TYPE(0);
|
||||
if (expectEXT(off.x > 0, true)) {
|
||||
const ivec2 yoff_border2 = expectEXT(off.x == 1, false) ? ivec2(-1, -1) : ivec2(-2, 0);
|
||||
ivec2 yoff_border2 = expectEXT(off.x == 1, false) ? ivec2(-1, -1) : ivec2(-2, 0);
|
||||
cur2 = TYPE(imageLoad(pred, sp + LADDR(off + yoff_border2))[comp]);
|
||||
}
|
||||
base += quant_table[quant_table_idx][3][(cur2 - cur) & MAX_QUANT_TABLE_MASK];
|
||||
@@ -195,7 +195,7 @@ ivec2 get_pred(readonly uimage2D pred, ivec2 sp, ivec2 off,
|
||||
ivec2 get_pred(readonly uimage2D pred, ivec2 sp, ivec2 off,
|
||||
uint comp, int sw, uint8_t quant_table_idx, bool extend_lookup)
|
||||
{
|
||||
const ivec2 yoff_border1 = off.x == 0 ? ivec2(1, -1) : ivec2(0, 0);
|
||||
ivec2 yoff_border1 = off.x == 0 ? ivec2(1, -1) : ivec2(0, 0);
|
||||
sp += off;
|
||||
|
||||
VTYPE3 top = VTYPE3(TYPE(0),
|
||||
@@ -219,7 +219,7 @@ ivec2 get_pred(readonly uimage2D pred, ivec2 sp, ivec2 off,
|
||||
if (has_extend_lookup && extend_lookup) {
|
||||
TYPE cur2 = TYPE(0);
|
||||
if (off.x > 0 && off != ivec2(1, 0)) {
|
||||
const ivec2 yoff_border2 = off.x == 1 ? ivec2(1, -1) : ivec2(0, 0);
|
||||
ivec2 yoff_border2 = off.x == 1 ? ivec2(1, -1) : ivec2(0, 0);
|
||||
cur2 = TYPE(imageLoad(pred, sp + ivec2(-2, 0) + yoff_border2)[comp]);
|
||||
}
|
||||
base += quant_table[quant_table_idx][3][(cur2 - cur) & MAX_QUANT_TABLE_MASK];
|
||||
|
||||
@@ -98,7 +98,6 @@ void decode_line_pcm(ivec2 sp, int w, int y, int p)
|
||||
for (int x = 0; x < w; x++) {
|
||||
uint v = 0;
|
||||
|
||||
[[unroll]]
|
||||
for (uint i = (rct_offset >> 1); i > 0; i >>= 1)
|
||||
v |= get_rac_equi() ? i : 0;
|
||||
|
||||
@@ -259,7 +258,7 @@ void writeout_rgb(in SliceContext sc, ivec2 sp, int w, int y, bool apply_rct)
|
||||
if (transparency)
|
||||
pix.a = int(imageLoad(dec[3], lpos)[0]);
|
||||
|
||||
if (expectEXT(apply_rct, true))
|
||||
if (apply_rct)
|
||||
pix = transform_sample(pix, sc.slice_rct_coef);
|
||||
else
|
||||
pix = ivec4(pix[fmt_lut[0]], pix[fmt_lut[1]],
|
||||
|
||||
@@ -81,7 +81,6 @@ void encode_line_pcm(in SliceContext sc, readonly uimage2D img,
|
||||
for (int x = 0; x < w; x++) {
|
||||
uint v = imageLoad(img, sp + LADDR(ivec2(x, y)))[comp];
|
||||
|
||||
[[unroll]]
|
||||
for (uint i = (rct_offset >> 1); i > 0; i >>= 1)
|
||||
put_rac_equi(bool(v & i));
|
||||
}
|
||||
@@ -89,7 +88,7 @@ void encode_line_pcm(in SliceContext sc, readonly uimage2D img,
|
||||
|
||||
void encode_line(in SliceContext sc, readonly uimage2D img, uint state_off,
|
||||
ivec2 sp, int y, uint p, uint comp,
|
||||
uint8_t quant_table_idx, const int run_index)
|
||||
uint8_t quant_table_idx, in int run_index)
|
||||
{
|
||||
int w = sc.slice_dim.x;
|
||||
|
||||
@@ -241,7 +240,7 @@ void preload_rgb(in SliceContext sc, ivec2 sp, int w, int y, bool apply_rct)
|
||||
|
||||
ivec4 pix = load_components(pos);
|
||||
|
||||
if (expectEXT(apply_rct, true))
|
||||
if (apply_rct)
|
||||
transform_sample(pix, sc.slice_rct_coef);
|
||||
|
||||
imageStore(tmp, lpos, pix);
|
||||
@@ -325,7 +324,7 @@ void encode_slice(in SliceContext sc, uint slice_idx)
|
||||
#endif
|
||||
}
|
||||
|
||||
void finalize_slice(const uint slice_idx)
|
||||
void finalize_slice(in uint slice_idx)
|
||||
{
|
||||
#ifdef GOLOMB
|
||||
uint32_t enc_len = hdr_len + flush_put_bits(pb);
|
||||
@@ -367,7 +366,7 @@ void finalize_slice(const uint slice_idx)
|
||||
|
||||
void main(void)
|
||||
{
|
||||
const uint slice_idx = gl_WorkGroupID.y*gl_NumWorkGroups.x + gl_WorkGroupID.x;
|
||||
uint slice_idx = gl_WorkGroupID.y*gl_NumWorkGroups.x + gl_WorkGroupID.x;
|
||||
|
||||
if (gl_LocalInvocationID.x == 0)
|
||||
rc = slice_ctx[slice_idx].c;
|
||||
|
||||
@@ -30,7 +30,7 @@ struct VlcState {
|
||||
uint8_t count;
|
||||
};
|
||||
|
||||
void update_vlc_state(inout VlcState state, const int v)
|
||||
void update_vlc_state(inout VlcState state, in int v)
|
||||
{
|
||||
int drift = state.drift;
|
||||
int count = state.count;
|
||||
|
||||
@@ -120,7 +120,7 @@ void renorm_encoder(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
void put_rac_internal(const uint range1, bool bit)
|
||||
void put_rac_internal(in uint range1, bool bit)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (range1 >= rc.range)
|
||||
@@ -208,7 +208,7 @@ void refill(void)
|
||||
rc.bs_off++;
|
||||
}
|
||||
|
||||
bool get_rac_internal(const uint range1)
|
||||
bool get_rac_internal(in uint range1)
|
||||
{
|
||||
uint ranged = rc.range - range1;
|
||||
bool bit = rc.low >= ranged;
|
||||
|
||||
Reference in New Issue
Block a user