xevd

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

README

go-xevd

License GoDoc Go Report Card Releases

Go bindings for mpeg5/xevd
MPEG-5 EVC decoder.

Requirements

requires xevd install on your system

$ git clone https://github.com/mpeg5/xevd.git
$ cd xevd
$ mkdir build
$ cd build
$ cmake .. -DSET_PROF=BASE
$ make
$ make install

Usage

Decode
import "github.com/octu0/go-xevd"

func main() {
	decoder, err := xevd.CreateDefaultBaselineDecoder()
	if err != nil {
		panic(err)
	}
	defer decoder.Close()

	f, err := os.Open("./testdata/src.evc")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	br := bufio.NewReader(f)
	if err := decoder.DecodeStream(br, func(buf *xevd.DecodeImageBuffer) {
		defer buf.Close()

		fmt.Printf("Frame:%s Slice:%s color:%s\n", buf.NALUnit, buf.Slice, buf.ColorSpace)
		// => Frame:IDR Slice:I color:YCbCr420

		if err := saveImage(buf.Img); err != nil {
			panic(err)
		}
	}); err != nil {
		panic(err)
	}
}

func saveImage(img image.Image) (string, error) {
	out, err := os.CreateTemp("/tmp", "out*.png")
	if err != nil {
		return "", err
	}
	defer out.Close()

	if err := png.Encode(out, img); err != nil {
		return "", err
	}
	return out.Name(), nil
}

Documentation

Index

Constants

View Source
const (
	AppName string = "go-xevd"
	Version string = "1.0.0"
)
View Source
const (
	NoMoreFrames             ReturnCode = 205
	OutNotAvailable                     = 204
	FrameDimensionChanged               = 203
	FrameDelayed                        = 202
	ErrWarnCRCIgnored                   = 200
	Ok                                  = 0
	Err                                 = -1
	ErrInvalidArgument                  = -101
	ErrOutOfMemory                      = -102
	ErrReachedMax                       = -103
	ErrUnsupported                      = -104
	ErrUnexpected                       = -105
	ErrUnsupportedColorSpace            = -201
	ErrMalformedBitstream               = -202
	ErrThreadAllocation                 = -203
	ErrBadCRC                           = -300
	ErrUnknown                          = -32767
)
View Source
const (
	ColorFormatUnknown   = 0
	ColorFormatYCbCr400  = 10 // Y onlu
	ColorFormatYCbCr420  = 11 // YCbCr 420
	ColorFormatYCbCr422  = 12 // YCbCr 422 narrow chroma
	ColorFormatYCbCr444  = 13 // YCbCr 444
	ColorFormatYCbCr422N = ColorFormatYCbCr422
	ColorFormatYCbCr422W = 18 // YCbCr 422 wide chroma
)
View Source
const (
	ConfigSetUsePicSignature ConfigType = 301
	ConfigGetCodecBitDepth              = 401
	ConfigGetWith                       = 402
	ConfigGetHeight                     = 403
	ConfigGetCodedWith                  = 404
	ConfigGetCodedHeight                = 405
	ConfigGetCodedSpace                 = 406
	ConfigGetMaxConfigDelay             = 407
)
View Source
const (
	NALUnitNonIDR NALUnitType = 0
	NALUnitIDR                = 1
	NALUnitSPS                = 24
	NALUnitPPS                = 25
	NALUnitAPS                = 26
	NALUnitFD                 = 27
	NALUnitSEI                = 28
)
View Source
const (
	SliceUnknown SliceType = -1
	SliceB                 = 0
	SliceP                 = 1
	SliceI                 = 2
)
View Source
const NALUnitLengthByteSize = 4

Variables

This section is empty.

Functions

func Failed

func Failed(rc ReturnCode) bool

func Succeed

func Succeed(rc ReturnCode) bool

Types

type BaselineDecoder

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

func CreateBaselineDecoder

func CreateBaselineDecoder(threads, maxBitstreamBufferSize int) (*BaselineDecoder, error)

func CreateDefaultBaselineDecoder

func CreateDefaultBaselineDecoder() (*BaselineDecoder, error)

func (*BaselineDecoder) Close

func (d *BaselineDecoder) Close()

func (*BaselineDecoder) Decode

func (d *BaselineDecoder) Decode(data []byte) (*DecodeImageBuffer, error)

func (*BaselineDecoder) DecodeStream

func (d *BaselineDecoder) DecodeStream(r io.Reader, fn DecodeStreamRecvFunc) error

type ColorFormatType

type ColorFormatType uint8

func (ColorFormatType) String

func (c ColorFormatType) String() string

type ConfigType

type ConfigType uint16

type DecodeImageBuffer

type DecodeImageBuffer struct {
	NALUnit    NALUnitType
	Slice      SliceType
	ColorSpace ColorFormatType
	Img        *image.YCbCr
	// contains filtered or unexported fields
}

func (*DecodeImageBuffer) Close

func (b *DecodeImageBuffer) Close()

func (*DecodeImageBuffer) HasData

func (b *DecodeImageBuffer) HasData() bool

type DecodeStreamRecvFunc

type DecodeStreamRecvFunc func(*DecodeImageBuffer)

type NALUnitType

type NALUnitType uint8

func (NALUnitType) String

func (n NALUnitType) String() string

type ReturnCode

type ReturnCode int

func (ReturnCode) Error

func (rc ReturnCode) Error() string

type SliceType

type SliceType int8

func (SliceType) String

func (s SliceType) String() string

Jump to

Keyboard shortcuts

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