mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
pixconv: apply YCC->RGB SIMD code to 444 JPEGs
name old speed new speed delta wuffs_jpeg_decode_19k_8bpp/clang11 368MB/s ± 0% 368MB/s ± 0% ~ (p=0.421 n=5+5) wuffs_jpeg_decode_30k_24bpp_progressive/clang11 333MB/s ± 0% 335MB/s ± 0% +0.54% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_sequential/clang11 1.01GB/s ± 0% 1.01GB/s ± 0% +0.38% (p=0.008 n=5+5) wuffs_jpeg_decode_77k_24bpp/clang11 829MB/s ± 0% 828MB/s ± 0% -0.16% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_420/clang11 902MB/s ± 0% 902MB/s ± 0% ~ (p=0.690 n=5+5) wuffs_jpeg_decode_552k_24bpp_444/clang11 649MB/s ± 0% 1121MB/s ± 0% +72.72% (p=0.008 n=5+5) wuffs_jpeg_decode_4002k_24bpp/clang11 905MB/s ± 0% 906MB/s ± 0% ~ (p=0.222 n=5+5) wuffs_jpeg_decode_19k_8bpp/gcc10 362MB/s ± 0% 351MB/s ± 0% -3.06% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_progressive/gcc10 328MB/s ± 0% 330MB/s ± 0% +0.53% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_sequential/gcc10 926MB/s ± 0% 921MB/s ± 0% -0.54% (p=0.008 n=5+5) wuffs_jpeg_decode_77k_24bpp/gcc10 757MB/s ± 0% 743MB/s ± 0% -1.83% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_420/gcc10 835MB/s ± 0% 814MB/s ± 0% -2.55% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_444/gcc10 655MB/s ± 0% 1001MB/s ± 0% +52.74% (p=0.008 n=5+5) wuffs_jpeg_decode_4002k_24bpp/gcc10 843MB/s ± 0% 820MB/s ± 0% -2.70% (p=0.016 n=4+5)
This commit is contained in:
1 parent
3dbfb00c42
commit
b3d0d7b855
2 files changed
+226
-316
No files matched your search
@@ -397,13 +397,13 @@ static const wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_funcs[4][4] = {
|
||||
{
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1v2_triangle,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1vn_box,
|
||||
},
|
||||
{
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v1_triangle,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v2_triangle,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2vn_box,
|
||||
},
|
||||
@@ -673,76 +673,59 @@ wuffs_base__pixel_swizzler__swizzle_ycc__general__box_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__convert_func convfunc) {
|
||||
// Convert an inv_h or inv_v value from {1, 2, 3, 4} to {12, 6, 4, 3}.
|
||||
uint32_t h0_out_of_12 = 12u / inv_h0;
|
||||
uint32_t h1_out_of_12 = 12u / inv_h1;
|
||||
uint32_t h2_out_of_12 = 12u / inv_h2;
|
||||
uint32_t v0_out_of_12 = 12u / inv_v0;
|
||||
uint32_t v1_out_of_12 = 12u / inv_v1;
|
||||
uint32_t v2_out_of_12 = 12u / inv_v2;
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc1 =
|
||||
(*upfuncs)[(inv_h1 - 1u) & 3u][(inv_v1 - 1u) & 3u];
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc2 =
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
|
||||
uint32_t iy0 = 0u;
|
||||
uint32_t iy1 = 0u;
|
||||
uint32_t iy2 = 0u;
|
||||
uint32_t y = 0u;
|
||||
while (true) {
|
||||
const uint8_t* src_iter0 = src_ptr0;
|
||||
const uint8_t* src_iter1 = src_ptr1;
|
||||
const uint8_t* src_iter2 = src_ptr2;
|
||||
uint32_t y;
|
||||
for (y = 0u; y < height; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major = src_ptr1 + ((y / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major = src_ptr2 + ((y / inv_v2) * (size_t)stride2);
|
||||
uint32_t total_src_len0 = 0u;
|
||||
uint32_t total_src_len1 = 0u;
|
||||
uint32_t total_src_len2 = 0u;
|
||||
|
||||
// TODO: call convfunc instead.
|
||||
// ¡ dst_iter = etc
|
||||
|
||||
uint32_t ix0 = 0u;
|
||||
uint32_t ix1 = 0u;
|
||||
uint32_t ix2 = 0u;
|
||||
uint32_t x = 0u;
|
||||
while (true) {
|
||||
uint32_t color = //
|
||||
wuffs_base__color_ycc__as__color_u32( //
|
||||
*src_iter0, *src_iter1, *src_iter2);
|
||||
wuffs_base__pixel_buffer__set_color_u32_at(dst, x, y, color);
|
||||
// ¡ dst_iter += 4
|
||||
while (x < width) {
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
}
|
||||
|
||||
if ((x + 1u) == width) {
|
||||
break;
|
||||
}
|
||||
x = x + 1u;
|
||||
ix0 += h0_out_of_12;
|
||||
if (ix0 >= 12u) {
|
||||
ix0 = 0u;
|
||||
src_iter0++;
|
||||
}
|
||||
ix1 += h1_out_of_12;
|
||||
if (ix1 >= 12u) {
|
||||
ix1 = 0u;
|
||||
src_iter1++;
|
||||
}
|
||||
ix2 += h2_out_of_12;
|
||||
if (ix2 >= 12u) {
|
||||
ix2 = 0u;
|
||||
src_iter2++;
|
||||
}
|
||||
}
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
total_src_len0 += src_len0;
|
||||
total_src_len1 += src_len1;
|
||||
total_src_len2 += src_len2;
|
||||
|
||||
if ((y + 1u) == height) {
|
||||
break;
|
||||
}
|
||||
y = y + 1u;
|
||||
iy0 += v0_out_of_12;
|
||||
if (iy0 >= 12u) {
|
||||
iy0 = 0u;
|
||||
src_ptr0 += stride0;
|
||||
}
|
||||
iy1 += v1_out_of_12;
|
||||
if (iy1 >= 12u) {
|
||||
iy1 = 0u;
|
||||
src_ptr1 += stride1;
|
||||
}
|
||||
iy2 += v2_out_of_12;
|
||||
if (iy2 >= 12u) {
|
||||
iy2 = 0u;
|
||||
src_ptr2 += stride2;
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
(*convfunc)(dst, x, end, y, up0, up1, up2);
|
||||
x = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1040,11 +1023,14 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
memcpy(&upfuncs, &wuffs_base__pixel_swizzler__swizzle_ycc__upsample_funcs,
|
||||
sizeof upfuncs);
|
||||
|
||||
if (triangle_filter_for_2to1 &&
|
||||
(wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h0, inv_v0) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h1, inv_v1) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h2, inv_v2))) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter;
|
||||
if (triangle_filter_for_2to1) {
|
||||
upfuncs[0][1] =
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1v2_triangle;
|
||||
upfuncs[1][0] =
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v1_triangle;
|
||||
upfuncs[1][1] =
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v2_triangle;
|
||||
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Don't use our AVX2 implementation for GCC (but do use it for clang). For
|
||||
@@ -1065,28 +1051,13 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
} else {
|
||||
switch (dst->pixcfg.private_impl.pixfmt.repr) {
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRX:
|
||||
if ((max_incl_h | max_incl_v) == 1) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__hv11;
|
||||
} else {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__box_filter;
|
||||
}
|
||||
break;
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBX:
|
||||
if ((max_incl_h | max_incl_v) == 1) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__hv11;
|
||||
} else {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__box_filter;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (triangle_filter_for_2to1 &&
|
||||
(wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h0, inv_v0) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h1, inv_v1) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h2, inv_v2))) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter;
|
||||
}
|
||||
|
||||
(*func)(dst, width, height, //
|
||||
|
||||
@@ -23949,13 +23949,13 @@ static const wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_funcs[4][4] = {
|
||||
{
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1v2_triangle,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1vn_box,
|
||||
},
|
||||
{
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v1_triangle,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v2_triangle,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2vn_box,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2vn_box,
|
||||
},
|
||||
@@ -24225,74 +24225,59 @@ wuffs_base__pixel_swizzler__swizzle_ycc__general__box_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__convert_func convfunc) {
|
||||
// Convert an inv_h or inv_v value from {1, 2, 3, 4} to {12, 6, 4, 3}.
|
||||
uint32_t h0_out_of_12 = 12u / inv_h0;
|
||||
uint32_t h1_out_of_12 = 12u / inv_h1;
|
||||
uint32_t h2_out_of_12 = 12u / inv_h2;
|
||||
uint32_t v0_out_of_12 = 12u / inv_v0;
|
||||
uint32_t v1_out_of_12 = 12u / inv_v1;
|
||||
uint32_t v2_out_of_12 = 12u / inv_v2;
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc1 =
|
||||
(*upfuncs)[(inv_h1 - 1u) & 3u][(inv_v1 - 1u) & 3u];
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc2 =
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
|
||||
uint32_t iy0 = 0u;
|
||||
uint32_t iy1 = 0u;
|
||||
uint32_t iy2 = 0u;
|
||||
uint32_t y = 0u;
|
||||
while (true) {
|
||||
const uint8_t* src_iter0 = src_ptr0;
|
||||
const uint8_t* src_iter1 = src_ptr1;
|
||||
const uint8_t* src_iter2 = src_ptr2;
|
||||
uint32_t y;
|
||||
for (y = 0u; y < height; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major = src_ptr1 + ((y / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major = src_ptr2 + ((y / inv_v2) * (size_t)stride2);
|
||||
uint32_t total_src_len0 = 0u;
|
||||
uint32_t total_src_len1 = 0u;
|
||||
uint32_t total_src_len2 = 0u;
|
||||
|
||||
// TODO: call convfunc instead.
|
||||
|
||||
uint32_t ix0 = 0u;
|
||||
uint32_t ix1 = 0u;
|
||||
uint32_t ix2 = 0u;
|
||||
uint32_t x = 0u;
|
||||
while (true) {
|
||||
uint32_t color = //
|
||||
wuffs_base__color_ycc__as__color_u32( //
|
||||
*src_iter0, *src_iter1, *src_iter2);
|
||||
wuffs_base__pixel_buffer__set_color_u32_at(dst, x, y, color);
|
||||
while (x < width) {
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
}
|
||||
|
||||
if ((x + 1u) == width) {
|
||||
break;
|
||||
}
|
||||
x = x + 1u;
|
||||
ix0 += h0_out_of_12;
|
||||
if (ix0 >= 12u) {
|
||||
ix0 = 0u;
|
||||
src_iter0++;
|
||||
}
|
||||
ix1 += h1_out_of_12;
|
||||
if (ix1 >= 12u) {
|
||||
ix1 = 0u;
|
||||
src_iter1++;
|
||||
}
|
||||
ix2 += h2_out_of_12;
|
||||
if (ix2 >= 12u) {
|
||||
ix2 = 0u;
|
||||
src_iter2++;
|
||||
}
|
||||
}
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
total_src_len0 += src_len0;
|
||||
total_src_len1 += src_len1;
|
||||
total_src_len2 += src_len2;
|
||||
|
||||
if ((y + 1u) == height) {
|
||||
break;
|
||||
}
|
||||
y = y + 1u;
|
||||
iy0 += v0_out_of_12;
|
||||
if (iy0 >= 12u) {
|
||||
iy0 = 0u;
|
||||
src_ptr0 += stride0;
|
||||
}
|
||||
iy1 += v1_out_of_12;
|
||||
if (iy1 >= 12u) {
|
||||
iy1 = 0u;
|
||||
src_ptr1 += stride1;
|
||||
}
|
||||
iy2 += v2_out_of_12;
|
||||
if (iy2 >= 12u) {
|
||||
iy2 = 0u;
|
||||
src_ptr2 += stride2;
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
(*convfunc)(dst, x, end, y, up0, up1, up2);
|
||||
x = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24480,76 +24465,59 @@ wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__box_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__convert_func convfunc) {
|
||||
uint32_t h0_out_of_12 = 12u / inv_h0;
|
||||
uint32_t h1_out_of_12 = 12u / inv_h1;
|
||||
uint32_t h2_out_of_12 = 12u / inv_h2;
|
||||
uint32_t v0_out_of_12 = 12u / inv_v0;
|
||||
uint32_t v1_out_of_12 = 12u / inv_v1;
|
||||
uint32_t v2_out_of_12 = 12u / inv_v2;
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc1 =
|
||||
(*upfuncs)[(inv_h1 - 1u) & 3u][(inv_v1 - 1u) & 3u];
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc2 =
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
|
||||
uint32_t iy0 = 0u;
|
||||
uint32_t iy1 = 0u;
|
||||
uint32_t iy2 = 0u;
|
||||
uint32_t y = 0u;
|
||||
while (true) {
|
||||
const uint8_t* src_iter0 = src_ptr0;
|
||||
const uint8_t* src_iter1 = src_ptr1;
|
||||
const uint8_t* src_iter2 = src_ptr2;
|
||||
uint32_t y;
|
||||
for (y = 0u; y < height; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major = src_ptr1 + ((y / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major = src_ptr2 + ((y / inv_v2) * (size_t)stride2);
|
||||
uint32_t total_src_len0 = 0u;
|
||||
uint32_t total_src_len1 = 0u;
|
||||
uint32_t total_src_len2 = 0u;
|
||||
|
||||
size_t dst_stride = dst->private_impl.planes[0].stride;
|
||||
uint8_t* dst_iter =
|
||||
dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y));
|
||||
|
||||
uint32_t ix0 = 0u;
|
||||
uint32_t ix1 = 0u;
|
||||
uint32_t ix2 = 0u;
|
||||
uint32_t x = 0u;
|
||||
while (true) {
|
||||
uint32_t color = //
|
||||
wuffs_base__color_ycc__as__color_u32( //
|
||||
*src_iter0, *src_iter1, *src_iter2);
|
||||
wuffs_base__poke_u32le__no_bounds_check(dst_iter, color);
|
||||
dst_iter += 4;
|
||||
while (x < width) {
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
}
|
||||
|
||||
if ((x + 1u) == width) {
|
||||
break;
|
||||
}
|
||||
x = x + 1u;
|
||||
ix0 += h0_out_of_12;
|
||||
if (ix0 >= 12u) {
|
||||
ix0 = 0u;
|
||||
src_iter0++;
|
||||
}
|
||||
ix1 += h1_out_of_12;
|
||||
if (ix1 >= 12u) {
|
||||
ix1 = 0u;
|
||||
src_iter1++;
|
||||
}
|
||||
ix2 += h2_out_of_12;
|
||||
if (ix2 >= 12u) {
|
||||
ix2 = 0u;
|
||||
src_iter2++;
|
||||
}
|
||||
}
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
total_src_len0 += src_len0;
|
||||
total_src_len1 += src_len1;
|
||||
total_src_len2 += src_len2;
|
||||
|
||||
if ((y + 1u) == height) {
|
||||
break;
|
||||
}
|
||||
y = y + 1u;
|
||||
iy0 += v0_out_of_12;
|
||||
if (iy0 >= 12u) {
|
||||
iy0 = 0u;
|
||||
src_ptr0 += stride0;
|
||||
}
|
||||
iy1 += v1_out_of_12;
|
||||
if (iy1 >= 12u) {
|
||||
iy1 = 0u;
|
||||
src_ptr1 += stride1;
|
||||
}
|
||||
iy2 += v2_out_of_12;
|
||||
if (iy2 >= 12u) {
|
||||
iy2 = 0u;
|
||||
src_ptr2 += stride2;
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
(*convfunc)(dst, x, end, y, up0, up1, up2);
|
||||
x = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24577,76 +24545,59 @@ wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__box_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__convert_func convfunc) {
|
||||
uint32_t h0_out_of_12 = 12u / inv_h0;
|
||||
uint32_t h1_out_of_12 = 12u / inv_h1;
|
||||
uint32_t h2_out_of_12 = 12u / inv_h2;
|
||||
uint32_t v0_out_of_12 = 12u / inv_v0;
|
||||
uint32_t v1_out_of_12 = 12u / inv_v1;
|
||||
uint32_t v2_out_of_12 = 12u / inv_v2;
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc1 =
|
||||
(*upfuncs)[(inv_h1 - 1u) & 3u][(inv_v1 - 1u) & 3u];
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_func upfunc2 =
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
|
||||
uint32_t iy0 = 0u;
|
||||
uint32_t iy1 = 0u;
|
||||
uint32_t iy2 = 0u;
|
||||
uint32_t y = 0u;
|
||||
while (true) {
|
||||
const uint8_t* src_iter0 = src_ptr0;
|
||||
const uint8_t* src_iter1 = src_ptr1;
|
||||
const uint8_t* src_iter2 = src_ptr2;
|
||||
uint32_t y;
|
||||
for (y = 0u; y < height; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major = src_ptr1 + ((y / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major = src_ptr2 + ((y / inv_v2) * (size_t)stride2);
|
||||
uint32_t total_src_len0 = 0u;
|
||||
uint32_t total_src_len1 = 0u;
|
||||
uint32_t total_src_len2 = 0u;
|
||||
|
||||
size_t dst_stride = dst->private_impl.planes[0].stride;
|
||||
uint8_t* dst_iter =
|
||||
dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y));
|
||||
|
||||
uint32_t ix0 = 0u;
|
||||
uint32_t ix1 = 0u;
|
||||
uint32_t ix2 = 0u;
|
||||
uint32_t x = 0u;
|
||||
while (true) {
|
||||
uint32_t color = //
|
||||
wuffs_base__color_ycc__as__color_u32_abgr(
|
||||
*src_iter0, *src_iter1, *src_iter2);
|
||||
wuffs_base__poke_u32le__no_bounds_check(dst_iter, color);
|
||||
dst_iter += 4;
|
||||
while (x < width) {
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
}
|
||||
|
||||
if ((x + 1u) == width) {
|
||||
break;
|
||||
}
|
||||
x = x + 1u;
|
||||
ix0 += h0_out_of_12;
|
||||
if (ix0 >= 12u) {
|
||||
ix0 = 0u;
|
||||
src_iter0++;
|
||||
}
|
||||
ix1 += h1_out_of_12;
|
||||
if (ix1 >= 12u) {
|
||||
ix1 = 0u;
|
||||
src_iter1++;
|
||||
}
|
||||
ix2 += h2_out_of_12;
|
||||
if (ix2 >= 12u) {
|
||||
ix2 = 0u;
|
||||
src_iter2++;
|
||||
}
|
||||
}
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
total_src_len0 += src_len0;
|
||||
total_src_len1 += src_len1;
|
||||
total_src_len2 += src_len2;
|
||||
|
||||
if ((y + 1u) == height) {
|
||||
break;
|
||||
}
|
||||
y = y + 1u;
|
||||
iy0 += v0_out_of_12;
|
||||
if (iy0 >= 12u) {
|
||||
iy0 = 0u;
|
||||
src_ptr0 += stride0;
|
||||
}
|
||||
iy1 += v1_out_of_12;
|
||||
if (iy1 >= 12u) {
|
||||
iy1 = 0u;
|
||||
src_ptr1 += stride1;
|
||||
}
|
||||
iy2 += v2_out_of_12;
|
||||
if (iy2 >= 12u) {
|
||||
iy2 = 0u;
|
||||
src_ptr2 += stride2;
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
(*convfunc)(dst, x, end, y, up0, up1, up2);
|
||||
x = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24859,11 +24810,14 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
memcpy(&upfuncs, &wuffs_base__pixel_swizzler__swizzle_ycc__upsample_funcs,
|
||||
sizeof upfuncs);
|
||||
|
||||
if (triangle_filter_for_2to1 &&
|
||||
(wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h0, inv_v0) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h1, inv_v1) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h2, inv_v2))) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter;
|
||||
if (triangle_filter_for_2to1) {
|
||||
upfuncs[0][1] =
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h1v2_triangle;
|
||||
upfuncs[1][0] =
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v1_triangle;
|
||||
upfuncs[1][1] =
|
||||
wuffs_base__pixel_swizzler__swizzle_ycc__upsample_inv_h2v2_triangle;
|
||||
|
||||
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Don't use our AVX2 implementation for GCC (but do use it for clang). For
|
||||
@@ -24884,28 +24838,13 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
} else {
|
||||
switch (dst->pixcfg.private_impl.pixfmt.repr) {
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__BGRX:
|
||||
if ((max_incl_h | max_incl_v) == 1) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__hv11;
|
||||
} else {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__box_filter;
|
||||
}
|
||||
break;
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
|
||||
case WUFFS_BASE__PIXEL_FORMAT__RGBX:
|
||||
if ((max_incl_h | max_incl_v) == 1) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__hv11;
|
||||
} else {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__box_filter;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (triangle_filter_for_2to1 &&
|
||||
(wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h0, inv_v0) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h1, inv_v1) ||
|
||||
wuffs_base__pixel_swizzler__has_triangle_upsampler(inv_h2, inv_v2))) {
|
||||
func = &wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter;
|
||||
}
|
||||
|
||||
(*func)(dst, width, height, //
|
||||
|
||||
Reference in new issue
Block a user