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
- Variables
- func AvAllocateImageBuffer(size int) []uint8
- func AvCalloc(n, s uintptr) unsafe.Pointer
- func AvDictSet(d **Dictionary, key, value string, flags int) int
- func AvDynarray2Add(t *unsafe.Pointer, n *int, e uintptr, d uint8) unsafe.Pointer
- func AvDynarrayAdd(t unsafe.Pointer, n *int, e unsafe.Pointer)
- func AvDynarrayAddNofree(p unsafe.Pointer, n *int, e unsafe.Pointer) int
- func AvFastMalloc(p unsafe.Pointer, s *uint, m uintptr)
- func AvFastRealloc(p unsafe.Pointer, s *uint, m uintptr) unsafe.Pointer
- func AvFrameCopyProps(d, s *Frame) int
- func AvFrameFree(f *Frame)
- func AvFrameGetBestEffortTimestamp(f *Frame) int64
- func AvFrameGetBuffer(f *Frame, a int) int
- func AvFrameGetQpTable(f *Frame, s, t *int) int8
- func AvFrameIsWritable(f *Frame) int
- func AvFrameMakeWritable(f *Frame) int
- func AvFrameMoveRef(d, s *Frame)
- func AvFrameRef(d, s *Frame) int
- func AvFrameSetQpTable(f *Frame, b *AvBufferRef, s, q int) int
- func AvFrameUnref(f *Frame)
- func AvFree(p unsafe.Pointer)
- func AvFreeImageBuffer(buffer []uint8)
- func AvFreep(p unsafe.Pointer)
- func AvGetChannelLayoutNbChannels(chanelLayout uint64) int
- func AvGetMediaTypeString(mt MediaType) string
- func AvGetPictureTypeChar(pt AvPictureType) string
- func AvGetSampleFmtName(sampleFmt int) string
- func AvImageFillArrays(dstData [8]*uint8, dstLinesize [8]int32, src []uint8, pixFmt PixelFormat, ...) int
- func AvImageGetBufferSize(pixFmt PixelFormat, width, height, align int) int
- func AvIntListLengthForSize(e uint, l int, t uint64) uint
- func AvMalloc(s uintptr) unsafe.Pointer
- func AvMallocz(s uintptr) unsafe.Pointer
- func AvMaxAlloc(m uintptr)
- func AvMemcpyBackptr(d *uintptr, b, c int)
- func AvMemdup(p *int, s uintptr) unsafe.Pointer
- func AvRealloc(p *int, s uintptr) unsafe.Pointer
- func AvReallocArray(p int, n, s uintptr) unsafe.Pointer
- func AvReallocF(p int, n, e uintptr) unsafe.Pointer
- func AvReallocp(p int, s uintptr) int
- func AvReallocpArray(p int, n, s uintptr) int
- func AvRescaleQ(a int64, bq Rational, cq Rational) int64
- func AvSizeMult(a, b uintptr, r *uintptr) int
- func AvStrdup(s string) string
- func AvStrerr(errcode int) string
- func AvStrndup(s string, l uintptr) string
- func AvXIfNull(p, x int)
- func AvutilConfiguration() string
- func AvutilLicense() string
- func AvutilVersion() uint
- func Data(f *Frame) *uint8
- func DrawYCbCrNew(src *image.YCbCr, buffers *[]float32) *float32
- func ErrorFromCode(code int) error
- func GetPicture(f *Frame, buffer *[]float32) (bufferr *[]float32, img *image.YCbCr, LastFrameFloat *float32, err error)
- func GetPictureGray(f *Frame, buffer *[]float32) (bufferr *[]float32, img *image.YCbCr, LastFrameFloat *float32, err error)
- func GetPictureRGB(f *Frame) (img *image.RGBA, err error)
- func GetPicturev5(f *Frame) (img *image.YCbCr, err error)
- func GetPicturevGrayScale(f *Frame) (img *image.Gray, err error)
- func Linesize(f *Frame) int
- func SetPicture(f *Frame, img *image.YCbCr)
- type AvBuffer
- type AvBufferPool
- type AvBufferRef
- type AvFrameSideData
- type AvFrameSideDataType
- type AvPictureType
- type AvTree
- type Dictionary
- type DictionaryEntry
- type File
- type Frame
- type MediaType
- type Options
- type PixelFormat
- type Rational
Constants ¶
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 )
const ( AV_CH_FRONT_LEFT = 0x1 AV_CH_FRONT_RIGHT = 0x2 AV_CH_LAYOUT_STEREO = 0x3 //(AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT) )
const ( AVERROR_EAGAIN = -11 AVERROR_EOF = -541478725 )
const ( MAX_AVERROR_STR_LEN = 255 AVERROR_UNKNOWN = "Unknown error" )
const ( AvErrorEOF = -('E' | ('O' << 8) | ('F' << 16) | (' ' << 24)) AvErrorEAGAIN = -35 )
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) )
const (
AV_TIME_BASE = 1000000
)
Variables ¶
var AV_NOPTS_VALUE int64 = -9223372036854775808
Functions ¶
func AvAllocateImageBuffer ¶
func AvCalloc ¶
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 AvDynarray2Add ¶
Add an element of size elem_size to a dynamic array.
func AvDynarrayAdd ¶
Add an element to a dynamic array.
func AvDynarrayAddNofree ¶
Add an element to a dynamic array.
func AvFastMalloc ¶
Allocate a buffer, reusing the given one if large enough.
func AvFastRealloc ¶
Reallocate the given block if it is not large enough, otherwise do nothing.
func AvFrameCopyProps ¶
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 AvFrameGetBuffer ¶
Allocate new buffer(s) for audio or video data.
func AvFrameGetQpTable ¶
func AvFrameMakeWritable ¶
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 ¶
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 AvFreeImageBuffer ¶
func AvFreeImageBuffer(buffer []uint8)
func AvFreep ¶
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 AvGetMediaTypeString ¶
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 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 ¶
Compute the length of an integer list.
func AvMalloc ¶
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if available on the CPU).
func AvMallocz ¶
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 ¶
deliberately overlapping memcpy implementation
func AvReallocF ¶
Allocate or reallocate a block of memory.
func AvReallocpArray ¶
func AvSizeMult ¶
Multiply two size_t values checking for overflow.
func AvStrndup ¶
char * av_strndup (const char *s, size_t len) av_malloc_attrib Duplicate a substring of the string s.
func AvutilConfiguration ¶
func AvutilConfiguration() string
Return the libavutil build-time configuration.
func ErrorFromCode ¶
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 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 ¶
GetPicture creates a YCbCr image from the frame
func SetPicture ¶
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 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 ¶
Create a new frame that references the same data as src.
func GetPicturev6 ¶
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.