mirror of
https://github.com/giorgisio/goav.git
synced 2024-04-21 12:31:56 +00:00
123 lines
4.1 KiB
Go
123 lines
4.1 KiB
Go
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
|
|
// Giorgis (habtom@giorgis.io)
|
|
|
|
package avutil
|
|
|
|
/*
|
|
#cgo pkg-config: libavutil
|
|
#include <libavutil/frame.h>
|
|
#include <stdlib.h>
|
|
*/
|
|
import "C"
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
type (
|
|
AvBuffer C.struct_AVBuffer
|
|
AvBufferRef C.struct_AVBufferRef
|
|
AvBufferPool C.struct_AVBufferPool
|
|
Frame C.struct_AVFrame
|
|
AvFrameSideData C.struct_AVFrameSideData
|
|
AvFrameSideDataType C.enum_AVFrameSideDataType
|
|
)
|
|
|
|
func AvprivFrameGetMetadatap(f *Frame) **Dictionary {
|
|
return (**Dictionary)(unsafe.Pointer(C.avpriv_frame_get_metadatap((*C.struct_AVFrame)(unsafe.Pointer(f)))))
|
|
}
|
|
|
|
func AvFrameSetQpTable(f *Frame, b *AvBufferRef, s, q int) int {
|
|
return int(C.av_frame_set_qp_table((*C.struct_AVFrame)(unsafe.Pointer(f)), (*C.struct_AVBufferRef)(unsafe.Pointer(b)), C.int(s), C.int(q)))
|
|
}
|
|
|
|
func AvFrameGetQpTable(f *Frame, s, t *int) int8 {
|
|
return int8(*C.av_frame_get_qp_table((*C.struct_AVFrame)(unsafe.Pointer(f)), (*C.int)(unsafe.Pointer(s)), (*C.int)(unsafe.Pointer(t))))
|
|
}
|
|
|
|
//Allocate an Frame and set its fields to default values.
|
|
func AvFrameAlloc() *Frame {
|
|
return (*Frame)(unsafe.Pointer(C.av_frame_alloc()))
|
|
}
|
|
|
|
//Free the frame and any dynamically allocated objects in it, e.g.
|
|
func AvFrameFree(f *Frame) {
|
|
C.av_frame_free((**C.struct_AVFrame)(unsafe.Pointer(f)))
|
|
}
|
|
|
|
//Allocate new buffer(s) for audio or video data.
|
|
func AvFrameGetBuffer(f *Frame, a int) int {
|
|
return int(C.av_frame_get_buffer((*C.struct_AVFrame)(unsafe.Pointer(f)), C.int(a)))
|
|
}
|
|
|
|
//Setup a new reference to the data described by an given frame.
|
|
func AvFrameRef(d, s *Frame) int {
|
|
return int(C.av_frame_ref((*C.struct_AVFrame)(unsafe.Pointer(d)), (*C.struct_AVFrame)(unsafe.Pointer(s))))
|
|
}
|
|
|
|
//Create a new frame that references the same data as src.
|
|
func AvFrameClone(f *Frame) *Frame {
|
|
return (*Frame)(C.av_frame_clone((*C.struct_AVFrame)(unsafe.Pointer(f))))
|
|
}
|
|
|
|
//Unreference all the buffers referenced by frame and reset the frame fields.
|
|
func AvFrameUnref(f *Frame) {
|
|
cf := (*C.struct_AVFrame)(unsafe.Pointer(f))
|
|
C.av_frame_unref(cf)
|
|
}
|
|
|
|
//Move everythnig contained in src to dst and reset src.
|
|
func AvFrameMoveRef(d, s *Frame) {
|
|
C.av_frame_move_ref((*C.struct_AVFrame)(unsafe.Pointer(d)), (*C.struct_AVFrame)(unsafe.Pointer(s)))
|
|
}
|
|
|
|
//Check if the frame data is writable.
|
|
func AvFrameIsWritable(f *Frame) int {
|
|
return int(C.av_frame_is_writable((*C.struct_AVFrame)(unsafe.Pointer(f))))
|
|
}
|
|
|
|
//Ensure that the frame data is writable, avoiding data copy if possible.
|
|
func AvFrameMakeWritable(f *Frame) int {
|
|
return int(C.av_frame_make_writable((*C.struct_AVFrame)(unsafe.Pointer(f))))
|
|
}
|
|
|
|
//Copy only "metadata" fields from src to dst.
|
|
func AvFrameCopyProps(d, s *Frame) int {
|
|
return int(C.av_frame_copy_props((*C.struct_AVFrame)(unsafe.Pointer(d)), (*C.struct_AVFrame)(unsafe.Pointer(s))))
|
|
}
|
|
|
|
//Get the buffer reference a given data plane is stored in.
|
|
func AvFrameGetPlaneBuffer(f *Frame, p int) *AvBufferRef {
|
|
return (*AvBufferRef)(C.av_frame_get_plane_buffer((*C.struct_AVFrame)(unsafe.Pointer(f)), C.int(p)))
|
|
}
|
|
|
|
//Add a new side data to a frame.
|
|
func AvFrameNewSideData(f *Frame, d AvFrameSideDataType, s int) *AvFrameSideData {
|
|
return (*AvFrameSideData)(C.av_frame_new_side_data((*C.struct_AVFrame)(unsafe.Pointer(f)), (C.enum_AVFrameSideDataType)(d), C.int(s)))
|
|
}
|
|
|
|
func AvFrameGetSideData(f *Frame, t AvFrameSideDataType) *AvFrameSideData {
|
|
return (*AvFrameSideData)(C.av_frame_get_side_data((*C.struct_AVFrame)(unsafe.Pointer(f)), (C.enum_AVFrameSideDataType)(t)))
|
|
}
|
|
|
|
func Data(f *Frame) *uint8 {
|
|
return (*uint8)(unsafe.Pointer((*C.uint8_t)(unsafe.Pointer(&f.data))))
|
|
}
|
|
func Linesize(f *Frame) int {
|
|
return int(*(*C.int)(unsafe.Pointer(&f.linesize)))
|
|
}
|
|
|
|
// //static int get_video_buffer (Frame *frame, int align)
|
|
// func GetVideoBuffer(f *Frame, a int) int {
|
|
// return int(C.get_video_buffer(f, C.int(a)))
|
|
// }
|
|
|
|
// //static int get_audio_buffer (Frame *frame, int align)
|
|
// func GetAudioBuffer(f *Frame, a int) int {
|
|
// return C.get_audio_buffer(f, C.int(a))
|
|
// }
|
|
|
|
// //static void get_frame_defaults (Frame *frame)
|
|
// func GetFrameDefaults(f *Frame) {
|
|
// C.get_frame_defaults(*C.struct_AVFrame(f))
|
|
// }
|