vulkan_ffv1: use proper rounded divisions for plane width and height

Fixes #20314
This commit is contained in:
Lynne
2025-12-13 18:41:53 +01:00
parent 91deb96d3c
commit c3291993eb
3 changed files with 13 additions and 10 deletions

View File

@@ -65,6 +65,9 @@ layout(buffer_reference, buffer_reference_align = 8) buffer u64buf {
#define mid_pred(a, b, c) \
max(min((a), (b)), min(max((a), (b)), (c)))
#define ceil_rshift(a, b) \
(-((-(a)) >> (b)))
/* TODO: optimize */
uint align(uint src, uint a)
{

View File

@@ -63,7 +63,7 @@ void decode_line_pcm(inout SliceContext sc, ivec2 sp, int w, int y, int p, int b
#ifndef RGB
if (p > 0 && p < 3) {
w >>= chroma_shift.x;
w = ceil_rshift(w, chroma_shift.x);
sp >>= chroma_shift;
}
#endif
@@ -83,7 +83,7 @@ void decode_line(inout SliceContext sc, ivec2 sp, int w,
{
#ifndef RGB
if (p > 0 && p < 3) {
w >>= chroma_shift.x;
w = ceil_rshift(w, chroma_shift.x);
sp >>= chroma_shift;
}
#endif
@@ -125,7 +125,7 @@ void decode_line(inout SliceContext sc, ivec2 sp, int w,
{
#ifndef RGB
if (p > 0 && p < 3) {
w >>= chroma_shift.x;
w = ceil_rshift(w, chroma_shift.x);
sp >>= chroma_shift;
}
#endif
@@ -249,7 +249,7 @@ void decode_slice(inout SliceContext sc, const uint slice_idx)
for (int p = 0; p < planes; p++) {
int h = sc.slice_dim.y;
if (p > 0 && p < 3)
h >>= chroma_shift.y;
h = ceil_rshift(h, chroma_shift.y);
for (int y = 0; y < h; y++)
decode_line_pcm(sc, sp, w, y, p, bits);
@@ -274,7 +274,7 @@ void decode_slice(inout SliceContext sc, const uint slice_idx)
for (int p = 0; p < planes; p++) {
int h = sc.slice_dim.y;
if (p > 0 && p < 3)
h >>= chroma_shift.y;
h = ceil_rshift(h, chroma_shift.y);
int run_index = 0;
for (int y = 0; y < h; y++)

View File

@@ -61,7 +61,7 @@ void encode_line_pcm(inout SliceContext sc, readonly uimage2D img,
#ifndef RGB
if (p > 0 && p < 3) {
w >>= chroma_shift.x;
w = ceil_rshift(w, chroma_shift.x);
sp >>= chroma_shift;
}
#endif
@@ -81,7 +81,7 @@ void encode_line(inout SliceContext sc, readonly uimage2D img, uint state_off,
#ifndef RGB
if (p > 0 && p < 3) {
w >>= chroma_shift.x;
w = ceil_rshift(w, chroma_shift.x);
sp >>= chroma_shift;
}
#endif
@@ -123,7 +123,7 @@ void encode_line(inout SliceContext sc, readonly uimage2D img, uint state_off,
#ifndef RGB
if (p > 0 && p < 3) {
w >>= chroma_shift.x;
w = ceil_rshift(w, chroma_shift.x);
sp >>= chroma_shift;
}
#endif
@@ -244,7 +244,7 @@ void encode_slice(inout SliceContext sc, const uint slice_idx)
int h = sc.slice_dim.y;
if (c > 0 && c < 3)
h >>= chroma_shift.y;
h = ceil_rshift(h, chroma_shift.y);
/* Takes into account dual-plane YUV formats */
int p = min(c, planes - 1);
@@ -276,7 +276,7 @@ void encode_slice(inout SliceContext sc, const uint slice_idx)
int h = sc.slice_dim.y;
if (c > 0 && c < 3)
h >>= chroma_shift.y;
h = ceil_rshift(h, chroma_shift.y);
int p = min(c, planes - 1);
int comp = c - p;