From 4329c27b552ed088fdd17ff0028083d64b49bf40 Mon Sep 17 00:00:00 2001 From: aggresss Date: Tue, 24 Oct 2023 21:24:55 +0800 Subject: [PATCH] 2023-10-24 21:24:55 CST W43D2 --- avcodec.go | 78 ++-- avcodec_bsf.go | 2 +- avcodec_codec.go | 18 +- avcodec_codec_desc.go | 4 +- avcodec_codec_par.go | 12 +- avcodec_dirac.go | 6 +- avfilter.go | 12 +- avfilter_buffersink.go | 10 +- avformat.go | 6 +- avformat_avio.go | 6 +- avutil_blowfish.go | 30 +- avutil_common.go | 226 +++++++++- avutil_crc.go | 41 ++ avutil_des.go | 69 +++ avutil_display.go | 25 ++ avutil_dovi_meta.go | 139 ++++++ avutil_downmix_info.go | 115 +++++ avutil_encryption_info.go | 358 +++++++++++++++ avutil_eval.go | 23 + avutil_fifo.go | 110 +++++ avutil_film_grain_params.go | 369 ++++++++++++++++ avutil_frame.go | 26 +- avutil_hash.go | 73 ++++ avutil_hdr_dynamic_metadata.go | 629 +++++++++++++++++++++++++++ avutil_hmac.go | 54 +++ avutil_hwcontext.go | 4 +- avutil_intfloat.go | 26 ++ avutil_intreadwrite.go | 165 +++++++ avutil_lfg.go | 38 ++ avutil_lzo.go | 21 + avutil_macros.go | 10 + avutil_mastering_display_metadata.go | 168 +++++++ avutil_mem.go | 2 +- avutil_opt.go | 78 +++- avutil_random_seed.go | 11 + avutil_rc4.go | 26 ++ avutil_replaygain.go | 69 +++ avutil_ripemd.go | 28 ++ avutil_video_enc_params.go | 216 +++++++++ avutil_xtea.go | 61 +++ examples/decode-audio/main.go | 3 +- examples/decode-video/main.go | 4 +- examples/encode-audio/main.go | 3 +- examples/extract-mvs/main.go | 156 ++++++- examples/filter-audio/main.go | 14 +- examples/http-multiclient/main.go | 135 +++++- ffmpeg_helper.go | 63 +-- 47 files changed, 3577 insertions(+), 165 deletions(-) create mode 100644 avutil_crc.go create mode 100644 avutil_des.go create mode 100644 avutil_display.go create mode 100644 avutil_dovi_meta.go create mode 100644 avutil_downmix_info.go create mode 100644 avutil_encryption_info.go create mode 100644 avutil_eval.go create mode 100644 avutil_fifo.go create mode 100644 avutil_film_grain_params.go create mode 100644 avutil_hash.go create mode 100644 avutil_hdr_dynamic_metadata.go create mode 100644 avutil_hmac.go create mode 100644 avutil_intfloat.go create mode 100644 avutil_intreadwrite.go create mode 100644 avutil_lfg.go create mode 100644 avutil_lzo.go create mode 100644 avutil_macros.go create mode 100644 avutil_mastering_display_metadata.go create mode 100644 avutil_random_seed.go create mode 100644 avutil_rc4.go create mode 100644 avutil_replaygain.go create mode 100644 avutil_ripemd.go create mode 100644 avutil_video_enc_params.go create mode 100644 avutil_xtea.go diff --git a/avcodec.go b/avcodec.go index 83bfbcb..c311cf3 100644 --- a/avcodec.go +++ b/avcodec.go @@ -157,14 +157,19 @@ func (psn *AVPanScan) GetHeightAddr() *int32 { } // Custom: GetPosition gets `AVPanScan.position` value. -func (psn *AVPanScan) GetPosition() []int16 { - return unsafe.Slice((*int16)(&psn.position[0][0]), 3*2) +func (psn *AVPanScan) GetPosition() (v [][]int16) { + for i := 0; i < 3; i++ { + v = append(v, unsafe.Slice((*int16)(&psn.position[i][0]), 2)) + } + return v } // Custom: SetPosition sets `AVPanScan.position` value. -func (psn *AVPanScan) SetPosition(v []int16) { - for i := 0; i < FFMIN(len(v), 3*2); i++ { - psn.position[i/2][i%2] = (C.int16_t)(v[i]) +func (psn *AVPanScan) SetPosition(v [][]int16) { + for i := 0; i < FFMIN(len(v), 3); i++ { + for j := 0; j < FFMIN(len(v[i]), 2); j++ { + psn.position[i][j] = (C.int16_t)(v[i][j]) + } } } @@ -173,21 +178,6 @@ func (psn *AVPanScan) GetPositionAddr() **int16 { return (**int16)(unsafe.Pointer(&psn.position)) } -// Custom: GetPositionIdx gets `AVPanScan.position` index value. -func (psn *AVPanScan) GetPositionIdx(x, y int) int16 { - return (int16)(psn.position[x][y]) -} - -// Custom: SetPositionIdx sets `AVPanScan.position` index value. -func (psn *AVPanScan) SetPositionIdx(x, y int, v int16) { - psn.position[x][y] = (C.int16_t)(v) -} - -// Custom: GetPositionIdxAddr gets `AVPanScan.position` index address. -func (psn *AVPanScan) GetPositionIdxAddr(x, y int) *int16 { - return (*int16)(&psn.position[x][y]) -} - // This structure describes the bitrate properties of an encoded bitstream. It // roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD // parameters for H.264/HEVC. @@ -341,17 +331,17 @@ func (avctx *AVCodecContext) GetLogLevelOffsetAddr() *int32 { return (*int32)(&avctx.log_level_offset) } -// Custom: GetCodecType gets `AVCodecContext.codec_type` value. +// Custom: GetCodecType gets `AVCodecContext.codectype` value. func (avctx *AVCodecContext) GetCodecType() AVMediaType { return (AVMediaType)(avctx.codec_type) } -// Custom: SetCodecType sets `AVCodecContext.codec_type` value. +// Custom: SetCodecType sets `AVCodecContext.codectype` value. func (avctx *AVCodecContext) SetCodecType(v AVMediaType) { avctx.codec_type = (C.enum_AVMediaType)(v) } -// Custom: GetCodecTypeAddr gets `AVCodecContext.codec_type` address. +// Custom: GetCodecTypeAddr gets `AVCodecContext.codectype` address. func (avctx *AVCodecContext) GetCodecTypeAddr() *AVMediaType { return (*AVMediaType)(&avctx.codec_type) } @@ -1463,17 +1453,17 @@ func (avctx *AVCodecContext) GetColorspaceAddr() *AVColorSpace { return (*AVColorSpace)(unsafe.Pointer(&avctx.colorspace)) } -// Custom: GetColorRange gets `AVCodecContext.color_range` value. +// Custom: GetColorRange gets `AVCodecContext.colorrange` value. func (avctx *AVCodecContext) GetColorRange() AVColorRange { return (AVColorRange)(avctx.color_range) } -// Custom: SetColorRange sets `AVCodecContext.color_range` value. +// Custom: SetColorRange sets `AVCodecContext.colorrange` value. func (avctx *AVCodecContext) SetColorRange(v AVColorRange) { avctx.color_range = (C.enum_AVColorRange)(v) } -// Custom: GetColorRangeAddr gets `AVCodecContext.color_range` address. +// Custom: GetColorRangeAddr gets `AVCodecContext.colorrange` address. func (avctx *AVCodecContext) GetColorRangeAddr() *AVColorRange { return (*AVColorRange)(unsafe.Pointer(&avctx.color_range)) } @@ -1658,17 +1648,17 @@ func (avctx *AVCodecContext) GetRequestChannelLayoutAddr() *uint64 { return (*uint64)(&avctx.request_channel_layout) } -// Custom: GetAudioServiceType gets `AVCodecContext.audio_service_type` value. +// Custom: GetAudioServiceType gets `AVCodecContext.audio_servicetype` value. func (avctx *AVCodecContext) GetAudioServiceType() AVAudioServiceType { return (AVAudioServiceType)(avctx.audio_service_type) } -// Custom: SetAudioServiceType sets `AVCodecContext.audio_service_type` value. +// Custom: SetAudioServiceType sets `AVCodecContext.audio_servicetype` value. func (avctx *AVCodecContext) SetAudioServiceType(v AVAudioServiceType) { avctx.audio_service_type = (C.enum_AVAudioServiceType)(v) } -// Custom: GetAudioServiceTypeAddr gets `AVCodecContext.audio_service_type` address. +// Custom: GetAudioServiceTypeAddr gets `AVCodecContext.audio_servicetype` address. func (avctx *AVCodecContext) GetAudioServiceTypeAddr() *AVAudioServiceType { return (*AVAudioServiceType)(unsafe.Pointer(&avctx.audio_service_type)) } @@ -1913,17 +1903,17 @@ const ( FF_CODER_TYPE_RLE = int32(C.FF_CODER_TYPE_RLE) ) -// Custom: GetCoderType gets `AVCodecContext.coder_type` value. +// Custom: GetCoderType gets `AVCodecContext.codertype` value. func (avctx *AVCodecContext) GetCoderType() int32 { return (int32)(avctx.coder_type) } -// Custom: SetCoderType sets `AVCodecContext.coder_type` value. +// Custom: SetCoderType sets `AVCodecContext.codertype` value. func (avctx *AVCodecContext) SetCoderType(v int32) { avctx.coder_type = (C.int)(v) } -// Custom: GetCoderTypeAddr gets `AVCodecContext.coder_type` address. +// Custom: GetCoderTypeAddr gets `AVCodecContext.codertype` address. func (avctx *AVCodecContext) GetCoderTypeAddr() *int32 { return (*int32)(&avctx.coder_type) } @@ -2552,17 +2542,17 @@ func (avctx *AVCodecContext) GetThreadCountAddr() *int32 { return (*int32)(&avctx.thread_count) } -// Custom: GetThreadType gets `AVCodecContext.thread_type` value. +// Custom: GetThreadType gets `AVCodecContext.threadtype` value. func (avctx *AVCodecContext) GetThreadType() int32 { return (int32)(avctx.thread_type) } -// Custom: SetThreadType sets `AVCodecContext.thread_type` value. +// Custom: SetThreadType sets `AVCodecContext.threadtype` value. func (avctx *AVCodecContext) SetThreadType(v int32) { avctx.thread_type = (C.int)(v) } -// Custom: GetThreadTypeAddr gets `AVCodecContext.thread_type` address. +// Custom: GetThreadTypeAddr gets `AVCodecContext.threadtype` address. func (avctx *AVCodecContext) GetThreadTypeAddr() *int32 { return (*int32)(&avctx.thread_type) } @@ -2572,17 +2562,17 @@ const ( FF_THREAD_SLICE = int32(C.FF_THREAD_SLICE) ) -// Custom: GetActiveThreadType gets `AVCodecContext.active_thread_type` value. +// Custom: GetActiveThreadType gets `AVCodecContext.active_threadtype` value. func (avctx *AVCodecContext) GetActiveThreadType() int32 { return (int32)(avctx.active_thread_type) } -// Custom: SetActiveThreadType sets `AVCodecContext.active_thread_type` value. +// Custom: SetActiveThreadType sets `AVCodecContext.active_threadtype` value. func (avctx *AVCodecContext) SetActiveThreadType(v int32) { avctx.active_thread_type = (C.int)(v) } -// Custom: GetActiveThreadTypeAddr gets `AVCodecContext.active_thread_type` address. +// Custom: GetActiveThreadTypeAddr gets `AVCodecContext.active_threadtype` address. func (avctx *AVCodecContext) GetActiveThreadTypeAddr() *int32 { return (*int32)(&avctx.active_thread_type) } @@ -3655,17 +3645,17 @@ func (sbtr *AVSubtitleRect) GetLinesizeAddr() **int32 { return (**int32)(unsafe.Pointer(&sbtr.linesize)) } -// Custom: GetType gets `AVSubtitleRect._type` value. +// Custom: GetType gets `AVSubtitleRect.type` value. func (sbtr *AVSubtitleRect) GetType() AVSubtitleType { return (AVSubtitleType)(sbtr._type) } -// Custom: SetType sets `AVSubtitleRect._type` value. +// Custom: SetType sets `AVSubtitleRect.type` value. func (sbtr *AVSubtitleRect) SetType(v AVSubtitleType) { sbtr._type = (C.enum_AVSubtitleType)(v) } -// Custom: GetTypeAddr gets `AVSubtitleRect._type` address. +// Custom: GetTypeAddr gets `AVSubtitleRect.type` address. func (sbtr *AVSubtitleRect) GetTypeAddr() *AVSubtitleType { return (*AVSubtitleType)(&sbtr._type) } @@ -4070,17 +4060,17 @@ func (cpc *AVCodecParserContext) GetNextFrameOffsetAddr() *int64 { return (*int64)(&cpc.next_frame_offset) } -// Custom: GetPictType gets `AVCodecParserContext.pict_type` value. +// Custom: GetPictType gets `AVCodecParserContext.picttype` value. func (cpc *AVCodecParserContext) GetPictType() int32 { return (int32)(cpc.pict_type) } -// Custom: SetPictType sets `AVCodecParserContext.pict_type` value. +// Custom: SetPictType sets `AVCodecParserContext.picttype` value. func (cpc *AVCodecParserContext) SetPictType(v int32) { cpc.pict_type = (C.int)(v) } -// Custom: GetPictTypeAddr gets `AVCodecParserContext.pict_type` address. +// Custom: GetPictTypeAddr gets `AVCodecParserContext.picttype` address. func (cpc *AVCodecParserContext) GetPictTypeAddr() *int32 { return (*int32)(&cpc.pict_type) } diff --git a/avcodec_bsf.go b/avcodec_bsf.go index ede4054..897fd79 100644 --- a/avcodec_bsf.go +++ b/avcodec_bsf.go @@ -142,7 +142,7 @@ func (bsf *AVBitStreamFilter) GetName() string { // Custom: GetCodecIds gets `AVBitStreamFilter.codec_ids` value. func (bsf *AVBitStreamFilter) GetCodecIds() []AVCodecID { - return TruncSlice((*AVCodecID)(bsf.codec_ids), func(ac AVCodecID) bool { + return SliceTrunc((*AVCodecID)(bsf.codec_ids), func(ac AVCodecID) bool { return ac == AV_CODEC_ID_NONE }) } diff --git a/avcodec_codec.go b/avcodec_codec.go index 72a397a..e2291ab 100644 --- a/avcodec_codec.go +++ b/avcodec_codec.go @@ -72,35 +72,35 @@ func (codec *AVCodec) GetCapabilities() int32 { // Custom: GetSupportedFramerates gets `AVCodec.supportedFramerates` value. func (codec *AVCodec) GetSupportedFramerates() []AVRational { - return TruncSlice((*AVRational)(codec.supported_framerates), func(ar AVRational) bool { + return SliceTrunc((*AVRational)(codec.supported_framerates), func(ar AVRational) bool { return ar.GetNum() == 0 && ar.GetDen() == 0 }) } // Custom: GetPixFmts gets `AVCodec.pix_fmts` value. func (codec *AVCodec) GetPixFmts() []AVPixelFormat { - return TruncSlice((*AVPixelFormat)(codec.pix_fmts), func(pf AVPixelFormat) bool { + return SliceTrunc((*AVPixelFormat)(codec.pix_fmts), func(pf AVPixelFormat) bool { return pf == AV_PIX_FMT_NONE }) } // Custom: GetSupportedSamplerates gets `AVCodec.supported_samplerates` value. func (codec *AVCodec) GetSupportedSamplerates() []int32 { - return TruncSlice((*int32)(codec.supported_samplerates), func(i int32) bool { + return SliceTrunc((*int32)(codec.supported_samplerates), func(i int32) bool { return i == 0 }) } // Custom: GetSampleFmts gets `AVCodec.sample_fmts` value. func (codec *AVCodec) GetSampleFmts() []AVSampleFormat { - return TruncSlice((*AVSampleFormat)(codec.sample_fmts), func(sf AVSampleFormat) bool { + return SliceTrunc((*AVSampleFormat)(codec.sample_fmts), func(sf AVSampleFormat) bool { return sf == AV_SAMPLE_FMT_NONE }) } // Custom: GetChannelLayouts gets `AVCodec.channel_layouts` value. func (codec *AVCodec) GetChannelLayouts() []uint64 { - return TruncSlice((*uint64)(codec.channel_layouts), func(u uint64) bool { + return SliceTrunc((*uint64)(codec.channel_layouts), func(u uint64) bool { return u == 0 }) } @@ -112,7 +112,7 @@ func (codec *AVCodec) GetMaxLowres() uint8 { // Custom: GetProfiles gets `AVCodec.profiles` value. func (codec *AVCodec) GetProfiles() []AVProfile { - return TruncSlice((*AVProfile)(codec.profiles), func(ap AVProfile) bool { + return SliceTrunc((*AVProfile)(codec.profiles), func(ap AVProfile) bool { return ap.GetProfile() == FF_PROFILE_UNKNOWN }) } @@ -201,17 +201,17 @@ func (hwc *AVCodecHWConfig) GetMethodsAddr() *int32 { return (*int32)(&hwc.methods) } -// Custom: GetDeviceType gets `AVCodecHWConfig.device_type` value. +// Custom: GetDeviceType gets `AVCodecHWConfig.devicetype` value. func (hwc *AVCodecHWConfig) GetDeviceType() AVHWDeviceType { return (AVHWDeviceType)(hwc.device_type) } -// Custom: SetDeviceType sets `AVCodecHWConfig.device_type` value. +// Custom: SetDeviceType sets `AVCodecHWConfig.devicetype` value. func (hwc *AVCodecHWConfig) SetDeviceType(v AVHWDeviceType) { hwc.device_type = (C.enum_AVHWDeviceType)(v) } -// Custom: GetDeviceTypeAddr gets `AVCodecHWConfig.device_type` address. +// Custom: GetDeviceTypeAddr gets `AVCodecHWConfig.devicetype` address. func (hwc *AVCodecHWConfig) GetDeviceTypeAddr() *AVHWDeviceType { return (*AVHWDeviceType)(&hwc.device_type) } diff --git a/avcodec_codec_desc.go b/avcodec_codec_desc.go index 1da4b53..129d20f 100644 --- a/avcodec_codec_desc.go +++ b/avcodec_codec_desc.go @@ -35,12 +35,12 @@ func (hwc *AVCodecDescriptor) GetProps() int32 { // Custom: GetMimeTypes gets `AVCodecDescriptor.mime_types` value. func (hwc *AVCodecDescriptor) GetMimeTypes() (v []string) { - return TruncStringSlice(hwc.mime_types) + return SliceTruncString(hwc.mime_types) } // Custom: GetProfiles gets `AVCodecDescriptor.profiles` value. func (hwc *AVCodecDescriptor) GetProfiles() []AVProfile { - return TruncSlice((*AVProfile)(hwc.profiles), func(ap AVProfile) bool { + return SliceTrunc((*AVProfile)(hwc.profiles), func(ap AVProfile) bool { return ap.GetProfile() == FF_PROFILE_UNKNOWN }) } diff --git a/avcodec_codec_par.go b/avcodec_codec_par.go index 055ab53..9742529 100644 --- a/avcodec_codec_par.go +++ b/avcodec_codec_par.go @@ -21,17 +21,17 @@ const ( // AVCodecParameters type AVCodecParameters C.struct_AVCodecParameters -// Custom: GetCodecType gets `AVCodecParameters.codec_type` value. +// Custom: GetCodecType gets `AVCodecParameters.codectype` value. func (par *AVCodecParameters) GetCodecType() AVMediaType { return (AVMediaType)(par.codec_type) } -// Custom: SetCodecType sets `AVCodecParameters.codec_type` value. +// Custom: SetCodecType sets `AVCodecParameters.codectype` value. func (par *AVCodecParameters) SetCodecType(v AVMediaType) { par.codec_type = (C.enum_AVMediaType)(v) } -// Custom: GetCodecTypeAddr gets `AVCodecParameters.codec_type` address. +// Custom: GetCodecTypeAddr gets `AVCodecParameters.codectype` address. func (par *AVCodecParameters) GetCodecTypeAddr() *AVMediaType { return (*AVMediaType)(unsafe.Pointer(&par.codec_type)) } @@ -246,17 +246,17 @@ func (par *AVCodecParameters) GetFieldOrderAddr() *AVFieldOrder { return (*AVFieldOrder)(unsafe.Pointer(&par.field_order)) } -// Custom: GetColorRange gets `AVCodecParameters.color_range` value. +// Custom: GetColorRange gets `AVCodecParameters.colorrange` value. func (par *AVCodecParameters) GetColorRange() AVColorRange { return (AVColorRange)(par.color_range) } -// Custom: SetColorRange sets `AVCodecParameters.color_range` value. +// Custom: SetColorRange sets `AVCodecParameters.colorrange` value. func (par *AVCodecParameters) SetColorRange(v AVColorRange) { par.color_range = (C.enum_AVColorRange)(v) } -// Custom: GetColorRangeAddr gets `AVCodecParameters.color_range` address. +// Custom: GetColorRangeAddr gets `AVCodecParameters.colorrange` address. func (par *AVCodecParameters) GetColorRangeAddr() *AVColorRange { return (*AVColorRange)(unsafe.Pointer(&par.color_range)) } diff --git a/avcodec_dirac.go b/avcodec_dirac.go index 5f1f769..6d9ca3a 100644 --- a/avcodec_dirac.go +++ b/avcodec_dirac.go @@ -337,17 +337,17 @@ func (dsh *AVDiracSeqHeader) GetPixFmtAddr() *AVPixelFormat { return (*AVPixelFormat)(&dsh.pix_fmt) } -// Custom: GetColorRange gets `AVDiracSeqHeader.color_range` value. +// Custom: GetColorRange gets `AVDiracSeqHeader.colorrange` value. func (dsh *AVDiracSeqHeader) GetColorRange() AVColorRange { return (AVColorRange)(dsh.color_range) } -// Custom: SetColorRange sets `AVDiracSeqHeader.color_range` value. +// Custom: SetColorRange sets `AVDiracSeqHeader.colorrange` value. func (dsh *AVDiracSeqHeader) SetColorRange(v AVColorRange) { dsh.color_range = (C.enum_AVColorRange)(v) } -// Custom: GetColorRangeAddr gets `AVDiracSeqHeader.color_range` address. +// Custom: GetColorRangeAddr gets `AVDiracSeqHeader.colorrange` address. func (dsh *AVDiracSeqHeader) GetColorRangeAddr() *AVColorRange { return (*AVColorRange)(&dsh.color_range) } diff --git a/avfilter.go b/avfilter.go index e08106d..6f158d4 100644 --- a/avfilter.go +++ b/avfilter.go @@ -300,17 +300,17 @@ func (fltc *AVFilterContext) GetGraphAddr() **AVFilterGraph { return (**AVFilterGraph)(unsafe.Pointer(&fltc.graph)) } -// Custom: GetThreadType gets `AVFilterContext.thread_type` value. +// Custom: GetThreadType gets `AVFilterContext.threadtype` value. func (fltc *AVFilterContext) GetThreadType() int32 { return (int32)(fltc.thread_type) } -// Custom: SetThreadType sets `AVFilterContext.thread_type` value. +// Custom: SetThreadType sets `AVFilterContext.threadtype` value. func (fltc *AVFilterContext) SetThreadType(v int32) { fltc.thread_type = (C.int)(v) } -// Custom: GetThreadTypeAddr gets `AVFilterContext.thread_type` address. +// Custom: GetThreadTypeAddr gets `AVFilterContext.threadtype` address. func (fltc *AVFilterContext) GetThreadTypeAddr() *int32 { return (*int32)(&fltc.thread_type) } @@ -866,17 +866,17 @@ func (fltg *AVFilterGraph) GetResampleLavrOpts() string { return C.GoString(fltg.resample_lavr_opts) } -// Custom: GetThreadType gets `AVFilterGraph.thread_type` value. +// Custom: GetThreadType gets `AVFilterGraph.threadtype` value. func (fltg *AVFilterGraph) GetThreadType() int32 { return (int32)(fltg.thread_type) } -// Custom: SetThreadType sets `AVFilterGraph.thread_type` value. +// Custom: SetThreadType sets `AVFilterGraph.threadtype` value. func (fltg *AVFilterGraph) SetThreadType(v int32) { fltg.thread_type = (C.int)(v) } -// Custom: GetThreadTypeAddr gets `AVFilterGraph.thread_type` address. +// Custom: GetThreadTypeAddr gets `AVFilterGraph.threadtype` address. func (fltg *AVFilterGraph) GetThreadTypeAddr() *int32 { return (*int32)(&fltg.thread_type) } diff --git a/avfilter_buffersink.go b/avfilter_buffersink.go index 565a54f..9f8132a 100644 --- a/avfilter_buffersink.go +++ b/avfilter_buffersink.go @@ -21,7 +21,7 @@ type AVBufferSinkParams C.struct_AVBufferSinkParams // Custom: GetPixelFmts gets `AVBufferSinkParams.pixel_fmts` value. func (bsp *AVBufferSinkParams) GetPixelFmts() []AVPixelFormat { - return TruncSlice((*AVPixelFormat)(bsp.pixel_fmts), func(pf AVPixelFormat) bool { + return SliceTrunc((*AVPixelFormat)(bsp.pixel_fmts), func(pf AVPixelFormat) bool { return pf == AV_PIX_FMT_NONE }) } @@ -36,21 +36,21 @@ type AVABufferSinkParams C.struct_AVABufferSinkParams // Custom: GetSampleFmts gets `AVABufferSinkParams.sample_fmts` value. func (absp *AVABufferSinkParams) GetSampleFmts() []AVSampleFormat { - return TruncSlice((*AVSampleFormat)(absp.sample_fmts), func(sf AVSampleFormat) bool { + return SliceTrunc((*AVSampleFormat)(absp.sample_fmts), func(sf AVSampleFormat) bool { return sf == AV_SAMPLE_FMT_NONE }) } // Custom: GetChannelLayouts gets `AVABufferSinkParams.channel_layouts` value. func (absp *AVABufferSinkParams) GetChannelLayouts() []int64 { - return TruncSlice((*int64)(absp.channel_layouts), func(i int64) bool { + return SliceTrunc((*int64)(absp.channel_layouts), func(i int64) bool { return i == -1 }) } // Custom: GetChannelCounts gets `AVABufferSinkParams.channel_counts` value. func (absp *AVABufferSinkParams) GetChannelCounts() []int32 { - return TruncSlice((*int32)(absp.channel_counts), func(i int32) bool { + return SliceTrunc((*int32)(absp.channel_counts), func(i int32) bool { return i == -1 }) } @@ -62,7 +62,7 @@ func (absp *AVABufferSinkParams) GetAllChannelCounts() int32 { // Custom: GetSampleRates gets `AVABufferSinkParams.sample_rates` value. func (absp *AVABufferSinkParams) GetSampleRates() []int32 { - return TruncSlice((*int32)(absp.sample_rates), func(i int32) bool { + return SliceTrunc((*int32)(absp.sample_rates), func(i int32) bool { return i == -1 }) } diff --git a/avformat.go b/avformat.go index 85d25cb..eaf8cdf 100644 --- a/avformat.go +++ b/avformat.go @@ -79,7 +79,7 @@ func (pd *AVProbeData) GetBufSizeAddr() *int32 { return (*int32)(&pd.buf_size) } -// Custom: GetMimeType gets `AVProbeData.mime_type` value. +// Custom: GetMimeType gets `AVProbeData.mimetype` value. func (pd *AVProbeData) GetMimeType() string { return C.GoString(pd.mime_type) } @@ -125,7 +125,7 @@ func (ofmt *AVOutputFormat) GetLongName() string { return C.GoString(ofmt.long_name) } -// Custom: GetMimeType gets `AVOutputFormat.mime_type` value. +// Custom: GetMimeType gets `AVOutputFormat.mimetype` value. func (ofmt *AVOutputFormat) GetMimeType() string { return C.GoString(ofmt.mime_type) } @@ -258,7 +258,7 @@ func (ifmt *AVInputFormat) GetPrivClassAddr() **AVClass { return (**AVClass)(unsafe.Pointer(&ifmt.priv_class)) } -// Custom: GetMimeType gets `AVInputFormat.mime_type` value. +// Custom: GetMimeType gets `AVInputFormat.mimetype` value. func (ifmt *AVInputFormat) GetMimeType() string { return C.GoString(ifmt.mime_type) } diff --git a/avformat_avio.go b/avformat_avio.go index 865ad95..c6286da 100644 --- a/avformat_avio.go +++ b/avformat_avio.go @@ -595,17 +595,17 @@ func (ctx *AVIOContext) GetIgnoreBoundaryPointAddr() *int32 { return (*int32)(&ctx.ignore_boundary_point) } -// Custom: GetCurrentType gets `AVIOContext.current_type` value. +// Custom: GetCurrentType gets `AVIOContext.currenttype` value. func (ctx *AVIOContext) GetCurrentType() AVIODataMarkerType { return (AVIODataMarkerType)(ctx.current_type) } -// Custom: SetCurrentType sets `AVIOContext.current_type` value. +// Custom: SetCurrentType sets `AVIOContext.currenttype` value. func (ctx *AVIOContext) SetCurrentType(v AVIODataMarkerType) { ctx.current_type = (C.enum_AVIODataMarkerType)(v) } -// Custom: GetCurrentTypeAddr gets `AVIOContext.current_type` address. +// Custom: GetCurrentTypeAddr gets `AVIOContext.currenttype` address. func (ctx *AVIOContext) GetCurrentTypeAddr() *AVIODataMarkerType { return (*AVIODataMarkerType)(&ctx.current_type) } diff --git a/avutil_blowfish.go b/avutil_blowfish.go index 7618c7c..d9172d1 100644 --- a/avutil_blowfish.go +++ b/avutil_blowfish.go @@ -30,14 +30,19 @@ func (bf *AVBlowfish) GetPAddr() **uint32 { } // Custom: GetS gets `AVBlowfish.s` value. -func (bf *AVBlowfish) GetS() []uint32 { - return unsafe.Slice((*uint32)(&bf.s[0][0]), 4*256) +func (bf *AVBlowfish) GetS() (v [][]uint32) { + for i := 0; i < 4; i++ { + v = append(v, unsafe.Slice((*uint32)(&bf.s[i][0]), 256)) + } + return v } // Custom: SetS sets `AVBlowfish.s` value. -func (bf *AVBlowfish) SetS(v []uint32) { - for i := 0; i < FFMIN(len(v), 4*256); i++ { - bf.s[i/256][i%256] = (C.uint32_t)(v[i]) +func (bf *AVBlowfish) SetS(v [][]uint32) { + for i := 0; i < FFMIN(len(v), 4); i++ { + for j := 0; j < FFMIN(len(v[i]), 256); j++ { + bf.s[i][j] = (C.uint32_t)(v[i][j]) + } } } @@ -46,21 +51,6 @@ func (bf *AVBlowfish) GetSAddr() **uint32 { return (**uint32)(unsafe.Pointer(&bf.s)) } -// Custom: GetSIdx gets `AVBlowfish.s` index value. -func (bf *AVBlowfish) GetSIdx(x, y int) uint32 { - return (uint32)(bf.s[x][y]) -} - -// Custom: SetSIdx sets `AVBlowfish.s` index value. -func (bf *AVBlowfish) SetSIdx(x, y int, v uint32) { - bf.s[x][y] = (C.uint32_t)(v) -} - -// Custom: GetSIdxAddr gets `AVBlowfish.s` index address. -func (bf *AVBlowfish) GetSIdxAddr(x, y int) *uint32 { - return (*uint32)(&bf.s[x][y]) -} - // AvBlowfishAlloc allocates an AVBlowfish context. func AvBlowfishAlloc() *AVBlowfish { return (*AVBlowfish)(C.av_blowfish_alloc()) diff --git a/avutil_common.go b/avutil_common.go index 0cdf0f7..838aa64 100644 --- a/avutil_common.go +++ b/avutil_common.go @@ -5,6 +5,7 @@ package ffmpeg */ import "C" +// AV_NE func AV_NE[T any](be, le T) T { if C.AV_HAVE_BIGENDIAN > 0 { return be @@ -12,11 +13,50 @@ func AV_NE[T any](be, le T) T { return le } +// RSHIFT +func RSHIFT[U, V HelperInteger](a U, b V) U { + if a > 0 { + return ((a) + ((1 << (b)) >> 1)) >> b + } + return ((a) + ((1 << (b)) >> 1) - 1) >> b +} + +// ROUNDED_DIV +func ROUNDED_DIV[T HelperInteger](a, b T) T { + if a >= 0 { + return ((a) + ((b) >> 1)) / b + } + return ((a) - ((b) >> 1)) / b +} + +// AV_CEIL_RSHIFT +func AV_CEIL_RSHIFT[U, V HelperInteger](a U, b V) U { + return -((-(a)) >> (b)) +} + +// FF_CEIL_RSHIFT +func FF_CEIL_RSHIFT[U, V HelperInteger](a U, b V) U { + return AV_CEIL_RSHIFT(a, b) +} + +// FFUDIV +func FFUDIV[T HelperInteger](a, b T) T { + if a > 0 { + return a / b + } + return ((a) - (b) + 1) / b +} + +// FFUMOD +func FFUMOD[T HelperInteger](a, b T) T { + return a - b*FFUDIV(a, b) +} + func FFABS[T HelperSingedInteger](a T) T { if a >= 0 { return a } - return 0 - a + return -a } func FFSIGNT[T HelperSingedInteger](a T) T { @@ -26,6 +66,41 @@ func FFSIGNT[T HelperSingedInteger](a T) T { return -1 } +// FFNABS +func FFNABS[T HelperSingedInteger](a T) T { + if a <= 0 { + return a + } + return -a +} + +// FFABSU +func FFABSU[T HelperSingedInteger](a T) uint32 { + if a <= 0 { + return -(uint32)(a) + } + return (uint32)(a) +} + +// FFABS64U +func FFABS64U[T HelperSingedInteger](a T) uint64 { + if a <= 0 { + return -(uint64)(a) + } + return (uint64)(a) +} + +// FFDIFFSIGN +func FFDIFFSIGN[T HelperInteger](x, y T) int { + if x > y { + return 1 + } else if x < y { + return -1 + } else { + return 0 + } +} + func FFMAX[T HelperInteger](a, b T) T { if a > b { return a @@ -47,3 +122,152 @@ func FFMIN[T HelperInteger](a, b T) T { func FFMIN3[T HelperInteger](a, b, c T) T { return FFMIN(FFMIN(a, b), c) } + +// FFSWAP +func FFSWAP[T any](a, b *T) { + swapTmp := *b + *b = *a + *a = swapTmp +} + +// NONEED: FF_ARRAY_ELEMS + +// AvLog2 +func AvLog2(v uint32) int32 { + return (int32)(C.av_log2((C.uint)(v))) +} + +// AvLog2_16bit +func AvLog2_16bit(v uint32) int32 { + return (int32)(C.av_log2_16bit((C.uint)(v))) +} + +// AvClipC clips a signed integer value into the amin-amax range. +func AvClipC(a, amin, amax int32) int32 { + return (int32)(C.av_clip_c((C.int)(a), (C.int)(amin), (C.int)(amax))) +} + +// AvClip64C clips a signed 64bit integer value into the amin-amax range. +func AvClip64C(a, amin, amax int64) int64 { + return (int64)(C.av_clip64_c((C.int64_t)(a), (C.int64_t)(amin), (C.int64_t)(amax))) +} + +// AvClipUint8C clips a signed integer value into the 0-255 range. +func AvClipUint8C(a int32) uint8 { + return (uint8)(C.av_clip_uint8_c((C.int)(a))) +} + +// AvClipInt8C clips a signed integer value into the -128,127 range. +func AvClipInt8C(a int32) int8 { + return (int8)(C.av_clip_int8_c((C.int)(a))) +} + +// AvClipUint16C clips a signed integer value into the 0-65535 range. +func AvClipUint16C(a int32) uint16 { + return (uint16)(C.av_clip_uint16_c((C.int)(a))) +} + +// AvClipInt16C clips a signed integer value into the -32768,32767 range. +func AvClipInt16C(a int32) int16 { + return (int16)(C.av_clip_int16_c((C.int)(a))) +} + +// AvCliplInt32C clips a signed 64-bit integer value into the -2147483648,2147483647 range. +func AvCliplInt32C(a int64) int32 { + return (int32)(C.av_clipl_int32_c((C.int64_t)(a))) +} + +// AvClipIntp2C clips a signed integer into the -(2^p),(2^p-1) range. +func AvClipIntp2C(a, p int32) int32 { + return (int32)(C.av_clip_intp2_c((C.int)(a), (C.int)(p))) +} + +// AvClipUintp2C clips a signed integer to an unsigned power of two range. +func AvClipUintp2C(a, p int32) uint32 { + return (uint32)(C.av_clip_uintp2_c((C.int)(a), (C.int)(p))) +} + +// AvModUintp2C clears high bits from an unsigned integer starting with specific bit position. +func AvModUintp2C(a, p uint32) uint32 { + return (uint32)(C.av_mod_uintp2_c((C.uint)(a), (C.uint)(p))) +} + +// AvSatAdd32C adds two signed 32-bit values with saturation. +func AvSatAdd32C(a, b int32) int32 { + return (int32)(C.av_sat_add32_c((C.int)(a), (C.int)(b))) +} + +// AvSatDadd32C adds a doubled value to another value with saturation at both stages. +func AvSatDadd32C(a, b int32) int32 { + return (int32)(C.av_sat_dadd32_c((C.int)(a), (C.int)(b))) +} + +// AvSatSub32C subtracts two signed 32-bit values with saturation. +func AvSatSub32C(a, b int32) int32 { + return (int32)(C.av_sat_sub32_c((C.int)(a), (C.int)(b))) +} + +// AvSatDsub32C subtracts a doubled value from another value with saturation at both stages. +func AvSatDsub32C(a, b int32) int32 { + return (int32)(C.av_sat_dsub32_c((C.int)(a), (C.int)(b))) +} + +// AvSatAdd64C adds two signed 64-bit values with saturation. +func AvSatAdd64C(a, b int64) int64 { + return (int64)(C.av_sat_add64_c((C.int64_t)(a), (C.int64_t)(b))) +} + +// AvSatSub64C subtracts two signed 64-bit values with saturation. +func AvSatSub64C(a, b int64) int64 { + return (int64)(C.av_sat_sub64_c((C.int64_t)(a), (C.int64_t)(b))) +} + +// AvClipfC clip a float value into the amin-amax range. +func AvClipfC(a, amin, amax float32) float32 { + return (float32)(C.av_clipf_c((C.float)(a), (C.float)(amin), (C.float)(amax))) +} + +// AvClipdC clips a double value into the amin-amax range. +func AvClipdC(a, amin, amax float64) float64 { + return (float64)(C.av_clipd_c((C.double)(a), (C.double)(amin), (C.double)(amax))) +} + +// AvCeilLog2C computes ceil(log2(x)). +func AvCeilLog2C(x int32) int32 { + return (int32)(C.av_ceil_log2_c((C.int)(x))) +} + +// AvPopcountC counts number of bits set to one in x +func AvPopcountC(x uint32) int32 { + return (int32)(C.av_popcount_c((C.uint)(x))) +} + +// AvPopcount64C counts number of bits set to one in x +func AvPopcount64C(x uint64) int32 { + return (int32)(C.av_popcount64_c((C.uint64_t)(x))) +} + +// AvParityC +func AvParityC(x uint32) int32 { + return (int32)(C.av_parity_c((C.uint32_t)(x))) +} + +// MKTAG +func MKTAG(a, b, c, d uint32) uint32 { + return (a) | ((b) << 8) | ((c) << 16) | ((uint32)(d) << 24) +} + +// MKBETAG +func MKBETAG(a, b, c, d uint32) uint32 { + return (d) | ((c) << 8) | ((b) << 16) | ((uint32)(a) << 24) +} + +// See https://pkg.go.dev/unicode/utf8 + +// NONEED: GET_UTF8 + +// NONEED: GET_UTF16 + +// NONEED: PUT_UTF8 + +// NONEED: PUT_UTF16 diff --git a/avutil_crc.go b/avutil_crc.go new file mode 100644 index 0000000..48c3255 --- /dev/null +++ b/avutil_crc.go @@ -0,0 +1,41 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVCRC +type AVCRC C.AVCRC + +// AVCRCId +type AVCRCId = C.AVCRCId + +const ( + AV_CRC_8_ATM = AVCRCId(C.AV_CRC_8_ATM) + AV_CRC_16_ANSI = AVCRCId(C.AV_CRC_16_ANSI) + AV_CRC_16_CCITT = AVCRCId(C.AV_CRC_16_CCITT) + AV_CRC_32_IEEE = AVCRCId(C.AV_CRC_32_IEEE) + AV_CRC_32_IEEE_LE = AVCRCId(C.AV_CRC_32_IEEE_LE) + AV_CRC_16_ANSI_LE = AVCRCId(C.AV_CRC_16_ANSI_LE) + AV_CRC_24_IEEE = AVCRCId(C.AV_CRC_24_IEEE) + AV_CRC_8_EBU = AVCRCId(C.AV_CRC_8_EBU) + AV_CRC_MAX = AVCRCId(C.AV_CRC_MAX) +) + +// AvCrcInit initializes a CRC table. +func AvCrcInit(ctx *AVCRC, le, bits int32, poly uint32, ctxSize int32) int32 { + return (int32)(C.av_crc_init((*C.AVCRC)(ctx), + (C.int)(le), (C.int)(bits), (C.uint32_t)(poly), (C.int)(ctxSize))) +} + +// AvCrcGetTable gets an initialized standard CRC table. +func AvCrcGetTable(crcId AVCRCId) *AVCRC { + return (*AVCRC)(C.av_crc_get_table((C.AVCRCId)(crcId))) +} + +// AvCrc calculates the CRC of a block. +func AvCrc(ctx *AVCRC, crc uint32, buffer *uint8, length uintptr) int32 { + return (int32)(C.av_crc((*C.AVCRC)(ctx), + (C.uint32_t)(crc), (*C.uint8_t)(buffer), (C.size_t)(length))) +} diff --git a/avutil_des.go b/avutil_des.go new file mode 100644 index 0000000..96c934a --- /dev/null +++ b/avutil_des.go @@ -0,0 +1,69 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +// AVDES +type AVDES C.struct_AVDES + +// Custom: GetRoundKeys gets `AVDES.round_keys` value. +func (d *AVDES) GetRoundKeys() (v [][]uint64) { + for i := 0; i < 3; i++ { + v = append(v, unsafe.Slice((*uint64)(&d.round_keys[i][0]), 16)) + } + return v +} + +// Custom: SetRoundKeys sets `AVDES.round_keys` value. +func (d *AVDES) SetRoundKeys(v [][]uint64) { + for i := 0; i < FFMIN(len(v), 3); i++ { + for j := 0; j < FFMIN(len(v[i]), 16); j++ { + d.round_keys[i][j] = (C.uint64_t)(v[i][j]) + } + } +} + +// Custom: GetRoundKeysAddr gets `AVDES.round_keys` address. +func (d *AVDES) GetRoundKeysAddr() **uint64 { + return (**uint64)(unsafe.Pointer(&d.round_keys)) +} + +// Custom: GetTripleDes gets `AVDES.triple_des` value. +func (d *AVDES) GetTripleDes() int32 { + return (int32)(d.triple_des) +} + +// Custom: SetTripleDes sets `AVDES.triple_des` value. +func (d *AVDES) SetTripleDes(v int32) { + d.triple_des = (C.int)(v) +} + +// Custom: GetTripleDesAddr gets `AVDES.triple_des` address. +func (d *AVDES) GetTripleDesAddr() *int32 { + return (*int32)(&d.triple_des) +} + +// AvDesAlloc allocates an AVDES context. +func AvDesAlloc() *AVDES { + return (*AVDES)(C.av_des_alloc()) +} + +// AvDesInit initializes an AVDES context. +func AvDesInit(d *AVDES, key *uint8, keyBits, decrypt int32) int32 { + return (int32)(C.av_des_init((*C.struct_AVDES)(d), (*C.uint8_t)(key), + (C.int)(keyBits), (C.int)(decrypt))) +} + +// AvDesCrypt encrypts / decrypts using the DES algorithm. +func AvDesCrypt(d *AVDES, dst, src *uint8, count int32, iv *uint8, decrypt int32) { + C.av_des_crypt((*C.struct_AVDES)(d), (*C.uint8_t)(dst), (*C.uint8_t)(src), + (C.int)(count), (*C.uint8_t)(iv), (C.int)(decrypt)) +} + +// AvDesMac calculates CBC-MAC using the DES algorithm. +func AvDesMac(d *AVDES, dst, src *uint8, count int32) { + C.av_des_mac((*C.struct_AVDES)(d), (*C.uint8_t)(dst), (*C.uint8_t)(src), (C.int)(count)) +} diff --git a/avutil_display.go b/avutil_display.go new file mode 100644 index 0000000..ed06f76 --- /dev/null +++ b/avutil_display.go @@ -0,0 +1,25 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AvDisplayRotationGet extracts the rotation component of the transformation matrix. +func AvDisplayRotationGet(matrix []int32) float64 { + if len(matrix) < 9 { + panic("matrix len < 9") + } + return (float64)(C.av_display_rotation_get((*C.int32_t)(&matrix[0]))) +} + +// AvDisplayRotationSet initializes a transformation matrix describing a pure counterclockwise +// rotation by the specified angle (in degrees). +func AvDisplayRotationSet(matrix []int32, angle float64) { + C.av_display_rotation_set((*C.int32_t)(&matrix[0]), (C.double)(angle)) +} + +// AvDisplayMatrixFlip flips the input matrix horizontally and/or vertically. +func AvDisplayMatrixFlip(matrix []int32, hflip, vflip int32) { + C.av_display_matrix_flip((*C.int32_t)(&matrix[0]), (C.int)(hflip), (C.int)(vflip)) +} diff --git a/avutil_dovi_meta.go b/avutil_dovi_meta.go new file mode 100644 index 0000000..a92d9ae --- /dev/null +++ b/avutil_dovi_meta.go @@ -0,0 +1,139 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +// AVDOVIDecoderConfigurationRecord +type AVDOVIDecoderConfigurationRecord C.struct_AVDOVIDecoderConfigurationRecord + +// Custom: GetDvVersionMajor gets `AVDOVIDecoderConfigurationRecord.dv_version_major` value. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvVersionMajor() uint8 { + return (uint8)(dcr.dv_version_major) +} + +// Custom: SetDvVersionMajor sets `AVDOVIDecoderConfigurationRecord.dv_version_major` value. +func (dcr *AVDOVIDecoderConfigurationRecord) SetDvVersionMajor(v uint8) { + dcr.dv_version_major = (C.uint8_t)(v) +} + +// Custom: GetDvVersionMajorAddr gets `AVDOVIDecoderConfigurationRecord.dv_version_major` address. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvVersionMajorAddr() *uint8 { + return (*uint8)(&dcr.dv_version_major) +} + +// Custom: GetDvVersionMinor gets `AVDOVIDecoderConfigurationRecord.dv_version_minor` value. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvVersionMinor() uint8 { + return (uint8)(dcr.dv_version_minor) +} + +// Custom: SetDvVersionMinor sets `AVDOVIDecoderConfigurationRecord.dv_version_minor` value. +func (dcr *AVDOVIDecoderConfigurationRecord) SetDvVersionMinor(v uint8) { + dcr.dv_version_minor = (C.uint8_t)(v) +} + +// Custom: GetDvVersionMinorAddr gets `AVDOVIDecoderConfigurationRecord.dv_version_minor` address. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvVersionMinorAddr() *uint8 { + return (*uint8)(&dcr.dv_version_minor) +} + +// Custom: GetDvProfile gets `AVDOVIDecoderConfigurationRecord.dv_profile` value. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvProfile() uint8 { + return (uint8)(dcr.dv_profile) +} + +// Custom: SetDvProfile sets `AVDOVIDecoderConfigurationRecord.dv_profile` value. +func (dcr *AVDOVIDecoderConfigurationRecord) SetDvProfile(v uint8) { + dcr.dv_profile = (C.uint8_t)(v) +} + +// Custom: GetDvProfileAddr gets `AVDOVIDecoderConfigurationRecord.dv_profile` address. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvProfileAddr() *uint8 { + return (*uint8)(&dcr.dv_profile) +} + +// Custom: GetDvLevel gets `AVDOVIDecoderConfigurationRecord.dv_level` value. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvLevel() uint8 { + return (uint8)(dcr.dv_level) +} + +// Custom: SetDvLevel sets `AVDOVIDecoderConfigurationRecord.dv_level` value. +func (dcr *AVDOVIDecoderConfigurationRecord) SetDvLevel(v uint8) { + dcr.dv_level = (C.uint8_t)(v) +} + +// Custom: GetDvLevelAddr gets `AVDOVIDecoderConfigurationRecord.dv_level` address. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvLevelAddr() *uint8 { + return (*uint8)(&dcr.dv_level) +} + +// Custom: GetRpuPresentFlag gets `AVDOVIDecoderConfigurationRecord.rpu_present_flag` value. +func (dcr *AVDOVIDecoderConfigurationRecord) GetRpuPresentFlag() uint8 { + return (uint8)(dcr.rpu_present_flag) +} + +// Custom: SetRpuPresentFlag sets `AVDOVIDecoderConfigurationRecord.rpu_present_flag` value. +func (dcr *AVDOVIDecoderConfigurationRecord) SetRpuPresentFlag(v uint8) { + dcr.rpu_present_flag = (C.uint8_t)(v) +} + +// Custom: GetRpuPresentFlagAddr gets `AVDOVIDecoderConfigurationRecord.rpu_present_flag` address. +func (dcr *AVDOVIDecoderConfigurationRecord) GetRpuPresentFlagAddr() *uint8 { + return (*uint8)(&dcr.rpu_present_flag) +} + +// Custom: GetElPresentFlag gets `AVDOVIDecoderConfigurationRecord.el_present_flag` value. +func (dcr *AVDOVIDecoderConfigurationRecord) GetElPresentFlag() uint8 { + return (uint8)(dcr.el_present_flag) +} + +// Custom: SetElPresentFlag sets `AVDOVIDecoderConfigurationRecord.el_present_flag` value. +func (dcr *AVDOVIDecoderConfigurationRecord) SetElPresentFlag(v uint8) { + dcr.el_present_flag = (C.uint8_t)(v) +} + +// Custom: GetElPresentFlagAddr gets `AVDOVIDecoderConfigurationRecord.el_present_flag` address. +func (dcr *AVDOVIDecoderConfigurationRecord) GetElPresentFlagAddr() *uint8 { + return (*uint8)(&dcr.el_present_flag) +} + +// Custom: GetBlPresentFlag gets `AVDOVIDecoderConfigurationRecord.bl_present_flag` value. +func (dcr *AVDOVIDecoderConfigurationRecord) GetBlPresentFlag() uint8 { + return (uint8)(dcr.bl_present_flag) +} + +// Custom: SetBlPresentFlag sets `AVDOVIDecoderConfigurationRecord.bl_present_flag` value. +func (dcr *AVDOVIDecoderConfigurationRecord) SetBlPresentFlag(v uint8) { + dcr.bl_present_flag = (C.uint8_t)(v) +} + +// Custom: GetBlPresentFlagAddr gets `AVDOVIDecoderConfigurationRecord.bl_present_flag` address. +func (dcr *AVDOVIDecoderConfigurationRecord) GetBlPresentFlagAddr() *uint8 { + return (*uint8)(&dcr.bl_present_flag) +} + +// Custom: GetDvBlSignalCompatibilityId +// gets `AVDOVIDecoderConfigurationRecord.dv_bl_signal_compatibility_id` value. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvBlSignalCompatibilityId() uint8 { + return (uint8)(dcr.dv_bl_signal_compatibility_id) +} + +// Custom: SetDvBlSignalCompatibilityId +// sets `AVDOVIDecoderConfigurationRecord.dv_bl_signal_compatibility_id` value. +func (dcr *AVDOVIDecoderConfigurationRecord) SetDvBlSignalCompatibilityId(v uint8) { + dcr.dv_bl_signal_compatibility_id = (C.uint8_t)(v) +} + +// Custom: GetDvBlSignalCompatibilityIdAddr +// gets `AVDOVIDecoderConfigurationRecord.dv_bl_signal_compatibility_id` address. +func (dcr *AVDOVIDecoderConfigurationRecord) GetDvBlSignalCompatibilityIdAddr() *uint8 { + return (*uint8)(&dcr.dv_bl_signal_compatibility_id) +} + +// AvDoviAlloc allocates a AVDOVIDecoderConfigurationRecord structure and initialize its +// fields to default values. +func AvDoviAlloc(size *uintptr) *AVDOVIDecoderConfigurationRecord { + return (*AVDOVIDecoderConfigurationRecord)(C.av_dovi_alloc((*C.size_t)(unsafe.Pointer(size)))) +} diff --git a/avutil_downmix_info.go b/avutil_downmix_info.go new file mode 100644 index 0000000..cd41b84 --- /dev/null +++ b/avutil_downmix_info.go @@ -0,0 +1,115 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVDownmixType +type AVDownmixType = C.enum_AVDownmixType + +const ( + AV_DOWNMIX_TYPE_UNKNOWN = AVDownmixType(C.AV_DOWNMIX_TYPE_UNKNOWN) + AV_DOWNMIX_TYPE_LORO = AVDownmixType(C.AV_DOWNMIX_TYPE_LORO) + AV_DOWNMIX_TYPE_LTRT = AVDownmixType(C.AV_DOWNMIX_TYPE_LTRT) + AV_DOWNMIX_TYPE_DPLII = AVDownmixType(C.AV_DOWNMIX_TYPE_DPLII) + AV_DOWNMIX_TYPE_NB = AVDownmixType(C.AV_DOWNMIX_TYPE_NB) +) + +// AVDownmixInfo +type AVDownmixInfo C.struct_AVDownmixInfo + +// Custom: GetPreferredDownmixType gets `AVDownmixInfo.preferred_downmixtype` value. +func (di *AVDownmixInfo) GetPreferredDownmixType() AVDownmixType { + return (AVDownmixType)(di.preferred_downmix_type) +} + +// Custom: SetPreferredDownmixType sets `AVDownmixInfo.preferred_downmixtype` value. +func (di *AVDownmixInfo) SetPreferredDownmixType(v AVDownmixType) { + di.preferred_downmix_type = (C.enum_AVDownmixType)(v) +} + +// Custom: GetPreferredDownmixTypeAddr gets `AVDownmixInfo.preferred_downmixtype` address. +func (di *AVDownmixInfo) GetPreferredDownmixTypeAddr() *AVDownmixType { + return (*AVDownmixType)(&di.preferred_downmix_type) +} + +// Custom: GetCenterMixLevel gets `AVDownmixInfo.center_mix_level` value. +func (di *AVDownmixInfo) GetCenterMixLevel() float64 { + return (float64)(di.center_mix_level) +} + +// Custom: SetCenterMixLevel sets `AVDownmixInfo.center_mix_level` value. +func (di *AVDownmixInfo) SetCenterMixLevel(v float64) { + di.center_mix_level = (C.double)(v) +} + +// Custom: GetCenterMixLevelAddr gets `AVDownmixInfo.center_mix_level` address. +func (di *AVDownmixInfo) GetCenterMixLevelAddr() *float64 { + return (*float64)(&di.center_mix_level) +} + +// Custom: GetCenterMixLevelLtrt gets `AVDownmixInfo.center_mix_level_ltrt` value. +func (di *AVDownmixInfo) GetCenterMixLevelLtrt() float64 { + return (float64)(di.center_mix_level_ltrt) +} + +// Custom: SetCenterMixLevelLtrt sets `AVDownmixInfo.center_mix_level_ltrt` value. +func (di *AVDownmixInfo) SetCenterMixLevelLtrt(v float64) { + di.center_mix_level_ltrt = (C.double)(v) +} + +// Custom: GetCenterMixLevelLtrtAddr gets `AVDownmixInfo.center_mix_level_ltrt` address. +func (di *AVDownmixInfo) GetCenterMixLevelLtrtAddr() *float64 { + return (*float64)(&di.center_mix_level_ltrt) +} + +// Custom: GetSurroundMixLevel gets `AVDownmixInfo.surround_mix_level` value. +func (di *AVDownmixInfo) GetSurroundMixLevel() float64 { + return (float64)(di.surround_mix_level) +} + +// Custom: SetSurroundMixLevel sets `AVDownmixInfo.surround_mix_level` value. +func (di *AVDownmixInfo) SetSurroundMixLevel(v float64) { + di.surround_mix_level = (C.double)(v) +} + +// Custom: GetSurroundMixLevelAddr gets `AVDownmixInfo.surround_mix_level` address. +func (di *AVDownmixInfo) GetSurroundMixLevelAddr() *float64 { + return (*float64)(&di.surround_mix_level) +} + +// Custom: GetSurroundMixLevelLtrt gets `AVDownmixInfo.surround_mix_level_ltrt` value. +func (di *AVDownmixInfo) GetSurroundMixLevelLtrt() float64 { + return (float64)(di.surround_mix_level_ltrt) +} + +// Custom: SetSurroundMixLevelLtrt sets `AVDownmixInfo.surround_mix_level_ltrt` value. +func (di *AVDownmixInfo) SetSurroundMixLevelLtrt(v float64) { + di.surround_mix_level_ltrt = (C.double)(v) +} + +// Custom: GetSurroundMixLevelLtrtAddr gets `AVDownmixInfo.surround_mix_level_ltrt` address. +func (di *AVDownmixInfo) GetSurroundMixLevelLtrtAddr() *float64 { + return (*float64)(&di.surround_mix_level_ltrt) +} + +// Custom: GetLfeMixLevel gets `AVDownmixInfo.lfe_mix_level` value. +func (di *AVDownmixInfo) GetLfeMixLevel() float64 { + return (float64)(di.lfe_mix_level) +} + +// Custom: SetLfeMixLevel sets `AVDownmixInfo.lfe_mix_level` value. +func (di *AVDownmixInfo) SetLfeMixLevel(v float64) { + di.lfe_mix_level = (C.double)(v) +} + +// Custom: GetLfeMixLevelAddr gets `AVDownmixInfo.lfe_mix_level` address. +func (di *AVDownmixInfo) GetLfeMixLevelAddr() *float64 { + return (*float64)(&di.lfe_mix_level) +} + +// AvDownmixInfoUpdateSideData gets a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing. +func AvDownmixInfoUpdateSideData(frame *AVFrame) *AVDownmixInfo { + return (*AVDownmixInfo)(C.av_downmix_info_update_side_data((*C.struct_AVFrame)(frame))) +} diff --git a/avutil_encryption_info.go b/avutil_encryption_info.go new file mode 100644 index 0000000..7df0335 --- /dev/null +++ b/avutil_encryption_info.go @@ -0,0 +1,358 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +// AVSubsampleEncryptionInfo +type AVSubsampleEncryptionInfo C.struct_AVSubsampleEncryptionInfo + +// Custom: GetBytesOfClearData gets `AVSubsampleEncryptionInfo.bytes_of_clear_data` value. +func (sei *AVSubsampleEncryptionInfo) GetBytesOfClearData() uint32 { + return (uint32)(sei.bytes_of_clear_data) +} + +// Custom: SetBytesOfClearData sets `AVSubsampleEncryptionInfo.bytes_of_clear_data` value. +func (sei *AVSubsampleEncryptionInfo) SetBytesOfClearData(v uint32) { + sei.bytes_of_clear_data = (C.uint32_t)(v) +} + +// Custom: GetBytesOfClearDataAddr gets `AVSubsampleEncryptionInfo.bytes_of_clear_data` address. +func (sei *AVSubsampleEncryptionInfo) GetBytesOfClearDataAddr() *uint32 { + return (*uint32)(&sei.bytes_of_clear_data) +} + +// Custom: GetBytesOfProtectedData gets `AVSubsampleEncryptionInfo.bytes_of_protected_data` value. +func (sei *AVSubsampleEncryptionInfo) GetBytesOfProtectedData() uint32 { + return (uint32)(sei.bytes_of_protected_data) +} + +// Custom: SetBytesOfProtectedData sets `AVSubsampleEncryptionInfo.bytes_of_protected_data` value. +func (sei *AVSubsampleEncryptionInfo) SetBytesOfProtectedData(v uint32) { + sei.bytes_of_protected_data = (C.uint32_t)(v) +} + +// Custom: GetBytesOfProtectedDataAddr gets `AVSubsampleEncryptionInfo.bytes_of_protected_data` address. +func (sei *AVSubsampleEncryptionInfo) GetBytesOfProtectedDataAddr() *uint32 { + return (*uint32)(&sei.bytes_of_protected_data) +} + +// AVEncryptionInfo +type AVEncryptionInfo C.struct_AVEncryptionInfo + +// Custom: GetScheme gets `AVEncryptionInfo.scheme` value. +func (ei *AVEncryptionInfo) GetScheme() uint32 { + return (uint32)(ei.scheme) +} + +// Custom: SetScheme sets `AVEncryptionInfo.scheme` value. +func (ei *AVEncryptionInfo) SetScheme(v uint32) { + ei.scheme = (C.uint32_t)(v) +} + +// Custom: GetSchemeAddr gets `AVEncryptionInfo.scheme` address. +func (ei *AVEncryptionInfo) GetSchemeAddr() *uint32 { + return (*uint32)(&ei.scheme) +} + +// Custom: GetCryptByteBlock gets `AVEncryptionInfo.crypt_byte_block` value. +func (ei *AVEncryptionInfo) GetCryptByteBlock() uint32 { + return (uint32)(ei.crypt_byte_block) +} + +// Custom: SetCryptByteBlock sets `AVEncryptionInfo.crypt_byte_block` value. +func (ei *AVEncryptionInfo) SetCryptByteBlock(v uint32) { + ei.crypt_byte_block = (C.uint32_t)(v) +} + +// Custom: GetCryptByteBlockAddr gets `AVEncryptionInfo.crypt_byte_block` address. +func (ei *AVEncryptionInfo) GetCryptByteBlockAddr() *uint32 { + return (*uint32)(&ei.crypt_byte_block) +} + +// Custom: GetSkipByteBlock gets `AVEncryptionInfo.skip_byte_block` value. +func (ei *AVEncryptionInfo) GetSkipByteBlock() uint32 { + return (uint32)(ei.skip_byte_block) +} + +// Custom: SetSkipByteBlock sets `AVEncryptionInfo.skip_byte_block` value. +func (ei *AVEncryptionInfo) SetSkipByteBlock(v uint32) { + ei.skip_byte_block = (C.uint32_t)(v) +} + +// Custom: GetSkipByteBlockAddr gets `AVEncryptionInfo.skip_byte_block` address. +func (ei *AVEncryptionInfo) GetSkipByteBlockAddr() *uint32 { + return (*uint32)(&ei.skip_byte_block) +} + +// Custom: GetKeyId gets `AVEncryptionInfo.key_id` value. +func (ei *AVEncryptionInfo) GetKeyId() *uint8 { + return (*uint8)(ei.key_id) +} + +// Custom: SetKeyId sets `AVEncryptionInfo.key_id` value. +func (ei *AVEncryptionInfo) SetKeyId(v *uint8) { + ei.key_id = (*C.uint8_t)(v) +} + +// Custom: GetKeyIdAddr gets `AVEncryptionInfo.key_id` address. +func (ei *AVEncryptionInfo) GetKeyIdAddr() **uint8 { + return (**uint8)(unsafe.Pointer(&ei.key_id)) +} + +// Custom: GetKeyIdSize gets `AVEncryptionInfo.key_id_size` value. +func (ei *AVEncryptionInfo) GetKeyIdSize() uint32 { + return (uint32)(ei.key_id_size) +} + +// Custom: SetKeyIdSize sets `AVEncryptionInfo.key_id_size` value. +func (ei *AVEncryptionInfo) SetKeyIdSize(v uint32) { + ei.key_id_size = (C.uint32_t)(v) +} + +// Custom: GetKeyIdSizeAddr gets `AVEncryptionInfo.key_id_size` address. +func (ei *AVEncryptionInfo) GetKeyIdSizeAddr() *uint32 { + return (*uint32)(&ei.key_id_size) +} + +// Custom: GetIv gets `AVEncryptionInfo.iv` value. +func (ei *AVEncryptionInfo) GetIv() *uint8 { + return (*uint8)(ei.iv) +} + +// Custom: SetIv sets `AVEncryptionInfo.iv` value. +func (ei *AVEncryptionInfo) SetIv(v *uint8) { + ei.iv = (*C.uint8_t)(v) +} + +// Custom: GetIvAddr gets `AVEncryptionInfo.iv` address. +func (ei *AVEncryptionInfo) GetIvAddr() **uint8 { + return (**uint8)(unsafe.Pointer(&ei.iv)) +} + +// Custom: GetIvSize gets `AVEncryptionInfo.iv_size` value. +func (ei *AVEncryptionInfo) GetIvSize() uint32 { + return (uint32)(ei.iv_size) +} + +// Custom: SetIvSize sets `AVEncryptionInfo.iv_size` value. +func (ei *AVEncryptionInfo) SetIvSize(v uint32) { + ei.iv_size = (C.uint32_t)(v) +} + +// Custom: GetIvSizeAddr gets `AVEncryptionInfo.iv_size` address. +func (ei *AVEncryptionInfo) GetIvSizeAddr() *uint32 { + return (*uint32)(&ei.iv_size) +} + +// Custom: GetSubsamples gets `AVEncryptionInfo.subsamples` value. +func (ei *AVEncryptionInfo) GetSubsamples() *AVSubsampleEncryptionInfo { + return (*AVSubsampleEncryptionInfo)(ei.subsamples) +} + +// Custom: SetSubsamples sets `AVEncryptionInfo.subsamples` value. +func (ei *AVEncryptionInfo) SetSubsamples(v *AVSubsampleEncryptionInfo) { + ei.subsamples = (*C.struct_AVSubsampleEncryptionInfo)(v) +} + +// Custom: GetSubsamplesAddr gets `AVEncryptionInfo.subsamples` address. +func (ei *AVEncryptionInfo) GetSubsamplesAddr() **AVSubsampleEncryptionInfo { + return (**AVSubsampleEncryptionInfo)(unsafe.Pointer(&ei.subsamples)) +} + +// Custom: GetSubsampleCount gets `AVEncryptionInfo.subsample_count` value. +func (ei *AVEncryptionInfo) GetSubsampleCount() uint32 { + return (uint32)(ei.subsample_count) +} + +// Custom: SetSubsampleCount sets `AVEncryptionInfo.subsample_count` value. +func (ei *AVEncryptionInfo) SetSubsampleCount(v uint32) { + ei.subsample_count = (C.uint32_t)(v) +} + +// Custom: GetSubsampleCountAddr gets `AVEncryptionInfo.subsample_count` address. +func (ei *AVEncryptionInfo) GetSubsampleCountAddr() *uint32 { + return (*uint32)(&ei.subsample_count) +} + +// AVEncryptionInitInfo +type AVEncryptionInitInfo C.struct_AVEncryptionInitInfo + +// Custom: GetSystemId gets `AVEncryptionInitInfo.system_id` value. +func (eii *AVEncryptionInitInfo) GetSystemId() *uint8 { + return (*uint8)(eii.system_id) +} + +// Custom: SetSystemId sets `AVEncryptionInitInfo.system_id` value. +func (eii *AVEncryptionInitInfo) SetSystemId(v *uint8) { + eii.system_id = (*C.uint8_t)(v) +} + +// Custom: GetSystemIdAddr gets `AVEncryptionInitInfo.system_id` address. +func (eii *AVEncryptionInitInfo) GetSystemIdAddr() **uint8 { + return (**uint8)(unsafe.Pointer(&eii.system_id)) +} + +// Custom: GetSystemIdSize gets `AVEncryptionInitInfo.system_id_size` value. +func (eii *AVEncryptionInitInfo) GetSystemIdSize() uint32 { + return (uint32)(eii.system_id_size) +} + +// Custom: SetSystemIdSize sets `AVEncryptionInitInfo.system_id_size` value. +func (eii *AVEncryptionInitInfo) SetSystemIdSize(v uint32) { + eii.system_id_size = (C.uint32_t)(v) +} + +// Custom: GetSystemIdSizeAddr gets `AVEncryptionInitInfo.system_id_size` address. +func (eii *AVEncryptionInitInfo) GetSystemIdSizeAddr() *uint32 { + return (*uint32)(&eii.system_id_size) +} + +// Custom: GetKeyIds gets `AVEncryptionInitInfo.key_ids` value. +func (eii *AVEncryptionInitInfo) GetKeyIds() []*uint8 { + return unsafe.Slice((**uint8)(unsafe.Pointer(eii.key_ids)), eii.key_id_size) +} + +// Custom: SetKeyIds sets `AVEncryptionInitInfo.key_ids` value. +func (eii *AVEncryptionInitInfo) SetKeyIds(v **uint8) { + eii.key_ids = (**C.uint8_t)(unsafe.Pointer(v)) +} + +// Custom: GetKeyIdsAddr gets `AVEncryptionInitInfo.key_ids` address. +func (eii *AVEncryptionInitInfo) GetKeyIdsAddr() ***uint8 { + return (***uint8)(unsafe.Pointer(&eii.key_ids)) +} + +// Custom: GetNumKeyIds gets `AVEncryptionInitInfo.num_key_ids` value. +func (eii *AVEncryptionInitInfo) GetNumKeyIds() uint32 { + return (uint32)(eii.num_key_ids) +} + +// Custom: SetNumKeyIds sets `AVEncryptionInitInfo.num_key_ids` value. +func (eii *AVEncryptionInitInfo) SetNumKeyIds(v uint32) { + eii.num_key_ids = (C.uint32_t)(v) +} + +// Custom: GetNumKeyIdsAddr gets `AVEncryptionInitInfo.num_key_ids` address. +func (eii *AVEncryptionInitInfo) GetNumKeyIdsAddr() *uint32 { + return (*uint32)(&eii.num_key_ids) +} + +// Custom: GetKeyIdSize gets `AVEncryptionInitInfo.key_id_size` value. +func (eii *AVEncryptionInitInfo) GetKeyIdSize() uint32 { + return (uint32)(eii.key_id_size) +} + +// Custom: SetKeyIdSize sets `AVEncryptionInitInfo.key_id_size` value. +func (eii *AVEncryptionInitInfo) SetKeyIdSize(v uint32) { + eii.key_id_size = (C.uint32_t)(v) +} + +// Custom: GetKeyIdSizeAddr gets `AVEncryptionInitInfo.key_id_size` address. +func (eii *AVEncryptionInitInfo) GetKeyIdSizeAddr() *uint32 { + return (*uint32)(&eii.key_id_size) +} + +// Custom: GetData gets `AVEncryptionInitInfo.data` value. +func (eii *AVEncryptionInitInfo) GetData() *uint8 { + return (*uint8)(eii.data) +} + +// Custom: SetData sets `AVEncryptionInitInfo.data` value. +func (eii *AVEncryptionInitInfo) SetData(v *uint8) { + eii.data = (*C.uint8_t)(v) +} + +// Custom: GetDataAddr gets `AVEncryptionInitInfo.data` address. +func (eii *AVEncryptionInitInfo) GetDataAddr() **uint8 { + return (**uint8)(unsafe.Pointer(&eii.data)) +} + +// Custom: GetDataSize gets `AVEncryptionInitInfo.data_size` value. +func (eii *AVEncryptionInitInfo) GetDataSize() uint32 { + return (uint32)(eii.data_size) +} + +// Custom: SetDataSize sets `AVEncryptionInitInfo.data_size` value. +func (eii *AVEncryptionInitInfo) SetDataSize(v uint32) { + eii.data_size = (C.uint32_t)(v) +} + +// Custom: GetDataSizeAddr gets `AVEncryptionInitInfo.data_size` address. +func (eii *AVEncryptionInitInfo) GetDataSizeAddr() *uint32 { + return (*uint32)(&eii.data_size) +} + +// Custom: GetNext gets `AVEncryptionInitInfo.next` value. +func (eii *AVEncryptionInitInfo) GetNext() *AVEncryptionInitInfo { + return (*AVEncryptionInitInfo)(eii.next) +} + +// Custom: SetNext sets `AVEncryptionInitInfo.next` value. +func (eii *AVEncryptionInitInfo) SetNext(v *AVEncryptionInitInfo) { + eii.next = (*C.struct_AVEncryptionInitInfo)(v) +} + +// Custom: GetNextAddr gets `AVEncryptionInitInfo.next` address. +func (eii *AVEncryptionInitInfo) GetNextAddr() **AVEncryptionInitInfo { + return (**AVEncryptionInitInfo)(unsafe.Pointer(&eii.next)) +} + +// AvEncryptionInfoAlloc allocates an AVEncryptionInfo structure and sub-pointers to hold the given +// number of subsamples. +func AvEncryptionInfoAlloc(subsampleCount, keyIdSize, ivSize uint32) *AVEncryptionInfo { + return (*AVEncryptionInfo)(C.av_encryption_info_alloc( + (C.uint32_t)(subsampleCount), (C.uint32_t)(keyIdSize), (C.uint32_t)(ivSize))) +} + +// AvEncryptionInfoClone allocates an AVEncryptionInfo structure with a copy of the given data. +func AvEncryptionInfoClone(info *AVEncryptionInfo) *AVEncryptionInfo { + return (*AVEncryptionInfo)(C.av_encryption_info_clone((*C.struct_AVEncryptionInfo)(info))) +} + +// AvEncryptionInfoFree frees the given encryption info object. +func AvEncryptionInfoFree(info *AVEncryptionInfo) { + C.av_encryption_info_free((*C.struct_AVEncryptionInfo)(info)) +} + +// AvEncryptionInfoGetSideData creates a copy of the AVEncryptionInfo that is contained +// in the given side data. +func AvEncryptionInfoGetSideData(sideData *uint8, sideDataSize uintptr) *AVEncryptionInfo { + return (*AVEncryptionInfo)(C.av_encryption_info_get_side_data( + (*C.uint8_t)(sideData), (C.size_t)(sideDataSize))) +} + +// AvEncryptionInfoAddSideData allocates and initializes side data that holds a copy +// of the given encryption info. +func AvEncryptionInfoAddSideData(info *AVEncryptionInfo, sideDataSize *uintptr) *uint8 { + return (*uint8)(C.av_encryption_info_add_side_data( + (*C.struct_AVEncryptionInfo)(info), (*C.size_t)(unsafe.Pointer(sideDataSize)))) +} + +// AvEncryptionInitInfoAlloc allocates an AVEncryptionInitInfo structure and sub-pointers to hold the +// given sizes. +func AvEncryptionInitInfoAlloc(systemIdSize, numKeyIds, keyIdSize, dataSize uint32) *AVEncryptionInitInfo { + return (*AVEncryptionInitInfo)(C.av_encryption_init_info_alloc( + (C.uint32_t)(systemIdSize), (C.uint32_t)(numKeyIds), (C.uint32_t)(keyIdSize), (C.uint32_t)(dataSize))) +} + +// AvEncryptionInitInfoFree frees the given encryption init info object. +func AvEncryptionInitInfoFree(info *AVEncryptionInitInfo) { + C.av_encryption_init_info_free((*C.struct_AVEncryptionInitInfo)(info)) +} + +// AvEncryptionInitInfoGetSideData creates a copy of the AVEncryptionInitInfo that is contained in the given +// side data. +func AvEncryptionInitInfoGetSideData(sideData *uint8, sideDataSize uintptr) *AVEncryptionInitInfo { + return (*AVEncryptionInitInfo)(C.av_encryption_init_info_get_side_data( + (*C.uint8_t)(sideData), (C.size_t)(sideDataSize))) +} + +// AvEncryptionInitInfoAddSideData allocates and initializes side data that holds a copy +// of the given encryption init info. +func AvEncryptionInitInfoAddSideData(info *AVEncryptionInitInfo, sideDataSize *uintptr) *uint8 { + return (*uint8)(C.av_encryption_init_info_add_side_data( + (*C.struct_AVEncryptionInitInfo)(info), (*C.size_t)(unsafe.Pointer(sideDataSize)))) +} diff --git a/avutil_eval.go b/avutil_eval.go new file mode 100644 index 0000000..3601fad --- /dev/null +++ b/avutil_eval.go @@ -0,0 +1,23 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVExpr +type AVExpr C.struct_AVExpr + +// NONEED: av_expr_parse_and_eval + +// NONEED: av_expr_parse + +// NONEED: av_expr_eval + +// NONEED: av_expr_count_vars + +// NONEED: av_expr_count_func + +// NONEED: av_expr_free + +// NONEED: av_strtod diff --git a/avutil_fifo.go b/avutil_fifo.go new file mode 100644 index 0000000..360a8da --- /dev/null +++ b/avutil_fifo.go @@ -0,0 +1,110 @@ +package ffmpeg + +/* +#include + +typedef void (*av_fifo_peek_func)(void*, void*, int); +typedef void (*av_fifo_read_func)(void*, void*, int); +typedef int (*av_fifo_write_func)(void*, void*, int); + +*/ +import "C" +import "unsafe" + +// AVFifoBuffer +type AVFifoBuffer C.struct_AVFifoBuffer + +// AvFifoAlloc initializes an AVFifoBuffer. +func AvFifoAlloc[T HelperInteger](size T) *AVFifoBuffer { + return (*AVFifoBuffer)(C.av_fifo_alloc((C.uint)(size))) +} + +// AvFifoAllocArray initializes an AVFifoBuffer. +func AvFifoAllocArray[U, V HelperInteger](nmemb U, size V) *AVFifoBuffer { + return (*AVFifoBuffer)(C.av_fifo_alloc_array((C.size_t)(nmemb), (C.size_t)(size))) +} + +// AvFifoFree frees an AVFifoBuffer. +func AvFifoFree(f *AVFifoBuffer) { + C.av_fifo_free((*C.struct_AVFifoBuffer)(f)) +} + +// AvFifoFreep frees an AVFifoBuffer and reset pointer to NULL. +func AvFifoFreep(f **AVFifoBuffer) { + C.av_fifo_freep((**C.struct_AVFifoBuffer)(unsafe.Pointer(f))) +} + +// AvFifoReset resets the AVFifoBuffer to the state right after AvFifoAlloc, in particular it is emptied. +func AvFifoReset(f *AVFifoBuffer) { + C.av_fifo_reset((*C.struct_AVFifoBuffer)(f)) +} + +// AvFifoSize returns the amount of data in bytes in the AVFifoBuffer, that is the +// amount of data you can read from it. +func AvFifoSize(f *AVFifoBuffer) int32 { + return (int32)(C.av_fifo_size((*C.struct_AVFifoBuffer)(f))) +} + +// AvFifoSpace returns the amount of space in bytes in the AVFifoBuffer, that is the +// amount of data you can write into it. +func AvFifoSpace(f *AVFifoBuffer) int32 { + return (int32)(C.av_fifo_space((*C.struct_AVFifoBuffer)(f))) +} + +// typedef void (*av_fifo_peek_func)(void*, void*, int); +type AvFifoPeekFunc = C.av_fifo_peek_func + +// AvFifoGenericPeekAt feeds data at specific position from an AVFifoBuffer to a user-supplied callback. +func AvFifoGenericPeekAt(f *AVFifoBuffer, dest CVoidPointer, + offset, bufSize int32, fn AvFifoPeekFunc) int32 { + return (int32)(C.av_fifo_generic_peek_at((*C.struct_AVFifoBuffer)(f), + VoidPointer(dest), (C.int)(offset), (C.int)(bufSize), (C.av_fifo_peek_func)(fn))) +} + +// AvFifoGenericPeek feeds data from an AVFifoBuffer to a user-supplied callback. +func AvFifoGenericPeek(f *AVFifoBuffer, dest CVoidPointer, + bufSize int32, fn AvFifoPeekFunc) int32 { + return (int32)(C.av_fifo_generic_peek((*C.struct_AVFifoBuffer)(f), + VoidPointer(dest), (C.int)(bufSize), (C.av_fifo_peek_func)(fn))) +} + +// typedef void (*av_fifo_read_func)(void*, void*, int); +type AvFifoReadFunc = C.av_fifo_read_func + +// AvFifoGenericRead feeds data from an AVFifoBuffer to a user-supplied callback. +func AvFifoGenericRead(f *AVFifoBuffer, dest CVoidPointer, + bufSize int32, fn AvFifoReadFunc) int32 { + return (int32)(C.av_fifo_generic_read((*C.struct_AVFifoBuffer)(f), + VoidPointer(dest), (C.int)(bufSize), (C.av_fifo_read_func)(fn))) +} + +// typedef int (*av_fifo_write_func)(void*, void*, int); +type AvFifoWriteFunc = C.av_fifo_write_func + +// AvFifoGenericWrite feeds data from a user-supplied callback to an AVFifoBuffer. +func AvFifoGenericWrite(f *AVFifoBuffer, src CVoidPointer, + size int32, fn AvFifoWriteFunc) int32 { + return (int32)(C.av_fifo_generic_write((*C.struct_AVFifoBuffer)(f), + VoidPointer(src), (C.int)(size), (C.av_fifo_write_func)(fn))) +} + +// AvFifoRealloc2 resizes an AVFifoBuffer. +func AvFifoRealloc2[T HelperInteger](f *AVFifoBuffer, size T) int32 { + return (int32)(C.av_fifo_realloc2((*C.struct_AVFifoBuffer)(f), (C.uint)(size))) +} + +// AvFifoGrow enlarges an AVFifoBuffer. +func AvFifoGrow[T HelperInteger](f *AVFifoBuffer, additionalSpace T) int32 { + return (int32)(C.av_fifo_grow((*C.struct_AVFifoBuffer)(f), (C.uint)(additionalSpace))) +} + +// AvFifoDrain reads and discards the specified amount of data from an AVFifoBuffer. +func AvFifoDrain[T HelperInteger](f *AVFifoBuffer, size T) { + C.av_fifo_drain((*C.struct_AVFifoBuffer)(f), (C.int)(size)) +} + +// AvFifoPeek2 returns a pointer to the data stored in a FIFO buffer at a certain offset. +// The FIFO buffer is not modified. +func AvFifoPeek2[T HelperInteger](f *AVFifoBuffer, offs T) *uint8 { + return (*uint8)(C.av_fifo_peek2((*C.struct_AVFifoBuffer)(f), (C.int)(offs))) +} diff --git a/avutil_film_grain_params.go b/avutil_film_grain_params.go new file mode 100644 index 0000000..e0e198b --- /dev/null +++ b/avutil_film_grain_params.go @@ -0,0 +1,369 @@ +package ffmpeg + +/* +#include + +AVFilmGrainAOMParams get_av_film_grain_params_codec_aom(AVFilmGrainParams *v) { + return v->codec.aom; +} + +void set_av_film_grain_params_codec_aom(AVFilmGrainParams *v, AVFilmGrainAOMParams p) { + v->codec.aom = p; +} + +AVFilmGrainAOMParams* get_av_film_grain_params_codec_aom_addr(AVFilmGrainParams *v) { + return &v->codec.aom; +} +*/ +import "C" +import "unsafe" + +// AVFilmGrainParamsType +type AVFilmGrainParamsType = C.enum_AVFilmGrainParamsType + +const ( + AV_FILM_GRAIN_PARAMS_NONE = AVFilmGrainParamsType(C.AV_FILM_GRAIN_PARAMS_NONE) + AV_FILM_GRAIN_PARAMS_AV1 = AVFilmGrainParamsType(C.AV_FILM_GRAIN_PARAMS_AV1) +) + +// AVFilmGrainAOMParams +type AVFilmGrainAOMParams C.struct_AVFilmGrainAOMParams + +// Custom: GetNumYPoints gets `AVFilmGrainAOMParams.num_y_points` value. +func (aomp *AVFilmGrainAOMParams) GetNumYPoints() int32 { + return (int32)(aomp.num_y_points) +} + +// Custom: SetNumYPoints sets `AVFilmGrainAOMParams.num_y_points` value. +func (aomp *AVFilmGrainAOMParams) SetNumYPoints(v int32) { + aomp.num_y_points = (C.int)(v) +} + +// Custom: GetNumYPointsAddr gets `AVFilmGrainAOMParams.num_y_points` address. +func (aomp *AVFilmGrainAOMParams) GetNumYPointsAddr() *int32 { + return (*int32)(&aomp.num_y_points) +} + +// Custom: GetYPoints gets `AVFilmGrainAOMParams.y_points` value. +func (aomp *AVFilmGrainAOMParams) GetYPoints() (v [][]uint8) { + for i := 0; i < 14; i++ { + v = append(v, unsafe.Slice((*uint8)(&aomp.y_points[i][0]), 2)) + } + return v +} + +// Custom: SetYPoints sets `AVFilmGrainAOMParams.y_points` value. +func (aomp *AVFilmGrainAOMParams) SetYPoints(v [][]uint8) { + for i := 0; i < FFMIN(len(v), 14); i++ { + for j := 0; j < FFMIN(len(v[i]), 2); j++ { + aomp.y_points[i][j] = (C.uint8_t)(v[i][j]) + } + } +} + +// Custom: GetYPointsAddr gets `AVFilmGrainAOMParams.y_points` address. +func (aomp *AVFilmGrainAOMParams) GetYPointsAddr() **uint8 { + return (**uint8)(unsafe.Pointer(&aomp.y_points)) +} + +// Custom: GetChromaScalingFromLuma gets `AVFilmGrainAOMParams.chroma_scaling_from_luma` value. +func (aomp *AVFilmGrainAOMParams) GetChromaScalingFromLuma() int32 { + return (int32)(aomp.chroma_scaling_from_luma) +} + +// Custom: SetChromaScalingFromLuma sets `AVFilmGrainAOMParams.chroma_scaling_from_luma` value. +func (aomp *AVFilmGrainAOMParams) SetChromaScalingFromLuma(v int32) { + aomp.chroma_scaling_from_luma = (C.int)(v) +} + +// Custom: GetChromaScalingFromLumaAddr gets `AVFilmGrainAOMParams.chroma_scaling_from_luma` address. +func (aomp *AVFilmGrainAOMParams) GetChromaScalingFromLumaAddr() *int32 { + return (*int32)(&aomp.chroma_scaling_from_luma) +} + +// Custom: GetNumUvPoints gets `AVFilmGrainAOMParams.num_uv_points` value. +func (aomp *AVFilmGrainAOMParams) GetNumUvPoints() []int32 { + return unsafe.Slice((*int32)(&aomp.num_uv_points[0]), 2) +} + +// Custom: SetNumUvPoints sets `AVFilmGrainAOMParams.num_uv_points` value. +func (aomp *AVFilmGrainAOMParams) SetNumUvPoints(v []int32) { + for i := 0; i < FFMIN(len(v), 2); i++ { + aomp.num_uv_points[i] = (C.int)(v[i]) + } +} + +// Custom: GetNumUvPointsAddr gets `AVFilmGrainAOMParams.num_uv_points` address. +func (aomp *AVFilmGrainAOMParams) GetNumUvPointsAddr() **int32 { + return (**int32)(unsafe.Pointer(&aomp.num_uv_points)) +} + +// Custom: GetUvPoints gets `AVFilmGrainAOMParams.uv_points` value. +func (aomp *AVFilmGrainAOMParams) GetUvPoints() (v [][][]uint8) { + for i := 0; i < 2; i++ { + tmp := [][]uint8{} + for j := 0; j < 10; j++ { + tmp = append(tmp, unsafe.Slice((*uint8)(&aomp.uv_points[i][j][0]), 2)) + } + v = append(v, tmp) + } + return v +} + +// Custom: SetUvPoints sets `AVFilmGrainAOMParams.uv_points` value. +func (aomp *AVFilmGrainAOMParams) SetUvPoints(v [][][]uint8) { + for i := 0; i < FFMIN(len(v), 2); i++ { + for j := 0; j < FFMIN(len(v[i]), 10); j++ { + for k := 0; k < FFMIN(len(v[i][j]), 2); k++ { + aomp.uv_points[i][j][k] = (C.uint8_t)(v[i][j][k]) + } + } + } +} + +// Custom: GetUvPointsAddr gets `AVFilmGrainAOMParams.uv_points` address. +func (aomp *AVFilmGrainAOMParams) GetUvPointsAddr() **uint8 { + return (**uint8)(unsafe.Pointer(&aomp.uv_points)) +} + +// Custom: GetScalingShift gets `AVFilmGrainAOMParams.scaling_shift` value. +func (aomp *AVFilmGrainAOMParams) GetScalingShift() int32 { + return (int32)(aomp.scaling_shift) +} + +// Custom: SetScalingShift sets `AVFilmGrainAOMParams.scaling_shift` value. +func (aomp *AVFilmGrainAOMParams) SetScalingShift(v int32) { + aomp.scaling_shift = (C.int)(v) +} + +// Custom: GetScalingShiftAddr gets `AVFilmGrainAOMParams.scaling_shift` address. +func (aomp *AVFilmGrainAOMParams) GetScalingShiftAddr() *int32 { + return (*int32)(&aomp.scaling_shift) +} + +// Custom: GetArCoeffLag gets `AVFilmGrainAOMParams.ar_coeff_lag` value. +func (aomp *AVFilmGrainAOMParams) GetArCoeffLag() int32 { + return (int32)(aomp.ar_coeff_lag) +} + +// Custom: SetArCoeffLag sets `AVFilmGrainAOMParams.ar_coeff_lag` value. +func (aomp *AVFilmGrainAOMParams) SetArCoeffLag(v int32) { + aomp.ar_coeff_lag = (C.int)(v) +} + +// Custom: GetArCoeffLagAddr gets `AVFilmGrainAOMParams.ar_coeff_lag` address. +func (aomp *AVFilmGrainAOMParams) GetArCoeffLagAddr() *int32 { + return (*int32)(&aomp.ar_coeff_lag) +} + +// Custom: GetArCoeffsY gets `AVFilmGrainAOMParams.ar_coeffs_y` value. +func (aomp *AVFilmGrainAOMParams) GetArCoeffsY() []int8 { + return unsafe.Slice((*int8)(&aomp.ar_coeffs_y[0]), 24) +} + +// Custom: SetArCoeffsY sets `AVFilmGrainAOMParams.ar_coeffs_y` value. +func (aomp *AVFilmGrainAOMParams) SetArCoeffsY(v []int8) { + for i := 0; i < FFMIN(len(v), 24); i++ { + aomp.ar_coeffs_y[i] = (C.int8_t)(v[i]) + } +} + +// Custom: GetArCoeffsYAddr gets `AVFilmGrainAOMParams.ar_coeffs_y` address. +func (aomp *AVFilmGrainAOMParams) GetArCoeffsYAddr() **int8 { + return (**int8)(unsafe.Pointer(&aomp.ar_coeffs_y)) +} + +// Custom: GetArCoeffsUv gets `AVFilmGrainAOMParams.ar_coeffs_uv` value. +func (aomp *AVFilmGrainAOMParams) GetArCoeffsUv() (v [][]int8) { + for i := 0; i < 2; i++ { + v = append(v, unsafe.Slice((*int8)(&aomp.ar_coeffs_uv[i][0]), 25)) + } + return v +} + +// Custom: SetArCoeffsUv sets `AVFilmGrainAOMParams.ar_coeffs_uv` value. +func (aomp *AVFilmGrainAOMParams) SetArCoeffsUv(v [][]int8) { + for i := 0; i < FFMIN(len(v), 2); i++ { + for j := 0; j < FFMIN(len(v[i]), 25); j++ { + aomp.ar_coeffs_uv[i][j] = (C.int8_t)(v[i][j]) + } + } +} + +// Custom: GetArCoeffsUvAddr gets `AVFilmGrainAOMParams.ar_coeffs_uv` address. +func (aomp *AVFilmGrainAOMParams) GetArCoeffsUvAddr() **int8 { + return (**int8)(unsafe.Pointer(&aomp.ar_coeffs_uv)) +} + +// Custom: GetArCoeffShift gets `AVFilmGrainAOMParams.ar_coeff_shift` value. +func (aomp *AVFilmGrainAOMParams) GetArCoeffShift() int32 { + return (int32)(aomp.ar_coeff_shift) +} + +// Custom: SetArCoeffShift sets `AVFilmGrainAOMParams.ar_coeff_shift` value. +func (aomp *AVFilmGrainAOMParams) SetArCoeffShift(v int32) { + aomp.ar_coeff_shift = (C.int)(v) +} + +// Custom: GetArCoeffShiftAddr gets `AVFilmGrainAOMParams.ar_coeff_shift` address. +func (aomp *AVFilmGrainAOMParams) GetArCoeffShiftAddr() *int32 { + return (*int32)(&aomp.ar_coeff_shift) +} + +// Custom: GetGrainScaleShift gets `AVFilmGrainAOMParams.grain_scale_shift` value. +func (aomp *AVFilmGrainAOMParams) GetGrainScaleShift() int32 { + return (int32)(aomp.grain_scale_shift) +} + +// Custom: SetGrainScaleShift sets `AVFilmGrainAOMParams.grain_scale_shift` value. +func (aomp *AVFilmGrainAOMParams) SetGrainScaleShift(v int32) { + aomp.grain_scale_shift = (C.int)(v) +} + +// Custom: GetGrainScaleShiftAddr gets `AVFilmGrainAOMParams.grain_scale_shift` address. +func (aomp *AVFilmGrainAOMParams) GetGrainScaleShiftAddr() *int32 { + return (*int32)(&aomp.grain_scale_shift) +} + +// Custom: GetUvMult gets `AVFilmGrainAOMParams.uv_mult` value. +func (aomp *AVFilmGrainAOMParams) GetUvMult() []int32 { + return unsafe.Slice((*int32)(&aomp.uv_mult[0]), 2) +} + +// Custom: SetUvMult sets `AVFilmGrainAOMParams.uv_mult` value. +func (aomp *AVFilmGrainAOMParams) SetUvMult(v []int32) { + for i := 0; i < FFMIN(len(v), 2); i++ { + aomp.uv_mult[i] = (C.int)(v[i]) + } +} + +// Custom: GetUvMultAddr gets `AVFilmGrainAOMParams.uv_mult` address. +func (aomp *AVFilmGrainAOMParams) GetUvMultAddr() **int32 { + return (**int32)(unsafe.Pointer(&aomp.uv_mult)) +} + +// Custom: GetUvMultLuma gets `AVFilmGrainAOMParams.uv_mult_luma` value. +func (aomp *AVFilmGrainAOMParams) GetUvMultLuma() []int32 { + return unsafe.Slice((*int32)(&aomp.uv_mult_luma[0]), 2) +} + +// Custom: SetUvMultLuma sets `AVFilmGrainAOMParams.uv_mult_luma` value. +func (aomp *AVFilmGrainAOMParams) SetUvMultLuma(v []int32) { + for i := 0; i < FFMIN(len(v), 2); i++ { + aomp.uv_mult_luma[i] = (C.int)(v[i]) + } +} + +// Custom: GetUvMultLumaAddr gets `AVFilmGrainAOMParams.uv_mult_luma` address. +func (aomp *AVFilmGrainAOMParams) GetUvMultLumaAddr() **int32 { + return (**int32)(unsafe.Pointer(&aomp.uv_mult_luma)) +} + +// Custom: GetUvOffset gets `AVFilmGrainAOMParams.uv_offset` value. +func (aomp *AVFilmGrainAOMParams) GetUvOffset() []int32 { + return unsafe.Slice((*int32)(&aomp.uv_offset[0]), 2) +} + +// Custom: SetUvOffset sets `AVFilmGrainAOMParams.uv_offset` value. +func (aomp *AVFilmGrainAOMParams) SetUvOffset(v []int32) { + for i := 0; i < FFMIN(len(v), 2); i++ { + aomp.uv_offset[i] = (C.int)(v[i]) + } +} + +// Custom: GetUvOffsetAddr gets `AVFilmGrainAOMParams.uv_offset` address. +func (aomp *AVFilmGrainAOMParams) GetUvOffsetAddr() **int32 { + return (**int32)(unsafe.Pointer(&aomp.uv_offset)) +} + +// Custom: GetOverlapFlag gets `AVFilmGrainAOMParams.overlap_flag` value. +func (aomp *AVFilmGrainAOMParams) GetOverlapFlag() int32 { + return (int32)(aomp.overlap_flag) +} + +// Custom: SetOverlapFlag sets `AVFilmGrainAOMParams.overlap_flag` value. +func (aomp *AVFilmGrainAOMParams) SetOverlapFlag(v int32) { + aomp.overlap_flag = (C.int)(v) +} + +// Custom: GetOverlapFlagAddr gets `AVFilmGrainAOMParams.overlap_flag` address. +func (aomp *AVFilmGrainAOMParams) GetOverlapFlagAddr() *int32 { + return (*int32)(&aomp.overlap_flag) +} + +// Custom: GetLimitOutputRange gets `AVFilmGrainAOMParams.limit_outputrange` value. +func (aomp *AVFilmGrainAOMParams) GetLimitOutputRange() int32 { + return (int32)(aomp.limit_output_range) +} + +// Custom: SetLimitOutputRange sets `AVFilmGrainAOMParams.limit_outputrange` value. +func (aomp *AVFilmGrainAOMParams) SetLimitOutputRange(v int32) { + aomp.limit_output_range = (C.int)(v) +} + +// Custom: GetLimitOutputRangeAddr gets `AVFilmGrainAOMParams.limit_outputrange` address. +func (aomp *AVFilmGrainAOMParams) GetLimitOutputRangeAddr() *int32 { + return (*int32)(&aomp.limit_output_range) +} + +// AVFilmGrainParams +type AVFilmGrainParams C.struct_AVFilmGrainParams + +// Custom: GetType gets `AVFilmGrainParams.type` value. +func (fgp *AVFilmGrainParams) GetType() AVFilmGrainParamsType { + return (AVFilmGrainParamsType)(fgp._type) +} + +// Custom: SetType sets `AVFilmGrainParams.type` value. +func (fgp *AVFilmGrainParams) SetType(v AVFilmGrainParamsType) { + fgp._type = (C.enum_AVFilmGrainParamsType)(v) +} + +// Custom: GetTypeAddr gets `AVFilmGrainParams.type` address. +func (fgp *AVFilmGrainParams) GetTypeAddr() *AVFilmGrainParamsType { + return (*AVFilmGrainParamsType)(&fgp._type) +} + +// Custom: GetSeed gets `AVFilmGrainParams.seed` value. +func (fgp *AVFilmGrainParams) GetSeed() uint64 { + return (uint64)(fgp.seed) +} + +// Custom: SetSeed sets `AVFilmGrainParams.seed` value. +func (fgp *AVFilmGrainParams) SetSeed(v uint64) { + fgp.seed = (C.uint64_t)(v) +} + +// Custom: GetSeedAddr gets `AVFilmGrainParams.seed` address. +func (fgp *AVFilmGrainParams) GetSeedAddr() *uint64 { + return (*uint64)(&fgp.seed) +} + +// Custom: GetCodecAom gets `AVFilmGrainParams.codec_aom` value. +func (fgp *AVFilmGrainParams) GetCodecAom() AVFilmGrainAOMParams { + return (AVFilmGrainAOMParams)( + C.get_av_film_grain_params_codec_aom((*C.struct_AVFilmGrainParams)(fgp))) +} + +// Custom: SetCodecAom sets `AVFilmGrainParams.codec_aom` value. +func (fgp *AVFilmGrainParams) SetCodecAom(v AVFilmGrainAOMParams) { + C.set_av_film_grain_params_codec_aom((*C.struct_AVFilmGrainParams)(fgp), + (C.struct_AVFilmGrainAOMParams)(v)) +} + +// Custom: GetCodecAomAddr gets `AVFilmGrainParams.codec_aom` address. +func (fgp *AVFilmGrainParams) GetCodecAomAddr() *AVFilmGrainAOMParams { + return (*AVFilmGrainAOMParams)(C.get_av_film_grain_params_codec_aom_addr( + (*C.struct_AVFilmGrainParams)(fgp))) +} + +// AvFilmGrainParamsAlloc allocates an AVFilmGrainParams structure and set its fields to +// default values. +func AvFilmGrainParamsAlloc(size *uintptr) *AVFilmGrainParams { + return (*AVFilmGrainParams)(C.av_film_grain_params_alloc((*C.size_t)(unsafe.Pointer(size)))) +} + +// AvFilmGrainParamsCreateSideData allocates a complete AVFilmGrainParams and add it to the frame. +func AvFilmGrainParamsCreateSideData(frame *AVFrame) *AVFilmGrainParams { + return (*AVFilmGrainParams)(C.av_film_grain_params_create_side_data((*C.struct_AVFrame)(frame))) +} diff --git a/avutil_frame.go b/avutil_frame.go index 8ba6584..b8105d4 100644 --- a/avutil_frame.go +++ b/avutil_frame.go @@ -276,14 +276,6 @@ func (frame *AVFrame) GetExtendedDataAddr() ***uint8 { return (***uint8)(unsafe.Pointer(&frame.extended_data)) } -// Custom: GetExtendedDataIdx gets `AVFrame.extended_data` index value. -func (frame *AVFrame) GetExtendedDataIdx(idx int) *uint8 { - if frame.extended_data == nil { - return nil - } - return (*uint8)(*PointerOffset(frame.extended_data, idx)) -} - // Custom: GetWidth gets `AVFrame.width` value. func (frame *AVFrame) GetWidth() int32 { return (int32)(frame.width) @@ -359,17 +351,17 @@ func (frame *AVFrame) GetKeyFrameAddr() *int32 { return (*int32)(&frame.key_frame) } -// Custom: GetPictType gets `AVFrame.pict_type` value. +// Custom: GetPictType gets `AVFrame.picttype` value. func (frame *AVFrame) GetPictType() AVPictureType { return (AVPictureType)(frame.pict_type) } -// Custom: SetPictType sets `AVFrame.pict_type` value. +// Custom: SetPictType sets `AVFrame.picttype` value. func (frame *AVFrame) SetPictType(v AVPictureType) { frame.pict_type = (C.enum_AVPictureType)(v) } -// Custom: GetPictTypeAddr gets `AVFrame.pict_type` address. +// Custom: GetPictTypeAddr gets `AVFrame.picttype` address. func (frame *AVFrame) GetPictTypeAddr() *AVPictureType { return (*AVPictureType)(unsafe.Pointer(&frame.pict_type)) } @@ -705,17 +697,17 @@ func (frame *AVFrame) GetFlagsAddr() *int32 { return (*int32)(&frame.flags) } -// Custom: GetColorRange gets `AVFrame.color_range` value. +// Custom: GetColorRange gets `AVFrame.colorrange` value. func (frame *AVFrame) GetColorRange() AVColorRange { return (AVColorRange)(frame.color_range) } -// Custom: SetColorRange sets `AVFrame.color_range` value. +// Custom: SetColorRange sets `AVFrame.colorrange` value. func (frame *AVFrame) SetColorRange(v AVColorRange) { frame.color_range = (C.enum_AVColorRange)(v) } -// Custom: GetColorRangeAddr gets `AVFrame.color_range` address. +// Custom: GetColorRangeAddr gets `AVFrame.colorrange` address. func (frame *AVFrame) GetColorRangeAddr() *AVColorRange { return (*AVColorRange)(unsafe.Pointer(&frame.color_range)) } @@ -922,17 +914,17 @@ func (frame *AVFrame) GetQstrideAddr() *int32 { return (*int32)(&frame.qstride) } -// Custom: GetQscaleType gets `AVFrame.qscale_type` value. +// Custom: GetQscaleType gets `AVFrame.qscaletype` value. func (frame *AVFrame) GetQscaleType() int32 { return (int32)(frame.qscale_type) } -// Custom: SetQscaleType sets `AVFrame.qscale_type` value. +// Custom: SetQscaleType sets `AVFrame.qscaletype` value. func (frame *AVFrame) SetQscaleType(v int32) { frame.qscale_type = (C.int)(v) } -// Custom: GetQscaleTypeAddr gets `AVFrame.qscale_type` address. +// Custom: GetQscaleTypeAddr gets `AVFrame.qscaletype` address. func (frame *AVFrame) GetQscaleTypeAddr() *int32 { return (*int32)(&frame.qscale_type) } diff --git a/avutil_hash.go b/avutil_hash.go new file mode 100644 index 0000000..0412f76 --- /dev/null +++ b/avutil_hash.go @@ -0,0 +1,73 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +type AVHashContext C.struct_AVHashContext + +// AvHashAlloc allocates a hash context for the algorithm specified by name. +func AvHashAlloc(ctx **AVHashContext, name string) int32 { + namePtr, nameFunc := StringCasting(name) + defer nameFunc() + return (int32)(C.av_hash_alloc( + (**C.struct_AVHashContext)(unsafe.Pointer(ctx)), (*C.char)(namePtr))) +} + +// AvHashNames gets the names of available hash algorithms. +func AvHashNames(i int32) string { + return C.GoString(C.av_hash_names((C.int)(i))) +} + +// AvHashGetName gets the name of the algorithm corresponding to the given hash context. +func AvHashGetName(ctx *AVHashContext) string { + return C.GoString(C.av_hash_get_name((*C.struct_AVHashContext)(ctx))) +} + +const ( + AV_HASH_MAX_SIZE = C.AV_HASH_MAX_SIZE +) + +// AvHashGetSize gets the size of the resulting hash value in bytes. +func AvHashGetSize(ctx *AVHashContext) int32 { + return (int32)(C.av_hash_get_size((*C.struct_AVHashContext)(ctx))) +} + +// AvHashInit initializes or reset a hash context. +func AvHashInit(ctx *AVHashContext) { + C.av_hash_init((*C.struct_AVHashContext)(ctx)) +} + +// AvHashUpdate updates a hash context with additional data. +func AvHashUpdate(ctx *AVHashContext, src *uint8, len int32) { + C.av_hash_update((*C.struct_AVHashContext)(ctx), (*C.uint8_t)(src), (C.int)(len)) +} + +// AvHashFinal finalizes a hash context and compute the actual hash value. +func AvHashFinal(ctx *AVHashContext, dst *uint8) { + C.av_hash_final((*C.struct_AVHashContext)(ctx), (*C.uint8_t)(dst)) +} + +// AvHashFinalBin finalizes a hash context and store the actual hash value in a buffer. +func AvHashFinalBin(ctx *AVHashContext, dst *uint8, size int32) { + C.av_hash_final_bin((*C.struct_AVHashContext)(ctx), (*C.uint8_t)(dst), (C.int)(size)) +} + +// AvHashFinalHex finalizes a hash context and store the hexadecimal representation of the +// actual hash value as a string. +func AvHashFinalHex(ctx *AVHashContext, dst *uint8, size int32) { + C.av_hash_final_hex((*C.struct_AVHashContext)(ctx), (*C.uint8_t)(dst), (C.int)(size)) +} + +// AvHashFinalB64 finalizes a hash context and store the Base64 representation of the +// actual hash value as a string. +func AvHashFinalB64(ctx *AVHashContext, dst *uint8, size int32) { + C.av_hash_final_b64((*C.struct_AVHashContext)(ctx), (*C.uint8_t)(dst), (C.int)(size)) +} + +// AvHashFreep frees hash context and set hash context pointer to `NULL`. +func AvHashFreep(ctx **AVHashContext) { + C.av_hash_freep((**C.struct_AVHashContext)(unsafe.Pointer(ctx))) +} diff --git a/avutil_hdr_dynamic_metadata.go b/avutil_hdr_dynamic_metadata.go new file mode 100644 index 0000000..1525a33 --- /dev/null +++ b/avutil_hdr_dynamic_metadata.go @@ -0,0 +1,629 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +// AVHDRPlusOverlapProcessOption +type AVHDRPlusOverlapProcessOption C.enum_AVHDRPlusOverlapProcessOption + +const ( + AV_HDR_PLUS_OVERLAP_PROCESS_WEIGHTED_AVERAGING = AVHDRPlusOverlapProcessOption( + C.AV_HDR_PLUS_OVERLAP_PROCESS_WEIGHTED_AVERAGING) + AV_HDR_PLUS_OVERLAP_PROCESS_LAYERING = AVHDRPlusOverlapProcessOption( + C.AV_HDR_PLUS_OVERLAP_PROCESS_LAYERING) +) + +// AVHDRPlusPercentile +type AVHDRPlusPercentile C.struct_AVHDRPlusPercentile + +// Custom: GetPercentage gets `AVHDRPlusPercentile.percentage` value. +func (pct *AVHDRPlusPercentile) GetPercentage() uint8 { + return (uint8)(pct.percentage) +} + +// Custom: SetPercentage sets `AVHDRPlusPercentile.percentage` value. +func (pct *AVHDRPlusPercentile) SetPercentage(v uint8) { + pct.percentage = (C.uint8_t)(v) +} + +// Custom: GetPercentageAddr gets `AVHDRPlusPercentile.percentage` address. +func (pct *AVHDRPlusPercentile) GetPercentageAddr() *uint8 { + return (*uint8)(&pct.percentage) +} + +// Custom: GetPercentile gets `AVHDRPlusPercentile.percentile` value. +func (pct *AVHDRPlusPercentile) GetPercentile() AVRational { + return (AVRational)(pct.percentile) +} + +// Custom: SetPercentile sets `AVHDRPlusPercentile.percentile` value. +func (pct *AVHDRPlusPercentile) SetPercentile(v AVRational) { + pct.percentile = (C.struct_AVRational)(v) +} + +// Custom: GetPercentileAddr gets `AVHDRPlusPercentile.percentile` address. +func (pct *AVHDRPlusPercentile) GetPercentileAddr() *AVRational { + return (*AVRational)(&pct.percentile) +} + +// AVHDRPlusColorTransformParams +type AVHDRPlusColorTransformParams C.struct_AVHDRPlusColorTransformParams + +// Custom: GetWindowUpperLeftCornerX gets `AVHDRPlusColorTransformParams.window_upper_left_corner_x` value. +func (ctp *AVHDRPlusColorTransformParams) GetWindowUpperLeftCornerX() AVRational { + return (AVRational)(ctp.window_upper_left_corner_x) +} + +// Custom: SetWindowUpperLeftCornerX sets `AVHDRPlusColorTransformParams.window_upper_left_corner_x` value. +func (ctp *AVHDRPlusColorTransformParams) SetWindowUpperLeftCornerX(v AVRational) { + ctp.window_upper_left_corner_x = (C.struct_AVRational)(v) +} + +// Custom: GetWindowUpperLeftCornerXAddr gets `AVHDRPlusColorTransformParams.window_upper_left_corner_x` address. +func (ctp *AVHDRPlusColorTransformParams) GetWindowUpperLeftCornerXAddr() *AVRational { + return (*AVRational)(&ctp.window_upper_left_corner_x) +} + +// Custom: GetWindowUpperLeftCornerY gets `AVHDRPlusColorTransformParams.window_upper_left_corner_y` value. +func (ctp *AVHDRPlusColorTransformParams) GetWindowUpperLeftCornerY() AVRational { + return (AVRational)(ctp.window_upper_left_corner_y) +} + +// Custom: SetWindowUpperLeftCornerY sets `AVHDRPlusColorTransformParams.window_upper_left_corner_y` value. +func (ctp *AVHDRPlusColorTransformParams) SetWindowUpperLeftCornerY(v AVRational) { + ctp.window_upper_left_corner_y = (C.struct_AVRational)(v) +} + +// Custom: GetWindowUpperLeftCornerYAddr gets `AVHDRPlusColorTransformParams.window_upper_left_corner_y` address. +func (ctp *AVHDRPlusColorTransformParams) GetWindowUpperLeftCornerYAddr() *AVRational { + return (*AVRational)(&ctp.window_upper_left_corner_y) +} + +// Custom: GetWindowLowerRightCornerX gets `AVHDRPlusColorTransformParams.window_lower_right_corner_x` value. +func (ctp *AVHDRPlusColorTransformParams) GetWindowLowerRightCornerX() AVRational { + return (AVRational)(ctp.window_lower_right_corner_x) +} + +// Custom: SetWindowLowerRightCornerX sets `AVHDRPlusColorTransformParams.window_lower_right_corner_x` value. +func (ctp *AVHDRPlusColorTransformParams) SetWindowLowerRightCornerX(v AVRational) { + ctp.window_lower_right_corner_x = (C.struct_AVRational)(v) +} + +// Custom: GetWindowLowerRightCornerXAddr gets `AVHDRPlusColorTransformParams.window_lower_right_corner_x` address. +func (ctp *AVHDRPlusColorTransformParams) GetWindowLowerRightCornerXAddr() *AVRational { + return (*AVRational)(&ctp.window_lower_right_corner_x) +} + +// Custom: GetWindowLowerRightCornerY gets `AVHDRPlusColorTransformParams.window_lower_right_corner_y` value. +func (ctp *AVHDRPlusColorTransformParams) GetWindowLowerRightCornerY() AVRational { + return (AVRational)(ctp.window_lower_right_corner_y) +} + +// Custom: SetWindowLowerRightCornerY sets `AVHDRPlusColorTransformParams.window_lower_right_corner_y` value. +func (ctp *AVHDRPlusColorTransformParams) SetWindowLowerRightCornerY(v AVRational) { + ctp.window_lower_right_corner_y = (C.struct_AVRational)(v) +} + +// Custom: GetWindowLowerRightCornerYAddr gets `AVHDRPlusColorTransformParams.window_lower_right_corner_y` address. +func (ctp *AVHDRPlusColorTransformParams) GetWindowLowerRightCornerYAddr() *AVRational { + return (*AVRational)(&ctp.window_lower_right_corner_y) +} + +// Custom: GetCenterOfEllipseX gets `AVHDRPlusColorTransformParams.center_of_ellipse_x` value. +func (ctp *AVHDRPlusColorTransformParams) GetCenterOfEllipseX() uint16 { + return (uint16)(ctp.center_of_ellipse_x) +} + +// Custom: SetCenterOfEllipseX sets `AVHDRPlusColorTransformParams.center_of_ellipse_x` value. +func (ctp *AVHDRPlusColorTransformParams) SetCenterOfEllipseX(v uint16) { + ctp.center_of_ellipse_x = (C.uint16_t)(v) +} + +// Custom: GetCenterOfEllipseXAddr gets `AVHDRPlusColorTransformParams.center_of_ellipse_x` address. +func (ctp *AVHDRPlusColorTransformParams) GetCenterOfEllipseXAddr() *uint16 { + return (*uint16)(&ctp.center_of_ellipse_x) +} + +// Custom: GetCenterOfEllipseY gets `AVHDRPlusColorTransformParams.center_of_ellipse_y` value. +func (ctp *AVHDRPlusColorTransformParams) GetCenterOfEllipseY() uint16 { + return (uint16)(ctp.center_of_ellipse_y) +} + +// Custom: SetCenterOfEllipseY sets `AVHDRPlusColorTransformParams.center_of_ellipse_y` value. +func (ctp *AVHDRPlusColorTransformParams) SetCenterOfEllipseY(v uint16) { + ctp.center_of_ellipse_y = (C.uint16_t)(v) +} + +// Custom: GetCenterOfEllipseYAddr gets `AVHDRPlusColorTransformParams.center_of_ellipse_y` address. +func (ctp *AVHDRPlusColorTransformParams) GetCenterOfEllipseYAddr() *uint16 { + return (*uint16)(&ctp.center_of_ellipse_y) +} + +// Custom: GetRotationAngle gets `AVHDRPlusColorTransformParams.rotation_angle` value. +func (ctp *AVHDRPlusColorTransformParams) GetRotationAngle() uint8 { + return (uint8)(ctp.rotation_angle) +} + +// Custom: SetRotationAngle sets `AVHDRPlusColorTransformParams.rotation_angle` value. +func (ctp *AVHDRPlusColorTransformParams) SetRotationAngle(v uint8) { + ctp.rotation_angle = (C.uint8_t)(v) +} + +// Custom: GetRotationAngleAddr gets `AVHDRPlusColorTransformParams.rotation_angle` address. +func (ctp *AVHDRPlusColorTransformParams) GetRotationAngleAddr() *uint8 { + return (*uint8)(&ctp.rotation_angle) +} + +// Custom: GetSemimajorAxisInternalEllipse gets `AVHDRPlusColorTransformParams.semimajor_axis_internal_ellipse` value. +func (ctp *AVHDRPlusColorTransformParams) GetSemimajorAxisInternalEllipse() uint16 { + return (uint16)(ctp.semimajor_axis_internal_ellipse) +} + +// Custom: SetSemimajorAxisInternalEllipse sets `AVHDRPlusColorTransformParams.semimajor_axis_internal_ellipse` value. +func (ctp *AVHDRPlusColorTransformParams) SetSemimajorAxisInternalEllipse(v uint16) { + ctp.semimajor_axis_internal_ellipse = (C.uint16_t)(v) +} + +// Custom: GetSemimajorAxisInternalEllipseAddr gets `AVHDRPlusColorTransformParams.semimajor_axis_internal_ellipse` address. +func (ctp *AVHDRPlusColorTransformParams) GetSemimajorAxisInternalEllipseAddr() *uint16 { + return (*uint16)(&ctp.semimajor_axis_internal_ellipse) +} + +// Custom: GetSemimajorAxisExternalEllipse gets `AVHDRPlusColorTransformParams.semimajor_axis_external_ellipse` value. +func (ctp *AVHDRPlusColorTransformParams) GetSemimajorAxisExternalEllipse() uint16 { + return (uint16)(ctp.semimajor_axis_external_ellipse) +} + +// Custom: SetSemimajorAxisExternalEllipse sets `AVHDRPlusColorTransformParams.semimajor_axis_external_ellipse` value. +func (ctp *AVHDRPlusColorTransformParams) SetSemimajorAxisExternalEllipse(v uint16) { + ctp.semimajor_axis_external_ellipse = (C.uint16_t)(v) +} + +// Custom: GetSemimajorAxisExternalEllipseAddr gets `AVHDRPlusColorTransformParams.semimajor_axis_external_ellipse` address. +func (ctp *AVHDRPlusColorTransformParams) GetSemimajorAxisExternalEllipseAddr() *uint16 { + return (*uint16)(&ctp.semimajor_axis_external_ellipse) +} + +// Custom: GetSemiminorAxisExternalEllipse gets `AVHDRPlusColorTransformParams.semiminor_axis_external_ellipse` value. +func (ctp *AVHDRPlusColorTransformParams) GetSemiminorAxisExternalEllipse() uint16 { + return (uint16)(ctp.semiminor_axis_external_ellipse) +} + +// Custom: SetSemiminorAxisExternalEllipse sets `AVHDRPlusColorTransformParams.semiminor_axis_external_ellipse` value. +func (ctp *AVHDRPlusColorTransformParams) SetSemiminorAxisExternalEllipse(v uint16) { + ctp.semiminor_axis_external_ellipse = (C.uint16_t)(v) +} + +// Custom: GetSemiminorAxisExternalEllipseAddr gets `AVHDRPlusColorTransformParams.semiminor_axis_external_ellipse` address. +func (ctp *AVHDRPlusColorTransformParams) GetSemiminorAxisExternalEllipseAddr() *uint16 { + return (*uint16)(&ctp.semiminor_axis_external_ellipse) +} + +// Custom: GetOverlapProcessOption gets `AVHDRPlusColorTransformParams.overlap_process_option` value. +func (ctp *AVHDRPlusColorTransformParams) GetOverlapProcessOption() AVHDRPlusOverlapProcessOption { + return (AVHDRPlusOverlapProcessOption)(ctp.overlap_process_option) +} + +// Custom: SetOverlapProcessOption sets `AVHDRPlusColorTransformParams.overlap_process_option` value. +func (ctp *AVHDRPlusColorTransformParams) SetOverlapProcessOption(v AVHDRPlusOverlapProcessOption) { + ctp.overlap_process_option = (C.enum_AVHDRPlusOverlapProcessOption)(v) +} + +// Custom: GetOverlapProcessOptionAddr gets `AVHDRPlusColorTransformParams.overlap_process_option` address. +func (ctp *AVHDRPlusColorTransformParams) GetOverlapProcessOptionAddr() *AVHDRPlusOverlapProcessOption { + return (*AVHDRPlusOverlapProcessOption)(&ctp.overlap_process_option) +} + +// Custom: GetMaxscl gets `AVHDRPlusColorTransformParams.maxscl` value. +func (ctp *AVHDRPlusColorTransformParams) GetMaxscl() []AVRational { + return unsafe.Slice((*AVRational)(&ctp.maxscl[0]), 3) +} + +// Custom: SetMaxscl sets `AVHDRPlusColorTransformParams.maxscl` value. +func (ctp *AVHDRPlusColorTransformParams) SetMaxscl(v []AVRational) { + for i := 0; i < FFMIN(len(v), 3); i++ { + ctp.maxscl[i] = (C.struct_AVRational)(v[i]) + } +} + +// Custom: GetMaxsclAddr gets `AVHDRPlusColorTransformParams.maxscl` address. +func (ctp *AVHDRPlusColorTransformParams) GetMaxsclAddr() **AVRational { + return (**AVRational)(unsafe.Pointer(&ctp.maxscl)) +} + +// Custom: GetAverageMaxrgb gets `AVHDRPlusColorTransformParams.average_maxrgb` value. +func (ctp *AVHDRPlusColorTransformParams) GetAverageMaxrgb() AVRational { + return (AVRational)(ctp.average_maxrgb) +} + +// Custom: SetAverageMaxrgb sets `AVHDRPlusColorTransformParams.average_maxrgb` value. +func (ctp *AVHDRPlusColorTransformParams) SetAverageMaxrgb(v AVRational) { + ctp.average_maxrgb = (C.struct_AVRational)(v) +} + +// Custom: GetAverageMaxrgbAddr gets `AVHDRPlusColorTransformParams.average_maxrgb` address. +func (ctp *AVHDRPlusColorTransformParams) GetAverageMaxrgbAddr() *AVRational { + return (*AVRational)(&ctp.average_maxrgb) +} + +// Custom: GetNumDistributionMaxrgbPercentiles gets `AVHDRPlusColorTransformParams.num_distribution_maxrgb_percentiles` value. +func (ctp *AVHDRPlusColorTransformParams) GetNumDistributionMaxrgbPercentiles() uint8 { + return (uint8)(ctp.num_distribution_maxrgb_percentiles) +} + +// Custom: SetNumDistributionMaxrgbPercentiles sets `AVHDRPlusColorTransformParams.num_distribution_maxrgb_percentiles` value. +func (ctp *AVHDRPlusColorTransformParams) SetNumDistributionMaxrgbPercentiles(v uint8) { + ctp.num_distribution_maxrgb_percentiles = (C.uint8_t)(v) +} + +// Custom: GetNumDistributionMaxrgbPercentilesAddr gets `AVHDRPlusColorTransformParams.num_distribution_maxrgb_percentiles` address. +func (ctp *AVHDRPlusColorTransformParams) GetNumDistributionMaxrgbPercentilesAddr() *uint8 { + return (*uint8)(&ctp.num_distribution_maxrgb_percentiles) +} + +// Custom: GetDistributionMaxrgb gets `AVHDRPlusColorTransformParams.distribution_maxrgb` value. +func (ctp *AVHDRPlusColorTransformParams) GetDistributionMaxrgb() []AVHDRPlusPercentile { + return unsafe.Slice((*AVHDRPlusPercentile)(&ctp.distribution_maxrgb[0]), 15) +} + +// Custom: SetDistributionMaxrgb sets `AVHDRPlusColorTransformParams.distribution_maxrgb` value. +func (ctp *AVHDRPlusColorTransformParams) SetDistributionMaxrgb(v []AVHDRPlusPercentile) { + for i := 0; i < FFMIN(len(v), 15); i++ { + ctp.distribution_maxrgb[i] = (C.struct_AVHDRPlusPercentile)(v[i]) + } +} + +// Custom: GetDistributionMaxrgbAddr gets `AVHDRPlusColorTransformParams.distribution_maxrgb` address. +func (ctp *AVHDRPlusColorTransformParams) GetDistributionMaxrgbAddr() **AVHDRPlusPercentile { + return (**AVHDRPlusPercentile)(unsafe.Pointer(&ctp.distribution_maxrgb)) +} + +// Custom: GetFractionBrightPixels gets `AVHDRPlusColorTransformParams.fraction_bright_pixels` value. +func (ctp *AVHDRPlusColorTransformParams) GetFractionBrightPixels() AVRational { + return (AVRational)(ctp.fraction_bright_pixels) +} + +// Custom: SetFractionBrightPixels sets `AVHDRPlusColorTransformParams.fraction_bright_pixels` value. +func (ctp *AVHDRPlusColorTransformParams) SetFractionBrightPixels(v AVRational) { + ctp.fraction_bright_pixels = (C.struct_AVRational)(v) +} + +// Custom: GetFractionBrightPixelsAddr gets `AVHDRPlusColorTransformParams.fraction_bright_pixels` address. +func (ctp *AVHDRPlusColorTransformParams) GetFractionBrightPixelsAddr() *AVRational { + return (*AVRational)(&ctp.fraction_bright_pixels) +} + +// Custom: GetToneMappingFlag gets `AVHDRPlusColorTransformParams.tone_mapping_flag` value. +func (ctp *AVHDRPlusColorTransformParams) GetToneMappingFlag() uint8 { + return (uint8)(ctp.tone_mapping_flag) +} + +// Custom: SetToneMappingFlag sets `AVHDRPlusColorTransformParams.tone_mapping_flag` value. +func (ctp *AVHDRPlusColorTransformParams) SetToneMappingFlag(v uint8) { + ctp.tone_mapping_flag = (C.uint8_t)(v) +} + +// Custom: GetToneMappingFlagAddr gets `AVHDRPlusColorTransformParams.tone_mapping_flag` address. +func (ctp *AVHDRPlusColorTransformParams) GetToneMappingFlagAddr() *uint8 { + return (*uint8)(&ctp.tone_mapping_flag) +} + +// Custom: GetKneePointX gets `AVHDRPlusColorTransformParams.knee_point_x` value. +func (ctp *AVHDRPlusColorTransformParams) GetKneePointX() AVRational { + return (AVRational)(ctp.knee_point_x) +} + +// Custom: SetKneePointX sets `AVHDRPlusColorTransformParams.knee_point_x` value. +func (ctp *AVHDRPlusColorTransformParams) SetKneePointX(v AVRational) { + ctp.knee_point_x = (C.struct_AVRational)(v) +} + +// Custom: GetKneePointXAddr gets `AVHDRPlusColorTransformParams.knee_point_x` address. +func (ctp *AVHDRPlusColorTransformParams) GetKneePointXAddr() *AVRational { + return (*AVRational)(&ctp.knee_point_x) +} + +// Custom: GetKneePointY gets `AVHDRPlusColorTransformParams.knee_point_y` value. +func (ctp *AVHDRPlusColorTransformParams) GetKneePointY() AVRational { + return (AVRational)(ctp.knee_point_y) +} + +// Custom: SetKneePointY sets `AVHDRPlusColorTransformParams.knee_point_y` value. +func (ctp *AVHDRPlusColorTransformParams) SetKneePointY(v AVRational) { + ctp.knee_point_y = (C.struct_AVRational)(v) +} + +// Custom: GetKneePointYAddr gets `AVHDRPlusColorTransformParams.knee_point_y` address. +func (ctp *AVHDRPlusColorTransformParams) GetKneePointYAddr() *AVRational { + return (*AVRational)(&ctp.knee_point_y) +} + +// Custom: GetNumBezierCurveAnchors gets `AVHDRPlusColorTransformParams.num_bezier_curve_anchors` value. +func (ctp *AVHDRPlusColorTransformParams) GetNumBezierCurveAnchors() uint8 { + return (uint8)(ctp.num_bezier_curve_anchors) +} + +// Custom: SetNumBezierCurveAnchors sets `AVHDRPlusColorTransformParams.num_bezier_curve_anchors` value. +func (ctp *AVHDRPlusColorTransformParams) SetNumBezierCurveAnchors(v uint8) { + ctp.num_bezier_curve_anchors = (C.uint8_t)(v) +} + +// Custom: GetNumBezierCurveAnchorsAddr gets `AVHDRPlusColorTransformParams.num_bezier_curve_anchors` address. +func (ctp *AVHDRPlusColorTransformParams) GetNumBezierCurveAnchorsAddr() *uint8 { + return (*uint8)(&ctp.num_bezier_curve_anchors) +} + +// Custom: GetBezierCurveAnchors gets `AVHDRPlusColorTransformParams.bezier_curve_anchors` value. +func (ctp *AVHDRPlusColorTransformParams) GetBezierCurveAnchors() []AVRational { + return unsafe.Slice((*AVRational)(&ctp.bezier_curve_anchors[0]), 15) +} + +// Custom: SetBezierCurveAnchors sets `AVHDRPlusColorTransformParams.bezier_curve_anchors` value. +func (ctp *AVHDRPlusColorTransformParams) SetBezierCurveAnchors(v []AVRational) { + for i := 0; i < FFMIN(len(v), 15); i++ { + ctp.bezier_curve_anchors[i] = (C.struct_AVRational)(v[i]) + } +} + +// Custom: GetBezierCurveAnchorsAddr gets `AVHDRPlusColorTransformParams.bezier_curve_anchors` address. +func (ctp *AVHDRPlusColorTransformParams) GetBezierCurveAnchorsAddr() **AVRational { + return (**AVRational)(unsafe.Pointer(&ctp.bezier_curve_anchors)) +} + +// Custom: GetColorSaturationMappingFlag gets `AVHDRPlusColorTransformParams.color_saturation_mapping_flag` value. +func (ctp *AVHDRPlusColorTransformParams) GetColorSaturationMappingFlag() uint8 { + return (uint8)(ctp.color_saturation_mapping_flag) +} + +// Custom: SetColorSaturationMappingFlag sets `AVHDRPlusColorTransformParams.color_saturation_mapping_flag` value. +func (ctp *AVHDRPlusColorTransformParams) SetColorSaturationMappingFlag(v uint8) { + ctp.color_saturation_mapping_flag = (C.uint8_t)(v) +} + +// Custom: GetColorSaturationMappingFlagAddr gets `AVHDRPlusColorTransformParams.color_saturation_mapping_flag` address. +func (ctp *AVHDRPlusColorTransformParams) GetColorSaturationMappingFlagAddr() *uint8 { + return (*uint8)(&ctp.color_saturation_mapping_flag) +} + +// Custom: GetColorSaturationWeight gets `AVHDRPlusColorTransformParams.color_saturation_weight` value. +func (ctp *AVHDRPlusColorTransformParams) GetColorSaturationWeight() AVRational { + return (AVRational)(ctp.color_saturation_weight) +} + +// Custom: SetColorSaturationWeight sets `AVHDRPlusColorTransformParams.color_saturation_weight` value. +func (ctp *AVHDRPlusColorTransformParams) SetColorSaturationWeight(v AVRational) { + ctp.color_saturation_weight = (C.struct_AVRational)(v) +} + +// Custom: GetColorSaturationWeightAddr gets `AVHDRPlusColorTransformParams.color_saturation_weight` address. +func (ctp *AVHDRPlusColorTransformParams) GetColorSaturationWeightAddr() *AVRational { + return (*AVRational)(&ctp.color_saturation_weight) +} + +// AVDynamicHDRPlus +type AVDynamicHDRPlus C.struct_AVDynamicHDRPlus + +// Custom: GetItuTT35CountryCode gets `AVDynamicHDRPlus.itu_t_t35_country_code` value. +func (dhp *AVDynamicHDRPlus) GetItuTT35CountryCode() uint8 { + return (uint8)(dhp.itu_t_t35_country_code) +} + +// Custom: SetItuTT35CountryCode sets `AVDynamicHDRPlus.itu_t_t35_country_code` value. +func (dhp *AVDynamicHDRPlus) SetItuTT35CountryCode(v uint8) { + dhp.itu_t_t35_country_code = (C.uint8_t)(v) +} + +// Custom: GetItuTT35CountryCodeAddr gets `AVDynamicHDRPlus.itu_t_t35_country_code` address. +func (dhp *AVDynamicHDRPlus) GetItuTT35CountryCodeAddr() *uint8 { + return (*uint8)(&dhp.itu_t_t35_country_code) +} + +// Custom: GetApplicationVersion gets `AVDynamicHDRPlus.application_version` value. +func (dhp *AVDynamicHDRPlus) GetApplicationVersion() uint8 { + return (uint8)(dhp.application_version) +} + +// Custom: SetApplicationVersion sets `AVDynamicHDRPlus.application_version` value. +func (dhp *AVDynamicHDRPlus) SetApplicationVersion(v uint8) { + dhp.application_version = (C.uint8_t)(v) +} + +// Custom: GetApplicationVersionAddr gets `AVDynamicHDRPlus.application_version` address. +func (dhp *AVDynamicHDRPlus) GetApplicationVersionAddr() *uint8 { + return (*uint8)(&dhp.application_version) +} + +// Custom: GetNumWindows gets `AVDynamicHDRPlus.num_windows` value. +func (dhp *AVDynamicHDRPlus) GetNumWindows() uint8 { + return (uint8)(dhp.num_windows) +} + +// Custom: SetNumWindows sets `AVDynamicHDRPlus.num_windows` value. +func (dhp *AVDynamicHDRPlus) SetNumWindows(v uint8) { + dhp.num_windows = (C.uint8_t)(v) +} + +// Custom: GetNumWindowsAddr gets `AVDynamicHDRPlus.num_windows` address. +func (dhp *AVDynamicHDRPlus) GetNumWindowsAddr() *uint8 { + return (*uint8)(&dhp.num_windows) +} + +// Custom: GetParams gets `AVDynamicHDRPlus.params` value. +func (dhp *AVDynamicHDRPlus) GetParams() []AVHDRPlusColorTransformParams { + return unsafe.Slice((*AVHDRPlusColorTransformParams)(&dhp.params[0]), 3) +} + +// Custom: SetParams sets `AVDynamicHDRPlus.params` value. +func (dhp *AVDynamicHDRPlus) SetParams(v []AVHDRPlusColorTransformParams) { + for i := 0; i < FFMIN(len(v), 3); i++ { + dhp.params[i] = (C.struct_AVHDRPlusColorTransformParams)(v[i]) + } +} + +// Custom: GetParamsAddr gets `AVDynamicHDRPlus.params` address. +func (dhp *AVDynamicHDRPlus) GetParamsAddr() **AVHDRPlusColorTransformParams { + return (**AVHDRPlusColorTransformParams)(unsafe.Pointer(&dhp.params)) +} + +// Custom: GetTargetedSystemDisplayMaximumLuminance gets `AVDynamicHDRPlus.targeted_system_display_maximum_luminance` value. +func (dhp *AVDynamicHDRPlus) GetTargetedSystemDisplayMaximumLuminance() AVRational { + return (AVRational)(dhp.targeted_system_display_maximum_luminance) +} + +// Custom: SetTargetedSystemDisplayMaximumLuminance sets `AVDynamicHDRPlus.targeted_system_display_maximum_luminance` value. +func (dhp *AVDynamicHDRPlus) SetTargetedSystemDisplayMaximumLuminance(v AVRational) { + dhp.targeted_system_display_maximum_luminance = (C.struct_AVRational)(v) +} + +// Custom: GetTargetedSystemDisplayMaximumLuminanceAddr gets `AVDynamicHDRPlus.targeted_system_display_maximum_luminance` address. +func (dhp *AVDynamicHDRPlus) GetTargetedSystemDisplayMaximumLuminanceAddr() *AVRational { + return (*AVRational)(&dhp.targeted_system_display_maximum_luminance) +} + +// Custom: GetTargetedSystemDisplayActualPeakLuminanceFlag gets `AVDynamicHDRPlus.targeted_system_display_actual_peak_luminance_flag` value. +func (dhp *AVDynamicHDRPlus) GetTargetedSystemDisplayActualPeakLuminanceFlag() uint8 { + return (uint8)(dhp.targeted_system_display_actual_peak_luminance_flag) +} + +// Custom: SetTargetedSystemDisplayActualPeakLuminanceFlag sets `AVDynamicHDRPlus.targeted_system_display_actual_peak_luminance_flag` value. +func (dhp *AVDynamicHDRPlus) SetTargetedSystemDisplayActualPeakLuminanceFlag(v uint8) { + dhp.targeted_system_display_actual_peak_luminance_flag = (C.uint8_t)(v) +} + +// Custom: GetTargetedSystemDisplayActualPeakLuminanceFlagAddr gets `AVDynamicHDRPlus.targeted_system_display_actual_peak_luminance_flag` address. +func (dhp *AVDynamicHDRPlus) GetTargetedSystemDisplayActualPeakLuminanceFlagAddr() *uint8 { + return (*uint8)(&dhp.targeted_system_display_actual_peak_luminance_flag) +} + +// Custom: GetNumRowsTargetedSystemDisplayActualPeakLuminance gets `AVDynamicHDRPlus.num_rows_targeted_system_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) GetNumRowsTargetedSystemDisplayActualPeakLuminance() uint8 { + return (uint8)(dhp.num_rows_targeted_system_display_actual_peak_luminance) +} + +// Custom: SetNumRowsTargetedSystemDisplayActualPeakLuminance sets `AVDynamicHDRPlus.num_rows_targeted_system_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) SetNumRowsTargetedSystemDisplayActualPeakLuminance(v uint8) { + dhp.num_rows_targeted_system_display_actual_peak_luminance = (C.uint8_t)(v) +} + +// Custom: GetNumRowsTargetedSystemDisplayActualPeakLuminanceAddr gets `AVDynamicHDRPlus.num_rows_targeted_system_display_actual_peak_luminance` address. +func (dhp *AVDynamicHDRPlus) GetNumRowsTargetedSystemDisplayActualPeakLuminanceAddr() *uint8 { + return (*uint8)(&dhp.num_rows_targeted_system_display_actual_peak_luminance) +} + +// Custom: GetNumColsTargetedSystemDisplayActualPeakLuminance gets `AVDynamicHDRPlus.num_cols_targeted_system_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) GetNumColsTargetedSystemDisplayActualPeakLuminance() uint8 { + return (uint8)(dhp.num_cols_targeted_system_display_actual_peak_luminance) +} + +// Custom: SetNumColsTargetedSystemDisplayActualPeakLuminance sets `AVDynamicHDRPlus.num_cols_targeted_system_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) SetNumColsTargetedSystemDisplayActualPeakLuminance(v uint8) { + dhp.num_cols_targeted_system_display_actual_peak_luminance = (C.uint8_t)(v) +} + +// Custom: GetNumColsTargetedSystemDisplayActualPeakLuminanceAddr gets `AVDynamicHDRPlus.num_cols_targeted_system_display_actual_peak_luminance` address. +func (dhp *AVDynamicHDRPlus) GetNumColsTargetedSystemDisplayActualPeakLuminanceAddr() *uint8 { + return (*uint8)(&dhp.num_cols_targeted_system_display_actual_peak_luminance) +} + +// Custom: GetTargetedSystemDisplayActualPeakLuminance gets `AVDynamicHDRPlus.targeted_system_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) GetTargetedSystemDisplayActualPeakLuminance() (v [][]AVRational) { + for i := 0; i < 25; i++ { + v = append(v, unsafe.Slice((*AVRational)(&dhp.targeted_system_display_actual_peak_luminance[i][0]), 25)) + } + return v +} + +// Custom: SetTargetedSystemDisplayActualPeakLuminance sets `AVDynamicHDRPlus.targeted_system_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) SetTargetedSystemDisplayActualPeakLuminance(v [][]AVRational) { + for i := 0; i < FFMIN(len(v), 25); i++ { + for j := 0; j < FFMIN(len(v[i]), 25); j++ { + dhp.targeted_system_display_actual_peak_luminance[i][j] = (C.struct_AVRational)(v[i][j]) + } + } +} + +// Custom: GetTargetedSystemDisplayActualPeakLuminanceAddr gets `AVDynamicHDRPlus.targeted_system_display_actual_peak_luminance` address. +func (dhp *AVDynamicHDRPlus) GetTargetedSystemDisplayActualPeakLuminanceAddr() **AVRational { + return (**AVRational)(unsafe.Pointer(&dhp.targeted_system_display_actual_peak_luminance)) +} + +// Custom: GetMasteringDisplayActualPeakLuminanceFlag gets `AVDynamicHDRPlus.mastering_display_actual_peak_luminance_flag` value. +func (dhp *AVDynamicHDRPlus) GetMasteringDisplayActualPeakLuminanceFlag() uint8 { + return (uint8)(dhp.mastering_display_actual_peak_luminance_flag) +} + +// Custom: SetMasteringDisplayActualPeakLuminanceFlag sets `AVDynamicHDRPlus.mastering_display_actual_peak_luminance_flag` value. +func (dhp *AVDynamicHDRPlus) SetMasteringDisplayActualPeakLuminanceFlag(v uint8) { + dhp.mastering_display_actual_peak_luminance_flag = (C.uint8_t)(v) +} + +// Custom: GetMasteringDisplayActualPeakLuminanceFlagAddr gets `AVDynamicHDRPlus.mastering_display_actual_peak_luminance_flag` address. +func (dhp *AVDynamicHDRPlus) GetMasteringDisplayActualPeakLuminanceFlagAddr() *uint8 { + return (*uint8)(&dhp.mastering_display_actual_peak_luminance_flag) +} + +// Custom: GetNumRowsMasteringDisplayActualPeakLuminance gets `AVDynamicHDRPlus.num_rows_mastering_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) GetNumRowsMasteringDisplayActualPeakLuminance() uint8 { + return (uint8)(dhp.num_rows_mastering_display_actual_peak_luminance) +} + +// Custom: SetNumRowsMasteringDisplayActualPeakLuminance sets `AVDynamicHDRPlus.num_rows_mastering_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) SetNumRowsMasteringDisplayActualPeakLuminance(v uint8) { + dhp.num_rows_mastering_display_actual_peak_luminance = (C.uint8_t)(v) +} + +// Custom: GetNumRowsMasteringDisplayActualPeakLuminanceAddr gets `AVDynamicHDRPlus.num_rows_mastering_display_actual_peak_luminance` address. +func (dhp *AVDynamicHDRPlus) GetNumRowsMasteringDisplayActualPeakLuminanceAddr() *uint8 { + return (*uint8)(&dhp.num_rows_mastering_display_actual_peak_luminance) +} + +// Custom: GetNumColsMasteringDisplayActualPeakLuminance gets `AVDynamicHDRPlus.num_cols_mastering_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) GetNumColsMasteringDisplayActualPeakLuminance() uint8 { + return (uint8)(dhp.num_cols_mastering_display_actual_peak_luminance) +} + +// Custom: SetNumColsMasteringDisplayActualPeakLuminance sets `AVDynamicHDRPlus.num_cols_mastering_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) SetNumColsMasteringDisplayActualPeakLuminance(v uint8) { + dhp.num_cols_mastering_display_actual_peak_luminance = (C.uint8_t)(v) +} + +// Custom: GetNumColsMasteringDisplayActualPeakLuminanceAddr gets `AVDynamicHDRPlus.num_cols_mastering_display_actual_peak_luminance` address. +func (dhp *AVDynamicHDRPlus) GetNumColsMasteringDisplayActualPeakLuminanceAddr() *uint8 { + return (*uint8)(&dhp.num_cols_mastering_display_actual_peak_luminance) +} + +// Custom: GetMasteringDisplayActualPeakLuminance gets `AVDynamicHDRPlus.mastering_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) GetMasteringDisplayActualPeakLuminance() (v [][]AVRational) { + for i := 0; i < 25; i++ { + v = append(v, unsafe.Slice((*AVRational)(&dhp.mastering_display_actual_peak_luminance[i][0]), 25)) + } + return v +} + +// Custom: SetMasteringDisplayActualPeakLuminance sets `AVDynamicHDRPlus.mastering_display_actual_peak_luminance` value. +func (dhp *AVDynamicHDRPlus) SetMasteringDisplayActualPeakLuminance(v [][]AVRational) { + for i := 0; i < FFMIN(len(v), 25); i++ { + for j := 0; j < FFMIN(len(v[i]), 25); j++ { + dhp.mastering_display_actual_peak_luminance[i][j] = (C.struct_AVRational)(v[i][j]) + } + } +} + +// Custom: GetMasteringDisplayActualPeakLuminanceAddr gets `AVDynamicHDRPlus.mastering_display_actual_peak_luminance` address. +func (dhp *AVDynamicHDRPlus) GetMasteringDisplayActualPeakLuminanceAddr() **AVRational { + return (**AVRational)(unsafe.Pointer(&dhp.mastering_display_actual_peak_luminance)) +} + +// AvDynamicHdrPlusAlloc allocates an AVDynamicHDRPlus structure and set its fields to +// default values. +func AvDynamicHdrPlusAlloc(size *uintptr) *AVDynamicHDRPlus { + return (*AVDynamicHDRPlus)(C.av_dynamic_hdr_plus_alloc((*C.size_t)(unsafe.Pointer(size)))) +} + +// AvDynamicHdrPlusCreateSideData allocates a complete AVDynamicHDRPlus and add it to the frame. +func AvDynamicHdrPlusCreateSideData(frame *AVFrame) *AVDynamicHDRPlus { + return (*AVDynamicHDRPlus)(C.av_dynamic_hdr_plus_create_side_data((*C.struct_AVFrame)(frame))) +} diff --git a/avutil_hmac.go b/avutil_hmac.go new file mode 100644 index 0000000..054e6e6 --- /dev/null +++ b/avutil_hmac.go @@ -0,0 +1,54 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVHMACType +type AVHMACType C.enum_AVHMACType + +const ( + AV_HMAC_MD5 = AVHMACType(C.AV_HMAC_MD5) + AV_HMAC_SHA1 = AVHMACType(C.AV_HMAC_SHA1) + AV_HMAC_SHA224 = AVHMACType(C.AV_HMAC_SHA224) + AV_HMAC_SHA256 = AVHMACType(C.AV_HMAC_SHA256) + AV_HMAC_SHA384 = AVHMACType(C.AV_HMAC_SHA384) + AV_HMAC_SHA512 = AVHMACType(C.AV_HMAC_SHA512) +) + +type AVHMAC C.struct_AVHMAC + +// AvHmacAlloc allocates an AVHMAC context. +func AvHmacAlloc(_type AVHMACType) *AVHMAC { + return (*AVHMAC)(C.av_hmac_alloc((C.enum_AVHMACType)(_type))) +} + +// AvHmacFree frees an AVHMAC context. +func AvHmacFree(ctx *AVHMAC) { + C.av_hmac_free((*C.struct_AVHMAC)(ctx)) +} + +// AvHmacInit initializes an AVHMAC context with an authentication key. +func AvHmacInit(ctx *AVHMAC, key *uint8, keylen uint32) { + C.av_hmac_init((*C.struct_AVHMAC)(ctx), (*C.uint8_t)(key), (C.uint)(keylen)) +} + +// AvHmacUpdate hashes data with the HMAC. +func AvHmacUpdate(ctx *AVHMAC, data *uint8, len uint32) { + C.av_hmac_update((*C.struct_AVHMAC)(ctx), (*C.uint8_t)(data), (C.uint)(len)) +} + +// AvHmacFinal finishes hashing and output the HMAC digest. +func AvHmacFinal(ctx *AVHMAC, out *uint8, outlen uint32) int32 { + return (int32)(C.av_hmac_final((*C.struct_AVHMAC)(ctx), (*C.uint8_t)(out), (C.uint)(outlen))) +} + +// AvHmacCalc hashes an array of data with a key. +func AvHmacCalc(ctx *AVHMAC, data *uint8, len uint32, + key *uint8, keylen uint32, + out *uint8, outlen uint32) int32 { + return (int32)(C.av_hmac_calc((*C.struct_AVHMAC)(ctx), (*C.uint8_t)(data), (C.uint)(len), + (*C.uint8_t)(key), (C.uint)(keylen), + (*C.uint8_t)(out), (C.uint)(outlen))) +} diff --git a/avutil_hwcontext.go b/avutil_hwcontext.go index d7df938..539c34d 100644 --- a/avutil_hwcontext.go +++ b/avutil_hwcontext.go @@ -410,7 +410,7 @@ type AVHWFramesConstraints C.struct_AVHWFramesConstraints // Custom: GetValidHwFormats gets `AVHWFramesConstraints.valid_hw_formats` value. func (fcs *AVHWFramesConstraints) GetValidHwFormats() []AVPixelFormat { - return TruncSlice((*AVPixelFormat)(fcs.valid_hw_formats), func(pf AVPixelFormat) bool { + return SliceTrunc((*AVPixelFormat)(fcs.valid_hw_formats), func(pf AVPixelFormat) bool { return pf == AV_PIX_FMT_NONE }) } @@ -427,7 +427,7 @@ func (fcs *AVHWFramesConstraints) GetValidHwFormatsAddr() **AVPixelFormat { // Custom: GetValidSwFormats gets `AVHWFramesConstraints.valid_sw_formats` value. func (fcs *AVHWFramesConstraints) GetValidSwFormats() []AVPixelFormat { - return TruncSlice((*AVPixelFormat)(fcs.valid_sw_formats), func(pf AVPixelFormat) bool { + return SliceTrunc((*AVPixelFormat)(fcs.valid_sw_formats), func(pf AVPixelFormat) bool { return pf == AV_PIX_FMT_NONE }) } diff --git a/avutil_intfloat.go b/avutil_intfloat.go new file mode 100644 index 0000000..c4d3433 --- /dev/null +++ b/avutil_intfloat.go @@ -0,0 +1,26 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AvInt2float reinterprets a 32-bit integer as a float. +func AvInt2float(i uint32) float32 { + return (float32)(C.av_int2float((C.uint32_t)(i))) +} + +// AvFloat2int reinterprets a float as a 32-bit integer. +func AvFloat2int(f float32) uint32 { + return (uint32)(C.av_float2int((C.float)(f))) +} + +// AvInt2double reinterprets a 64-bit integer as a double. +func AvInt2double(i uint64) float64 { + return (float64)(C.av_int2double((C.uint64_t)(i))) +} + +// AvDouble2int reinterprets a double as a 64-bit integer. +func AvDouble2int(f float64) uint64 { + return (uint64)(C.av_double2int((C.double)(f))) +} diff --git a/avutil_intreadwrite.go b/avutil_intreadwrite.go new file mode 100644 index 0000000..550dc4d --- /dev/null +++ b/avutil_intreadwrite.go @@ -0,0 +1,165 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// See https://pkg.go.dev/encoding/binary + +// Arch-specific headers can provide any combination of +// AV_[RW][BLN](16|24|32|48|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. +// Preprocessor symbols must be defined, even if these are implemented +// as inline functions. +// +// R/W means read/write, B/L/N means big/little/native endianness. +// The following macros require aligned access, compared to their +// unaligned variants: AV_(COPY|SWAP|ZERO)(64|128), AV_[RW]N[8-64]A. +// Incorrect usage may range from abysmal performance to crash +// depending on the platform. +// +// The unaligned variants are AV_[RW][BLN][8-64] and AV_COPY*U. + +// Define AV_[RW]N helper macros to simplify definitions not provided +// by per-arch headers. + +// NONEED: AV_RN + +// NONEED: AV_WN + +// NONEED: AV_RN16 + +// NONEED: AV_RN32 + +// NONEED: AV_RN64 + +// NONEED: AV_WN16 + +// NONEED: AV_WN32 + +// NONEED: AV_WN64 + +// NONEED: AV_RB + +// NONEED: AV_WB + +// NONEED: AV_RL + +// NONEED: AV_WL + +// NONEED: AV_RB8 + +// NONEED: AV_WB8 + +// NONEED: AV_RL8 + +// NONEED: AV_WL8 + +// NONEED: AV_RB16 + +// NONEED: AV_WB16 + +// NONEED: AV_RL16 + +// NONEED: AV_WL16 + +// NONEED: AV_RB32 + +// NONEED: AV_WB32 + +// NONEED: AV_RL32 + +// NONEED: AV_WL32 + +// NONEED: AV_RB64 + +// NONEED: AV_WB64 + +// NONEED: AV_RL64 + +// NONEED: AV_WL64 + +// NONEED: AV_RB24 + +// NONEED: AV_WB24 + +// NONEED: AV_RL24 + +// NONEED: AV_WL24 + +// NONEED: AV_RB48 + +// NONEED: AV_WB48 + +// NONEED: AV_RL48 + +// NONEED: AV_WL48 + +// The AV_[RW]NA macros access naturally aligned data +// in a type-safe way. + +// NONEED: AV_RNA + +// NONEED: AV_WNA + +// NONEED: AV_RN16A + +// NONEED: AV_RN32A + +// NONEED: AV_RN64A + +// NONEED: AV_WN16A + +// NONEED: AV_WN32A + +// NONEED: AV_WN64A + +// NONEED: AV_RLA + +// NONEED: AV_WLA + +// NONEED: AV_RL64A + +// NONEED: AV_WL64A + +// The AV_COPYxxU macros are suitable for copying data to/from unaligned +// memory locations. + +// NONEED: AV_COPYU + +// NONEED: AV_COPY16U + +// NONEED: AV_COPY32U + +// NONEED: AV_COPY64U + +// NONEED: AV_COPY128U + +// Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be +// naturally aligned. They may be implemented using MMX, +// so emms_c() must be called before using any float code +// afterwards. + +// NONEED: AV_COPY + +// NONEED: AV_COPY16 + +// NONEED: AV_COPY32 + +// NONEED: AV_COPY64 + +// NONEED: AV_COPY128 + +// NONEED: AV_SWAP + +// NONEED: AV_SWAP64 + +// NONEED: AV_ZERO + +// NONEED: AV_ZERO16 + +// NONEED: AV_ZERO32 + +// NONEED: AV_ZERO64 + +// NONEED: AV_ZERO128 diff --git a/avutil_lfg.go b/avutil_lfg.go new file mode 100644 index 0000000..431c088 --- /dev/null +++ b/avutil_lfg.go @@ -0,0 +1,38 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +type AVLFG C.struct_AVLFG + +// AvLfgInit +func AvLfgInit(c *AVLFG, seed uint32) { + C.av_lfg_init((*C.struct_AVLFG)(c), (C.uint)(seed)) +} + +// AvLfgInitFromData seeds the state of the ALFG using binary data. +func AvLfgInitFromData(c *AVLFG, data *uint8, length uint) int32 { + return (int32)(C.av_lfg_init_from_data((*C.struct_AVLFG)(c), + (*C.uint8_t)(data), (C.uint)(length))) +} + +// AvLfgGet gets the next random unsigned 32-bit number using an ALFG. +func AvLfgGet(c *AVLFG) uint32 { + return (uint32)(C.av_lfg_get((*C.struct_AVLFG)(c))) +} + +// AvMlfgGet gets the next random unsigned 32-bit number using a MLFG. +func AvMlfgGet(c *AVLFG) uint32 { + return (uint32)(C.av_mlfg_get((*C.struct_AVLFG)(c))) +} + +// AvBmgGet gets the next two numbers generated by a Box-Muller Gaussian +// generator using the random numbers issued by lfg. +func AvBmgGet(lfg *AVLFG, out []float64) { + if len(out) < 2 { + panic("out len < 2") + } + C.av_bmg_get((*C.struct_AVLFG)(lfg), (*C.double)(&out[0])) +} diff --git a/avutil_lzo.go b/avutil_lzo.go new file mode 100644 index 0000000..6e97237 --- /dev/null +++ b/avutil_lzo.go @@ -0,0 +1,21 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +const ( + AV_LZO_INPUT_DEPLETED = C.AV_LZO_INPUT_DEPLETED + AV_LZO_OUTPUT_FULL = C.AV_LZO_OUTPUT_FULL + AV_LZO_INVALID_BACKPTR = C.AV_LZO_INVALID_BACKPTR + AV_LZO_ERROR = C.AV_LZO_ERROR + AV_LZO_INPUT_PADDING = C.AV_LZO_INPUT_PADDING + AV_LZO_OUTPUT_PADDING = C.AV_LZO_OUTPUT_PADDING +) + +// AvLzo1xDecode decodes LZO 1x compressed data. +func AvLzo1xDecode(out CVoidPointer, outlen *int32, in CVoidPointer, inlen *int32) int32 { + return (int32)(C.av_lzo1x_decode(VoidPointer(out), + (*C.int)(outlen), VoidPointer(in), (*C.int)(inlen))) +} diff --git a/avutil_macros.go b/avutil_macros.go new file mode 100644 index 0000000..d9997a8 --- /dev/null +++ b/avutil_macros.go @@ -0,0 +1,10 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +func FFALIGN[T HelperInteger](x, a T) T { + return ((x) + (a) - 1) & ^((a) - 1) +} diff --git a/avutil_mastering_display_metadata.go b/avutil_mastering_display_metadata.go new file mode 100644 index 0000000..16c0d0b --- /dev/null +++ b/avutil_mastering_display_metadata.go @@ -0,0 +1,168 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +// AVMasteringDisplayMetadata +type AVMasteringDisplayMetadata C.struct_AVMasteringDisplayMetadata + +// Custom: GetDisplayPrimaries gets `AVMasteringDisplayMetadata.display_primaries` value. +func (mdm *AVMasteringDisplayMetadata) GetDisplayPrimaries() (v [][]AVRational) { + for i := 0; i < 3; i++ { + v = append(v, unsafe.Slice((*AVRational)(&mdm.display_primaries[i][0]), 2)) + } + return v +} + +// Custom: SetDisplayPrimaries sets `AVMasteringDisplayMetadata.display_primaries` value. +func (mdm *AVMasteringDisplayMetadata) SetDisplayPrimaries(v [][]AVRational) { + for i := 0; i < FFMIN(len(v), 3); i++ { + for j := 0; j < FFMIN(len(v[i]), 2); j++ { + mdm.display_primaries[i][j] = (C.struct_AVRational)(v[i][j]) + } + } +} + +// Custom: GetDisplayPrimariesAddr gets `AVMasteringDisplayMetadata.display_primaries` address. +func (mdm *AVMasteringDisplayMetadata) GetDisplayPrimariesAddr() **AVRational { + return (**AVRational)(unsafe.Pointer(&mdm.display_primaries)) +} + +// Custom: GetWhitePoint gets `AVMasteringDisplayMetadata.white_point` value. +func (mdm *AVMasteringDisplayMetadata) GetWhitePoint() []AVRational { + return unsafe.Slice((*AVRational)(&mdm.white_point[0]), 2) +} + +// Custom: SetWhitePoint sets `AVMasteringDisplayMetadata.white_point` value. +func (mdm *AVMasteringDisplayMetadata) SetWhitePoint(v []AVRational) { + for i := 0; i < FFMIN(len(v), 2); i++ { + mdm.white_point[i] = (C.struct_AVRational)(v[i]) + } +} + +// Custom: GetWhitePointAddr gets `AVMasteringDisplayMetadata.white_point` address. +func (mdm *AVMasteringDisplayMetadata) GetWhitePointAddr() **AVRational { + return (**AVRational)(unsafe.Pointer(&mdm.white_point)) +} + +// Custom: GetMinLuminance gets `AVMasteringDisplayMetadata.min_luminance` value. +func (mdm *AVMasteringDisplayMetadata) GetMinLuminance() AVRational { + return (AVRational)(mdm.min_luminance) +} + +// Custom: SetMinLuminance sets `AVMasteringDisplayMetadata.min_luminance` value. +func (mdm *AVMasteringDisplayMetadata) SetMinLuminance(v AVRational) { + mdm.min_luminance = (C.struct_AVRational)(v) +} + +// Custom: GetMinLuminanceAddr gets `AVMasteringDisplayMetadata.min_luminance` address. +func (mdm *AVMasteringDisplayMetadata) GetMinLuminanceAddr() *AVRational { + return (*AVRational)(&mdm.min_luminance) +} + +// Custom: GetMaxLuminance gets `AVMasteringDisplayMetadata.max_luminance` value. +func (mdm *AVMasteringDisplayMetadata) GetMaxLuminance() AVRational { + return (AVRational)(mdm.max_luminance) +} + +// Custom: SetMaxLuminance sets `AVMasteringDisplayMetadata.max_luminance` value. +func (mdm *AVMasteringDisplayMetadata) SetMaxLuminance(v AVRational) { + mdm.max_luminance = (C.struct_AVRational)(v) +} + +// Custom: GetMaxLuminanceAddr gets `AVMasteringDisplayMetadata.max_luminance` address. +func (mdm *AVMasteringDisplayMetadata) GetMaxLuminanceAddr() *AVRational { + return (*AVRational)(&mdm.max_luminance) +} + +// Custom: GetHasPrimaries gets `AVMasteringDisplayMetadata.has_primaries` value. +func (mdm *AVMasteringDisplayMetadata) GetHasPrimaries() int32 { + return (int32)(mdm.has_primaries) +} + +// Custom: SetHasPrimaries sets `AVMasteringDisplayMetadata.has_primaries` value. +func (mdm *AVMasteringDisplayMetadata) SetHasPrimaries(v int32) { + mdm.has_primaries = (C.int)(v) +} + +// Custom: GetHasPrimariesAddr gets `AVMasteringDisplayMetadata.has_primaries` address. +func (mdm *AVMasteringDisplayMetadata) GetHasPrimariesAddr() *int32 { + return (*int32)(&mdm.has_primaries) +} + +// Custom: GetHasLuminance gets `AVMasteringDisplayMetadata.has_luminance` value. +func (mdm *AVMasteringDisplayMetadata) GetHasLuminance() int32 { + return (int32)(mdm.has_luminance) +} + +// Custom: SetHasLuminance sets `AVMasteringDisplayMetadata.has_luminance` value. +func (mdm *AVMasteringDisplayMetadata) SetHasLuminance(v int32) { + mdm.has_luminance = (C.int)(v) +} + +// Custom: GetHasLuminanceAddr gets `AVMasteringDisplayMetadata.has_luminance` address. +func (mdm *AVMasteringDisplayMetadata) GetHasLuminanceAddr() *int32 { + return (*int32)(&mdm.has_luminance) +} + +// AvMasteringDisplayMetadataAlloc allocates an AVMasteringDisplayMetadata structure +// and set its fields to default values. +func AvMasteringDisplayMetadataAlloc() *AVMasteringDisplayMetadata { + return (*AVMasteringDisplayMetadata)(C.av_mastering_display_metadata_alloc()) +} + +// AvMasteringDisplayMetadataCreateSideData allocates a complete AVMasteringDisplayMetadata +// and add it to the frame. +func AvMasteringDisplayMetadataCreateSideData(frame *AVFrame) *AVMasteringDisplayMetadata { + return (*AVMasteringDisplayMetadata)(C.av_mastering_display_metadata_create_side_data( + (*C.struct_AVFrame)(frame))) +} + +// AVContentLightMetadata +type AVContentLightMetadata C.struct_AVContentLightMetadata + +// Custom: GetMaxCLL gets `AVContentLightMetadata.MaxCLL` value. +func (clm *AVContentLightMetadata) GetMaxCLL() uint32 { + return (uint32)(clm.MaxCLL) +} + +// Custom: SetMaxCLL sets `AVContentLightMetadata.MaxCLL` value. +func (clm *AVContentLightMetadata) SetMaxCLL(v uint32) { + clm.MaxCLL = (C.uint)(v) +} + +// Custom: GetMaxCLLAddr gets `AVContentLightMetadata.MaxCLL` address. +func (clm *AVContentLightMetadata) GetMaxCLLAddr() *uint32 { + return (*uint32)(&clm.MaxCLL) +} + +// Custom: GetMaxFALL gets `AVContentLightMetadata.MaxFALL` value. +func (clm *AVContentLightMetadata) GetMaxFALL() uint32 { + return (uint32)(clm.MaxFALL) +} + +// Custom: SetMaxFALL sets `AVContentLightMetadata.MaxFALL` value. +func (clm *AVContentLightMetadata) SetMaxFALL(v uint32) { + clm.MaxFALL = (C.uint)(v) +} + +// Custom: GetMaxFALLAddr gets `AVContentLightMetadata.MaxFALL` address. +func (clm *AVContentLightMetadata) GetMaxFALLAddr() *uint32 { + return (*uint32)(&clm.MaxFALL) +} + +// AvContentLightMetadataAlloc allocates an AVContentLightMetadata structure and set its fields to +// default values. +func AvContentLightMetadataAlloc(size *uintptr) *AVContentLightMetadata { + return (*AVContentLightMetadata)(C.av_content_light_metadata_alloc( + (*C.size_t)(unsafe.Pointer(size)))) +} + +// AvContentLightMetadataCreateSideData allocates a complete AVContentLightMetadata and add it to the frame. +func AvContentLightMetadataCreateSideData(frame *AVFrame) *AVContentLightMetadata { + return (*AVContentLightMetadata)(C.av_content_light_metadata_create_side_data( + (*C.struct_AVFrame)(frame))) +} diff --git a/avutil_mem.go b/avutil_mem.go index 3416abd..2d76909 100644 --- a/avutil_mem.go +++ b/avutil_mem.go @@ -119,7 +119,7 @@ func AvDynarray2Add[T HelperInteger](tabPtr CVoidPointerPointer, nbPtr *int32, } // AvSizeMult multiplies two `size_t` values checking for overflow. -func AvSizeMult[T HelperInteger](a, b T, r *uint) int32 { +func AvSizeMult[T HelperInteger](a, b T, r *uintptr) int32 { return (int32)(C.av_size_mult((C.size_t)(a), (C.size_t)(b), (*C.size_t)(unsafe.Pointer(r)))) } diff --git a/avutil_opt.go b/avutil_opt.go index 6a22e40..a3af823 100644 --- a/avutil_opt.go +++ b/avutil_opt.go @@ -7,18 +7,50 @@ int64_t get_av_option_default_val_i64(AVOption *opt) { return opt->default_val.i64; } +void set_av_option_default_val_i64(AVOption *opt, int64_t v) { + opt->default_val.i64 = v; +} + +int64_t* get_av_option_default_val_i64_addr(AVOption *opt) { + return &opt->default_val.i64; +} + double get_av_option_default_val_dbl(AVOption *opt) { return opt->default_val.dbl; } +void set_av_option_default_val_dbl(AVOption *opt, double v) { + opt->default_val.dbl = v; +} + +double* get_av_option_default_val_dbl_addr(AVOption *opt) { + return &opt->default_val.dbl; +} + const char* get_av_option_default_val_str(AVOption *opt) { return opt->default_val.str; } +void set_av_option_default_val_str(AVOption *opt, const char* v) { + opt->default_val.str = v; +} + +const char** get_av_option_default_val_str_addr(AVOption *opt) { + return &opt->default_val.str; +} + AVRational get_av_option_default_val_q(AVOption *opt) { return opt->default_val.q; } +void set_av_option_default_val_q(AVOption *opt, AVRational v) { + opt->default_val.q = v; +} + +AVRational* get_av_option_default_val_q_addr(AVOption *opt) { + return &opt->default_val.q; +} + int av_opt_set_int_list_wrap(void *obj, const char *name, void *val, uint64_t term, int flags, int size) { if (av_int_list_length(val, term) > INT_MAX / size) { return AVERROR(EINVAL); @@ -104,21 +136,61 @@ func (opt *AVOption) GetDefaultValI64() int64 { return (int64)(C.get_av_option_default_val_i64((*C.struct_AVOption)(opt))) } +// Custom: SetDefaultValI64 sets `AVOption.default_val.i64` value. +func (opt *AVOption) SetDefaultValI64(v int64) { + C.set_av_option_default_val_i64((*C.struct_AVOption)(opt), (C.int64_t)(v)) +} + +// Custom: GetDefaultValI64Addr gets `AVOption.default_val.i64` address. +func (opt *AVOption) GetDefaultValI64Addr() *int64 { + return (*int64)(C.get_av_option_default_val_i64_addr((*C.struct_AVOption)(opt))) +} + // Custom: GetDefaultValDbl gets `AVOption.default_val.dbl` value. func (opt *AVOption) GetDefaultValDbl() float64 { return (float64)(C.get_av_option_default_val_dbl((*C.struct_AVOption)(opt))) } +// Custom: SetDefaultValDbl sets `AVOption.default_val.dbl` value. +func (opt *AVOption) SetDefaultValDbl(v float64) { + C.set_av_option_default_val_dbl((*C.struct_AVOption)(opt), (C.double)(v)) +} + +// Custom: GetDefaultValDblAddr gets `AVOption.default_val.dbl` address. +func (opt *AVOption) GetDefaultValDblAddr() *float64 { + return (*float64)(C.get_av_option_default_val_dbl_addr((*C.struct_AVOption)(opt))) +} + // Custom: GetDefaultValStr gets `AVOption.default_val.str` value. func (opt *AVOption) GetDefaultValStr() string { return C.GoString(C.get_av_option_default_val_str((*C.struct_AVOption)(opt))) } +// Custom: SetDefaultValStr sets `AVOption.default_val.str` value. +func (opt *AVOption) SetDefaultValStr(v *int8) { + C.set_av_option_default_val_str((*C.struct_AVOption)(opt), (*C.char)(v)) +} + +// Custom: GetDefaultValStrAddr gets `AVOption.default_val.str` address. +func (opt *AVOption) GetDefaultValStrAddr() **int8 { + return (**int8)(unsafe.Pointer(C.get_av_option_default_val_str_addr((*C.struct_AVOption)(opt)))) +} + // Custom: GetDefaultValQ gets `AVOption.default_val.q` value. func (opt *AVOption) GetDefaultValQ() AVRational { return (AVRational)(C.get_av_option_default_val_q((*C.struct_AVOption)(opt))) } +// Custom: SetDefaultValQ sets `AVOption.default_val.q` value. +func (opt *AVOption) SetDefaultValQ(v AVRational) { + C.set_av_option_default_val_q((*C.struct_AVOption)(opt), (C.struct_AVRational)(v)) +} + +// Custom: GetDefaultValQAddr gets `AVOption.default_val.q` address. +func (opt *AVOption) GetDefaultValQAddr() *AVRational { + return (*AVRational)(C.get_av_option_default_val_q_addr((*C.struct_AVOption)(opt))) +} + // Custom: GetMin gets `AVOption.min` value. func (opt *AVOption) GetMin() float64 { return (float64)(opt.min) @@ -254,17 +326,17 @@ func (optr *AVOptionRange) GetComponentMaxAddr() *float64 { return (*float64)(&optr.component_max) } -// Custom: GetIsRange gets `AVOptionRange.is_range` value. +// Custom: GetIsRange gets `AVOptionRange.isrange` value. func (optr *AVOptionRange) GetIsRange() int32 { return (int32)(optr.is_range) } -// Custom: SetIsRange sets `AVOptionRange.is_range` value. +// Custom: SetIsRange sets `AVOptionRange.isrange` value. func (optr *AVOptionRange) SetIsRange(v int32) { optr.is_range = (C.int)(v) } -// Custom: GetIsRangeAddr gets `AVOptionRange.is_range` address. +// Custom: GetIsRangeAddr gets `AVOptionRange.isrange` address. func (optr *AVOptionRange) GetIsRangeAddr() *int32 { return (*int32)(&optr.is_range) } diff --git a/avutil_random_seed.go b/avutil_random_seed.go new file mode 100644 index 0000000..c02dd44 --- /dev/null +++ b/avutil_random_seed.go @@ -0,0 +1,11 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AvGetRandomSeed gets a seed to use in conjunction with random functions. +func AvGetRandomSeed() uint32 { + return (uint32)(C.av_get_random_seed()) +} diff --git a/avutil_rc4.go b/avutil_rc4.go new file mode 100644 index 0000000..51ad435 --- /dev/null +++ b/avutil_rc4.go @@ -0,0 +1,26 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +type AVRC4 C.struct_AVRC4 + +// AvRc4Alloc allocates an AVRC4 context. +func AvRc4Alloc() *AVRC4 { + return (*AVRC4)(C.av_rc4_alloc()) +} + +// AvRc4Init initializes an AVRC4 context. +func AvRc4Init(d *AVRC4, key *uint8, keyBits int32, decrypt int32) int32 { + return (int32)(C.av_rc4_init((*C.struct_AVRC4)(d), + (*C.uint8_t)(key), (C.int)(keyBits), (C.int)(decrypt))) +} + +// AvRc4Crypt encrypts / decrypts using the RC4 algorithm. +func AvRc4Crypt(d *AVRC4, dst, src *uint8, count int32, iv *uint8, decrypt int32) { + C.av_rc4_crypt((*C.struct_AVRC4)(d), + (*C.uint8_t)(dst), (*C.uint8_t)(src), + (C.int)(count), (*C.uint8_t)(iv), (C.int)(decrypt)) +} diff --git a/avutil_replaygain.go b/avutil_replaygain.go new file mode 100644 index 0000000..a4470c5 --- /dev/null +++ b/avutil_replaygain.go @@ -0,0 +1,69 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +// AVReplayGain +type AVReplayGain C.struct_AVReplayGain + +// Custom: GetTrackGain gets `AVReplayGain.track_gain` value. +func (rg *AVReplayGain) GetTrackGain() int32 { + return (int32)(rg.track_gain) +} + +// Custom: SetTrackGain sets `AVReplayGain.track_gain` value. +func (rg *AVReplayGain) SetTrackGain(v int32) { + rg.track_gain = (C.int32_t)(v) +} + +// Custom: GetTrackGainAddr gets `AVReplayGain.track_gain` address. +func (rg *AVReplayGain) GetTrackGainAddr() *int32 { + return (*int32)(&rg.track_gain) +} + +// Custom: GetTrackPeak gets `AVReplayGain.track_peak` value. +func (rg *AVReplayGain) GetTrackPeak() uint32 { + return (uint32)(rg.track_peak) +} + +// Custom: SetTrackPeak sets `AVReplayGain.track_peak` value. +func (rg *AVReplayGain) SetTrackPeak(v uint32) { + rg.track_peak = (C.uint32_t)(v) +} + +// Custom: GetTrackPeakAddr gets `AVReplayGain.track_peak` address. +func (rg *AVReplayGain) GetTrackPeakAddr() *uint32 { + return (*uint32)(&rg.track_peak) +} + +// Custom: GetAlbumGain gets `AVReplayGain.album_gain` value. +func (rg *AVReplayGain) GetAlbumGain() int32 { + return (int32)(rg.album_gain) +} + +// Custom: SetAlbumGain sets `AVReplayGain.album_gain` value. +func (rg *AVReplayGain) SetAlbumGain(v int32) { + rg.album_gain = (C.int32_t)(v) +} + +// Custom: GetAlbumGainAddr gets `AVReplayGain.album_gain` address. +func (rg *AVReplayGain) GetAlbumGainAddr() *int32 { + return (*int32)(&rg.album_gain) +} + +// Custom: GetAlbumPeak gets `AVReplayGain.album_peak` value. +func (rg *AVReplayGain) GetAlbumPeak() uint32 { + return (uint32)(rg.album_peak) +} + +// Custom: SetAlbumPeak sets `AVReplayGain.album_peak` value. +func (rg *AVReplayGain) SetAlbumPeak(v uint32) { + rg.album_peak = (C.uint32_t)(v) +} + +// Custom: GetAlbumPeakAddr gets `AVReplayGain.album_peak` address. +func (rg *AVReplayGain) GetAlbumPeakAddr() *uint32 { + return (*uint32)(&rg.album_peak) +} diff --git a/avutil_ripemd.go b/avutil_ripemd.go new file mode 100644 index 0000000..42c2e7f --- /dev/null +++ b/avutil_ripemd.go @@ -0,0 +1,28 @@ +package ffmpeg + +/* +#include +*/ +import "C" + +type AVRIPEMD C.struct_AVRIPEMD + +// AvRipemdAlloc allocates an AVRIPEMD context. +func AvRipemdAlloc() *AVRIPEMD { + return (*AVRIPEMD)(C.av_ripemd_alloc()) +} + +// AvRipemdInit initializes RIPEMD hashing. +func AvRipemdInit(context *AVRIPEMD, bits int32) int32 { + return (int32)(C.av_ripemd_init((*C.struct_AVRIPEMD)(context), (C.int)(bits))) +} + +// AvRipemdUpdate updates hash value. +func AvRipemdUpdate(context *AVRIPEMD, data *uint8, len uint32) { + C.av_ripemd_update((*C.struct_AVRIPEMD)(context), (*C.uint8_t)(data), (C.uint)(len)) +} + +// AvRipemdFinal finishes hashing and output digest value. +func AvRipemdFinal(context *AVRIPEMD, digest *uint8) { + C.av_ripemd_final((*C.struct_AVRIPEMD)(context), (*C.uint8_t)(digest)) +} diff --git a/avutil_video_enc_params.go b/avutil_video_enc_params.go new file mode 100644 index 0000000..8e28b41 --- /dev/null +++ b/avutil_video_enc_params.go @@ -0,0 +1,216 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +// AVVideoEncParamsType +type AVVideoEncParamsType = C.enum_AVVideoEncParamsType + +const ( + AV_VIDEO_ENC_PARAMS_NONE = AVVideoEncParamsType(C.AV_VIDEO_ENC_PARAMS_NONE) + AV_VIDEO_ENC_PARAMS_VP9 = AVVideoEncParamsType(C.AV_VIDEO_ENC_PARAMS_VP9) + AV_VIDEO_ENC_PARAMS_H264 = AVVideoEncParamsType(C.AV_VIDEO_ENC_PARAMS_H264) + AV_VIDEO_ENC_PARAMS_MPEG2 = AVVideoEncParamsType(C.AV_VIDEO_ENC_PARAMS_MPEG2) +) + +// AVVideoEncParams +type AVVideoEncParams C.struct_AVVideoEncParams + +// Custom: GetNbBlocks gets `AVVideoEncParams.nb_blocks` value. +func (vep *AVVideoEncParams) GetNbBlocks() uint32 { + return (uint32)(vep.nb_blocks) +} + +// Custom: SetNbBlocks sets `AVVideoEncParams.nb_blocks` value. +func (vep *AVVideoEncParams) SetNbBlocks(v uint32) { + vep.nb_blocks = (C.uint)(v) +} + +// Custom: GetNbBlocksAddr gets `AVVideoEncParams.nb_blocks` address. +func (vep *AVVideoEncParams) GetNbBlocksAddr() *uint32 { + return (*uint32)(&vep.nb_blocks) +} + +// Custom: GetBlocksOffset gets `AVVideoEncParams.blocks_offset` value. +func (vep *AVVideoEncParams) GetBlocksOffset() uintptr { + return (uintptr)(vep.blocks_offset) +} + +// Custom: SetBlocksOffset sets `AVVideoEncParams.blocks_offset` value. +func (vep *AVVideoEncParams) SetBlocksOffset(v uintptr) { + vep.blocks_offset = (C.size_t)(v) +} + +// Custom: GetBlocksOffsetAddr gets `AVVideoEncParams.blocks_offset` address. +func (vep *AVVideoEncParams) GetBlocksOffsetAddr() *uintptr { + return (*uintptr)(unsafe.Pointer(&vep.blocks_offset)) +} + +// Custom: GetBlockSize gets `AVVideoEncParams.block_size` value. +func (vep *AVVideoEncParams) GetBlockSize() uintptr { + return (uintptr)(vep.block_size) +} + +// Custom: SetBlockSize sets `AVVideoEncParams.block_size` value. +func (vep *AVVideoEncParams) SetBlockSize(v uintptr) { + vep.block_size = (C.size_t)(v) +} + +// Custom: GetBlockSizeAddr gets `AVVideoEncParams.block_size` address. +func (vep *AVVideoEncParams) GetBlockSizeAddr() *uintptr { + return (*uintptr)(unsafe.Pointer(&vep.block_size)) +} + +// Custom: GetType gets `AVVideoEncParams.type` value. +func (vep *AVVideoEncParams) GetType() AVVideoEncParamsType { + return (AVVideoEncParamsType)(vep._type) +} + +// Custom: SetType sets `AVVideoEncParams.type` value. +func (vep *AVVideoEncParams) SetType(v AVVideoEncParamsType) { + vep._type = (C.enum_AVVideoEncParamsType)(v) +} + +// Custom: GetTypeAddr gets `AVVideoEncParams.type` address. +func (vep *AVVideoEncParams) GetTypeAddr() *AVVideoEncParamsType { + return (*AVVideoEncParamsType)(&vep._type) +} + +// Custom: GetQp gets `AVVideoEncParams.qp` value. +func (vep *AVVideoEncParams) GetQp() int32 { + return (int32)(vep.qp) +} + +// Custom: SetQp sets `AVVideoEncParams.qp` value. +func (vep *AVVideoEncParams) SetQp(v int32) { + vep.qp = (C.int32_t)(v) +} + +// Custom: GetQpAddr gets `AVVideoEncParams.qp` address. +func (vep *AVVideoEncParams) GetQpAddr() *int32 { + return (*int32)(&vep.qp) +} + +// Custom: GetDeltaQp gets `AVVideoEncParams.delta_qp` value. +func (vep *AVVideoEncParams) GetDeltaQp() (v [][]int32) { + for i := 0; i < 4; i++ { + v = append(v, unsafe.Slice((*int32)(&vep.delta_qp[i][0]), 2)) + } + return v +} + +// Custom: SetDeltaQp sets `AVVideoEncParams.delta_qp` value. +func (vep *AVVideoEncParams) SetDeltaQp(v [][]int32) { + for i := 0; i < FFMIN(len(v), 4); i++ { + for j := 0; j < FFMIN(len(v[i]), 2); j++ { + vep.delta_qp[i][j] = (C.int)(v[i][j]) + } + } +} + +// Custom: GetDeltaQpAddr gets `AVVideoEncParams.delta_qp` address. +func (vep *AVVideoEncParams) GetDeltaQpAddr() **int32 { + return (**int32)(unsafe.Pointer(&vep.delta_qp)) +} + +// AVVideoBlockParams +type AVVideoBlockParams C.struct_AVVideoBlockParams + +// Custom: GetSrcX gets `AVVideoBlockParams.src_x` value. +func (vbp *AVVideoBlockParams) GetSrcX() int32 { + return (int32)(vbp.src_x) +} + +// Custom: SetSrcX sets `AVVideoBlockParams.src_x` value. +func (vbp *AVVideoBlockParams) SetSrcX(v int32) { + vbp.src_x = (C.int)(v) +} + +// Custom: GetSrcXAddr gets `AVVideoBlockParams.src_x` address. +func (vbp *AVVideoBlockParams) GetSrcXAddr() *int32 { + return (*int32)(&vbp.src_x) +} + +// Custom: GetSrcY gets `AVVideoBlockParams.src_y` value. +func (vbp *AVVideoBlockParams) GetSrcY() int32 { + return (int32)(vbp.src_y) +} + +// Custom: SetSrcY sets `AVVideoBlockParams.src_y` value. +func (vbp *AVVideoBlockParams) SetSrcY(v int32) { + vbp.src_y = (C.int)(v) +} + +// Custom: GetSrcYAddr gets `AVVideoBlockParams.src_y` address. +func (vbp *AVVideoBlockParams) GetSrcYAddr() *int32 { + return (*int32)(&vbp.src_y) +} + +// Custom: GetW gets `AVVideoBlockParams.w` value. +func (vbp *AVVideoBlockParams) GetW() int32 { + return (int32)(vbp.w) +} + +// Custom: SetW sets `AVVideoBlockParams.w` value. +func (vbp *AVVideoBlockParams) SetW(v int32) { + vbp.w = (C.int)(v) +} + +// Custom: GetWAddr gets `AVVideoBlockParams.w` address. +func (vbp *AVVideoBlockParams) GetWAddr() *int32 { + return (*int32)(&vbp.w) +} + +// Custom: GetH gets `AVVideoBlockParams.h` value. +func (vbp *AVVideoBlockParams) GetH() int32 { + return (int32)(vbp.h) +} + +// Custom: SetH sets `AVVideoBlockParams.h` value. +func (vbp *AVVideoBlockParams) SetH(v int32) { + vbp.h = (C.int)(v) +} + +// Custom: GetHAddr gets `AVVideoBlockParams.h` address. +func (vbp *AVVideoBlockParams) GetHAddr() *int32 { + return (*int32)(&vbp.h) +} + +// Custom: GetDeltaQp gets `AVVideoBlockParams.delta_qp` value. +func (vbp *AVVideoBlockParams) GetDeltaQp() int32 { + return (int32)(vbp.delta_qp) +} + +// Custom: SetDeltaQp sets `AVVideoBlockParams.delta_qp` value. +func (vbp *AVVideoBlockParams) SetDeltaQp(v int32) { + vbp.delta_qp = (C.int32_t)(v) +} + +// Custom: GetDeltaQpAddr gets `AVVideoBlockParams.delta_qp` address. +func (vbp *AVVideoBlockParams) GetDeltaQpAddr() *int32 { + return (*int32)(&vbp.delta_qp) +} + +// AvVideoEncParamsBlock gets the block at the specified idx. +func AvVideoEncParamsBlock(par *AVVideoEncParams, idx uint32) *AVVideoBlockParams { + return (*AVVideoBlockParams)(C.av_video_enc_params_block((*C.struct_AVVideoEncParams)(par), (C.uint)(idx))) +} + +// AvVideoEncParamsAlloc allocates memory for AVVideoEncParams of the given type, plus an array of +// nbBlocks AVVideoBlockParams and initializes the variables. +func AvVideoEncParamsAlloc(_type AVVideoEncParamsType, nbBlocks uint32, outSize *uintptr) *AVVideoEncParams { + return (*AVVideoEncParams)(C.av_video_enc_params_alloc((C.enum_AVVideoEncParamsType)(_type), + (C.uint)(nbBlocks), (*C.size_t)(unsafe.Pointer(outSize)))) +} + +// AvVideoEncParamsCreateSideData sllocates memory for AVEncodeInfoFrame plus an array of +// nbBlocks AVEncodeInfoBlock in the given AVFrame frame +// as AVFrameSideData of type AV_FRAME_DATA_VIDEO_ENC_PARAMS +// and initializes the variables. +func AvVideoEncParamsCreateSideData(frame *AVFrame, _type AVVideoEncParamsType, nbBlocks uint32) *AVVideoEncParams { + return (*AVVideoEncParams)(C.av_video_enc_params_create_side_data((*C.struct_AVFrame)(frame), + (C.enum_AVVideoEncParamsType)(_type), (C.uint)(nbBlocks))) +} diff --git a/avutil_xtea.go b/avutil_xtea.go new file mode 100644 index 0000000..cc1996e --- /dev/null +++ b/avutil_xtea.go @@ -0,0 +1,61 @@ +package ffmpeg + +/* +#include +*/ +import "C" +import "unsafe" + +type AVXTEA C.struct_AVXTEA + +// Custom: GetKey gets `AVXTEA.key` value. +func (dct *AVXTEA) GetKey() []uint32 { + return unsafe.Slice((*uint32)(&dct.key[0]), 16) +} + +// Custom: SetKey sets `AVXTEA.key` value. +func (dct *AVXTEA) SetKey(v []uint32) { + for i := 0; i < FFMIN(len(v), 16); i++ { + dct.key[i] = (C.uint32_t)(v[i]) + } +} + +// Custom: GetKeyAddr gets `AVXTEA.key` address. +func (dct *AVXTEA) GetKeyAddr() **uint32 { + return (**uint32)(unsafe.Pointer(&dct.key)) +} + +// AvXteaAlloc allocates an AVXTEA context. +func AvXteaAlloc() *AVXTEA { + return (*AVXTEA)(C.av_xtea_alloc()) +} + +// AvXteaInit initializes an AVXTEA context. +func AvXteaInit(ctx *AVXTEA, key []uint8) { + if len(key) < 16 { + panic("key len < 16") + } + C.av_xtea_init((*C.struct_AVXTEA)(ctx), (*C.uint8_t)(&key[0])) +} + +// AvXteaLeInit initializes an AVXTEA context. +func AvXteaLeInit(ctx *AVXTEA, key []uint8) { + if len(key) < 16 { + panic("key len < 16") + } + C.av_xtea_le_init((*C.struct_AVXTEA)(ctx), (*C.uint8_t)(&key[0])) +} + +// AvXteaCrypt encrypts or decrypts a buffer using a previously initialized context, +// in big endian format. +func AvXteaCrypt(ctx *AVXTEA, dst, src *uint8, count int32, iv *uint8, decrypt int32) { + C.av_xtea_crypt((*C.struct_AVXTEA)(ctx), (*C.uint8_t)(dst), (*C.uint8_t)(src), + (C.int)(count), (*C.uint8_t)(iv), (C.int)(decrypt)) +} + +// AvXteaLeCrypt encrypts or decrypts a buffer using a previously initialized context, +// in little endian format. +func AvXteaLeCrypt(ctx *AVXTEA, dst, src *uint8, count int32, iv *uint8, decrypt int32) { + C.av_xtea_le_crypt((*C.struct_AVXTEA)(ctx), (*C.uint8_t)(dst), (*C.uint8_t)(src), + (C.int)(count), (*C.uint8_t)(iv), (C.int)(decrypt)) +} diff --git a/examples/decode-audio/main.go b/examples/decode-audio/main.go index 8aa23bc..4dc7b47 100644 --- a/examples/decode-audio/main.go +++ b/examples/decode-audio/main.go @@ -60,9 +60,10 @@ func decode(decCtx *ffmpeg.AVCodecContext, pkt *ffmpeg.AVPacket, frame *ffmpeg.A fmt.Fprintf(os.Stderr, "Failed to calculate data size\n") os.Exit(1) } + data := ffmpeg.SliceSlice(&frame.GetData()[0], decCtx.GetChannels(), frame.GetNbSamples()*dataSize) for i := int32(0); i < frame.GetNbSamples(); i++ { for ch := 0; ch < int(decCtx.GetChannels()); ch++ { - outfile.Write(ffmpeg.ByteSliceWithOffset(frame.GetData()[ch], dataSize*i, dataSize)) + outfile.Write(data[ch][dataSize*i : dataSize*(i+1)]) } } } diff --git a/examples/decode-video/main.go b/examples/decode-video/main.go index f99375e..a1ea846 100644 --- a/examples/decode-video/main.go +++ b/examples/decode-video/main.go @@ -5,6 +5,7 @@ import ( "io" "os" "syscall" + "unsafe" ffmpeg "github.com/qrtc/ffmpeg-dev-go" ) @@ -16,8 +17,9 @@ const ( func pgmSave(buf *uint8, wrap, xsize, ysize int32, filename string) { f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) fmt.Fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255) + bufSlice := unsafe.Slice(buf, xsize*ysize) for i := int32(0); i < ysize; i++ { - f.Write(ffmpeg.ByteSliceWithOffset(buf, i+wrap, xsize)) + f.Write(bufSlice[i+wrap : i+wrap+xsize]) } f.Close() } diff --git a/examples/encode-audio/main.go b/examples/encode-audio/main.go index 9212ee1..202b897 100644 --- a/examples/encode-audio/main.go +++ b/examples/encode-audio/main.go @@ -73,10 +73,9 @@ func encode(ctx *ffmpeg.AVCodecContext, frame *ffmpeg.AVFrame, pkt *ffmpeg.AVPac os.Exit(1) } - output.Write(ffmpeg.ByteSlice(pkt.GetData(), pkt.GetSize())) + output.Write(unsafe.Slice(pkt.GetData(), pkt.GetSize())) ffmpeg.AvPacketUnref(pkt) } - } func main() { diff --git a/examples/extract-mvs/main.go b/examples/extract-mvs/main.go index 7905807..cef2963 100644 --- a/examples/extract-mvs/main.go +++ b/examples/extract-mvs/main.go @@ -1,5 +1,159 @@ package main -func main() { +// http-multiclient README.txt http://localhost:8082 +import ( + "fmt" + "os" + "syscall" + "unsafe" + + ffmpeg "github.com/qrtc/ffmpeg-dev-go" +) + +var ( + videoFrameCount int + srcFilename string +) + +func decodePacket(videoDecCtx *ffmpeg.AVCodecContext, + pkt *ffmpeg.AVPacket, frame *ffmpeg.AVFrame) (ret int32) { + + if ret = ffmpeg.AvCodecSendPacket(videoDecCtx, pkt); ret < 0 { + fmt.Fprintf(os.Stderr, "Error while sending a packet to the decoder: %s\n", ffmpeg.AvErr2str(ret)) + return ret + } + + for ret >= 0 { + ret = ffmpeg.AvCodecReceiveFrame(videoDecCtx, frame) + if ret == ffmpeg.AVERROR(syscall.EAGAIN) || ret == ffmpeg.AVERROR_EOF { + break + } else if ret < 0 { + fmt.Fprintf(os.Stderr, "Error while receiving a frame from the decoder: %s\n", ffmpeg.AvErr2str(ret)) + return ret + } + + if ret > 0 { + videoFrameCount++ + if sd := ffmpeg.AvFrameGetSideData(frame, ffmpeg.AV_FRAME_DATA_MOTION_VECTORS); sd != nil { + mvs := (*ffmpeg.AVMotionVector)(unsafe.Pointer(sd.GetData())) + nbMvs := int(sd.GetSize()) / int(unsafe.Sizeof(*mvs)) + for i := 0; i < nbMvs; i++ { + mv := ffmpeg.PointerOffset(mvs, i) + fmt.Fprintf(os.Stdout, "%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,0x%d\n", + videoFrameCount, mv.GetSource(), + mv.GetW(), mv.GetH(), mv.GetSrcX(), mv.GetSrcY(), + mv.GetDstX(), mv.GetDstY(), mv.GetFlags()) + } + } + ffmpeg.AvFrameUnref(frame) + } + } + + return 0 +} + +func openCodecContext(fmtCtx *ffmpeg.AVFormatContext, _type ffmpeg.AVMediaType) ( + videoStreamIdx int32, videoStream *ffmpeg.AVStream, videoDecCtx *ffmpeg.AVCodecContext, ret int32) { + var ( + dec *ffmpeg.AVCodec + opt *ffmpeg.AVDictionary + ) + ret = ffmpeg.AvFindBestStream(fmtCtx, _type, -1, -1, &dec, 0) + if ret < 0 { + fmt.Fprintf(os.Stderr, "Could not find %s stream in input file '%s'\n", + ffmpeg.AvGetMediaTypeString(_type), srcFilename) + return 0, nil, nil, ret + } else { + videoStreamIdx = ret + videoStream = fmtCtx.GetStreams()[videoStreamIdx] + + if videoDecCtx = ffmpeg.AvCodecAllocContext3(dec); videoDecCtx == nil { + fmt.Fprintf(os.Stderr, "Failed to allocate codec\n") + return 0, nil, nil, ffmpeg.AVERROR(syscall.EINVAL) + } + + if ret = ffmpeg.AvCodecParametersToContext(videoDecCtx, videoStream.GetCodecpar()); ret < 0 { + fmt.Fprintf(os.Stderr, "Failed to copy codec parameters to codec context\n") + return 0, nil, nil, ret + } + + // Init the video decoder + ffmpeg.AvDictSet(&opt, "flags2", "+export_mvs", 0) + if ret = ffmpeg.AvCodecOpen2(videoDecCtx, dec, &opt); ret < 0 { + fmt.Fprintf(os.Stderr, "Failed to open %s codec\n", ffmpeg.AvGetMediaTypeString(_type)) + return 0, nil, nil, ret + } + + } + return videoStreamIdx, videoStream, videoDecCtx, 0 +} + +func main() { + var ( + fmtCtx *ffmpeg.AVFormatContext + videoDecCtx *ffmpeg.AVCodecContext + videoStream *ffmpeg.AVStream + videoStreamIdx int32 + frame *ffmpeg.AVFrame + + pkt ffmpeg.AVPacket + ret int32 + ) + + if len(os.Args) != 2 { + fmt.Fprintf(os.Stderr, "Usage: %s