1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

ffv1_common: minor RGB optimization

This commit is contained in:
Lynne
2025-05-02 15:39:55 +02:00
parent bd41838b60
commit 8a2d921627

View File

@ -100,17 +100,17 @@ uint slice_coord(uint width, uint sx, uint num_h_slices, uint chroma_shift)
ivec2 get_pred(readonly uimage2D pred, ivec2 sp, ivec2 off, ivec2 get_pred(readonly uimage2D pred, ivec2 sp, ivec2 off,
int comp, int sw, uint8_t quant_table_idx, bool extend_lookup) int comp, int sw, uint8_t quant_table_idx, bool extend_lookup)
{ {
const ivec2 yoff_border1 = expectEXT(off.x == 0, false) ? ivec2(1, -1) : ivec2(0, 0); const 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 */ /* Thanks to the same coincidence as below, we can skip checking if off == 0, 1 */
VTYPE3 top = VTYPE3(TYPE(imageLoad(pred, sp + LADDR(off + ivec2(-1, -1) + yoff_border1))[comp]), VTYPE3 top = VTYPE3(TYPE(imageLoad(pred, sp + LADDR(yoff_border1 + ivec2(-1, -1)))[comp]),
TYPE(imageLoad(pred, sp + LADDR(off + ivec2(0, -1)))[comp]), TYPE(imageLoad(pred, sp + LADDR(off + ivec2(0, -1)))[comp]),
TYPE(imageLoad(pred, sp + LADDR(off + ivec2(min(1, sw - off.x - 1), -1)))[comp])); TYPE(imageLoad(pred, sp + LADDR(off + ivec2(min(1, sw - off.x - 1), -1)))[comp]));
/* Normally, we'd need to check if off != ivec2(0, 0) here, since otherwise, we must /* Normally, we'd need to check if off != ivec2(0, 0) here, since otherwise, we must
* return zero. However, ivec2(-1, 0) + ivec2(1, -1) == ivec2(0, -1), e.g. previous * return zero. However, ivec2(-1, 0) + ivec2(1, -1) == ivec2(0, -1), e.g. previous
* row, 0 offset, same slice, which is zero since we zero out the buffer for RGB */ * row, 0 offset, same slice, which is zero since we zero out the buffer for RGB */
TYPE cur = TYPE(imageLoad(pred, sp + LADDR(off + ivec2(-1, 0) + yoff_border1))[comp]); TYPE cur = TYPE(imageLoad(pred, sp + LADDR(yoff_border1 + ivec2(-1, 0)))[comp]);
int base = quant_table[quant_table_idx][0][(cur - top[0]) & MAX_QUANT_TABLE_MASK] + int base = quant_table[quant_table_idx][0][(cur - top[0]) & MAX_QUANT_TABLE_MASK] +
quant_table[quant_table_idx][1][(top[0] - top[1]) & MAX_QUANT_TABLE_MASK] + quant_table[quant_table_idx][1][(top[0] - top[1]) & MAX_QUANT_TABLE_MASK] +