jpeg

package
v0.0.0-...-98db5b7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: CC-BY-4.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHandle

func MakeHandle(devbuff, pinnedbuff uint) (*nvjpeg.Handle, error)

MakeHandle creates an jpeg handle if devbuff == 0 then default setting will be used if pinnedbuff == 0 then default setting will be used

Types

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

Channel contains a pointer to cuda memory along with Pitch and Height

func (*Channel) Mem

func (c *Channel) Mem() cutil.Mem

Mem returns the gocu.Mem of the channel

func (*Channel) Set

func (c *Channel) Set(ptr cutil.Mem, w, h int32)

Set sets the channels

func (*Channel) Size

func (c *Channel) Size() (w, h int32)

Size returns the w, h values of channel

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes jpegs int nvjpeg.Images

func CreateDecoder

func CreateDecoder(h *nvjpeg.Handle, s gocu.Streamer) (*Decoder, error)

CreateDecoder creates a decoder

func (*Decoder) BatchPhaseInitialize

func (d *Decoder) BatchPhaseInitialize(r []io.Reader, maxCputhreads int, frmt nvjpeg.OutputFormat, allocator gocu.Allocator) (data [][]byte, dests []*Image, err error)

BatchPhaseInitialize initialezes a batch of phases. It also initializes the bytes(BatchedPhase1) and dests (BatchedPhase3) used for the phases.

func (*Decoder) BatchedPhase1

func (d *Decoder) BatchedPhase1(data []byte, imgidx, threadidx int) error

BatchedPhase1 does phase one of batch decoding

func (*Decoder) BatchedPhase3

func (d *Decoder) BatchedPhase3(dest []*Image) error

BatchedPhase3 does phase three of batched decoding

func (*Decoder) BatchedPhse2

func (d *Decoder) BatchedPhse2() error

BatchedPhse2 does phase two of batched decoding

func (*Decoder) DecodeAIO

func (d *Decoder) DecodeAIO(r io.Reader, frmt nvjpeg.OutputFormat, allocator gocu.Allocator) (*Image, error)

DecodeAIO decodes one jpeg through all the phases in on function

func (*Decoder) DecodeBatchedAIO

func (d *Decoder) DecodeBatchedAIO(r []io.Reader, maxCPUthreads int, frmt nvjpeg.OutputFormat, allocator gocu.Allocator) ([]*Image, error)

DecodeBatchedAIO returns a batch of images

func (*Decoder) Phase1

func (d *Decoder) Phase1(data []byte, frmt nvjpeg.OutputFormat) error

Phase1 does the first phase of decoding

func (*Decoder) Phase2

func (d *Decoder) Phase2() error

Phase2 does the second phase of decoding

func (*Decoder) Phase3

func (d *Decoder) Phase3(dest *Image) error

Phase3 does the third and last phase of decoding. dest needs to be preallocated.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder streamlines nvjpegs encoderparams, encoderstate, handle, and gocu.Streamer.

func CreateEncoder

func CreateEncoder(h *nvjpeg.Handle, s gocu.Streamer) (*Encoder, error)

CreateEncoder creates an encoder

func (*Encoder) EncodeImage

func (e *Encoder) EncodeImage(src *nvjpeg.Image, fmt nvjpeg.InputFormat, swidth, sheight int32) error

EncodeImage - Compresses the image in the provided format to the JPEG stream using the paramters set by encoder, and stores it in the Encoder.

func (*Encoder) EncodeYUV

func (e *Encoder) EncodeYUV(src *nvjpeg.Image, srcChroma nvjpeg.ChromaSubsampling, swidth, sheight int32) error

EncodeYUV -Compresses the image in YUV colorspace to JPEG stream using the paramters set by encoder, and stores it in the Encoder.

func (*Encoder) GetBufferSize

func (e *Encoder) GetBufferSize(width, height int32) (maxStreamLength uint, err error)

GetBufferSize - Returns the maximum possible buffer size that is needed to store the compressed JPEG stream, for the given input parameters.

func (*Encoder) GetByteSize

func (e *Encoder) GetByteSize() (uint, error)

GetByteSize returns the number of bytes in compressed buffer. Can be used to make p for Read()

func (*Encoder) Read

func (e *Encoder) Read(p []byte) (n int, err error)

Read reads up to len(p). n is the number of bytes read. if len(p) < buffer stream function will not read any bytes. error sould return number of that should be made for p, or it will contain bigger error issues from nvjpeg. Use GetByteSize() to get the size of p.

func (*Encoder) SetOptimizedHuffman

func (e *Encoder) SetOptimizedHuffman(optimized bool) error

SetOptimizedHuffman - Sets whether or not to use optimized Huffman. Using optimized Huffman produces smaller JPEG bitstream sizes with the same quality, but with slower performance. Default is false

func (*Encoder) SetQuality

func (e *Encoder) SetQuality(quality int32) error

SetQuality sets the quality of the paramters of the endcoder Quality should be a number between 1 and 100. The default is set to 70

func (*Encoder) SetSamplingFactors

func (e *Encoder) SetSamplingFactors(factor nvjpeg.ChromaSubsampling) error

SetSamplingFactors -Sets which chroma subsampling will be used for JPEG compression. ssfactor that will be used for JPEG compression. If the input is in YUV color model and ssfactor is different from the subsampling factors of source image, then the NVJPEG library will convert subsampling to the value of chroma_subsampling. Default value is 4:4:4.

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image contains the data used for nvjpeg images

func CreateDestImage

func CreateDestImage(h *nvjpeg.Handle, frmt nvjpeg.OutputFormat, r io.Reader, allocator gocu.Allocator) (*Image, error)

CreateDestImage returns an empty Image used to place data from stream into it

func (*Image) GetChannels

func (img *Image) GetChannels() []Channel

GetChannels returns the channels being held by img

func (*Image) Size

func (img *Image) Size() (w, h int32)

Size returns the pitch and height

Jump to

Keyboard shortcuts

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