avutil

package
v0.0.0-...-acfd9e9 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package avutil is a utility library to aid portable multimedia programming. It contains safe portable string functions, random number generators, data structures, additional mathematics functions, cryptography and multimedia related functionality. Some generic features and utilities provided by the libavutil library

Package avutil is a utility library to aid portable multimedia programming. It contains safe portable string functions, random number generators, data structures, additional mathematics functions, cryptography and multimedia related functionality. Some generic features and utilities provided by the libavutil library

Index

Constants

View Source
const (
	AVMEDIA_TYPE_UNKNOWN    = -1
	AVMEDIA_TYPE_VIDEO      = 0
	AVMEDIA_TYPE_AUDIO      = 1
	AVMEDIA_TYPE_DATA       = 2
	AVMEDIA_TYPE_SUBTITLE   = 3
	AVMEDIA_TYPE_ATTACHMENT = 4
	AVMEDIA_TYPE_NB         = 5
)
View Source
const (
	AV_CH_FRONT_LEFT    = 0x1
	AV_CH_FRONT_RIGHT   = 0x2
	AV_CH_LAYOUT_STEREO = 0x3 //(AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
)
View Source
const (
	AVERROR_EAGAIN = -11
	AVERROR_EOF    = -541478725
)
View Source
const (
	MAX_AVERROR_STR_LEN = 255
	AVERROR_UNKNOWN     = "Unknown error"
)
View Source
const (
	AvErrorEOF    = -('E' | ('O' << 8) | ('F' << 16) | (' ' << 24))
	AvErrorEAGAIN = -35
)
View Source
const (
	AV_SAMPLE_FMT_NONE = int(C.AV_SAMPLE_FMT_NONE)
	AV_SAMPLE_FMT_U8   = int(C.AV_SAMPLE_FMT_U8)
	AV_SAMPLE_FMT_S16  = int(C.AV_SAMPLE_FMT_S16)
	AV_SAMPLE_FMT_S32  = int(C.AV_SAMPLE_FMT_S32)
	AV_SAMPLE_FMT_FLT  = int(C.AV_SAMPLE_FMT_FLT)
	AV_SAMPLE_FMT_DBL  = int(C.AV_SAMPLE_FMT_DBL)

	AV_SAMPLE_FMT_U8P  = int(C.AV_SAMPLE_FMT_U8P)
	AV_SAMPLE_FMT_S16P = int(C.AV_SAMPLE_FMT_S16P)
	AV_SAMPLE_FMT_S32P = int(C.AV_SAMPLE_FMT_S32P)
	AV_SAMPLE_FMT_FLTP = int(C.AV_SAMPLE_FMT_FLTP)
	AV_SAMPLE_FMT_DBLP = int(C.AV_SAMPLE_FMT_DBLP)
	AV_SAMPLE_FMT_S64  = int(C.AV_SAMPLE_FMT_S64)
	AV_SAMPLE_FMT_S64P = int(C.AV_SAMPLE_FMT_S64P)

	AV_SAMPLE_FMT_NB = int(C.AV_SAMPLE_FMT_NB)
)
View Source
const (
	AV_TIME_BASE = 1000000
)

Variables

View Source
var AV_NOPTS_VALUE int64 = -9223372036854775808

Functions

func AvAllocateImageBuffer

func AvAllocateImageBuffer(size int) []uint8

func AvCalloc

func AvCalloc(n, s uintptr) unsafe.Pointer

Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block.

func AvDictSet

func AvDictSet(d **Dictionary, key, value string, flags int) int

func AvDynarray2Add

func AvDynarray2Add(t *unsafe.Pointer, n *int, e uintptr, d uint8) unsafe.Pointer

Add an element of size elem_size to a dynamic array.

func AvDynarrayAdd

func AvDynarrayAdd(t unsafe.Pointer, n *int, e unsafe.Pointer)

Add an element to a dynamic array.

func AvDynarrayAddNofree

func AvDynarrayAddNofree(p unsafe.Pointer, n *int, e unsafe.Pointer) int

Add an element to a dynamic array.

func AvFastMalloc

func AvFastMalloc(p unsafe.Pointer, s *uint, m uintptr)

Allocate a buffer, reusing the given one if large enough.

func AvFastRealloc

func AvFastRealloc(p unsafe.Pointer, s *uint, m uintptr) unsafe.Pointer

Reallocate the given block if it is not large enough, otherwise do nothing.

func AvFrameCopyProps

func AvFrameCopyProps(d, s *Frame) int

Copy only "metadata" fields from src to dst.

func AvFrameFree

func AvFrameFree(f *Frame)

Free the frame and any dynamically allocated objects in it, e.g.

func AvFrameGetBestEffortTimestamp

func AvFrameGetBestEffortTimestamp(f *Frame) int64

func AvFrameGetBuffer

func AvFrameGetBuffer(f *Frame, a int) int

Allocate new buffer(s) for audio or video data.

func AvFrameGetQpTable

func AvFrameGetQpTable(f *Frame, s, t *int) int8

func AvFrameIsWritable

func AvFrameIsWritable(f *Frame) int

Check if the frame data is writable.

func AvFrameMakeWritable

func AvFrameMakeWritable(f *Frame) int

Ensure that the frame data is writable, avoiding data copy if possible.

func AvFrameMoveRef

func AvFrameMoveRef(d, s *Frame)

Move everythnig contained in src to dst and reset src.

func AvFrameRef

func AvFrameRef(d, s *Frame) int

Setup a new reference to the data described by an given frame.

func AvFrameSetQpTable

func AvFrameSetQpTable(f *Frame, b *AvBufferRef, s, q int) int

func AvFrameUnref

func AvFrameUnref(f *Frame)

Unreference all the buffers referenced by frame and reset the frame fields.

func AvFree

func AvFree(p unsafe.Pointer)

Free a memory block which has been allocated with av_malloc(z)() or av_realloc().

func AvFreeImageBuffer

func AvFreeImageBuffer(buffer []uint8)

func AvFreep

func AvFreep(p unsafe.Pointer)

Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer pointing to it to NULL.

func AvGetChannelLayoutNbChannels

func AvGetChannelLayoutNbChannels(chanelLayout uint64) int

func AvGetMediaTypeString

func AvGetMediaTypeString(mt MediaType) string

Return a string describing the media_type enum, NULL if media_type is unknown.

func AvGetPictureTypeChar

func AvGetPictureTypeChar(pt AvPictureType) string

Return a single letter to describe the given picture type pict_type.

func AvGetSampleFmtName

func AvGetSampleFmtName(sampleFmt int) string

func AvImageFillArrays

func AvImageFillArrays(dstData [8]*uint8, dstLinesize [8]int32, src []uint8,
	pixFmt PixelFormat, width, height, align int) int

Setup the data pointers and linesizes based on the specified image parameters and the provided array.

func AvImageGetBufferSize

func AvImageGetBufferSize(pixFmt PixelFormat, width, height, align int) int

Return the size in bytes of the amount of data required to store an image with the given parameters.

func AvIntListLengthForSize

func AvIntListLengthForSize(e uint, l int, t uint64) uint

Compute the length of an integer list.

func AvMalloc

func AvMalloc(s uintptr) unsafe.Pointer

Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if available on the CPU).

func AvMallocz

func AvMallocz(s uintptr) unsafe.Pointer

Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if available on the CPU) and zero all the bytes of the block.

func AvMaxAlloc

func AvMaxAlloc(m uintptr)

Set the maximum size that may me allocated in one block.

func AvMemcpyBackptr

func AvMemcpyBackptr(d *uintptr, b, c int)

deliberately overlapping memcpy implementation

func AvMemdup

func AvMemdup(p *int, s uintptr) unsafe.Pointer

Duplicate the buffer p.

func AvRealloc

func AvRealloc(p *int, s uintptr) unsafe.Pointer

Allocate or reallocate a block of memory.

func AvReallocArray

func AvReallocArray(p int, n, s uintptr) unsafe.Pointer

func AvReallocF

func AvReallocF(p int, n, e uintptr) unsafe.Pointer

Allocate or reallocate a block of memory.

func AvReallocp

func AvReallocp(p int, s uintptr) int

Allocate or reallocate a block of memory.

func AvReallocpArray

func AvReallocpArray(p int, n, s uintptr) int

func AvRescaleQ

func AvRescaleQ(a int64, bq Rational, cq Rational) int64

func AvSizeMult

func AvSizeMult(a, b uintptr, r *uintptr) int

Multiply two size_t values checking for overflow.

func AvStrdup

func AvStrdup(s string) string

Duplicate the string s.

func AvStrerr

func AvStrerr(errcode int) string

func AvStrndup

func AvStrndup(s string, l uintptr) string

char * av_strndup (const char *s, size_t len) av_malloc_attrib Duplicate a substring of the string s.

func AvXIfNull

func AvXIfNull(p, x int)

Return x default pointer in case p is NULL.

func AvutilConfiguration

func AvutilConfiguration() string

Return the libavutil build-time configuration.

func AvutilLicense

func AvutilLicense() string

Return the libavutil license.

func AvutilVersion

func AvutilVersion() uint

Return the LIBAvUTIL_VERSION_INT constant.

func Data

func Data(f *Frame) *uint8

func DrawYCbCrNew

func DrawYCbCrNew(src *image.YCbCr, buffers *[]float32) *float32

func ErrorFromCode

func ErrorFromCode(code int) error

func GetPicture

func GetPicture(f *Frame, buffer *[]float32) (bufferr *[]float32, img *image.YCbCr, LastFrameFloat *float32, err error)

GetPicture creates a YCbCr image from the frame

func GetPictureGray

func GetPictureGray(f *Frame, buffer *[]float32) (bufferr *[]float32, img *image.YCbCr, LastFrameFloat *float32, err error)

GetPicture creates a YCbCr image from the frame

func GetPictureRGB

func GetPictureRGB(f *Frame) (img *image.RGBA, err error)
func GetPicture(f *Frame) (img *image.YCbCr, err error) {
	// For 4:4:4, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/1.
	// For 4:2:2, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/2.
	// For 4:2:0, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/4.
	// For 4:4:0, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/2.
	// For 4:1:1, CStride == YStride/4 && len(Cb) == len(Cr) == len(Y)/4.
	// For 4:1:0, CStride == YStride/4 && len(Cb) == len(Cr) == len(Y)/8.

	w := int(f.linesize[0])
	h := int(f.height)
	r := image.Rectangle{image.Point{0, 0}, image.Point{w, h}}
	// TODO: Use the sub sample ratio from the input image 'f.format'
	img = image.NewYCbCr(r, image.YCbCrSubsampleRatio420)
	// convert the frame data data to a Go byte array

	yb_tmp := C.GoBytes(unsafe.Pointer(f.data[0]), C.int(w*h))
	yb := make([]uint8, len(yb_tmp))
	copy(yb, yb_tmp)
	img.Y = yb
	wCb := int(f.linesize[1])
	if unsafe.Pointer(f.data[1]) != nil {

		//img.Cb = C.GoBytes(unsafe.Pointer(f.data[1]), C.int(wCb*h/2))
		cb_tmp := C.GoBytes(unsafe.Pointer(f.data[1]), C.int(wCb*h/2))
		cb := make([]uint8, len(cb_tmp))
		copy(cb, cb_tmp)
		img.Cb = cb
	}

	wCr := int(f.linesize[2])
	if unsafe.Pointer(f.data[2]) != nil {
		//img.Cr = C.GoBytes(unsafe.Pointer(f.data[2]), C.int(wCr*h/2))

		cr_tmp := C.GoBytes(unsafe.Pointer(f.data[2]), C.int(wCr*h/2))
		cr := make([]uint8, len(cr_tmp))
		copy(cr, cr_tmp)
		img.Cr = cr
	}
	return
}

func GetPicturev5

func GetPicturev5(f *Frame) (img *image.YCbCr, err error)

GetPicture creates a YCbCr image from the frame

func GetPicturevGrayScale

func GetPicturevGrayScale(f *Frame) (img *image.Gray, err error)

func Linesize

func Linesize(f *Frame) int

func SetPicture

func SetPicture(f *Frame, img *image.YCbCr)

SetPicture creates a YCbCr image from the frame

Types

type AvBuffer

type AvBuffer C.struct_AVBuffer

type AvBufferPool

type AvBufferPool C.struct_AVBufferPool

type AvBufferRef

type AvBufferRef C.struct_AVBufferRef

func AvFrameGetPlaneBuffer

func AvFrameGetPlaneBuffer(f *Frame, p int) *AvBufferRef

Get the buffer reference a given data plane is stored in.

type AvFrameSideData

type AvFrameSideData C.struct_AVFrameSideData

Frame C.struct_AVFrame

func AvFrameGetSideData

func AvFrameGetSideData(f *Frame, t AvFrameSideDataType) *AvFrameSideData

func AvFrameNewSideData

func AvFrameNewSideData(f *Frame, d AvFrameSideDataType, s int) *AvFrameSideData

Add a new side data to a frame.

type AvFrameSideDataType

type AvFrameSideDataType C.enum_AVFrameSideDataType

type AvPictureType

type AvPictureType C.enum_AVPictureType

type AvTree

type AvTree C.struct_AVTree

type Dictionary

type Dictionary C.struct_AVDictionary

type DictionaryEntry

type DictionaryEntry C.struct_AVDictionaryEntry

func AvDictGet

func AvDictGet(d *Dictionary, key string, prev *DictionaryEntry, flags int) *DictionaryEntry

func (*DictionaryEntry) Key

func (e *DictionaryEntry) Key() string

func (*DictionaryEntry) Value

func (e *DictionaryEntry) Value() string

type File

type File C.FILE

func AvFopenUtf8

func AvFopenUtf8(p, m string) *File

Open a file using a UTF-8 filename.

type Frame

type Frame struct {
	Data          [8]*uint8
	Linesize      [8]int32
	Extended_data **uint8

	Nb_samples int32

	Key_frame              int32
	Pict_type              uint32
	Sample_aspect_ratio    Rational
	Pts                    int64
	Pkt_pts                int64
	Pkt_dts                int64
	Coded_picture_number   int32
	Display_picture_number int32
	Quality                int32
	Pad_cgo_0              [4]byte
	Opaque                 *byte
	Error                  [8]uint64
	Repeat_pict            int32
	Interlaced_frame       int32
	Top_field_first        int32
	Palette_has_changed    int32
	Reordered_opaque       int64
	Sample_rate            int32
	Pad_cgo_1              [4]byte
	Channel_layout         uint64
	Buf                    [8]*AvBufferRef
	Extended_buf           **AvBufferRef
	Nb_extended_buf        int32
	Pad_cgo_2              [4]byte
	Side_data              **AvFrameSideData
	Nb_side_data           int32
	Flags                  int32
	Color_range            uint32
	Color_primaries        uint32
	Color_trc              uint32
	Colorspace             uint32
	Chroma_location        uint32
	Pad_cgo_3              [4]byte
	Best_effort_timestamp  int64
	Pkt_pos                int64
	Pkt_duration           int64
	Metadata               *Dictionary
	Decode_error_flags     int32
	Channels               int32
	Pkt_size               int32
	Pad_cgo_4              [4]byte
	Qscale_table           *int8
	Qstride                int32
	Qscale_type            int32
	Qp_table_buf           *AvBufferRef
	Hw_frames_ctx          *AvBufferRef
	// contains filtered or unexported fields
}

func AvFrameAlloc

func AvFrameAlloc() *Frame

Allocate an Frame and set its fields to default values.

func AvFrameClone

func AvFrameClone(f *Frame) *Frame

Create a new frame that references the same data as src.

func GetPicturev6

func GetPicturev6(f *Frame) (img *Frame, err error)

func (*Frame) Format

func (f *Frame) Format() int

Format returns the frame's format.

func (*Frame) Height

func (f *Frame) Height() int

Height returns the frame height

func (*Frame) SetFormat

func (f *Frame) SetFormat(format int)

SetFormat sets the frame's format.

func (*Frame) SetHeight

func (f *Frame) SetHeight(h int)

SetHeight setes the frame height

func (*Frame) SetWidth

func (f *Frame) SetWidth(w int)

SetWidth sets the frame width

func (*Frame) Width

func (f *Frame) Width() int

Width returns the frame width

type MediaType

type MediaType C.enum_AVMediaType

type Options

type Options C.struct_AVOptions

type PixelFormat

type PixelFormat C.enum_AVPixelFormat

type Rational

type Rational C.struct_AVRational
var AV_TIME_BASE_Q Rational = NewRational(1, AV_TIME_BASE)

func AvGetTimeBaseQ

func AvGetTimeBaseQ() Rational

Return the fractional representation of the internal time base.

func NewRational

func NewRational(num, den int) Rational

func (*Rational) Den

func (r *Rational) Den() int

func (*Rational) Num

func (r *Rational) Num() int

func (*Rational) SetDen

func (r *Rational) SetDen(den int)

func (*Rational) SetNum

func (r *Rational) SetNum(num int)

func (*Rational) ToDouble

func (r *Rational) ToDouble() float64

Jump to

Keyboard shortcuts

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