...

Package sampling

Overview ▾

func ResampleBytes

func ResampleBytes(data []byte, bitsPerSample int) []uint32

ResampleBytes resamples the raw data which is in 8-bit (byte) format as a different bit count per sample, up to 32 bits (uint32).

func ResampleUint32

func ResampleUint32(data []uint32, bitsPerInputSample int, bitsPerOutputSample int) []uint32

ResampleUint32 resamples the raw data which is in <=32-bit (uint32) format as a different bit count per sample, up to 32 bits (uint32).

bitsPerOutputSample is the number of bits for each output sample (up to 32) bitsPerInputSample is the number of bits used in each input sample (up to 32)

type Reader

Reader allows to get samples from provided image

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

func NewReader

func NewReader(img imageutil.ImageBase) *Reader

NewReader creates new image based sample reader with specified bitsPerOutputSample.

func (*Reader) ReadSample

func (r *Reader) ReadSample() (uint32, error)

ReadSample gets next sample from the reader. If there is no more samples, the function returns an error.

func (*Reader) ReadSamples

func (r *Reader) ReadSamples(samples []uint32) (err error)

ReadSamples reads as many samples as possible up to the size of provided slice.

type SampleReader

SampleReader is an interface that allows to read samples.

type SampleReader interface {
    ReadSample() (uint32, error)
    ReadSamples(samples []uint32) error
}

type SampleWriter

SampleWriter allows to write single or multiple samples at once.

type SampleWriter interface {
    WriteSample(sample uint32) error
    WriteSamples(samples []uint32) error
}

type Writer

Writer allows to get samples from provided image

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

func NewWriter

func NewWriter(img imageutil.ImageBase) *Writer

NewWriter creates new sample writer for provided input 'img'.

func (*Writer) WriteSample

func (w *Writer) WriteSample(sample uint32) error

WriteSample writes the sample into given writer.

func (*Writer) WriteSamples

func (w *Writer) WriteSamples(samples []uint32) error

WriteSamples writes multiple samples at once.