image-simd

module
v0.0.0-...-123047e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: BSD-3-Clause

README

image-simd

English | Русский


English

A SIMD-accelerated fork of golang.org/x/image — supplementary Go image packages.

What's different from the original

This fork adds SIMD-accelerated image drawing via Go's auto-vectorization, specifically in the draw sub-package:

Feature Original (golang.org/x/image) image-simd
draw.Draw (RGBA/NRGBA) Scalar pixel-by-pixel SIMD auto-vectorized accumulation
Horizontal accumulation Scalar float64 loops Vectorized with archsimd.Float64x4
Vertical accumulation Scalar float64 loops Vectorized with archsimd.Float64x4
How it works

The draw sub-package contains two build-tagged implementations:

  • draw/simd_helpers.go (GOEXPERIMENT=simd && amd64) — Uses archsimd.Float64x4 vectors for parallel weighted accumulation of RGBA/NRGBA pixel channels:

    • accumulateHorizontalRGBA — processes all 4 channels simultaneously
    • accumulateHorizontalNRGBA — handles alpha correction + 4-channel accumulation
    • accumulateVertical — vectorized vertical weighted sum
  • draw/simd_fallback.go (!GOEXPERIMENT=simd || !amd64) — Standard scalar loops for platforms without SIMD support.

Usage

Drop-in replacement for golang.org/x/image:

import "github.com/Anykey-Nomad/image-simd/draw"

// Same API as golang.org/x/image/draw
draw.Draw(dst, src.Bounds(), src, src.Min, draw.Over)

To enable SIMD acceleration:

GOEXPERIMENT=simd go build
API

The API is identical to golang.org/x/image. All standard image operations (draw, font, math/fixed, tiff, webp, etc.) are available.

License

Same as the original: BSD 3-Clause License.


Русский

Форк golang.org/x/image с SIMD-ускорением — вспомогательные Go-пакеты для изображений.

Отличия от оригинала

Этот форк добавляет SIMD-ускоренную отрисовку изображений через автовекторизацию Go, конкретно в под-пакете draw:

Функция Оригинал (golang.org/x/image) image-simd
draw.Draw (RGBA/NRGBA) Посимвольная scalar-обработка SIMD автовекторизированное накопление
Горизонтальное накопление Scalar циклы float64 Векторизовано с archsimd.Float64x4
Вертикальное накопление Scalar циклы float64 Векторизовано с archsimd.Float64x4
Как это работает

Под-пакет draw содержит две реализации с build-тегами:

  • draw/simd_helpers.go (GOEXPERIMENT=simd && amd64) — Использует векторы archsimd.Float64x4 для параллельного взвешенного накопления каналов пикселей RGBA/NRGBA:

    • accumulateHorizontalRGBA — обрабатывает все 4 канала одновременно
    • accumulateHorizontalNRGBA — обрабатывает альфа-коррекцию + накопление 4 каналов
    • accumulateVertical — векторизованная вертикальная взвешенная сумма
  • draw/simd_fallback.go (!GOEXPERIMENT=simd || !amd64) — Стандартные scalar-циклы для платформ без поддержки SIMD.

Использование

Замена golang.org/x/image без изменений кода:

import "github.com/Anykey-Nomad/image-simd/draw"

// API идентична golang.org/x/image/draw
draw.Draw(dst, src.Bounds(), src, src.Min, draw.Over)

Для включения SIMD-ускорения:

GOEXPERIMENT=simd go build
API

API идентичен golang.org/x/image. Доступны все стандартные операции (draw, font, math/fixed, tiff, webp и др.).

Лицензия

BSD 3-Clause License — идентична оригиналу.

Directories

Path Synopsis
Package bmp implements a BMP image decoder and encoder.
Package bmp implements a BMP image decoder and encoder.
Package ccitt implements a CCITT (fax) image decoder.
Package ccitt implements a CCITT (fax) image decoder.
Package colornames provides named colors as defined in the SVG 1.1 spec.
Package colornames provides named colors as defined in the SVG 1.1 spec.
Package draw provides image composition functions.
Package draw provides image composition functions.
Package font defines an interface for font faces, for drawing text on an image.
Package font defines an interface for font faces, for drawing text on an image.
basicfont
Package basicfont provides fixed-size font faces.
Package basicfont provides fixed-size font faces.
gofont/gobold
Package gobold provides the "Go Bold" TrueType font from the Go font family.
Package gobold provides the "Go Bold" TrueType font from the Go font family.
gofont/gobolditalic
Package gobolditalic provides the "Go Bold Italic" TrueType font from the Go font family.
Package gobolditalic provides the "Go Bold Italic" TrueType font from the Go font family.
gofont/goitalic
Package goitalic provides the "Go Italic" TrueType font from the Go font family.
Package goitalic provides the "Go Italic" TrueType font from the Go font family.
gofont/gomedium
Package gomedium provides the "Go Medium" TrueType font from the Go font family.
Package gomedium provides the "Go Medium" TrueType font from the Go font family.
gofont/gomediumitalic
Package gomediumitalic provides the "Go Medium Italic" TrueType font from the Go font family.
Package gomediumitalic provides the "Go Medium Italic" TrueType font from the Go font family.
gofont/gomono
Package gomono provides the "Go Mono" TrueType font from the Go font family.
Package gomono provides the "Go Mono" TrueType font from the Go font family.
gofont/gomonobold
Package gomonobold provides the "Go Mono Bold" TrueType font from the Go font family.
Package gomonobold provides the "Go Mono Bold" TrueType font from the Go font family.
gofont/gomonobolditalic
Package gomonobolditalic provides the "Go Mono Bold Italic" TrueType font from the Go font family.
Package gomonobolditalic provides the "Go Mono Bold Italic" TrueType font from the Go font family.
gofont/gomonoitalic
Package gomonoitalic provides the "Go Mono Italic" TrueType font from the Go font family.
Package gomonoitalic provides the "Go Mono Italic" TrueType font from the Go font family.
gofont/goregular
Package goregular provides the "Go Regular" TrueType font from the Go font family.
Package goregular provides the "Go Regular" TrueType font from the Go font family.
gofont/gosmallcaps
Package gosmallcaps provides the "Go Smallcaps" TrueType font from the Go font family.
Package gosmallcaps provides the "Go Smallcaps" TrueType font from the Go font family.
gofont/gosmallcapsitalic
Package gosmallcapsitalic provides the "Go Smallcaps Italic" TrueType font from the Go font family.
Package gosmallcapsitalic provides the "Go Smallcaps Italic" TrueType font from the Go font family.
inconsolata
Package inconsolata provides pre-rendered bitmap versions of the Inconsolata font family.
Package inconsolata provides pre-rendered bitmap versions of the Inconsolata font family.
opentype
Package opentype implements a glyph rasterizer for TTF (TrueType Fonts) and OTF (OpenType Fonts).
Package opentype implements a glyph rasterizer for TTF (TrueType Fonts) and OTF (OpenType Fonts).
plan9font
Package plan9font implements font faces for the Plan 9 font and subfont file formats.
Package plan9font implements font faces for the Plan 9 font and subfont file formats.
sfnt
Package sfnt implements a decoder for TTF (TrueType Fonts) and OTF (OpenType Fonts).
Package sfnt implements a decoder for TTF (TrueType Fonts) and OTF (OpenType Fonts).
internal
safemath
Package safemath contains overflow-safe math functions.
Package safemath contains overflow-safe math functions.
math
f32
Package f32 implements float32 vector and matrix types.
Package f32 implements float32 vector and matrix types.
f64
Package f64 implements float64 vector and matrix types.
Package f64 implements float64 vector and matrix types.
fixed
Package fixed implements fixed-point integer types.
Package fixed implements fixed-point integer types.
Package riff implements the Resource Interchange File Format, used by media formats such as AVI, WAVE and WEBP.
Package riff implements the Resource Interchange File Format, used by media formats such as AVI, WAVE and WEBP.
Package tiff implements a TIFF image decoder and encoder.
Package tiff implements a TIFF image decoder and encoder.
lzw
Package lzw implements the Lempel-Ziv-Welch compressed data format, described in T. A. Welch, “A Technique for High-Performance Data Compression”, Computer, 17(6) (June 1984), pp 8-19.
Package lzw implements the Lempel-Ziv-Welch compressed data format, described in T. A. Welch, “A Technique for High-Performance Data Compression”, Computer, 17(6) (June 1984), pp 8-19.
Package vector provides a rasterizer for 2-D vector graphics.
Package vector provides a rasterizer for 2-D vector graphics.
Package vp8 implements a decoder for the VP8 lossy image format.
Package vp8 implements a decoder for the VP8 lossy image format.
Package vp8l implements a decoder for the VP8L lossless image format.
Package vp8l implements a decoder for the VP8L lossless image format.
Package webp implements a decoder for WEBP images.
Package webp implements a decoder for WEBP images.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL