mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
cgen: optimize etc__swizzle_ycck for 420 bgrx/rgbx
name old speed new speed delta wuffs_jpeg_decode_30k_24bpp_progressive/clang11 172MB/s ± 0% 200MB/s ± 0% +15.74% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_sequential/clang11 292MB/s ± 0% 362MB/s ± 0% +23.88% (p=0.008 n=5+5) wuffs_jpeg_decode_77k_24bpp/clang11 256MB/s ± 0% 307MB/s ± 0% +19.79% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_420/clang11 264MB/s ± 0% 318MB/s ± 0% +20.32% (p=0.008 n=5+5) wuffs_jpeg_decode_4002k_24bpp/clang11 269MB/s ± 0% 320MB/s ± 0% +19.13% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_progressive/gcc10 202MB/s ± 0% 224MB/s ± 0% +11.01% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_sequential/gcc10 350MB/s ± 0% 454MB/s ± 0% +29.83% (p=0.008 n=5+5) wuffs_jpeg_decode_77k_24bpp/gcc10 248MB/s ± 0% 311MB/s ± 0% +24.97% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_420/gcc10 261MB/s ± 0% 327MB/s ± 0% +25.49% (p=0.008 n=5+5) wuffs_jpeg_decode_4002k_24bpp/gcc10 259MB/s ± 0% 324MB/s ± 0% +25.38% (p=0.008 n=5+5)
This commit is contained in:
1 parent
aec9003ea0
commit
379000a711
3 files changed
+369
-12
No files matched your search
@@ -22,6 +22,13 @@ import (
|
||||
func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
||||
src := embedBasePixConvSubmoduleYcckC.Trim()
|
||||
|
||||
generalTriangleFilter, err := extractCFunc(src, ""+
|
||||
"static void //\n"+
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter(\n")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
generalBoxFilter, err := extractCFunc(src, ""+
|
||||
"static void //\n"+
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__general__box_filter(\n")
|
||||
@@ -40,15 +47,24 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
||||
|
||||
// ----
|
||||
|
||||
const dstIterEtc = "" +
|
||||
const dstIterEtcSansX = "" +
|
||||
"size_t dst_stride = dst->private_impl.planes[0].stride;\n" +
|
||||
"uint8_t* dst_iter =\n" +
|
||||
" dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y));\n"
|
||||
const setColorU32At = "" +
|
||||
const dstIterWithX = "" +
|
||||
"size_t dst_stride = dst->private_impl.planes[0].stride;\n" +
|
||||
"uint8_t* dst_iter =\n" +
|
||||
" dst->private_impl.planes[0].ptr + (dst_stride * ((size_t)y)) + (4 * ((size_t)x));\n"
|
||||
const setColorU32AtSrcIter = "" +
|
||||
"wuffs_base__poke_u32le__no_bounds_check(\n" +
|
||||
" dst_iter, wuffs_base__color_ycc__as__color_u32_FLAVOR(\n" +
|
||||
" *src_iter0, *src_iter1, *src_iter2));\n" +
|
||||
"dst_iter += 4;\n"
|
||||
const setColorU32AtUp = "" +
|
||||
"wuffs_base__poke_u32le__no_bounds_check(\n" +
|
||||
" dst_iter, wuffs_base__color_ycc__as__color_u32_FLAVOR(\n" +
|
||||
" *up0++, *up1++, *up2++));\n" +
|
||||
"dst_iter += 4;\n"
|
||||
const useIxHv11 = "" +
|
||||
"src_iter0++;\n" +
|
||||
"src_iter1++;\n" +
|
||||
@@ -58,6 +74,37 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
||||
"src_ptr1 += stride1;\n" +
|
||||
"src_ptr2 += stride2;\n"
|
||||
|
||||
// ----
|
||||
|
||||
generalTriangleFilterPatches := []struct {
|
||||
newFuncNameLine string
|
||||
patchMap map[string]string
|
||||
}{{
|
||||
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__triangle_filter(\n",
|
||||
map[string]string{
|
||||
"// ¡ dst_iter = etc\n": dstIterWithX,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtUp, "_FLAVOR", "", 1),
|
||||
},
|
||||
}, {
|
||||
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__triangle_filter(\n",
|
||||
map[string]string{
|
||||
"// ¡ dst_iter = etc\n": dstIterWithX,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtUp, "_FLAVOR", "_abgr", 1),
|
||||
},
|
||||
}}
|
||||
|
||||
for _, p := range generalTriangleFilterPatches {
|
||||
const oldFuncNameLine = "wuffs_base__pixel_swizzler__swizzle_ycc__general__triangle_filter(\n"
|
||||
p.patchMap[oldFuncNameLine] = p.newFuncNameLine
|
||||
if err := patchCFunc(buf, generalTriangleFilter, oldFuncNameLine, p.patchMap); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
generalBoxFilterPatches := []struct {
|
||||
newFuncNameLine string
|
||||
patchMap map[string]string
|
||||
@@ -65,22 +112,22 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
||||
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__box_filter(\n",
|
||||
map[string]string{
|
||||
"// ¡ dst_iter = etc\n": dstIterEtc,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32At, "_FLAVOR", "", 1),
|
||||
"// ¡ dst_iter = etc\n": dstIterEtcSansX,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtSrcIter, "_FLAVOR", "", 1),
|
||||
},
|
||||
}, {
|
||||
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__box_filter(\n",
|
||||
map[string]string{
|
||||
"// ¡ dst_iter = etc\n": dstIterEtc,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32At, "_FLAVOR", "_abgr", 1),
|
||||
"// ¡ dst_iter = etc\n": dstIterEtcSansX,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtSrcIter, "_FLAVOR", "_abgr", 1),
|
||||
},
|
||||
}, {
|
||||
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__bgrx__hv11(\n",
|
||||
map[string]string{
|
||||
"// ¡ dst_iter = etc\n": dstIterEtc,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32At, "_FLAVOR", "", 1),
|
||||
"// ¡ dst_iter = etc\n": dstIterEtcSansX,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtSrcIter, "_FLAVOR", "", 1),
|
||||
"// ¡ BEGIN declare iy\n": "",
|
||||
"// ¡ BEGIN declare ix\n": "",
|
||||
"// ¡ BEGIN use ix\n": useIxHv11,
|
||||
@@ -90,8 +137,8 @@ func insertBasePixConvSubmoduleYcckC(buf *buffer) error {
|
||||
|
||||
"wuffs_base__pixel_swizzler__swizzle_ycc__rgbx__hv11(\n",
|
||||
map[string]string{
|
||||
"// ¡ dst_iter = etc\n": dstIterEtc,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32At, "_FLAVOR", "_abgr", 1),
|
||||
"// ¡ dst_iter = etc\n": dstIterEtcSansX,
|
||||
"// ¡ BEGIN set_color_u32_at\n": strings.Replace(setColorU32AtSrcIter, "_FLAVOR", "_abgr", 1),
|
||||
"// ¡ BEGIN declare iy\n": "",
|
||||
"// ¡ BEGIN declare ix\n": "",
|
||||
"// ¡ BEGIN use ix\n": useIxHv11,
|
||||
|
||||
Reference in new issue
Block a user