base: tweak swizzle_ycck ycc_upsampling parameter

This moves from a 2-valued "basic (box) or fancy (triangle)" upsampling
parameter to a 3-valued one, which can now represent the fact that
libjpeg's and libwebp's fancy (triangle) upsampling is ever-so-slightly
different (see script/script/replicate-libwebp-chroma-upsampling.go and
its comments).

This is not an optimization or pessimization per se, but for the record,
the performance impact is mixed.

name                                             old speed     new speed     delta

wuffs_jpeg_decode_19k_8bpp/clang14               317MB/s ± 0%  314MB/s ± 0%  -0.99%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_progressive/clang14  318MB/s ± 0%  328MB/s ± 0%  +3.13%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_sequential/clang14   879MB/s ± 0%  871MB/s ± 0%  -0.83%  (p=0.008 n=5+5)
wuffs_jpeg_decode_77k_24bpp/clang14              719MB/s ± 0%  713MB/s ± 0%  -0.89%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_420/clang14         779MB/s ± 0%  771MB/s ± 0%  -1.01%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_444/clang14         902MB/s ± 0%  890MB/s ± 0%  -1.32%  (p=0.008 n=5+5)
wuffs_jpeg_decode_4002k_24bpp/clang14            784MB/s ± 0%  779MB/s ± 0%  -0.66%  (p=0.008 n=5+5)

wuffs_jpeg_decode_19k_8bpp/gcc12                 358MB/s ± 0%  362MB/s ± 0%  +0.93%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_progressive/gcc12    305MB/s ± 0%  311MB/s ± 0%  +1.91%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_sequential/gcc12     912MB/s ± 0%  918MB/s ± 0%  +0.73%  (p=0.016 n=4+5)
wuffs_jpeg_decode_77k_24bpp/gcc12                749MB/s ± 0%  763MB/s ± 0%  +1.83%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_420/gcc12           813MB/s ± 0%  824MB/s ± 0%  +1.37%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_444/gcc12           969MB/s ± 0%  984MB/s ± 0%  +1.62%  (p=0.008 n=5+5)
wuffs_jpeg_decode_4002k_24bpp/gcc12              815MB/s ± 0%  832MB/s ± 0%  +2.06%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2026-07-03 21:38:28 +10:00
1 parent e3b5a7d506
commit 85a0283cfc
8 files changed
+211 -61

No files matched your search

+9 -2
View File
@@ -2072,7 +2072,9 @@ pri func decoder.swizzle_colorful!(dst: ptr base.pixel_buffer, workbuf: slice ba
var height1 : base.u32[..= 0x1_0008]
var height2 : base.u32[..= 0x1_0008]
var height3 : base.u32[..= 0x1_0008]
var status : base.status
var ycc_upsampling : base.u8
var status : base.status
if this.swizzle_immediately {
i = this.swizzle_immediately_c_offsets[0] as base.u64
@@ -2137,6 +2139,11 @@ pri func decoder.swizzle_colorful!(dst: ptr base.pixel_buffer, workbuf: slice ba
}
}
ycc_upsampling = base.YCC_UPSAMPLING__BASIC as base.u8
if not this.use_lower_quality {
ycc_upsampling = base.YCC_UPSAMPLING__FANCY_LIKE_LIBJPEG as base.u8
}
status = this.swizzler.swizzle_ycck!(
dst: args.dst,
dst_palette: args.dst.palette_or_else(fallback: this.dst_palette[..]),
@@ -2169,7 +2176,7 @@ pri func decoder.swizzle_colorful!(dst: ptr base.pixel_buffer, workbuf: slice ba
v2: this.components_v[2],
v3: this.components_v[3],
ycc_model: this.ycc_model,
triangle_filter_for_2to1: not this.use_lower_quality,
ycc_upsampling: ycc_upsampling,
scratch_buffer_2k: this.swizzle_ycck_scratch_buffer_2k[..])
return status
}
+1 -1
View File
@@ -425,7 +425,7 @@ pri func decoder.swizzle_one_row_of_macroblocks!(
v2: 1,
v3: 0,
ycc_model: base.YCC_MODEL__BT_601_STUDIO_RANGE as base.u8,
triangle_filter_for_2to1: false,
ycc_upsampling: base.YCC_UPSAMPLING__BASIC as base.u8,
scratch_buffer_2k: this.swizzle_ycck_scratch_buffer_2k[..])
return status
}