Documentation
¶
Overview ¶
Package nvjpeg2k provides Go bindings for NVIDIA's nvJPEG2000 decoder, libnvjpeg2k.
This package loads libnvjpeg2k on its own. It shares no handle, no loader, and no symbol table with nvJPEG: they are separate libraries.
Decode order ¶
A decode is four steps, and the metadata step is not optional. Parse the bitstream into a Bitstream, read Bitstream.ImageInfo and, for every component, Bitstream.ComponentInfo, allocate one device buffer per component from those per-component dimensions and bit depths, then decode into them. Component width, height, precision and sign vary per component: a subsampled chroma plane is smaller than the luma plane, and the image dimensions in ImageInfo do not describe it. Sizing every plane from the image dimensions overruns nothing detectable on the host and corrupts the decode.
LayoutOf performs the metadata step and returns a Layout; Layout.Bind turns caller-owned device buffers into a Destination only if they match that layout, and Handle.DecodeInto accepts nothing else. The raw Handle.Decode, Handle.DecodeImage and Handle.DecodeTile wrappers take an Image you filled in yourself and check nothing.
A tile decode has its own extents. Use LayoutOfTile and Handle.DecodeTileInto for one; a whole-image layout is refused there, and a tile layout is refused by Handle.DecodeInto.
Ownership ¶
Handle, DecodeState, Bitstream, and DecodeParams are library-owned resources reached through opaque handles. Each has a Destroy method and none is finalized automatically; a dropped handle leaks. Destroy the decode state and the bitstream before the library handle that created them.
Decode output buffers are caller-owned device memory. This package does not allocate them, does not free them, and cannot check their size. The pixel-data and pitch arrays in Image are host arrays that the library reads during the call; the device addresses they hold must stay valid until the CUDA stream has completed, because the decode functions are asynchronous with respect to the host.
The input buffer passed to Handle.Parse is read during that call and is not retained; Handle.Parse keeps it alive across the call. The parsed metadata lives in the Bitstream until it is reparsed or destroyed, and a Layout read from a Bitstream describes the bitstream as it was parsed at that moment.
The header documents a Handle as thread safe and usable from several host threads at once. It documents a DecodeState as reusable only if the caller makes a stream or device synchronize CUDA call between two decodes that share it. This package does not enforce either rule and has not verified them.
Availability ¶
Importing this package does not open the library. The first call loads it, or returns *LibraryError describing every name tried. A symbol missing from an older libnvjpeg2k returns *SymbolError naming it. Neither panics. Use Has or the generated Has* predicates to probe before calling.
Encode is not bound. See the nvJPEG2000 documentation for the encode API.
Library lifecycle ¶
- NewHandleWithAllocators: creates a library handle with caller-supplied device and pinned allocators.
- NewHandle: creates a library handle with the default backend and allocators.
- NewHandleWithAllocatorsV2: creates a library handle with stream-ordered caller-supplied allocators.
- Handle.Close: releases a library handle and the resources it owns.
- Handle.SetDeviceMemoryPadding: rounds later device allocations up to a multiple of padding bytes.
- Handle.SetPinnedMemoryPadding: rounds later pinned host allocations up to a multiple of padding bytes.
Decode ¶
- Handle.Decode: decodes a whole image into caller-allocated device buffers.
- Handle.DecodeImage: decodes a whole image into caller-allocated device buffers, under decode parameters.
- Handle.DecodeTile: decodes one tile into caller-allocated device buffers.
Decode parameters ¶
- NewDecodeParams: creates a decode parameters handle holding output options.
- DecodeParams.Close: releases a decode parameters handle.
- DecodeParams.SetDecodeArea: restricts decoding to a rectangle within the tile of interest.
- DecodeParams.SetOutputFormat: selects planar or interleaved output.
- DecodeParams.SetRGBOutput: requests RGB output for chroma-subsampled sYCC streams.
Decode state ¶
- NewDecodeState: creates a decode state holding the intermediate buffers a decode needs.
- DecodeState.Close: releases a decode state.
Library version ¶
- GetCudartProperty: returns one component of the CUDA Toolkit version the library was built against.
- Handle.DeviceMemoryPadding: returns the current device allocation padding in bytes.
- Handle.PinnedMemoryPadding: returns the current pinned host allocation padding in bytes.
- GetProperty: returns one component of the loaded library's version.
Bitstream parsing and metadata ¶
- NewBitstream: creates an empty bitstream handle to parse into.
- Bitstream.Close: releases a bitstream handle and the metadata parsed into it.
- Bitstream.ColorSpace: returns the color space recorded in a JP2 container.
- Bitstream.ComponentNLTInfo: returns one component's nonlinear-transformation parameters.
- Bitstream.ComponentInfo: returns one component's dimensions, bit depth, and signedness.
- Bitstream.ImageInfo: returns the image dimensions, tile grid, and component count.
- Bitstream.ResolutionComponentDim: returns one tile component's width and height at a resolution level.
- Bitstream.ResolutionsInTile: returns the number of resolution levels present in a tile.
- Bitstream.TileComponentDim: returns one tile component's width and height.
- Handle.ParseFile: parses a JPEG 2000 file from disk.
Example ¶
Example decodes one JPEG 2000 file into caller-allocated device memory.
It is written out in full because the order matters: the per-component metadata is read before anything is allocated, and the allocation sizes come from that metadata rather than from the image dimensions.
cudaMalloc and cudaFree stand in for whichever CUDA binding the caller uses; this package never allocates device memory.
package main
import (
"log"
"os"
"github.com/tmc/lib/nvidia/nvjpeg2k"
)
func main() {
data, err := os.ReadFile("image.jp2")
if err != nil {
log.Fatal(err)
}
handle, err := nvjpeg2k.NewHandle()
if err != nil {
log.Fatal(err)
}
defer handle.Close()
state, err := nvjpeg2k.NewDecodeState(handle)
if err != nil {
log.Fatal(err)
}
defer state.Close()
bitstream, err := nvjpeg2k.NewBitstream()
if err != nil {
log.Fatal(err)
}
defer bitstream.Close()
if err := handle.Parse(data, bitstream); err != nil {
log.Fatal(err)
}
// The metadata step. Every allocation below is sized from what this
// returns, never from Layout.Info: a subsampled chroma plane is smaller
// than the image.
layout, err := nvjpeg2k.LayoutOf(bitstream, nvjpeg2k.Uint8, nvjpeg2k.FormatPlanar)
if err != nil {
log.Fatal(err)
}
var buffers []nvjpeg2k.DeviceBuffer
for _, req := range layout.Buffers() {
ptr, err := cudaMalloc(req.MinSizeInBytes)
if err != nil {
log.Fatal(err)
}
defer cudaFree(ptr)
buffers = append(buffers, nvjpeg2k.DeviceBuffer{
Ptr: ptr,
PitchInBytes: req.MinPitchInBytes,
SizeInBytes: req.MinSizeInBytes,
})
}
destination, err := layout.Bind(buffers...)
if err != nil {
log.Fatal(err)
}
// Asynchronous: the buffers must stay allocated until the stream has
// completed, and the decode state must not be reused before then.
if err := handle.DecodeInto(state, bitstream, nil, destination, 0); err != nil {
log.Fatal(err)
}
if err := cudaStreamSynchronize(0); err != nil {
log.Fatal(err)
}
}
func cudaMalloc(size int) (uintptr, error) { panic("stand-in for a CUDA allocation") }
func cudaFree(ptr uintptr) error { panic("stand-in for a CUDA free") }
func cudaStreamSynchronize(s uintptr) error { panic("stand-in for cudaStreamSynchronize") }
Output:
Index ¶
- Constants
- func Close() error
- func Decode(handle Handle, decodeState DecodeState, jpeg2kStream Bitstream, ...) error
- func DecodeImage(handle Handle, decodeState DecodeState, jpeg2kStream Bitstream, ...) error
- func DecodeParamsDestroy(decodeParams DecodeParams) error
- func DecodeParamsSetDecodeArea(decodeParams DecodeParams, startX uint32, endX uint32, startY uint32, ...) error
- func DecodeParamsSetOutputFormat(decodeParams DecodeParams, format ImageFormat) error
- func DecodeParamsSetRGBOutput(decodeParams DecodeParams, forceRgb int32) error
- func DecodeStateDestroy(decodeState DecodeState) error
- func DecodeTile(handle Handle, decodeState DecodeState, jpeg2kStream Bitstream, ...) error
- func Destroy(handle Handle) error
- func GetCudartProperty(property LibraryPropertyType) (int32, error)
- func GetDeviceMemoryPadding(handle Handle) (uint, error)
- func GetPinnedMemoryPadding(handle Handle) (uint, error)
- func GetProperty(property LibraryPropertyType) (int32, error)
- func Has(symbol string) bool
- func HasCreate() bool
- func HasCreateSimple() bool
- func HasCreateV2() bool
- func HasDecode() bool
- func HasDecodeImage() bool
- func HasDecodeParamsCreate() bool
- func HasDecodeParamsDestroy() bool
- func HasDecodeParamsSetDecodeArea() bool
- func HasDecodeParamsSetOutputFormat() bool
- func HasDecodeParamsSetRGBOutput() bool
- func HasDecodeStateCreate() bool
- func HasDecodeStateDestroy() bool
- func HasDecodeTile() bool
- func HasDestroy() bool
- func HasGetCudartProperty() bool
- func HasGetDeviceMemoryPadding() bool
- func HasGetPinnedMemoryPadding() bool
- func HasGetProperty() bool
- func HasSetDeviceMemoryPadding() bool
- func HasSetPinnedMemoryPadding() bool
- func HasStreamCreate() bool
- func HasStreamDestroy() bool
- func HasStreamGetColorSpace() bool
- func HasStreamGetComponentNLTInfo() bool
- func HasStreamGetImageComponentInfo() bool
- func HasStreamGetImageInfo() bool
- func HasStreamGetResolutionComponentDim() bool
- func HasStreamGetResolutionsInTile() bool
- func HasStreamGetTileComponentDim() bool
- func HasStreamParse() bool
- func HasStreamParseFile() bool
- func Load(path string) error
- func Loaded() bool
- func Path() string
- func SetDeviceMemoryPadding(padding uint, handle Handle) error
- func SetPinnedMemoryPadding(padding uint, handle Handle) error
- func StreamDestroy(streamHandle Bitstream) error
- func StreamGetResolutionComponentDim(streamHandle Bitstream, componentId uint32, tileId uint32, resLevel uint32) (resWidth uint32, resHeight uint32, err error)
- func StreamGetResolutionsInTile(streamHandle Bitstream, tileId uint32) (uint32, error)
- func StreamGetTileComponentDim(streamHandle Bitstream, componentId uint32, tileId uint32) (tileWidth uint32, tileHeight uint32, err error)
- func StreamParseFile(handle Handle, filename string, streamHandle Bitstream) error
- type Backend
- type BindFailure
- type Bitstream
- func (b *Bitstream) Close() error
- func (b Bitstream) ColorSpace() (ColorSpace, error)
- func (b Bitstream) ComponentInfo(componentId uint32) (ImageComponentInfo, error)
- func (b Bitstream) ComponentNLTInfo(componentId uint32) (NLTInfo, error)
- func (b Bitstream) ImageInfo() (ImageInfo, error)
- func (b Bitstream) ResolutionComponentDim(componentId uint32, tileId uint32, resLevel uint32) (resWidth uint32, resHeight uint32, err error)
- func (b Bitstream) ResolutionsInTile(tileId uint32) (uint32, error)
- func (b Bitstream) TileComponentDim(componentId uint32, tileId uint32) (tileWidth uint32, tileHeight uint32, err error)
- type BitstreamType
- type BufferRequirement
- type CallError
- type ColorSpace
- type ComponentLayout
- type DecodeParams
- type DecodeState
- type Destination
- type DeviceAllocator
- type DeviceAllocatorV2
- type DeviceBuffer
- type EncodeConfig
- type Handle
- func Create(backend Backend, deviceAllocator *DeviceAllocator, ...) (Handle, error)
- func CreateSimple() (Handle, error)
- func CreateV2(backend Backend, devAllocator *DeviceAllocatorV2, ...) (Handle, error)
- func NewHandle() (Handle, error)
- func NewHandleWithAllocators(backend Backend, deviceAllocator *DeviceAllocator, ...) (Handle, error)
- func NewHandleWithAllocatorsV2(backend Backend, devAllocator *DeviceAllocatorV2, ...) (Handle, error)
- func (h *Handle) Close() error
- func (h Handle) Decode(decodeState DecodeState, jpeg2kStream Bitstream, decodeOutput *Image, ...) error
- func (h Handle) DecodeImage(decodeState DecodeState, jpeg2kStream Bitstream, decodeParams DecodeParams, ...) error
- func (h Handle) DecodeInto(state DecodeState, bs Bitstream, params *Params, dst *Destination, ...) error
- func (h Handle) DecodeTile(decodeState DecodeState, jpeg2kStream Bitstream, decodeParams DecodeParams, ...) error
- func (h Handle) DecodeTileInto(state DecodeState, bs Bitstream, params *Params, tileID, numResLevels uint32, ...) error
- func (h Handle) DeviceMemoryPadding() (uint, error)
- func (h Handle) Parse(data []byte, bs Bitstream) error
- func (h Handle) ParseFile(filename string, streamHandle Bitstream) error
- func (h Handle) PinnedMemoryPadding() (uint, error)
- func (h Handle) SetDeviceMemoryPadding(padding uint) error
- func (h Handle) SetPinnedMemoryPadding(padding uint) error
- type Image
- type ImageComponentInfo
- type ImageFormat
- type ImageInfo
- type ImageType
- type Layout
- type LibraryAttempt
- type LibraryConflictError
- type LibraryError
- type LibraryPropertyType
- type NLTInfo
- type NLTType
- type Params
- func (p *Params) Destroy() error
- func (p *Params) Handle() DecodeParams
- func (p *Params) OutputFormat() ImageFormat
- func (p *Params) RGBOutput() bool
- func (p *Params) SetDecodeArea(startX, endX, startY, endY uint32) error
- func (p *Params) SetOutputFormat(format ImageFormat) error
- func (p *Params) SetRGBOutput(rgb bool) error
- type PinnedAllocator
- type PinnedAllocatorV2
- type ProgOrder
- type QualityType
- type Result
- type SymbolError
Examples ¶
Constants ¶
const ( // HeaderVersionMajor is NVJPEG2K_VER_MAJOR from the pinned header. HeaderVersionMajor = 0 // HeaderVersionMinor is NVJPEG2K_VER_MINOR from the pinned header. HeaderVersionMinor = 11 // HeaderVersionPatch is NVJPEG2K_VER_PATCH from the pinned header. HeaderVersionPatch = 0 // HeaderVersionBuild is NVJPEG2K_VER_BUILD from the pinned header. HeaderVersionBuild = 51 )
Header version constants, from the pinned nvjpeg2k_version.h these bindings were generated from. The loaded library reports its own version through GetProperty, which may differ.
const MaxResolutions = 33
MaxResolutions is NVJPEG2K_MAXRES, the largest number of resolution levels a JPEG 2000 codestream may carry.
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close() error
Close unloads the library and clears all bound function pointers.
The function pointers are package-level state, so Close must not be called concurrently with any other call into this package: doing so is a use-after-free. It is intended for test teardown, not for reclaiming a live library.
func Decode ¶
func Decode(handle Handle, decodeState DecodeState, jpeg2kStream Bitstream, decodeOutput *Image, stream driver.Stream) error
Decode decodes a whole image into caller-allocated device buffers.
Decodes a single image and writes it to the output device buffers. The function is asynchronous with respect to the host. All GPU tasks will be submitted to the provided stream. Prior to calling this function, the user must parse the bitstream using nvjpeg2kStreamParse() such that the bitstream information is stored in jpeg2kStream.
The decode is asynchronous: it returns once the work is submitted to stream. The output struct is read on the host during the call, but the device addresses it holds must stay allocated until stream has completed. Synchronize the stream or the device before reusing the decode state for another image.
- handle: [in] Library handle
- decodeState: [in] Decode state handle
- jpeg2kStream: [in] Bitstream handle with parsed information
- decodeOutput: in/out Decode output struct. The struct should be on host memory. The image component pointers should point to device memory. See Image
- stream: [in] CUDA stream. Can be set to 0
Wraps nvjpeg2kDecode.
func DecodeImage ¶
func DecodeImage(handle Handle, decodeState DecodeState, jpeg2kStream Bitstream, decodeParams DecodeParams, decodeOutput *Image, stream driver.Stream) error
DecodeImage decodes a whole image into caller-allocated device buffers, under decode parameters.
Decodes a single image and writes it to the output device buffers. The function is asynchronous with respect to the host. All GPU tasks will be submitted to the provided stream. Prior to calling this function, the user must parse the bitstream using nvjpeg2kStreamParse() such that the bitstream information is stored in jpeg2kStream. It is possible to control the decode output using an instance of DecodeParams.
The decode is asynchronous: it returns once the work is submitted to stream. The output struct is read on the host during the call, but the device addresses it holds must stay allocated until stream has completed. Synchronize the stream or the device before reusing the decode state for another image.
- handle: [in] Library handle
- decodeState: [in] Decode state handle
- jpeg2kStream: [in] Bitstream handle with parsed information
- decodeParams: [in] Decode parameters to control output (e.g. area of interest, RGB output). Can be set to NULL
- decodeOutput: in/out Decode output struct. The struct should be on host memory. The image component pointers should point to device memory. See Image
- stream: [in] CUDA stream. Can be set to 0
Wraps nvjpeg2kDecodeImage.
func DecodeParamsDestroy ¶
func DecodeParamsDestroy(decodeParams DecodeParams) error
DecodeParamsDestroy releases a decode parameters handle.
- decodeParams: [in] Decode parameters handle to release
Wraps nvjpeg2kDecodeParamsDestroy.
func DecodeParamsSetDecodeArea ¶
func DecodeParamsSetDecodeArea(decodeParams DecodeParams, startX uint32, endX uint32, startY uint32, endY uint32) error
DecodeParamsSetDecodeArea restricts decoding to a rectangle within the tile of interest.
The coordinates are relative to the image origin and should be within the tile of interest. If the coordinates are set to 0, the entire tile will be decoded.
- decodeParams: in/out Decode parameters handle
- startX: [in] Left coordinate of the decode area
- endX: [in] Right coordinate of the decode area
- startY: [in] Top coordinate of the decode area
- endY: [in] Bottom coordinate of the decode area
Wraps nvjpeg2kDecodeParamsSetDecodeArea.
func DecodeParamsSetOutputFormat ¶
func DecodeParamsSetOutputFormat(decodeParams DecodeParams, format ImageFormat) error
DecodeParamsSetOutputFormat selects planar or interleaved output.
Sets the decode output format. When using FormatInterleaved with 420/422 chroma subsampling, RGB output (DecodeParams.SetRGBOutput) must also be enabled.
The decode output buffer should be allocated in the following manner to support FormatInterleaved:
- decodeParams: in/out Decode parameters handle
- format: [in] Output format. Defaults to FormatPlanar
Wraps nvjpeg2kDecodeParamsSetOutputFormat.
func DecodeParamsSetRGBOutput ¶
func DecodeParamsSetRGBOutput(decodeParams DecodeParams, forceRgb int32) error
DecodeParamsSetRGBOutput requests RGB output for chroma-subsampled sYCC streams.
Enables RGB decode output for images with 444/422/420 chroma subsampling when the stream's color space is sYCC. It is ignored for other color spaces (e.g. sRGB 444). YCC to RGB conversion is based on sYCC, Amendment 1 to IEC 61966-2-1. The color conversion is applied at a tile granularity due to which the chroma reconstruction may not be accurate for tiles with odd dimensions.
- decodeParams: in/out Decode parameters handle
- forceRgb: [in] Set to 1 to enable RGB output
Wraps nvjpeg2kDecodeParamsSetRGBOutput.
func DecodeStateDestroy ¶
func DecodeStateDestroy(decodeState DecodeState) error
DecodeStateDestroy releases a decode state.
- decodeState: [in] Decode state handle to release
Wraps nvjpeg2kDecodeStateDestroy.
func DecodeTile ¶
func DecodeTile(handle Handle, decodeState DecodeState, jpeg2kStream Bitstream, decodeParams DecodeParams, tileId uint32, numResLevels uint32, decodeOutput *Image, stream driver.Stream) error
DecodeTile decodes one tile into caller-allocated device buffers.
Decodes a tile within an image and writes it to the output device buffers. The function is asynchronous with respect to the host. All GPU tasks will be submitted to the provided stream. Prior to calling this function, the user must parse the bitstream using nvjpeg2kStreamParse() such that the bitstream information is stored in jpeg2kStream.
The decode is asynchronous: it returns once the work is submitted to stream. The output struct is read on the host during the call, but the device addresses it holds must stay allocated until stream has completed. Synchronize the stream or the device before reusing the decode state for another image.
- handle: [in] Library handle
- decodeState: [in] Decode state handle
- jpeg2kStream: [in] Bitstream handle with parsed information
- decodeParams: [in] Decode parameters to control output. Can be set to NULL
- tileId: [in] Raster scan based tile index
- numResLevels: [in] Number of resolutions to decode within the tile. When set to 0, the image is decoded at full resolution. Maximum allowed resolutions in a tile can be determined using Bitstream.ResolutionsInTile
- decodeOutput: in/out Decode output struct. The struct should be on host memory. The image component pointers should point to device memory. See Image
- stream: [in] CUDA stream. Can be set to 0
Wraps nvjpeg2kDecodeTile.
func Destroy ¶
Destroy releases a library handle and the resources it owns.
Destroy every decode state, bitstream, and decode parameters handle created from this handle first. Handles are not finalized automatically; a dropped handle leaks.
- handle: [in] Library handle to release
Wraps nvjpeg2kDestroy.
func GetCudartProperty ¶
func GetCudartProperty(property LibraryPropertyType) (int32, error)
GetCudartProperty returns one component of the CUDA Toolkit version the library was built against.
Returns the numeric value for the major version, minor version, or the patch level of the CUDA toolkit that was used to build the nvJPEG2000 library.
- property: [in] Version type: MAJOR_VERSION, MINOR_VERSION, or PATCH_LEVEL
Wraps nvjpeg2kGetCudartProperty.
func GetDeviceMemoryPadding ¶
GetDeviceMemoryPadding returns the current device allocation padding in bytes.
- handle: [in] Library handle
Wraps nvjpeg2kGetDeviceMemoryPadding.
func GetPinnedMemoryPadding ¶
GetPinnedMemoryPadding returns the current pinned host allocation padding in bytes.
- handle: [in] Library handle
Wraps nvjpeg2kGetPinnedMemoryPadding.
func GetProperty ¶
func GetProperty(property LibraryPropertyType) (int32, error)
GetProperty returns one component of the loaded library's version.
Returns the numeric value for the major version, minor version, or the patch level of the nvJPEG2000 library.
- property: [in] Version type: MAJOR_VERSION, MINOR_VERSION, or PATCH_LEVEL
Wraps nvjpeg2kGetProperty.
func Has ¶
Has reports whether the named C symbol resolved in the loaded library, loading it first if necessary. It returns false if the library failed to load. Use it to gate on capabilities before calling into them.
Example ¶
ExampleHas shows probing before calling. The library is opened on the first call, not at import, so this is also how to find out whether it is installed without provoking an error.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nvjpeg2k"
)
func main() {
if !nvjpeg2k.Has("nvjpeg2kStreamGetComponentNLTInfo") {
fmt.Println("no NLT metadata: floating-point destinations are unavailable")
}
}
Output:
func HasCreate ¶
func HasCreate() bool
HasCreate reports whether nvjpeg2kCreate resolved in the loaded library.
func HasCreateSimple ¶
func HasCreateSimple() bool
HasCreateSimple reports whether nvjpeg2kCreateSimple resolved in the loaded library.
func HasCreateV2 ¶
func HasCreateV2() bool
HasCreateV2 reports whether nvjpeg2kCreateV2 resolved in the loaded library.
func HasDecode ¶
func HasDecode() bool
HasDecode reports whether nvjpeg2kDecode resolved in the loaded library.
func HasDecodeImage ¶
func HasDecodeImage() bool
HasDecodeImage reports whether nvjpeg2kDecodeImage resolved in the loaded library.
func HasDecodeParamsCreate ¶
func HasDecodeParamsCreate() bool
HasDecodeParamsCreate reports whether nvjpeg2kDecodeParamsCreate resolved in the loaded library.
func HasDecodeParamsDestroy ¶
func HasDecodeParamsDestroy() bool
HasDecodeParamsDestroy reports whether nvjpeg2kDecodeParamsDestroy resolved in the loaded library.
func HasDecodeParamsSetDecodeArea ¶
func HasDecodeParamsSetDecodeArea() bool
HasDecodeParamsSetDecodeArea reports whether nvjpeg2kDecodeParamsSetDecodeArea resolved in the loaded library.
func HasDecodeParamsSetOutputFormat ¶
func HasDecodeParamsSetOutputFormat() bool
HasDecodeParamsSetOutputFormat reports whether nvjpeg2kDecodeParamsSetOutputFormat resolved in the loaded library.
func HasDecodeParamsSetRGBOutput ¶
func HasDecodeParamsSetRGBOutput() bool
HasDecodeParamsSetRGBOutput reports whether nvjpeg2kDecodeParamsSetRGBOutput resolved in the loaded library.
func HasDecodeStateCreate ¶
func HasDecodeStateCreate() bool
HasDecodeStateCreate reports whether nvjpeg2kDecodeStateCreate resolved in the loaded library.
func HasDecodeStateDestroy ¶
func HasDecodeStateDestroy() bool
HasDecodeStateDestroy reports whether nvjpeg2kDecodeStateDestroy resolved in the loaded library.
func HasDecodeTile ¶
func HasDecodeTile() bool
HasDecodeTile reports whether nvjpeg2kDecodeTile resolved in the loaded library.
func HasDestroy ¶
func HasDestroy() bool
HasDestroy reports whether nvjpeg2kDestroy resolved in the loaded library.
func HasGetCudartProperty ¶
func HasGetCudartProperty() bool
HasGetCudartProperty reports whether nvjpeg2kGetCudartProperty resolved in the loaded library.
func HasGetDeviceMemoryPadding ¶
func HasGetDeviceMemoryPadding() bool
HasGetDeviceMemoryPadding reports whether nvjpeg2kGetDeviceMemoryPadding resolved in the loaded library.
func HasGetPinnedMemoryPadding ¶
func HasGetPinnedMemoryPadding() bool
HasGetPinnedMemoryPadding reports whether nvjpeg2kGetPinnedMemoryPadding resolved in the loaded library.
func HasGetProperty ¶
func HasGetProperty() bool
HasGetProperty reports whether nvjpeg2kGetProperty resolved in the loaded library.
func HasSetDeviceMemoryPadding ¶
func HasSetDeviceMemoryPadding() bool
HasSetDeviceMemoryPadding reports whether nvjpeg2kSetDeviceMemoryPadding resolved in the loaded library.
func HasSetPinnedMemoryPadding ¶
func HasSetPinnedMemoryPadding() bool
HasSetPinnedMemoryPadding reports whether nvjpeg2kSetPinnedMemoryPadding resolved in the loaded library.
func HasStreamCreate ¶
func HasStreamCreate() bool
HasStreamCreate reports whether nvjpeg2kStreamCreate resolved in the loaded library.
func HasStreamDestroy ¶
func HasStreamDestroy() bool
HasStreamDestroy reports whether nvjpeg2kStreamDestroy resolved in the loaded library.
func HasStreamGetColorSpace ¶
func HasStreamGetColorSpace() bool
HasStreamGetColorSpace reports whether nvjpeg2kStreamGetColorSpace resolved in the loaded library.
func HasStreamGetComponentNLTInfo ¶
func HasStreamGetComponentNLTInfo() bool
HasStreamGetComponentNLTInfo reports whether nvjpeg2kStreamGetComponentNLTInfo resolved in the loaded library.
func HasStreamGetImageComponentInfo ¶
func HasStreamGetImageComponentInfo() bool
HasStreamGetImageComponentInfo reports whether nvjpeg2kStreamGetImageComponentInfo resolved in the loaded library.
func HasStreamGetImageInfo ¶
func HasStreamGetImageInfo() bool
HasStreamGetImageInfo reports whether nvjpeg2kStreamGetImageInfo resolved in the loaded library.
func HasStreamGetResolutionComponentDim ¶
func HasStreamGetResolutionComponentDim() bool
HasStreamGetResolutionComponentDim reports whether nvjpeg2kStreamGetResolutionComponentDim resolved in the loaded library.
func HasStreamGetResolutionsInTile ¶
func HasStreamGetResolutionsInTile() bool
HasStreamGetResolutionsInTile reports whether nvjpeg2kStreamGetResolutionsInTile resolved in the loaded library.
func HasStreamGetTileComponentDim ¶
func HasStreamGetTileComponentDim() bool
HasStreamGetTileComponentDim reports whether nvjpeg2kStreamGetTileComponentDim resolved in the loaded library.
func HasStreamParse ¶
func HasStreamParse() bool
HasStreamParse reports whether nvjpeg2kStreamParse resolved in the loaded library.
func HasStreamParseFile ¶
func HasStreamParseFile() bool
HasStreamParseFile reports whether nvjpeg2kStreamParseFile resolved in the loaded library.
func Load ¶
Load opens the shared library from path, or from the default search list when path is empty, and binds all symbols. Callers that need to direct loading should call Load before any other function; otherwise the first call loads from the default search list.
Load is idempotent: calling it again with the same path, or with an empty path, returns nil. Calling it with a different path after a successful load returns *LibraryConflictError rather than replacing the library. After a failed load, Load retries.
func Loaded ¶
func Loaded() bool
Loaded reports whether the library is currently loaded. It does not trigger a load.
func Path ¶
func Path() string
Path returns the path or name the loaded library was opened from, or the empty string if no library is loaded.
func SetDeviceMemoryPadding ¶
SetDeviceMemoryPadding rounds later device allocations up to a multiple of padding bytes.
After success on this call, any device memory allocation would be padded to the multiple of specified number of bytes. This helps minimize the number of device memory reallocations.
- padding: [in] Padding size in bytes
- handle: in/out Library handle
Wraps nvjpeg2kSetDeviceMemoryPadding.
func SetPinnedMemoryPadding ¶
SetPinnedMemoryPadding rounds later pinned host allocations up to a multiple of padding bytes.
After success on this call, any pinned host memory allocation would be padded to the multiple of specified number of bytes. This helps minimize the number of pinned memory reallocations.
- padding: [in] Padding size in bytes
- handle: in/out Library handle
Wraps nvjpeg2kSetPinnedMemoryPadding.
func StreamDestroy ¶
StreamDestroy releases a bitstream handle and the metadata parsed into it.
- streamHandle: [in] Bitstream handle to release
Wraps nvjpeg2kStreamDestroy.
func StreamGetResolutionComponentDim ¶
func StreamGetResolutionComponentDim(streamHandle Bitstream, componentId uint32, tileId uint32, resLevel uint32) (resWidth uint32, resHeight uint32, err error)
StreamGetResolutionComponentDim returns one tile component's width and height at a resolution level.
The resolution dimensions are computed as follows:
- res_scale = 1 << (num_resolutions - resLevel - 1)
- resWidth = (tile_width + res_scale - 1) >> res_scale
- resHeight = (tile_height + res_scale - 1) >> res_scale
Parameters:
- streamHandle: [in] Bitstream handle
- componentId: [in] Component index
- tileId: [in] Raster scan based tile index
- resLevel: [in] Resolution level
- resWidth: [out] Resolution width for the specified tile component and resolution level
- resHeight: [out] Resolution height for the specified tile component and resolution level
Wraps nvjpeg2kStreamGetResolutionComponentDim.
func StreamGetResolutionsInTile ¶
StreamGetResolutionsInTile returns the number of resolution levels present in a tile.
The number of resolutions is defined as: numResolutions = numWaveletDecompositionLevels + 1. Tiles in JPEG2000 are indexed in raster scan order. Bitstream.ImageInfo retrieves the number of tiles present along both the x and y directions. For tile coordinates tile_x, tile_y: tileId = tile_y * num_tiles_x + tile_x.
- streamHandle: [in] Bitstream handle
- tileId: [in] Raster scan based tile index
Wraps nvjpeg2kStreamGetResolutionsInTile.
func StreamGetTileComponentDim ¶
func StreamGetTileComponentDim(streamHandle Bitstream, componentId uint32, tileId uint32) (tileWidth uint32, tileHeight uint32, err error)
StreamGetTileComponentDim returns one tile component's width and height.
This function is useful when the tile dimensions in ImageInfo are not a multiple of the image dimensions.
- streamHandle: [in] Bitstream handle
- componentId: [in] Component index
- tileId: [in] Raster scan based tile index
- tileWidth: [out] Tile width for the specified tile component
- tileHeight: [out] Tile height for the specified tile component
Wraps nvjpeg2kStreamGetTileComponentDim.
func StreamParseFile ¶
StreamParseFile parses a JPEG 2000 file from disk.
Accepts a JPEG2000 file on disk as input and parses the JPEG2000 header information. The parsed information is stored in the stream handle and can be retrieved by the stream query APIs.
- handle: [in] Library handle
- filename: [in] Path to the JPEG2000 file on disk
- streamHandle: [in] Bitstream handle to store parsed information
Wraps nvjpeg2kStreamParseFile.
Types ¶
type Backend ¶
type Backend int32
Backend represents the internal implementation the library uses.
const (
BackendDefault Backend = 0 // Default backend implementation.
)
type BindFailure ¶
BindFailure names a symbol the loaded library exports but that could not be bound, and why.
func BindFailures ¶
func BindFailures() []BindFailure
BindFailures returns the symbols the loaded library exports that could not be bound, sorted by symbol name, or nil if every exported symbol bound. Calling one of these reports *SymbolError with the same Err.
A load that reports no error can still leave symbols unbound: the library is fine and the signatures are not representable here. Call this after Load to find that out at once rather than one call site at a time. It does not trigger a load, and returns nil if none has happened.
type Bitstream ¶
type Bitstream uintptr
Bitstream is an opaque handle for nvjpeg2kStream_t.
func NewBitstream ¶
NewBitstream creates an empty bitstream handle to parse into.
Wraps nvjpeg2kStreamCreate.
func StreamCreate ¶
StreamCreate creates an empty bitstream handle to parse into.
Wraps nvjpeg2kStreamCreate.
func (*Bitstream) Close ¶
Close releases a bitstream handle and the metadata parsed into it.
If b is zero, Close returns nil. Otherwise Close sets b to zero when the call succeeds and leaves it unchanged when it fails. Only b is zeroed: a copy of it still refers to the released object.
Wraps nvjpeg2kStreamDestroy.
func (Bitstream) ColorSpace ¶
func (b Bitstream) ColorSpace() (ColorSpace, error)
ColorSpace returns the color space recorded in a JP2 container.
For a JPEG2000 codestream (.j2k file), this function will retrieve ColorspaceUnknown since color space information is not available.
Wraps nvjpeg2kStreamGetColorSpace.
func (Bitstream) ComponentInfo ¶
func (b Bitstream) ComponentInfo(componentId uint32) (ImageComponentInfo, error)
ComponentInfo returns one component's dimensions, bit depth, and signedness.
Retrieves the component level information defined in ImageComponentInfo. This information can be used in allocating output buffers on device memory. Component level information is useful when the dimensions vary across components.
- componentId: [in] Component index
Wraps nvjpeg2kStreamGetImageComponentInfo.
func (Bitstream) ComponentNLTInfo ¶
ComponentNLTInfo returns one component's nonlinear-transformation parameters.
If the parsed bitstream contains an NLT marker that applies to componentId (either Cnlt = componentId or Cnlt = 65535 for "all components"), nltInfo->type reports the marker's Tnlt and nltInfo->bit_depth reports BDnlt. Otherwise nltInfo->type is NltNone and nltInfo->bit_depth falls back to the SIZ marker precision.
Use this to choose the destination type for an NLT-type-3 stream:
- FP16 — when every component BDnlt = 16.
- FP32 — when every component BDnlt in {16, 32} and at least one is >= 16. BDnlt = 16 components are widened via __half2float at decode time. See ImageType for the full destination-type restrictions.
Parameters:
- componentId: [in] Component index (0..num_components-1)
Wraps nvjpeg2kStreamGetComponentNLTInfo.
func (Bitstream) ImageInfo ¶
ImageInfo returns the image dimensions, tile grid, and component count.
Retrieves the image information defined in ImageInfo. This information is useful in allocating output buffers on device memory.
Wraps nvjpeg2kStreamGetImageInfo.
func (Bitstream) ResolutionComponentDim ¶
func (b Bitstream) ResolutionComponentDim(componentId uint32, tileId uint32, resLevel uint32) (resWidth uint32, resHeight uint32, err error)
ResolutionComponentDim returns one tile component's width and height at a resolution level.
The resolution dimensions are computed as follows:
- res_scale = 1 << (num_resolutions - resLevel - 1)
- resWidth = (tile_width + res_scale - 1) >> res_scale
- resHeight = (tile_height + res_scale - 1) >> res_scale
Parameters:
- componentId: [in] Component index
- tileId: [in] Raster scan based tile index
- resLevel: [in] Resolution level
- resWidth: [out] Resolution width for the specified tile component and resolution level
- resHeight: [out] Resolution height for the specified tile component and resolution level
Wraps nvjpeg2kStreamGetResolutionComponentDim.
func (Bitstream) ResolutionsInTile ¶
ResolutionsInTile returns the number of resolution levels present in a tile.
The number of resolutions is defined as: numResolutions = numWaveletDecompositionLevels + 1. Tiles in JPEG2000 are indexed in raster scan order. Bitstream.ImageInfo retrieves the number of tiles present along both the x and y directions. For tile coordinates tile_x, tile_y: tileId = tile_y * num_tiles_x + tile_x.
- tileId: [in] Raster scan based tile index
Wraps nvjpeg2kStreamGetResolutionsInTile.
func (Bitstream) TileComponentDim ¶
func (b Bitstream) TileComponentDim(componentId uint32, tileId uint32) (tileWidth uint32, tileHeight uint32, err error)
TileComponentDim returns one tile component's width and height.
This function is useful when the tile dimensions in ImageInfo are not a multiple of the image dimensions.
- componentId: [in] Component index
- tileId: [in] Raster scan based tile index
- tileWidth: [out] Tile width for the specified tile component
- tileHeight: [out] Tile height for the specified tile component
Wraps nvjpeg2kStreamGetTileComponentDim.
type BitstreamType ¶
type BitstreamType int32
BitstreamType represents the container a JPEG 2000 codestream is wrapped in.
const ( StreamJ2K BitstreamType = 0 // JPEG2000 codestream (.j2k). StreamJP2 BitstreamType = 1 // JP2 container (.jp2). )
func (BitstreamType) String ¶
func (e BitstreamType) String() string
String returns the constant name, or a numeric representation for unknown values.
type BufferRequirement ¶
BufferRequirement is the minimum shape of one destination allocation.
MinSizeInBytes is computed from MinPitchInBytes. A buffer whose pitch is larger than the minimum needs proportionally more bytes, which is why Layout.Bind recomputes the size from the pitch the caller actually supplies rather than comparing against this value alone.
type CallError ¶
CallError reports that a library call returned a failure result.
Unwrap returns Result, so errors.Is(err, c) reports whether the call returned the Result constant c, and errors.As(err, &r) with r of type Result recovers the code.
type ColorSpace ¶
type ColorSpace int32
ColorSpace represents a JP2 color space.
const ( ColorspaceNotSupported ColorSpace = -1 // Color space is not supported. ColorspaceUnknown ColorSpace = 0 // Color space is unknown. ColorspaceSrgb ColorSpace = 1 // sRGB color space. ColorspaceGray ColorSpace = 2 // Grayscale. ColorspaceSycc ColorSpace = 3 // sYCC color space. )
func StreamGetColorSpace ¶
func StreamGetColorSpace(streamHandle Bitstream) (ColorSpace, error)
StreamGetColorSpace returns the color space recorded in a JP2 container.
For a JPEG2000 codestream (.j2k file), this function will retrieve ColorspaceUnknown since color space information is not available.
- streamHandle: [in] Bitstream handle
Wraps nvjpeg2kStreamGetColorSpace.
func (ColorSpace) String ¶
func (e ColorSpace) String() string
String returns the constant name, or a numeric representation for unknown values.
type ComponentLayout ¶
type ComponentLayout struct {
// Width and Height are the component's extent in samples. For a tile
// layout they are the tile's extent for this component, which is smaller
// than the image extent whenever the image is tiled.
Width, Height uint32
// Precision is the component bit depth from the SIZ marker, and Signed
// reports whether its samples are signed.
Precision uint8
Signed bool
// NLT is the nonlinear transformation the component's NLT marker selects,
// NltNone when there is none, and NLTBitDepth is the effective output bit
// depth (BDnlt, falling back to Precision when no marker is present).
// Both are zero when the loaded library does not export
// nvjpeg2kStreamGetComponentNLTInfo; see [Layout.NLTKnown].
NLT NLTType
NLTBitDepth uint8
}
ComponentLayout is what the bitstream says about one image component. Every field is read from the codestream, not derived from the image dimensions: components of one image differ in extent (a subsampled chroma plane is smaller than the luma plane), in precision, and in signedness.
type DecodeParams ¶
type DecodeParams uintptr
DecodeParams is an opaque handle for nvjpeg2kDecodeParams_t.
func DecodeParamsCreate ¶
func DecodeParamsCreate() (DecodeParams, error)
DecodeParamsCreate creates a decode parameters handle holding output options.
Wraps nvjpeg2kDecodeParamsCreate.
func NewDecodeParams ¶
func NewDecodeParams() (DecodeParams, error)
NewDecodeParams creates a decode parameters handle holding output options.
Wraps nvjpeg2kDecodeParamsCreate.
func (*DecodeParams) Close ¶
func (d *DecodeParams) Close() error
Close releases a decode parameters handle.
If d is zero, Close returns nil. Otherwise Close sets d to zero when the call succeeds and leaves it unchanged when it fails. Only d is zeroed: a copy of it still refers to the released object.
Wraps nvjpeg2kDecodeParamsDestroy.
func (DecodeParams) SetDecodeArea ¶
SetDecodeArea restricts decoding to a rectangle within the tile of interest.
The coordinates are relative to the image origin and should be within the tile of interest. If the coordinates are set to 0, the entire tile will be decoded.
- startX: [in] Left coordinate of the decode area
- endX: [in] Right coordinate of the decode area
- startY: [in] Top coordinate of the decode area
- endY: [in] Bottom coordinate of the decode area
Wraps nvjpeg2kDecodeParamsSetDecodeArea.
func (DecodeParams) SetOutputFormat ¶
func (d DecodeParams) SetOutputFormat(format ImageFormat) error
SetOutputFormat selects planar or interleaved output.
Sets the decode output format. When using FormatInterleaved with 420/422 chroma subsampling, RGB output (DecodeParams.SetRGBOutput) must also be enabled.
The decode output buffer should be allocated in the following manner to support FormatInterleaved:
- format: [in] Output format. Defaults to FormatPlanar
Wraps nvjpeg2kDecodeParamsSetOutputFormat.
func (DecodeParams) SetRGBOutput ¶
func (d DecodeParams) SetRGBOutput(forceRgb int32) error
SetRGBOutput requests RGB output for chroma-subsampled sYCC streams.
Enables RGB decode output for images with 444/422/420 chroma subsampling when the stream's color space is sYCC. It is ignored for other color spaces (e.g. sRGB 444). YCC to RGB conversion is based on sYCC, Amendment 1 to IEC 61966-2-1. The color conversion is applied at a tile granularity due to which the chroma reconstruction may not be accurate for tiles with odd dimensions.
- forceRgb: [in] Set to 1 to enable RGB output
Wraps nvjpeg2kDecodeParamsSetRGBOutput.
type DecodeState ¶
type DecodeState uintptr
DecodeState is an opaque handle for nvjpeg2kDecodeState_t.
func DecodeStateCreate ¶
func DecodeStateCreate(handle Handle) (DecodeState, error)
DecodeStateCreate creates a decode state holding the intermediate buffers a decode needs.
- handle: [in] Library handle
Wraps nvjpeg2kDecodeStateCreate.
func NewDecodeState ¶
func NewDecodeState(handle Handle) (DecodeState, error)
NewDecodeState creates a decode state holding the intermediate buffers a decode needs.
- handle: [in] Library handle
Wraps nvjpeg2kDecodeStateCreate.
func (*DecodeState) Close ¶
func (d *DecodeState) Close() error
Close releases a decode state.
If d is zero, Close returns nil. Otherwise Close sets d to zero when the call succeeds and leaves it unchanged when it fails. Only d is zeroed: a copy of it still refers to the released object.
Wraps nvjpeg2kDecodeStateDestroy.
type Destination ¶
type Destination struct {
// contains filtered or unexported fields
}
Destination is a set of device buffers checked against a Layout and ready to be decoded into. It holds the host-side pointer and pitch arrays the library reads during a decode call, and keeps them reachable for as long as the Destination is.
A Destination does not own the device memory it names.
func (*Destination) Buffers ¶
func (d *Destination) Buffers() []DeviceBuffer
Buffers returns a copy of the device buffers the destination names.
func (*Destination) Layout ¶
func (d *Destination) Layout() *Layout
Layout returns the layout the destination was bound against.
type DeviceAllocator ¶
type DeviceAllocator struct {
// Device memory allocation callback.
DeviceMalloc uintptr
// Device memory free callback.
DeviceFree uintptr
}
DeviceAllocator represents a pair of caller-supplied device allocation callbacks.
type DeviceAllocatorV2 ¶
type DeviceAllocatorV2 struct {
// Extended device memory allocation callback.
DeviceMalloc uintptr
// Extended device memory free callback.
DeviceFree uintptr
// User-defined context pointer.
DeviceCtx uintptr
}
DeviceAllocatorV2 represents a pair of caller-supplied stream-ordered device allocation callbacks.
type DeviceBuffer ¶
type DeviceBuffer struct {
// Ptr is the device address of the first sample.
Ptr uintptr
// PitchInBytes is the distance between the starts of two consecutive
// rows, at least the layout's minimum pitch.
PitchInBytes int
// SizeInBytes is the size of the allocation at Ptr. [Layout.Bind] uses it
// to reject a buffer that cannot hold PitchInBytes times the row count.
SizeInBytes int
}
DeviceBuffer is one caller-owned device allocation that a decode writes into. This package never allocates or frees device memory: Ptr is a device address obtained from the CUDA runtime or driver, and the caller keeps it alive until the decode's CUDA stream has completed.
type EncodeConfig ¶
type EncodeConfig struct {
// Bitstream type (J2K or JP2).
StreamType BitstreamType
// Color space of the image.
ColorSpace ColorSpace
// Should be set to 0 for J2K or NVJPEG2K_RSIZ_HT for HTJ2K.
Rsiz uint16
// Image width in pixels. Minimum value 1.
ImageWidth uint32
// Image height in pixels. Minimum value 1.
ImageHeight uint32
// Set to 1 to enable tiling, 0 to disable.
EnableTiling uint32
// Tile width. Valid only when enable_tiling is 1. Should be less than image_width.
TileWidth uint32
// Tile height. Valid only when enable_tiling is 1. Should be less than image_height.
TileHeight uint32
// Number of image components (1-4).
NumComponents uint32
// Pointer to per-component information. Must be a valid pointer.
ImageCompInfo *ImageComponentInfo
// Should be set to 0.
EnableSOPMarker uint32
// Should be set to 0.
EnableEPHMarker uint32
// Progression order.
ProgOrder ProgOrder
// Number of quality layers. Should be set to 1.
NumLayers uint32
// Multi-component transform mode. 0 for YCC/Grayscale, 1 for RGB.
MctMode uint32
// Number of resolutions. Cannot be greater than image/tile dimensions.
NumResolutions uint32
// Code block width. Valid values: 32, 64, 128. 128 requires HTJ2K (EncodeModes = NVJPEG2K_MODE_HT) and is subject to the spec area limit CodeBlockW * CodeBlockH <= 4096.
CodeBlockW uint32
// Code block height. Valid values: 32, 64. The same area limit as CodeBlockW applies.
CodeBlockH uint32
// Should be set to 0 for J2K or NVJPEG2K_MODE_HT for HTJ2K.
EncodeModes uint32
// Set to 1 for irreversible (lossy) transform, 0 for reversible (lossless).
Irreversible uint32
// Number of valid precinct entries. Set to 0 to disable custom precincts.
NumPrecinctsInit uint32
// Precinct widths per resolution. Should be a power of 2. Valid only when num_precincts_init is non-zero.
PrecinctWidth [33]uint32
// Precinct heights per resolution. Should be a power of 2. Valid only when num_precincts_init is non-zero.
PrecinctHeight [33]uint32
}
EncodeConfig represents the codestream parameters an encode writes into the COD and SIZ markers.
type Handle ¶
type Handle uintptr
Handle is an opaque handle for nvjpeg2kHandle_t.
func Create ¶
func Create(backend Backend, deviceAllocator *DeviceAllocator, pinnedAllocator *PinnedAllocator) (Handle, error)
Create creates a library handle with caller-supplied device and pinned allocators.
Creates an instance of the library using the input arguments. The user has flexibility to choose the backend implementation and provide allocators.
- backend: [in] Backend to use. Currently BackendDefault is supported
- deviceAllocator: [in] See DeviceAllocator. If NULL, default cudaMalloc() / cudaFree() are used
- pinnedAllocator: [in] See PinnedAllocator. If NULL, default cudaHostAlloc() / cudaFreeHost() are used
Wraps nvjpeg2kCreate.
func CreateSimple ¶
CreateSimple creates a library handle with the default backend and allocators.
Creates an instance of the library handle with default backend and memory allocators.
Wraps nvjpeg2kCreateSimple.
func CreateV2 ¶
func CreateV2(backend Backend, devAllocator *DeviceAllocatorV2, pinnedAllocator *PinnedAllocatorV2) (Handle, error)
CreateV2 creates a library handle with stream-ordered caller-supplied allocators.
Creates an instance of the library using extended allocators that accept CUDA streams and user context.
- backend: [in] Backend to use. Currently BackendDefault is supported
- devAllocator: [in] See DeviceAllocatorV2. Cannot be NULL
- pinnedAllocator: [in] See PinnedAllocatorV2. Cannot be NULL
Wraps nvjpeg2kCreateV2.
func NewHandle ¶
NewHandle creates a library handle with the default backend and allocators.
Creates an instance of the library handle with default backend and memory allocators.
Wraps nvjpeg2kCreateSimple.
func NewHandleWithAllocators ¶
func NewHandleWithAllocators(backend Backend, deviceAllocator *DeviceAllocator, pinnedAllocator *PinnedAllocator) (Handle, error)
NewHandleWithAllocators creates a library handle with caller-supplied device and pinned allocators.
Creates an instance of the library using the input arguments. The user has flexibility to choose the backend implementation and provide allocators.
- backend: [in] Backend to use. Currently BackendDefault is supported
- deviceAllocator: [in] See DeviceAllocator. If NULL, default cudaMalloc() / cudaFree() are used
- pinnedAllocator: [in] See PinnedAllocator. If NULL, default cudaHostAlloc() / cudaFreeHost() are used
Wraps nvjpeg2kCreate.
func NewHandleWithAllocatorsV2 ¶
func NewHandleWithAllocatorsV2(backend Backend, devAllocator *DeviceAllocatorV2, pinnedAllocator *PinnedAllocatorV2) (Handle, error)
NewHandleWithAllocatorsV2 creates a library handle with stream-ordered caller-supplied allocators.
Creates an instance of the library using extended allocators that accept CUDA streams and user context.
- backend: [in] Backend to use. Currently BackendDefault is supported
- devAllocator: [in] See DeviceAllocatorV2. Cannot be NULL
- pinnedAllocator: [in] See PinnedAllocatorV2. Cannot be NULL
Wraps nvjpeg2kCreateV2.
func (*Handle) Close ¶
Close releases a library handle and the resources it owns.
Destroy every decode state, bitstream, and decode parameters handle created from this handle first. Handles are not finalized automatically; a dropped handle leaks.
If h is zero, Close returns nil. Otherwise Close sets h to zero when the call succeeds and leaves it unchanged when it fails. Only h is zeroed: a copy of it still refers to the released object.
Wraps nvjpeg2kDestroy.
func (Handle) Decode ¶
func (h Handle) Decode(decodeState DecodeState, jpeg2kStream Bitstream, decodeOutput *Image, stream driver.Stream) error
Decode decodes a whole image into caller-allocated device buffers.
Decodes a single image and writes it to the output device buffers. The function is asynchronous with respect to the host. All GPU tasks will be submitted to the provided stream. Prior to calling this function, the user must parse the bitstream using nvjpeg2kStreamParse() such that the bitstream information is stored in jpeg2kStream.
The decode is asynchronous: it returns once the work is submitted to stream. The output struct is read on the host during the call, but the device addresses it holds must stay allocated until stream has completed. Synchronize the stream or the device before reusing the decode state for another image.
- decodeState: [in] Decode state handle
- jpeg2kStream: [in] Bitstream handle with parsed information
- decodeOutput: in/out Decode output struct. The struct should be on host memory. The image component pointers should point to device memory. See Image
- stream: [in] CUDA stream. Can be set to 0
Wraps nvjpeg2kDecode.
func (Handle) DecodeImage ¶
func (h Handle) DecodeImage(decodeState DecodeState, jpeg2kStream Bitstream, decodeParams DecodeParams, decodeOutput *Image, stream driver.Stream) error
DecodeImage decodes a whole image into caller-allocated device buffers, under decode parameters.
Decodes a single image and writes it to the output device buffers. The function is asynchronous with respect to the host. All GPU tasks will be submitted to the provided stream. Prior to calling this function, the user must parse the bitstream using nvjpeg2kStreamParse() such that the bitstream information is stored in jpeg2kStream. It is possible to control the decode output using an instance of DecodeParams.
The decode is asynchronous: it returns once the work is submitted to stream. The output struct is read on the host during the call, but the device addresses it holds must stay allocated until stream has completed. Synchronize the stream or the device before reusing the decode state for another image.
- decodeState: [in] Decode state handle
- jpeg2kStream: [in] Bitstream handle with parsed information
- decodeParams: [in] Decode parameters to control output (e.g. area of interest, RGB output). Can be set to NULL
- decodeOutput: in/out Decode output struct. The struct should be on host memory. The image component pointers should point to device memory. See Image
- stream: [in] CUDA stream. Can be set to 0
Wraps nvjpeg2kDecodeImage.
func (Handle) DecodeInto ¶
func (h Handle) DecodeInto(state DecodeState, bs Bitstream, params *Params, dst *Destination, stream driver.Stream) error
DecodeInto decodes a whole image into buffers that were checked against the bitstream's own metadata. It is the checked form of Handle.Decode and Handle.DecodeImage: it refuses a destination built from a different bitstream, a tile destination, and decode parameters that disagree with the destination's layout.
params may be nil, which decodes with the library's defaults.
The call is asynchronous with respect to the host: it returns once the work is submitted to stream. Every device buffer the destination names must stay allocated until stream has completed, and the decode state must not be reused for another image before then.
func (Handle) DecodeTile ¶
func (h Handle) DecodeTile(decodeState DecodeState, jpeg2kStream Bitstream, decodeParams DecodeParams, tileId uint32, numResLevels uint32, decodeOutput *Image, stream driver.Stream) error
DecodeTile decodes one tile into caller-allocated device buffers.
Decodes a tile within an image and writes it to the output device buffers. The function is asynchronous with respect to the host. All GPU tasks will be submitted to the provided stream. Prior to calling this function, the user must parse the bitstream using nvjpeg2kStreamParse() such that the bitstream information is stored in jpeg2kStream.
The decode is asynchronous: it returns once the work is submitted to stream. The output struct is read on the host during the call, but the device addresses it holds must stay allocated until stream has completed. Synchronize the stream or the device before reusing the decode state for another image.
- decodeState: [in] Decode state handle
- jpeg2kStream: [in] Bitstream handle with parsed information
- decodeParams: [in] Decode parameters to control output. Can be set to NULL
- tileId: [in] Raster scan based tile index
- numResLevels: [in] Number of resolutions to decode within the tile. When set to 0, the image is decoded at full resolution. Maximum allowed resolutions in a tile can be determined using Bitstream.ResolutionsInTile
- decodeOutput: in/out Decode output struct. The struct should be on host memory. The image component pointers should point to device memory. See Image
- stream: [in] CUDA stream. Can be set to 0
Wraps nvjpeg2kDecodeTile.
func (Handle) DecodeTileInto ¶
func (h Handle) DecodeTileInto(state DecodeState, bs Bitstream, params *Params, tileID, numResLevels uint32, dst *Destination, stream driver.Stream) error
DecodeTileInto decodes one tile into buffers that were checked against that tile's own component dimensions. It is the checked form of Handle.DecodeTile.
numResLevels is the number of resolution levels to decode; 0 decodes the tile at full resolution. A layout describes the full-resolution extent, so any other value is refused here: use Handle.DecodeTile and size the buffers from Bitstream.ResolutionComponentDim.
params may be nil. The asynchrony and buffer-lifetime rules of Handle.DecodeInto apply.
func (Handle) DeviceMemoryPadding ¶
DeviceMemoryPadding returns the current device allocation padding in bytes.
Wraps nvjpeg2kGetDeviceMemoryPadding.
func (Handle) Parse ¶
Parse parses a JPEG 2000 bitstream held in host memory into bs.
data is read during the call and is not retained: the parsed metadata belongs to bs and stays valid until bs is parsed again or destroyed. The length the library receives is derived from data, so the pointer and the length cannot disagree.
Parse wraps nvjpeg2kStreamParse. That entry point also takes save_metadata and save_stream, which the header documents as reserved and requires to be 0; they are not exposed and are always passed as 0.
func (Handle) ParseFile ¶
ParseFile parses a JPEG 2000 file from disk.
Accepts a JPEG2000 file on disk as input and parses the JPEG2000 header information. The parsed information is stored in the stream handle and can be retrieved by the stream query APIs.
- filename: [in] Path to the JPEG2000 file on disk
- streamHandle: [in] Bitstream handle to store parsed information
Wraps nvjpeg2kStreamParseFile.
func (Handle) PinnedMemoryPadding ¶
PinnedMemoryPadding returns the current pinned host allocation padding in bytes.
Wraps nvjpeg2kGetPinnedMemoryPadding.
func (Handle) SetDeviceMemoryPadding ¶
SetDeviceMemoryPadding rounds later device allocations up to a multiple of padding bytes.
After success on this call, any device memory allocation would be padded to the multiple of specified number of bytes. This helps minimize the number of device memory reallocations.
- padding: [in] Padding size in bytes
Wraps nvjpeg2kSetDeviceMemoryPadding.
func (Handle) SetPinnedMemoryPadding ¶
SetPinnedMemoryPadding rounds later pinned host allocations up to a multiple of padding bytes.
After success on this call, any pinned host memory allocation would be padded to the multiple of specified number of bytes. This helps minimize the number of pinned memory reallocations.
- padding: [in] Padding size in bytes
Wraps nvjpeg2kSetPinnedMemoryPadding.
type Image ¶
type Image struct {
// Array of pointers to component data in device memory.
PixelData *uintptr
// Array of pitch values (in bytes) for each component.
PitchInBytes *uint
// Pixel data type. See [ImageType] for supported types.
PixelType ImageType
// Number of image components.
NumComponents uint32
}
Image represents a set of caller-owned component buffers in device memory.
type ImageComponentInfo ¶
type ImageComponentInfo struct {
// Width of the component in pixels.
ComponentWidth uint32
// Height of the component in pixels.
ComponentHeight uint32
// Bit depth of the component.
Precision uint8
// 1 if the component samples are signed, 0 otherwise.
Sgn uint8
}
ImageComponentInfo represents one component's dimensions and sample format, as parsed from the bitstream.
func StreamGetImageComponentInfo ¶
func StreamGetImageComponentInfo(streamHandle Bitstream, componentId uint32) (ImageComponentInfo, error)
StreamGetImageComponentInfo returns one component's dimensions, bit depth, and signedness.
Retrieves the component level information defined in ImageComponentInfo. This information can be used in allocating output buffers on device memory. Component level information is useful when the dimensions vary across components.
- streamHandle: [in] Bitstream handle
- componentId: [in] Component index
Wraps nvjpeg2kStreamGetImageComponentInfo.
type ImageFormat ¶
type ImageFormat int32
ImageFormat represents how component samples are arranged in memory.
const ( FormatPlanar ImageFormat = 0 // All components are stored in separate planes. FormatInterleaved ImageFormat = 1 // All components are stored in interleaved order. Not supported when component dimensions differ. )
func (ImageFormat) String ¶
func (e ImageFormat) String() string
String returns the constant name, or a numeric representation for unknown values.
type ImageInfo ¶
type ImageInfo struct {
// Width of the image in pixels.
ImageWidth uint32
// Height of the image in pixels.
ImageHeight uint32
// Width of a tile in pixels.
TileWidth uint32
// Height of a tile in pixels.
TileHeight uint32
// Number of tiles in the horizontal direction.
NumTilesX uint32
// Number of tiles in the vertical direction.
NumTilesY uint32
// Number of image components.
NumComponents uint32
}
ImageInfo represents an image's dimensions, tile grid, and component count.
func StreamGetImageInfo ¶
StreamGetImageInfo returns the image dimensions, tile grid, and component count.
Retrieves the image information defined in ImageInfo. This information is useful in allocating output buffers on device memory.
- streamHandle: [in] Bitstream handle
Wraps nvjpeg2kStreamGetImageInfo.
type ImageType ¶
type ImageType int32
ImageType represents the sample type of a decode destination.
const ( Uint8 ImageType = 0 // Unsigned 8-bit integer. Uint16 ImageType = 1 // Unsigned 16-bit integer. Int16 ImageType = 2 // Signed 16-bit integer. FP16 ImageType = 3 // IEEE-754 binary16. Requires NLT type 3 on every component with BDnlt = 16. FP32 ImageType = 4 // IEEE-754 binary32. Requires NLT type 3 on every component with BDnlt in {16, 32}; BDnlt = 16 components are promoted to float, BDnlt = 32 components are bit-reinterpreted. )
func (ImageType) BytesPerSample ¶
BytesPerSample returns the size in bytes of one sample of type t, or 0 if t is not one of the types this package knows.
Example ¶
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nvjpeg2k"
)
func main() {
for _, t := range []nvjpeg2k.ImageType{nvjpeg2k.Uint8, nvjpeg2k.Uint16, nvjpeg2k.FP32} {
fmt.Println(t, t.BytesPerSample())
}
}
Output: Uint8 1 Uint16 2 FP32 4
type Layout ¶
type Layout struct {
// Info is the image header: extent, tile grid, and component count.
Info ImageInfo
// PixelType is the sample type the destination buffers hold, and Format
// is how the components are arranged across them.
PixelType ImageType
Format ImageFormat
// Components has one entry per image component, in codestream order.
Components []ComponentLayout
// Tile reports whether this layout describes a single tile rather than
// the whole image, and TileID names that tile when it does.
Tile bool
TileID uint32
// NLTKnown reports whether the per-component NLT fields were read. They
// are not when the loaded library predates
// nvjpeg2kStreamGetComponentNLTInfo.
NLTKnown bool
// contains filtered or unexported fields
}
Layout is the destination description for one parsed bitstream, read from that bitstream's metadata. It is the only thing in this package that knows how large a decode output must be.
A Layout is a snapshot. Parsing another bitstream into the same Bitstream handle invalidates it, and nothing in this package can detect that.
func LayoutOf ¶
func LayoutOf(bs Bitstream, pixelType ImageType, format ImageFormat) (*Layout, error)
LayoutOf reads the metadata a whole-image decode destination must match: the image header and then, for every component, that component's own dimensions, precision, and signedness.
pixelType and format describe the destination the caller intends to allocate. LayoutOf rejects combinations the header documents as invalid for this bitstream, so the error arrives before any device memory is allocated rather than as a corrupt image afterwards.
Example (Subsampled) ¶
ExampleLayoutOf_subsampled shows why the destination sizes come from the per-component metadata. For a 4:2:0 image the three planes have three different sizes, and the image dimensions describe only the first.
package main
import (
"fmt"
"github.com/tmc/lib/nvidia/nvjpeg2k"
)
func main() {
// Values a 64x32 4:2:0 8-bit image would produce.
requirements := []nvjpeg2k.BufferRequirement{
{MinPitchInBytes: 64, Rows: 32, MinSizeInBytes: 2048},
{MinPitchInBytes: 32, Rows: 16, MinSizeInBytes: 512},
{MinPitchInBytes: 32, Rows: 16, MinSizeInBytes: 512},
}
for i, req := range requirements {
fmt.Printf("component %d: %d bytes\n", i, req.MinSizeInBytes)
}
}
Output: component 0: 2048 bytes component 1: 512 bytes component 2: 512 bytes
func LayoutOfTile ¶
func LayoutOfTile(bs Bitstream, tileID uint32, pixelType ImageType, format ImageFormat) (*Layout, error)
LayoutOfTile reads the metadata a single-tile decode destination must match. A tile's components are smaller than the image's; sizing a tile decode from LayoutOf overruns nothing the host can see and corrupts the output.
func (*Layout) Bind ¶
func (l *Layout) Bind(buffers ...DeviceBuffer) (*Destination, error)
Bind checks caller-owned device buffers against the layout and returns a Destination that Handle.DecodeInto will accept. The buffers must be in the order Layout.Buffers describes.
Bind cannot tell whether Ptr is really a device address, whether it is still allocated, or whether SizeInBytes is truthful; it checks only what the caller reports against what the bitstream requires.
func (*Layout) Buffers ¶
func (l *Layout) Buffers() []BufferRequirement
Buffers returns the minimum shape of every destination allocation, in the order Layout.Bind expects them: one per component for FormatPlanar, and exactly one for FormatInterleaved.
type LibraryAttempt ¶
LibraryAttempt records one failed attempt to open the shared library.
type LibraryConflictError ¶
type LibraryConflictError struct {
Loaded string
Requested string
// Implicit reports that the loaded library was opened lazily and no
// successful Load has since acknowledged it. A
// caller that sees this called some
// other function first, and that call took the default search list.
Implicit bool
}
LibraryConflictError reports a Load call naming a different library than the one already loaded. Only one library is loaded per process.
func (*LibraryConflictError) Error ¶
func (e *LibraryConflictError) Error() string
Error reports the conflicting library paths, and whether the library that is already loaded got there without a Load call.
type LibraryError ¶
type LibraryError struct {
Library string
Env string
Path string
Attempts []LibraryAttempt
Hint string
}
LibraryError reports that libnvjpeg2k could not be opened. Attempts lists every name tried in order. Path is set when an explicit path, from Load or NVJPEG2K_LIB_PATH, was requested and failed. Hint reports pkg-config discovery results and query failures, when discovery ran.
Example ¶
ExampleLibraryError shows the shape of a load failure. Nothing in this package panics when the library is missing.
package main
import (
"errors"
"fmt"
"github.com/tmc/lib/nvidia/nvjpeg2k"
)
func main() {
_, err := nvjpeg2k.NewHandle()
var libErr *nvjpeg2k.LibraryError
if errors.As(err, &libErr) {
fmt.Println("libnvjpeg2k not loadable; names tried:")
for _, attempt := range libErr.Attempts {
fmt.Println(" ", attempt.Name)
}
}
}
Output:
func (*LibraryError) Error ¶
func (e *LibraryError) Error() string
Error describes the library load attempts and their errors.
func (*LibraryError) Unwrap ¶
func (e *LibraryError) Unwrap() []error
Unwrap returns the error from each attempt.
type LibraryPropertyType ¶
type LibraryPropertyType int32
LibraryPropertyType represents one component of a version number.
const ( MajorVersion LibraryPropertyType = 0 // The major version number. MinorVersion LibraryPropertyType = 1 // The minor version number. PatchLevel LibraryPropertyType = 2 // The patch level. )
func (LibraryPropertyType) String ¶
func (e LibraryPropertyType) String() string
String returns the constant name, or a numeric representation for unknown values.
type NLTInfo ¶
type NLTInfo struct {
// Nonlinearity type for this component.
Type NLTType
// Post-NLT bit depth (BDnlt), 1 to 128. When Type is NLTNone this is the SIZ marker precision, so it always reflects the effective output integer range.
BitDepth uint8
}
NLTInfo represents one component's NLT marker parameters, as parsed from the bitstream.
func StreamGetComponentNLTInfo ¶
StreamGetComponentNLTInfo returns one component's nonlinear-transformation parameters.
If the parsed bitstream contains an NLT marker that applies to componentId (either Cnlt = componentId or Cnlt = 65535 for "all components"), nltInfo->type reports the marker's Tnlt and nltInfo->bit_depth reports BDnlt. Otherwise nltInfo->type is NltNone and nltInfo->bit_depth falls back to the SIZ marker precision.
Use this to choose the destination type for an NLT-type-3 stream:
- FP16 — when every component BDnlt = 16.
- FP32 — when every component BDnlt in {16, 32} and at least one is >= 16. BDnlt = 16 components are widened via __half2float at decode time. See ImageType for the full destination-type restrictions.
Parameters:
- streamHandle: [in] Bitstream handle
- componentId: [in] Component index (0..num_components-1)
Wraps nvjpeg2kStreamGetComponentNLTInfo.
type NLTType ¶
type NLTType int32
NLTType represents the nonlinear transformation an NLT marker selects.
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
Params is a DecodeParams handle together with the settings applied through it. Handle.DecodeInto needs to know the output format to check a destination against, and the C API has no way to read a setting back, so this type records what was set.
The zero Params is not usable; create one with NewParams and release it with Params.Destroy.
func (*Params) Destroy ¶
Destroy releases the decode parameters handle. It is not idempotent and the handle is not finalized automatically.
func (*Params) Handle ¶
func (p *Params) Handle() DecodeParams
Handle returns the underlying DecodeParams for use with the raw decode calls. Settings applied through it are invisible to Handle.DecodeInto.
func (*Params) OutputFormat ¶
func (p *Params) OutputFormat() ImageFormat
OutputFormat reports the output format that was set, FormatPlanar if none was.
func (*Params) SetDecodeArea ¶
SetDecodeArea restricts decoding to a rectangle within the tile of interest. A Layout describes the full component extent, so once an area is set Handle.DecodeInto refuses the parameters and the caller must size the buffers itself and use Handle.DecodeImage directly.
func (*Params) SetOutputFormat ¶
func (p *Params) SetOutputFormat(format ImageFormat) error
SetOutputFormat selects planar or interleaved output.
func (*Params) SetRGBOutput ¶
SetRGBOutput requests RGB output for chroma-subsampled sYCC streams. The header documents it as ignored for other color spaces.
type PinnedAllocator ¶
type PinnedAllocator struct {
// Pinned memory allocation callback.
PinnedMalloc uintptr
// Pinned memory free callback.
PinnedFree uintptr
}
PinnedAllocator represents a pair of caller-supplied pinned host allocation callbacks.
type PinnedAllocatorV2 ¶
type PinnedAllocatorV2 struct {
// Extended pinned memory allocation callback.
PinnedMalloc uintptr
// Extended pinned memory free callback.
PinnedFree uintptr
// User-defined context pointer.
PinnedCtx uintptr
}
PinnedAllocatorV2 represents a pair of caller-supplied stream-ordered pinned host allocation callbacks.
type ProgOrder ¶
type ProgOrder int32
ProgOrder represents a JPEG 2000 progression order.
const ( Lrcp ProgOrder = 0 // Layer-Resolution-Component-Position. Rlcp ProgOrder = 1 // Resolution-Layer-Component-Position. Rpcl ProgOrder = 2 // Resolution-Position-Component-Layer. Pcrl ProgOrder = 3 // Position-Component-Resolution-Layer. Cprl ProgOrder = 4 // Component-Position-Resolution-Layer. )
type QualityType ¶
type QualityType int32
QualityType represents how an encode quality value is interpreted.
const ( QualityTypeTargetPsnr QualityType = 0 // Quality value is interpreted as desired Peak Signal-to-Noise Ratio (PSNR) target. The higher the value, the better quality image is produced. Quality value should be positive floating point. Cannot be used with HT encoder. QualityTypeQuantizationStep QualityType = 1 // Quality value is interpreted as quantization step (by how much pixel data will be divided). The higher the value, the worse quality image is produced. Quality value should be positive floating point. QualityTypeQFactor QualityType = 2 // Quality value is interpreted as JPEG-like quality factor (1.0 worst to 100.0 best). Can only be used when the input colorspace is YCC, Grayscale, or RGB with MCT enabled. )
func (QualityType) String ¶
func (e QualityType) String() string
String returns the constant name, or a numeric representation for unknown values.
type Result ¶
type Result int32
Result represents a nvjpeg2k API error code (nvjpeg2kStatus_t).
const ( Success Result = 0 // The API call finished successfully. Note that many calls are asynchronous and some errors may only appear after synchronization. ErrNotInitialized Result = 1 // The library handle was not initialized. ErrInvalidParameter Result = 2 // Wrong parameter was passed. For example, a null pointer as input data, or an invalid enum value. ErrBadJpeg Result = 3 // Cannot parse the JPEG2000 stream. Likely due to a corruption that cannot be handled. ErrJpegNotSupported Result = 4 // Attempting to decode a JPEG2000 stream that is not supported by the nvJPEG2000 library. ErrAllocatorFailure Result = 5 // The user-provided allocator functions, for either memory allocation or for releasing the memory, returned a non-zero code. ErrExecutionFailed Result = 6 // Error during the execution of the device tasks. ErrArchMismatch Result = 7 // The device capabilities are not enough for the set of input parameters provided. ErrInternalError Result = 8 // Unknown error occurred in the library. ErrImplementationNotSupported Result = 9 // API is not supported by the backend. )
nvjpeg2k error codes from nvjpeg2k.h.
type SymbolError ¶
SymbolError reports that a symbol is not callable.
Err distinguishes the two ways that happens. A nil Err means the loaded library does not export the symbol, which is what an installation older than the symbol looks like. A non-nil Err means the library does export it and the binding itself failed; the library is not at fault.
func (*SymbolError) Error ¶
func (e *SymbolError) Error() string
Error reports the uncallable library symbol and, when the symbol was present but could not be bound, why.
func (*SymbolError) Unwrap ¶
func (e *SymbolError) Unwrap() error
Unwrap returns the reason the symbol could not be bound, or nil when the loaded library does not export it.