diff --git a/avutil_avstring.go b/avutil_avstring.go index d16dafb..25068a5 100644 --- a/avutil_avstring.go +++ b/avutil_avstring.go @@ -53,7 +53,7 @@ import "C" // NONEED: av_append_path_component -type AVEscapeMode C.enum_AVEscapeMode +type AVEscapeMode = C.enum_AVEscapeMode const ( AV_ESCAPE_MODE_AUTO = C.AV_ESCAPE_MODE_AUTO diff --git a/avutil_common.go b/avutil_common.go index 838aa64..ba123ad 100644 --- a/avutil_common.go +++ b/avutil_common.go @@ -137,8 +137,8 @@ func AvLog2(v uint32) int32 { return (int32)(C.av_log2((C.uint)(v))) } -// AvLog2_16bit -func AvLog2_16bit(v uint32) int32 { +// AvLog2With16bit +func AvLog2With16bit(v uint32) int32 { return (int32)(C.av_log2_16bit((C.uint)(v))) } diff --git a/avutil_hash.go b/avutil_hash.go index 0412f76..0984fe6 100644 --- a/avutil_hash.go +++ b/avutil_hash.go @@ -6,6 +6,7 @@ package ffmpeg import "C" import "unsafe" +// AVHashContext type AVHashContext C.struct_AVHashContext // AvHashAlloc allocates a hash context for the algorithm specified by name. diff --git a/avutil_hdr_dynamic_metadata.go b/avutil_hdr_dynamic_metadata.go index 1525a33..ff56aa2 100644 --- a/avutil_hdr_dynamic_metadata.go +++ b/avutil_hdr_dynamic_metadata.go @@ -7,7 +7,7 @@ import "C" import "unsafe" // AVHDRPlusOverlapProcessOption -type AVHDRPlusOverlapProcessOption C.enum_AVHDRPlusOverlapProcessOption +type AVHDRPlusOverlapProcessOption = C.enum_AVHDRPlusOverlapProcessOption const ( AV_HDR_PLUS_OVERLAP_PROCESS_WEIGHTED_AVERAGING = AVHDRPlusOverlapProcessOption( diff --git a/avutil_hmac.go b/avutil_hmac.go index 054e6e6..6e23e3b 100644 --- a/avutil_hmac.go +++ b/avutil_hmac.go @@ -6,7 +6,7 @@ package ffmpeg import "C" // AVHMACType -type AVHMACType C.enum_AVHMACType +type AVHMACType = C.enum_AVHMACType const ( AV_HMAC_MD5 = AVHMACType(C.AV_HMAC_MD5) @@ -17,6 +17,7 @@ const ( AV_HMAC_SHA512 = AVHMACType(C.AV_HMAC_SHA512) ) +// AVHMAC type AVHMAC C.struct_AVHMAC // AvHmacAlloc allocates an AVHMAC context. diff --git a/avutil_lfg.go b/avutil_lfg.go index 431c088..90682b0 100644 --- a/avutil_lfg.go +++ b/avutil_lfg.go @@ -5,6 +5,7 @@ package ffmpeg */ import "C" +// AVLFG type AVLFG C.struct_AVLFG // AvLfgInit diff --git a/avutil_rc4.go b/avutil_rc4.go index 51ad435..0ac3fc0 100644 --- a/avutil_rc4.go +++ b/avutil_rc4.go @@ -5,6 +5,7 @@ package ffmpeg */ import "C" +// AVRC4 type AVRC4 C.struct_AVRC4 // AvRc4Alloc allocates an AVRC4 context. diff --git a/avutil_ripemd.go b/avutil_ripemd.go index 42c2e7f..863a622 100644 --- a/avutil_ripemd.go +++ b/avutil_ripemd.go @@ -5,6 +5,7 @@ package ffmpeg */ import "C" +// AVRIPEMD type AVRIPEMD C.struct_AVRIPEMD // AvRipemdAlloc allocates an AVRIPEMD context. diff --git a/avutil_sha.go b/avutil_sha.go new file mode 100644 index 0000000..7d4a41c --- /dev/null +++ b/avutil_sha.go @@ -0,0 +1,29 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVSHA +type AVSHA C.struct_AVSHA + +// AvShaAlloc allocates an AVSHA context. +func AvShaAlloc() *AVSHA { + return (*AVSHA)(C.av_sha_alloc()) +} + +// AvShaInit initializes SHA-1 or SHA-2 hashing. +func AvShaInit(context *AVSHA, bits int32) int32 { + return (int32)(C.av_sha_init((*C.struct_AVSHA)(context), (C.int)(bits))) +} + +// AvShaUpdate updates hash value. +func AvShaUpdate(ctx *AVSHA, data *uint8, len uint32) { + C.av_sha_update((*C.struct_AVSHA)(ctx), (*C.uint8_t)(data), (C.uint)(len)) +} + +// AvShaFinal finishes hashing and output digest value. +func AvShaFinal(ctx *AVSHA, digest *uint8) { + C.av_sha_final((*C.struct_AVSHA)(ctx), (*C.uint8_t)(digest)) +} diff --git a/avutil_sha512.go b/avutil_sha512.go new file mode 100644 index 0000000..6a53d7f --- /dev/null +++ b/avutil_sha512.go @@ -0,0 +1,29 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVSHA512 +type AVSHA512 C.struct_AVSHA512 + +// AvSha512Alloc allocates an AVSHA512 context. +func AvSha512Alloc() *AVSHA512 { + return (*AVSHA512)(C.av_sha512_alloc()) +} + +// AvSha512Init initializes SHA-2 512 hashing. +func AvSha512Init(context *AVSHA512, bits int32) int32 { + return (int32)(C.av_sha512_init((*C.struct_AVSHA512)(context), (C.int)(bits))) +} + +// AvSha512Update updates hash value. +func AvSha512Update(ctx *AVSHA512, data *uint8, len uint32) { + C.av_sha512_update((*C.struct_AVSHA512)(ctx), (*C.uint8_t)(data), (C.uint)(len)) +} + +// AvSha512Final finishes hashing and output digest value. +func AvSha512Final(ctx *AVSHA512, digest *uint8) { + C.av_sha512_final((*C.struct_AVSHA512)(ctx), (*C.uint8_t)(digest)) +} diff --git a/avutil_spherical.go b/avutil_spherical.go new file mode 100644 index 0000000..3589578 --- /dev/null +++ b/avutil_spherical.go @@ -0,0 +1,181 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +type AVSphericalProjection = C.enum_AVSphericalProjection + +const ( + AV_SPHERICAL_EQUIRECTANGULAR = AVSphericalProjection(C.AV_SPHERICAL_EQUIRECTANGULAR) + AV_SPHERICAL_CUBEMAP = AVSphericalProjection(C.AV_SPHERICAL_CUBEMAP) + AV_SPHERICAL_EQUIRECTANGULAR_TILE = AVSphericalProjection(C.AV_SPHERICAL_EQUIRECTANGULAR_TILE) +) + +type AVSphericalMapping C.struct_AVSphericalMapping + +// Custom: GetProjection gets `AVSphericalMapping.projection` value. +func (smp *AVSphericalMapping) GetProjection() AVSphericalProjection { + return (AVSphericalProjection)(smp.projection) +} + +// Custom: SetProjection sets `AVSphericalMapping.projection` value. +func (smp *AVSphericalMapping) SetProjection(v AVSphericalProjection) { + smp.projection = (C.enum_AVSphericalProjection)(v) +} + +// Custom: GetProjectionAddr gets `AVSphericalMapping.projection` address. +func (smp *AVSphericalMapping) GetProjectionAddr() *AVSphericalProjection { + return (*AVSphericalProjection)(&smp.projection) +} + +// Custom: GetYaw gets `AVSphericalMapping.yaw` value. +func (smp *AVSphericalMapping) GetYaw() int32 { + return (int32)(smp.yaw) +} + +// Custom: SetYaw sets `AVSphericalMapping.yaw` value. +func (smp *AVSphericalMapping) SetYaw(v int32) { + smp.yaw = (C.int32_t)(v) +} + +// Custom: GetYawAddr gets `AVSphericalMapping.yaw` address. +func (smp *AVSphericalMapping) GetYawAddr() *int32 { + return (*int32)(&smp.yaw) +} + +// Custom: GetPitch gets `AVSphericalMapping.pitch` value. +func (smp *AVSphericalMapping) GetPitch() int32 { + return (int32)(smp.pitch) +} + +// Custom: SetPitch sets `AVSphericalMapping.pitch` value. +func (smp *AVSphericalMapping) SetPitch(v int32) { + smp.pitch = (C.int32_t)(v) +} + +// Custom: GetPitchAddr gets `AVSphericalMapping.pitch` address. +func (smp *AVSphericalMapping) GetPitchAddr() *int32 { + return (*int32)(&smp.pitch) +} + +// Custom: GetRoll gets `AVSphericalMapping.roll` value. +func (smp *AVSphericalMapping) GetRoll() int32 { + return (int32)(smp.roll) +} + +// Custom: SetRoll sets `AVSphericalMapping.roll` value. +func (smp *AVSphericalMapping) SetRoll(v int32) { + smp.roll = (C.int32_t)(v) +} + +// Custom: GetRollAddr gets `AVSphericalMapping.roll` address. +func (smp *AVSphericalMapping) GetRollAddr() *int32 { + return (*int32)(&smp.roll) +} + +// Custom: GetBoundLeft gets `AVSphericalMapping.bound_left` value. +func (smp *AVSphericalMapping) GetBoundLeft() uint32 { + return (uint32)(smp.bound_left) +} + +// Custom: SetBoundLeft sets `AVSphericalMapping.bound_left` value. +func (smp *AVSphericalMapping) SetBoundLeft(v uint32) { + smp.bound_left = (C.uint32_t)(v) +} + +// Custom: GetBoundLeftAddr gets `AVSphericalMapping.bound_left` address. +func (smp *AVSphericalMapping) GetBoundLeftAddr() *uint32 { + return (*uint32)(&smp.bound_left) +} + +// Custom: GetBoundTop gets `AVSphericalMapping.bound_top` value. +func (smp *AVSphericalMapping) GetBoundTop() uint32 { + return (uint32)(smp.bound_top) +} + +// Custom: SetBoundTop sets `AVSphericalMapping.bound_top` value. +func (smp *AVSphericalMapping) SetBoundTop(v uint32) { + smp.bound_top = (C.uint32_t)(v) +} + +// Custom: GetBoundTopAddr gets `AVSphericalMapping.bound_top` address. +func (smp *AVSphericalMapping) GetBoundTopAddr() *uint32 { + return (*uint32)(&smp.bound_top) +} + +// Custom: GetBoundRight gets `AVSphericalMapping.bound_right` value. +func (smp *AVSphericalMapping) GetBoundRight() uint32 { + return (uint32)(smp.bound_right) +} + +// Custom: SetBoundRight sets `AVSphericalMapping.bound_right` value. +func (smp *AVSphericalMapping) SetBoundRight(v uint32) { + smp.bound_right = (C.uint32_t)(v) +} + +// Custom: GetBoundRightAddr gets `AVSphericalMapping.bound_right` address. +func (smp *AVSphericalMapping) GetBoundRightAddr() *uint32 { + return (*uint32)(&smp.bound_right) +} + +// Custom: GetBoundBottom gets `AVSphericalMapping.bound_bottom` value. +func (smp *AVSphericalMapping) GetBoundBottom() uint32 { + return (uint32)(smp.bound_bottom) +} + +// Custom: SetBoundBottom sets `AVSphericalMapping.bound_bottom` value. +func (smp *AVSphericalMapping) SetBoundBottom(v uint32) { + smp.bound_bottom = (C.uint32_t)(v) +} + +// Custom: GetBoundBottomAddr gets `AVSphericalMapping.bound_bottom` address. +func (smp *AVSphericalMapping) GetBoundBottomAddr() *uint32 { + return (*uint32)(&smp.bound_bottom) +} + +// Custom: GetPadding gets `AVSphericalMapping.padding` value. +func (smp *AVSphericalMapping) GetPadding() uint32 { + return (uint32)(smp.padding) +} + +// Custom: SetPadding sets `AVSphericalMapping.padding` value. +func (smp *AVSphericalMapping) SetPadding(v uint32) { + smp.padding = (C.uint32_t)(v) +} + +// Custom: GetPaddingAddr gets `AVSphericalMapping.padding` address. +func (smp *AVSphericalMapping) GetPaddingAddr() *uint32 { + return (*uint32)(&smp.padding) +} + +// AvSphericalAlloc allocate a AVSphericalVideo structure and initialize its fields to default +// values. +func AvSphericalAlloc(size *uintptr) *AVSphericalMapping { + return (*AVSphericalMapping)(C.av_spherical_alloc((*C.size_t)(unsafe.Pointer(size)))) +} + +// AvSphericalTileBounds converts the bounding fields from an AVSphericalVideo +// from 0.32 fixed point to pixels. +func AvSphericalTileBounds(_map *AVSphericalMapping, + width, height uintptr, + left, top, right, bottom *uintptr) { + C.av_spherical_tile_bounds((*C.struct_AVSphericalMapping)(_map), + (C.size_t)(width), (C.size_t)(height), + (*C.size_t)(unsafe.Pointer(left)), (*C.size_t)(unsafe.Pointer(top)), + (*C.size_t)(unsafe.Pointer(right)), (*C.size_t)(unsafe.Pointer(bottom))) +} + +// AvSphericalProjectionName provides a human-readable name of a given AVSphericalProjection. +func AvSphericalProjectionName(projection AVSphericalProjection) string { + return C.GoString(C.av_spherical_projection_name((C.enum_AVSphericalProjection)(projection))) +} + +// AvSphericalFromName gets the AVSphericalProjection form a human-readable name. +func AvSphericalFromName(name string) int32 { + namePtr, nameFunc := StringCasting(name) + defer nameFunc() + return (int32)(C.av_spherical_from_name((*C.char)(namePtr))) +} diff --git a/avutil_stereo3d.go b/avutil_stereo3d.go new file mode 100644 index 0000000..004f6d3 --- /dev/null +++ b/avutil_stereo3d.go @@ -0,0 +1,102 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVStereo3DType +type AVStereo3DType = C.enum_AVStereo3DType + +const ( + AV_STEREO3D_2D = AVStereo3DType(C.AV_STEREO3D_2D) + AV_STEREO3D_SIDEBYSIDE = AVStereo3DType(C.AV_STEREO3D_SIDEBYSIDE) + AV_STEREO3D_TOPBOTTOM = AVStereo3DType(C.AV_STEREO3D_TOPBOTTOM) + AV_STEREO3D_FRAMESEQUENCE = AVStereo3DType(C.AV_STEREO3D_FRAMESEQUENCE) + AV_STEREO3D_CHECKERBOARD = AVStereo3DType(C.AV_STEREO3D_CHECKERBOARD) + AV_STEREO3D_SIDEBYSIDE_QUINCUNX = AVStereo3DType(C.AV_STEREO3D_SIDEBYSIDE_QUINCUNX) + AV_STEREO3D_LINES = AVStereo3DType(C.AV_STEREO3D_LINES) + AV_STEREO3D_COLUMNS = AVStereo3DType(C.AV_STEREO3D_COLUMNS) +) + +// AVStereo3DView +type AVStereo3DView = C.enum_AVStereo3DView + +const ( + AV_STEREO3D_VIEW_PACKED = AVStereo3DView(C.AV_STEREO3D_VIEW_PACKED) + AV_STEREO3D_VIEW_LEFT = AVStereo3DView(C.AV_STEREO3D_VIEW_LEFT) + AV_STEREO3D_VIEW_RIGHT = AVStereo3DView(C.AV_STEREO3D_VIEW_RIGHT) +) + +const ( + AV_STEREO3D_FLAG_INVERT = C.AV_STEREO3D_FLAG_INVERT +) + +type AVStereo3D C.struct_AVStereo3D + +// Custom: GetType gets `AVStereo3D.type` value. +func (s3d *AVStereo3D) GetType() AVStereo3DType { + return (AVStereo3DType)(s3d._type) +} + +// Custom: SetType sets `AVStereo3D.type` value. +func (s3d *AVStereo3D) SetType(v AVStereo3DType) { + s3d._type = (C.enum_AVStereo3DType)(v) +} + +// Custom: GetTypeAddr gets `AVStereo3D.type` address. +func (s3d *AVStereo3D) GetTypeAddr() *AVStereo3DType { + return (*AVStereo3DType)(&s3d._type) +} + +// Custom: GetFlags gets `AVStereo3D.flags` value. +func (s3d *AVStereo3D) GetFlags() int32 { + return (int32)(s3d.flags) +} + +// Custom: SetFlags sets `AVStereo3D.flags` value. +func (s3d *AVStereo3D) SetFlags(v int32) { + s3d.flags = (C.int32_t)(v) +} + +// Custom: GetFlagsAddr gets `AVStereo3D.flags` address. +func (s3d *AVStereo3D) GetFlagsAddr() *int32 { + return (*int32)(&s3d.flags) +} + +// Custom: GetView gets `AVStereo3D.view` value. +func (s3d *AVStereo3D) GetView() AVStereo3DView { + return (AVStereo3DView)(s3d.view) +} + +// Custom: SetView sets `AVStereo3D.view` value. +func (s3d *AVStereo3D) SetView(v AVStereo3DView) { + s3d.view = (C.enum_AVStereo3DView)(v) +} + +// Custom: GetViewAddr gets `AVStereo3D.view` address. +func (s3d *AVStereo3D) GetViewAddr() *AVStereo3DView { + return (*AVStereo3DView)(&s3d.view) +} + +// AvStereo3dAlloc allocates an AVStereo3D structure and set its fields to default values. +func AvStereo3dAlloc() *AVStereo3D { + return (*AVStereo3D)(C.av_stereo3d_alloc()) +} + +// AvStereo3dCreateSideData allocates a complete AVFrameSideData and add it to the frame. +func AvStereo3dCreateSideData(frame *AVFrame) *AVStereo3D { + return (*AVStereo3D)(C.av_stereo3d_create_side_data((*C.struct_AVFrame)(frame))) +} + +// AvStereo3dTypeName provides a human-readable name of a given stereo3d type. +func AvStereo3dTypeName(_type uint32) string { + return C.GoString(C.av_stereo3d_type_name((C.uint)(_type))) +} + +// AvStereo3dFromName gets the AVStereo3DType form a human-readable name. +func AvStereo3dFromName(name string) int32 { + namePtr, nameFunc := StringCasting(name) + defer nameFunc() + return (int32)(C.av_stereo3d_from_name((*C.char)(namePtr))) +} diff --git a/avutil_threadmessage.go b/avutil_threadmessage.go new file mode 100644 index 0000000..c7871d6 --- /dev/null +++ b/avutil_threadmessage.go @@ -0,0 +1,71 @@ +package ffmpeg + +/* +#include + +typedef void (*av_thread_message_free_func)(void *msg); +*/ +import "C" +import "unsafe" + +type AVThreadMessageQueue C.struct_AVThreadMessageQueue + +// AVThreadMessageFlags +type AVThreadMessageFlags = C.enum_AVThreadMessageFlags + +const ( + AV_THREAD_MESSAGE_NONBLOCK = AVThreadMessageFlags(C.AV_THREAD_MESSAGE_NONBLOCK) +) + +// AvThreadMessageQueueAlloc allocates a new message queue. +func AvThreadMessageQueueAlloc[T HelperInteger](mq **AVThreadMessageQueue, nelem, elsize T) int32 { + return (int32)(C.av_thread_message_queue_alloc( + (**C.struct_AVThreadMessageQueue)(unsafe.Pointer(mq)), (C.uint)(nelem), (C.uint)(elsize))) +} + +// AvThreadMessageQueueFree frees a message queue. +func AvThreadMessageQueueFree(mq **AVThreadMessageQueue) { + C.av_thread_message_queue_free((**C.struct_AVThreadMessageQueue)(unsafe.Pointer(mq))) +} + +// AvThreadMessageQueueSend sends a message on the queue. +func AvThreadMessageQueueSend(mq *AVThreadMessageQueue, msg CVoidPointer, flags uint32) int32 { + return (int32)(C.av_thread_message_queue_send((*C.struct_AVThreadMessageQueue)(mq), + VoidPointer(msg), (C.uint)(flags))) +} + +// AvThreadMessageQueueRecv receives a message from the queue. +func AvThreadMessageQueueRecv(mq *AVThreadMessageQueue, msg CVoidPointer, flags uint32) int32 { + return (int32)(C.av_thread_message_queue_recv((*C.struct_AVThreadMessageQueue)(mq), + VoidPointer(msg), (C.uint)(flags))) +} + +// AvThreadMessageQueueSetErrSend sets the sending error code. +func AvThreadMessageQueueSetErrSend(mq *AVThreadMessageQueue, err int32) { + C.av_thread_message_queue_set_err_send((*C.struct_AVThreadMessageQueue)(mq), (C.int)(err)) +} + +// AvThreadMessageQueueSetErrRecv set the receiving error code. +func AvThreadMessageQueueSetErrRecv(mq *AVThreadMessageQueue, err int32) { + C.av_thread_message_queue_set_err_recv((*C.struct_AVThreadMessageQueue)(mq), (C.int)(err)) +} + +// typedef void (*av_thread_message_free_func)(void *msg); +type AvThreadMessageFreeFunc = C.av_thread_message_free_func + +// AvThreadMessageQueueSetFreeFunc sets the optional free message callback function which will be called if an +// operation is removing messages from the queue. +func AvThreadMessageQueueSetFreeFunc(mq *AVThreadMessageQueue, freeFunc AvThreadMessageFreeFunc) { + C.av_thread_message_queue_set_free_func((*C.struct_AVThreadMessageQueue)(mq), + (C.av_thread_message_free_func)(freeFunc)) +} + +// AvThreadMessageQueueNbElems returns the current number of messages in the queue. +func AvThreadMessageQueueNbElems(mq *AVThreadMessageQueue) int32 { + return (int32)(C.av_thread_message_queue_nb_elems((*C.struct_AVThreadMessageQueue)(mq))) +} + +// AvThreadMessageFlush flushes the message queue. +func AvThreadMessageFlush(mq *AVThreadMessageQueue) { + C.av_thread_message_flush((*C.struct_AVThreadMessageQueue)(mq)) +} diff --git a/avutil_time.go b/avutil_time.go new file mode 100644 index 0000000..77b4959 --- /dev/null +++ b/avutil_time.go @@ -0,0 +1,27 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AvGettime gets the current time in microseconds. +func AvGettime() int64 { + return (int64)(C.av_gettime()) +} + +// AvGettimeRelative gets the current time in microseconds since some unspecified starting point. +func AvGettimeRelative() int64 { + return (int64)(C.av_gettime_relative()) +} + +// AvGettimeRelativeIsMonotonic indicates with a boolean result if the AvGettimeRelative() time source +// is monotonic. +func AvGettimeRelativeIsMonotonic() int32 { + return (int32)(C.av_gettime_relative_is_monotonic()) +} + +// AvUsleep sleeps for a period of time. +func AvUsleep(usec uint32) int32 { + return (int32)(C.av_usleep((C.uint)(usec))) +} diff --git a/avutil_timecode.go b/avutil_timecode.go new file mode 100644 index 0000000..c7975f5 --- /dev/null +++ b/avutil_timecode.go @@ -0,0 +1,153 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +const ( + AV_TIMECODE_STR_SIZE = C.AV_TIMECODE_STR_SIZE +) + +type AVTimecodeFlag = C.enum_AVTimecodeFlag + +const ( + AV_TIMECODE_FLAG_DROPFRAME = AVTimecodeFlag(C.AV_TIMECODE_FLAG_DROPFRAME) + AV_TIMECODE_FLAG_24HOURSMAX = AVTimecodeFlag(C.AV_TIMECODE_FLAG_24HOURSMAX) + AV_TIMECODE_FLAG_ALLOWNEGATIVE = AVTimecodeFlag(C.AV_TIMECODE_FLAG_ALLOWNEGATIVE) +) + +type AVTimecode C.AVTimecode + +// Custom: GetStart gets `AVTimecode.start` value. +func (tc *AVTimecode) GetStart() int32 { + return (int32)(tc.start) +} + +// Custom: SetStart sets `AVTimecode.start` value. +func (tc *AVTimecode) SetStart(v int32) { + tc.start = (C.int)(v) +} + +// Custom: GetStartAddr gets `AVTimecode.start` address. +func (tc *AVTimecode) GetStartAddr() *int32 { + return (*int32)(&tc.start) +} + +// Custom: GetFlags gets `AVTimecode.flags` value. +func (tc *AVTimecode) GetFlags() uint32 { + return (uint32)(tc.flags) +} + +// Custom: SetFlags sets `AVTimecode.flags` value. +func (tc *AVTimecode) SetFlags(v uint32) { + tc.flags = (C.uint32_t)(v) +} + +// Custom: GetFlagsAddr gets `AVTimecode.flags` address. +func (tc *AVTimecode) GetFlagsAddr() *uint32 { + return (*uint32)(&tc.flags) +} + +// Custom: GetRate gets `AVTimecode.rate` value. +func (tc *AVTimecode) GetRate() AVRational { + return (AVRational)(tc.rate) +} + +// Custom: SetRate sets `AVTimecode.rate` value. +func (tc *AVTimecode) SetRate(v AVRational) { + tc.rate = (C.struct_AVRational)(v) +} + +// Custom: GetRateAddr gets `AVTimecode.rate` address. +func (tc *AVTimecode) GetRateAddr() *AVRational { + return (*AVRational)(&tc.rate) +} + +// Custom: GetFps gets `AVTimecode.fps` value. +func (tc *AVTimecode) GetFps() uint32 { + return (uint32)(tc.fps) +} + +// Custom: SetFps sets `AVTimecode.fps` value. +func (tc *AVTimecode) SetFps(v uint32) { + tc.fps = (C.uint)(v) +} + +// Custom: GetFpsAddr gets `AVTimecode.fps` address. +func (tc *AVTimecode) GetFpsAddr() *uint32 { + return (*uint32)(&tc.fps) +} + +// AvTimecodeAdjustNtscFramenum2 adjusts frame number for NTSC drop frame time code. +func AvTimecodeAdjustNtscFramenum2(framenum, fps int32) int32 { + return (int32)(C.av_timecode_adjust_ntsc_framenum2((C.int)(framenum), (C.int)(fps))) +} + +// AvTimecodeGetSmpteFromFramenum converts frame number to SMPTE 12M binary representation. +func AvTimecodeGetSmpteFromFramenum(tc *AVTimecode, framenum int32) uint32 { + return (uint32)(C.av_timecode_get_smpte_from_framenum((*C.AVTimecode)(tc), (C.int)(framenum))) +} + +// AvTimecodeGetSmpte converts sei info to SMPTE 12M binary representation. +func AvTimecodeGetSmpte(rate AVRational, drop, hh, mm, ss, ff int32) int32 { + return (int32)(C.av_timecode_get_smpte((C.struct_AVRational)(rate), + (C.int)(drop), (C.int)(hh), (C.int)(mm), (C.int)(ss), (C.int)(ff))) +} + +// AvTimecodeMakeString loads timecode string in buf. +func AvTimecodeMakeString(tc *AVTimecode, framenum int32) (buf, bufPar string) { + b := make([]C.char, AV_TIMECODE_STR_SIZE+1) + ret := C.av_timecode_make_string((*C.AVTimecode)(tc), (*C.char)(&b[0]), (C.int)(framenum)) + return C.GoString(&b[0]), C.GoString(ret) +} + +// AvTimecodeMakeSmpteTcString2 gets the timecode string from the SMPTE timecode format. +func AvTimecodeMakeSmpteTcString2(rate AVRational, tcsmpte uint32, preventDf, skipField int32) (buf, bufPar string) { + b := make([]C.char, AV_TIMECODE_STR_SIZE+1) + ret := C.av_timecode_make_smpte_tc_string2((*C.char)(&b[0]), + (C.AVRational)(rate), (C.uint32_t)(tcsmpte), (C.int)(preventDf), (C.int)(skipField)) + return C.GoString(&b[0]), C.GoString(ret) +} + +// AvTimecodeMakeSmpteTcString gets the timecode string from the SMPTE timecode format. +func AvTimecodeMakeSmpteTcString(tcsmpte uint32, preventDf int32) (buf, bufPar string) { + b := make([]C.char, AV_TIMECODE_STR_SIZE+1) + ret := C.av_timecode_make_smpte_tc_string((*C.char)(&b[0]), (C.uint32_t)(tcsmpte), (C.int)(preventDf)) + return C.GoString(&b[0]), C.GoString(ret) +} + +// AvTimecodeMakeMpegTcString gets the timecode string from the 25-bit timecode format (MPEG GOP format). +func AvTimecodeMakeMpegTcString(tc25bit uint32) (buf, bufPar string) { + b := make([]C.char, AV_TIMECODE_STR_SIZE+1) + ret := C.av_timecode_make_mpeg_tc_string((*C.char)(&b[0]), (C.uint32_t)(tc25bit)) + return C.GoString(&b[0]), C.GoString(ret) +} + +// AvTimecodeInit initializes a timecode struct with the passed parameters. +func AvTimecodeInit(tc *AVTimecode, rate AVRational, flags, frameStart int32, logCtx CVoidPointer) int32 { + return (int32)(C.av_timecode_init((*C.AVTimecode)(tc), (C.struct_AVRational)(rate), + (C.int)(flags), (C.int)(frameStart), VoidPointer(logCtx))) +} + +// AvTimecodeInitFromComponents initializes a timecode struct from the passed timecode components. +func AvTimecodeInitFromComponents(tc *AVTimecode, rate AVRational, + flags, hh, mm, ss, ff int32, logCtx CVoidPointer) int32 { + return (int32)(C.av_timecode_init_from_components((*C.AVTimecode)(tc), + (C.struct_AVRational)(rate), (C.int)(flags), + (C.int)(hh), (C.int)(mm), (C.int)(ss), (C.int)(ff), + VoidPointer(logCtx))) +} + +// AvTimecodeInitFromString parses timecode representation (hh:mm:ss[:;.]ff). +func AvTimecodeInitFromString(tc *AVTimecode, rate AVRational, str string, logCtx CVoidPointer) int32 { + strPtr, strFunc := StringCasting(str) + defer strFunc() + return (int32)(C.av_timecode_init_from_string((*C.AVTimecode)(tc), (C.struct_AVRational)(rate), + (*C.char)(strPtr), VoidPointer(logCtx))) +} + +// AvTimecodeCheckFrameRate checks if the timecode feature is available for the given frame rate +func AvTimecodeCheckFrameRate(rate AVRational) int32 { + return (int32)(C.av_timecode_check_frame_rate((C.struct_AVRational)(rate))) +} diff --git a/avutil_timestamp.go b/avutil_timestamp.go new file mode 100644 index 0000000..8e3182f --- /dev/null +++ b/avutil_timestamp.go @@ -0,0 +1,33 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +const ( + AV_TS_MAX_STRING_SIZE = C.AV_TS_MAX_STRING_SIZE +) + +// AvTsMakeString makes a timestamp string. +func AvTsMakeString(ts int64) string { + b := make([]C.char, AV_TS_MAX_STRING_SIZE+1) + return C.GoString(C.av_ts_make_string((*C.char)(&b[0]), (C.int64_t)(ts))) +} + +// AvTs2str +func AvTs2str[T HelperInteger](ts T) string { + return AvTsMakeString(int64(ts)) +} + +// AvTsMakeTimeString makes a timestamp string. +func AvTsMakeTimeString(ts int64, tb *AVRational) string { + b := make([]C.char, AV_TS_MAX_STRING_SIZE+1) + return C.GoString(C.av_ts_make_time_string((*C.char)(&b[0]), + (C.int64_t)(ts), (*C.struct_AVRational)(tb))) +} + +// AvTs2timestr +func AvTs2timestr[T HelperInteger](ts T, tb *AVRational) string { + return AvTsMakeTimeString((int64)(ts), tb) +} diff --git a/avutil_tree.go b/avutil_tree.go new file mode 100644 index 0000000..9ad8735 --- /dev/null +++ b/avutil_tree.go @@ -0,0 +1,56 @@ +package ffmpeg + +/* +#include + +typedef int (*av_tree_cmp_func)(void *opaque, void *elem); +typedef int (*av_tree_enu_func)(void *opaque, void *elem); + +*/ +import "C" +import "unsafe" + +type AVTreeNode C.struct_AVTreeNode + +// typedef int (*av_tree_cmp_func)(void *opaque, void *elem); +type AvTreeCmpFunc = C.av_tree_cmp_func + +// typedef int (*av_tree_enu_func)(void *opaque, void *elem); +type AvTreeEnuFunc = C.av_tree_enu_func + +// AvTreeNodeAlloc allocates an AVTreeNode. +func AvTreeNodeAlloc() *AVTreeNode { + return (*AVTreeNode)(C.av_tree_node_alloc()) +} + +// AvTreeFind finds an element. +func AvTreeFind(root *AVTreeNode, key CVoidPointer, + cmp AvTreeCmpFunc, next []unsafe.Pointer) unsafe.Pointer { + if next != nil && len(next) < 2 { + panic("next len < 2") + } + return (unsafe.Pointer)(C.av_tree_find((*C.struct_AVTreeNode)(root), + VoidPointer(key), (C.av_tree_cmp_func)(cmp), + (*unsafe.Pointer)(unsafe.Pointer(&next[0])))) +} + +// AvTreeInsert inserts or removes an element. +func AvTreeInsert(rootp **AVTreeNode, key CVoidPointer, + cmp AvTreeCmpFunc, next **AVTreeNode) unsafe.Pointer { + return (unsafe.Pointer)(C.av_tree_insert( + (**C.struct_AVTreeNode)(unsafe.Pointer(rootp)), + VoidPointer(key), (C.av_tree_cmp_func)(cmp), + (**C.struct_AVTreeNode)(unsafe.Pointer(next)))) +} + +// AvTreeDestroy +func AvTreeDestroy(t *AVTreeNode) { + C.av_tree_destroy((*C.struct_AVTreeNode)(t)) +} + +// AvTreeEnumerate applies enu(opaque, &elem) to all the elements in the tree in a given range. +func AvTreeEnumerate(t *AVTreeNode, opaque CVoidPointer, + cmp AvTreeCmpFunc, enu AvTreeEnuFunc) { + C.av_tree_enumerate((*C.struct_AVTreeNode)(t), VoidPointer(opaque), + (C.av_tree_cmp_func)(cmp), (C.av_tree_enu_func)(enu)) +} diff --git a/avutil_twofish.go b/avutil_twofish.go new file mode 100644 index 0000000..e998dc7 --- /dev/null +++ b/avutil_twofish.go @@ -0,0 +1,27 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVTWOFISH +type AVTWOFISH C.struct_AVTWOFISH + +// AvTwofishAlloc allocates an AVTWOFISH context. +func AvTwofishAlloc() *AVTWOFISH { + return (*AVTWOFISH)(C.av_twofish_alloc()) +} + +// AvTwofishInit initializes an AVTWOFISH context. +func AvTwofishInit(d *AVTWOFISH, key *uint8, keyBits int32) int32 { + return (int32)(C.av_twofish_init((*C.struct_AVTWOFISH)(d), + (*C.uint8_t)(key), (C.int)(keyBits))) +} + +// AvTwofishCrypt encrypts or decrypts a buffer using a previously initialized context +func AvTwofishCrypt(d *AVTWOFISH, dst, src *uint8, count int32, iv *uint8, decrypt int32) { + C.av_twofish_crypt((*C.struct_AVTWOFISH)(d), + (*C.uint8_t)(dst), (*C.uint8_t)(src), + (C.int)(count), (*C.uint8_t)(iv), (C.int)(decrypt)) +} diff --git a/avutil_tx.go b/avutil_tx.go new file mode 100644 index 0000000..4ce0f4d --- /dev/null +++ b/avutil_tx.go @@ -0,0 +1,166 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +// AVTXContext +type AVTXContext C.struct_AVTXContext + +// AVComplexFloat +type AVComplexFloat C.struct_AVComplexFloat + +// Custom: Make new AVComplexFloat. +func AvMakeComxFloat(re, im float32) AVComplexFloat { + return (AVComplexFloat)(C.struct_AVComplexFloat{ + re: (C.float)(re), + im: (C.float)(im)}) +} + +// Custom: GetRe gets `AVComplexFloat.re` value. +func (cf *AVComplexFloat) GetRe() float32 { + return (float32)(cf.re) +} + +// Custom: SetRe sets `AVComplexFloat.re` value. +func (cf *AVComplexFloat) SetRe(v float32) { + cf.re = (C.float)(v) +} + +// Custom: GetReAddr gets `AVComplexFloat.re` address. +func (cf *AVComplexFloat) GetReAddr() *float32 { + return (*float32)(&cf.re) +} + +// Custom: GetIm gets `AVComplexFloat.im` value. +func (cf *AVComplexFloat) GetIm() float32 { + return (float32)(cf.im) +} + +// Custom: SetIm sets `AVComplexFloat.im` value. +func (cf *AVComplexFloat) SetIm(v float32) { + cf.im = (C.float)(v) +} + +// Custom: GetImAddr gets `AVComplexFloat.im` address. +func (cf *AVComplexFloat) GetImAddr() *float32 { + return (*float32)(&cf.im) +} + +// AVComplexDouble +type AVComplexDouble C.struct_AVComplexDouble + +// Custom: Make new AVComplexDouble. +func AvMakeComxDouble(re, im float64) AVComplexDouble { + return (AVComplexDouble)(C.struct_AVComplexDouble{ + re: (C.double)(re), + im: (C.double)(im)}) +} + +// Custom: GetRe gets `AVComplexDouble.re` value. +func (cd *AVComplexDouble) GetRe() float64 { + return (float64)(cd.re) +} + +// Custom: SetRe sets `AVComplexDouble.re` value. +func (cd *AVComplexDouble) SetRe(v float64) { + cd.re = (C.double)(v) +} + +// Custom: GetReAddr gets `AVComplexDouble.re` address. +func (cd *AVComplexDouble) GetReAddr() *float64 { + return (*float64)(&cd.re) +} + +// Custom: GetIm gets `AVComplexDouble.im` value. +func (cd *AVComplexDouble) GetIm() float64 { + return (float64)(cd.im) +} + +// Custom: SetIm sets `AVComplexDouble.im` value. +func (cd *AVComplexDouble) SetIm(v float64) { + cd.im = (C.double)(v) +} + +// Custom: GetImAddr gets `AVComplexDouble.im` address. +func (cd *AVComplexDouble) GetImAddr() *float64 { + return (*float64)(&cd.im) +} + +// AVComplexInt32 +type AVComplexInt32 C.struct_AVComplexInt32 + +// Custom: Make new AVComplexFloat. +func AvMakeComxInt32(re, im int32) AVComplexInt32 { + return (AVComplexInt32)(C.struct_AVComplexInt32{ + re: (C.int32_t)(re), + im: (C.int32_t)(im)}) +} + +// Custom: GetRe gets `AVComplexInt32.re` value. +func (ci *AVComplexInt32) GetRe() int32 { + return (int32)(ci.re) +} + +// Custom: SetRe sets `AVComplexInt32.re` value. +func (ci *AVComplexInt32) SetRe(v int32) { + ci.re = (C.int32_t)(v) +} + +// Custom: GetReAddr gets `AVComplexInt32.re` address. +func (ci *AVComplexInt32) GetReAddr() *int32 { + return (*int32)(&ci.re) +} + +// Custom: GetIm gets `AVComplexInt32.im` value. +func (ci *AVComplexInt32) GetIm() int32 { + return (int32)(ci.im) +} + +// Custom: SetIm sets `AVComplexInt32.im` value. +func (ci *AVComplexInt32) SetIm(v int32) { + ci.im = (C.int32_t)(v) +} + +// Custom: GetImAddr gets `AVComplexInt32.im` address. +func (ci *AVComplexInt32) GetImAddr() *int32 { + return (*int32)(&ci.im) +} + +// AVTXType +type AVTXType = C.enum_AVTXType + +const ( + AV_TX_FLOAT_FFT = AVTXType(C.AV_TX_FLOAT_FFT) + AV_TX_FLOAT_MDCT = AVTXType(C.AV_TX_FLOAT_MDCT) + AV_TX_DOUBLE_FFT = AVTXType(C.AV_TX_DOUBLE_FFT) + AV_TX_DOUBLE_MDCT = AVTXType(C.AV_TX_DOUBLE_MDCT) + AV_TX_INT32_FFT = AVTXType(C.AV_TX_INT32_FFT) + AV_TX_INT32_MDCT = AVTXType(C.AV_TX_INT32_MDCT) +) + +// typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride); +type AvTxFn = C.av_tx_fn + +// AVTXFlags +type AVTXFlags = C.enum_AVTXFlags + +const ( + AV_TX_INPLACE = AVTXFlags(C.AV_TX_INPLACE) +) + +// AvTxInit initializes a transform context with the given configuration +// (i)MDCTs with an odd length are currently not supported. +func AvTxInit(ctx **AVTXContext, tx *AvTxFn, _type AVTXType, + inv, len int32, scale CVoidPointer, flags uint64) int32 { + return (int32)(C.av_tx_init((**C.struct_AVTXContext)(unsafe.Pointer(ctx)), + (*C.av_tx_fn)(tx), (C.enum_AVTXType)(_type), + (C.int)(inv), (C.int)(len), VoidPointer(scale), (C.uint64_t)(flags))) +} + +// AvTxUninit frees a context and sets ctx to NULL, does nothing when ctx == NULL +func AvTxUninit(ctx **AVTXContext) { + C.av_tx_uninit((**C.struct_AVTXContext)(unsafe.Pointer(ctx))) +}