mirror of
https://github.com/qrtc/ffmpeg-dev-go.git
synced 2025-10-04 15:23:13 +08:00
2023-10-19 14:31:46 CST W42D4
This commit is contained in:
199
avcodec_codec.go
199
avcodec_codec.go
@@ -4,7 +4,6 @@ package ffmpeg
|
||||
#include <libavcodec/codec.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
const (
|
||||
AV_CODEC_CAP_DRAW_HORIZ_BAND = C.AV_CODEC_CAP_DRAW_HORIZ_BAND
|
||||
@@ -30,178 +29,135 @@ const (
|
||||
AV_CODEC_CAP_ENCODER_FLUSH = C.AV_CODEC_CAP_ENCODER_FLUSH
|
||||
)
|
||||
|
||||
// AvProfile
|
||||
type AvProfile C.struct_AVProfile
|
||||
// AVProfile
|
||||
type AVProfile C.struct_AVProfile
|
||||
|
||||
// Custom: GetProfile gets `AVProfile.profile` value.
|
||||
func (p *AvProfile) GetProfile() int32 {
|
||||
func (p *AVProfile) GetProfile() int32 {
|
||||
return (int32)(p.profile)
|
||||
}
|
||||
|
||||
// Custom: GetName gets `AVProfile.name` value.
|
||||
func (p *AvProfile) GetName() string {
|
||||
func (p *AVProfile) GetName() string {
|
||||
return C.GoString(p.name)
|
||||
}
|
||||
|
||||
// AvCodec
|
||||
type AvCodec C.struct_AVCodec
|
||||
// AVCodec
|
||||
type AVCodec C.struct_AVCodec
|
||||
|
||||
// Custom: GetName gets `AVCodec.name` value.
|
||||
func (codec *AvCodec) GetName() string {
|
||||
func (codec *AVCodec) GetName() string {
|
||||
return C.GoString(codec.name)
|
||||
}
|
||||
|
||||
// Custom: GetLongName gets `AVCodec.long_name` value.
|
||||
func (codec *AvCodec) GetLongName() string {
|
||||
func (codec *AVCodec) GetLongName() string {
|
||||
return C.GoString(codec.long_name)
|
||||
}
|
||||
|
||||
// Custom: GetType gets `AVCodec.type` value.
|
||||
func (codec *AvCodec) GetType() AvMediaType {
|
||||
return (AvMediaType)(codec._type)
|
||||
func (codec *AVCodec) GetType() AVMediaType {
|
||||
return (AVMediaType)(codec._type)
|
||||
}
|
||||
|
||||
// Custom: GetType gets `AVCodec.id` value.
|
||||
func (codec *AvCodec) GetID() AvCodecID {
|
||||
return (AvCodecID)(codec.id)
|
||||
func (codec *AVCodec) GetID() AVCodecID {
|
||||
return (AVCodecID)(codec.id)
|
||||
}
|
||||
|
||||
// Custom: GetCapabilities gets `AVCodec.capabilities` value.
|
||||
func (codec *AvCodec) GetCapabilities() int32 {
|
||||
func (codec *AVCodec) GetCapabilities() int32 {
|
||||
return (int32)(codec.capabilities)
|
||||
}
|
||||
|
||||
// Custom: GetSupportedFramerates gets `AVCodec.supportedFramerates` value.
|
||||
func (codec *AvCodec) GetSupportedFramerates() (v []AvRational) {
|
||||
if codec.supported_framerates == nil {
|
||||
return v
|
||||
}
|
||||
zeroQ := AvMakeQ(0, 0)
|
||||
ptr := (*AvRational)(codec.supported_framerates)
|
||||
for AvCmpQ(zeroQ, *ptr) != 0 {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*AvRational)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
func (codec *AVCodec) GetSupportedFramerates() []AVRational {
|
||||
return TruncSlice((*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() (v []AvPixelFormat) {
|
||||
if codec.pix_fmts == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*AvPixelFormat)(codec.pix_fmts)
|
||||
for *ptr != AV_PIX_FMT_NONE {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*AvPixelFormat)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
func (codec *AVCodec) GetPixFmts() []AVPixelFormat {
|
||||
return TruncSlice((*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() (v []int32) {
|
||||
if codec.supported_samplerates == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*int32)(codec.supported_samplerates)
|
||||
for *ptr != 0 {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
func (codec *AVCodec) GetSupportedSamplerates() []int32 {
|
||||
return TruncSlice((*int32)(codec.supported_samplerates), func(i int32) bool {
|
||||
return i == 0
|
||||
})
|
||||
}
|
||||
|
||||
// Custom: GetSampleFmts gets `AVCodec.sample_fmts` value.
|
||||
func (codec *AvCodec) GetSampleFmts() (v []AvSampleFormat) {
|
||||
if codec.sample_fmts == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*AvSampleFormat)(codec.sample_fmts)
|
||||
for *ptr != AV_SAMPLE_FMT_NONE {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*AvSampleFormat)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
func (codec *AVCodec) GetSampleFmts() []AVSampleFormat {
|
||||
return TruncSlice((*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() (v []uint64) {
|
||||
if codec.channel_layouts == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*uint64)(codec.channel_layouts)
|
||||
for *ptr != 0 {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
func (codec *AVCodec) GetChannelLayouts() []uint64 {
|
||||
return TruncSlice((*uint64)(codec.channel_layouts), func(u uint64) bool {
|
||||
return u == 0
|
||||
})
|
||||
}
|
||||
|
||||
// Custom: GetMaxLowres gets `AVCodec.max_lowres` value.
|
||||
func (codec *AvCodec) GetMaxLowres() uint8 {
|
||||
func (codec *AVCodec) GetMaxLowres() uint8 {
|
||||
return (uint8)(codec.max_lowres)
|
||||
}
|
||||
|
||||
// Custom: GetProfiles gets `AVCodec.profiles` value.
|
||||
func (codec *AvCodec) GetProfiles() (v []AvProfile) {
|
||||
if codec.profiles == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*AvProfile)(codec.profiles)
|
||||
for ptr.GetProfile() != FF_PROFILE_UNKNOWN {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*AvProfile)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
func (codec *AVCodec) GetProfiles() []AVProfile {
|
||||
return TruncSlice((*AVProfile)(codec.profiles), func(ap AVProfile) bool {
|
||||
return ap.GetProfile() == FF_PROFILE_UNKNOWN
|
||||
})
|
||||
}
|
||||
|
||||
// Custom: GetWrapperName gets `AVCodec.wrapper_name` value.
|
||||
func (codec *AvCodec) GetWrapperName() string {
|
||||
func (codec *AVCodec) GetWrapperName() string {
|
||||
return C.GoString(codec.wrapper_name)
|
||||
}
|
||||
|
||||
// AvCodecIterate iterates over all registered codecs.
|
||||
func AvCodecIterate(opaque *unsafe.Pointer) *AvCodec {
|
||||
return (*AvCodec)(C.av_codec_iterate(opaque))
|
||||
func AvCodecIterate(opaque CVoidPointerPointer) *AVCodec {
|
||||
return (*AVCodec)(C.av_codec_iterate(VoidPointerPointer(opaque)))
|
||||
}
|
||||
|
||||
// AvCodecFindDecoder finds a registered decoder with a matching codec ID.
|
||||
func AvCodecFindDecoder(id AvCodecID) *AvCodec {
|
||||
return (*AvCodec)(C.avcodec_find_decoder((C.enum_AVCodecID)(id)))
|
||||
func AvCodecFindDecoder(id AVCodecID) *AVCodec {
|
||||
return (*AVCodec)(C.avcodec_find_decoder((C.enum_AVCodecID)(id)))
|
||||
}
|
||||
|
||||
// AvCodecFindDecoderByName finds a registered decoder with the specified name.
|
||||
func AvCodecFindDecoderByName(name string) *AvCodec {
|
||||
func AvCodecFindDecoderByName(name string) *AVCodec {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvCodec)(C.avcodec_find_decoder_by_name((*C.char)(namePtr)))
|
||||
return (*AVCodec)(C.avcodec_find_decoder_by_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvCodecFindEncoder finds a registered encoder with a matching codec ID.
|
||||
func AvCodecFindEncoder(id AvCodecID) *AvCodec {
|
||||
return (*AvCodec)(C.avcodec_find_encoder((C.enum_AVCodecID)(id)))
|
||||
func AvCodecFindEncoder(id AVCodecID) *AVCodec {
|
||||
return (*AVCodec)(C.avcodec_find_encoder((C.enum_AVCodecID)(id)))
|
||||
}
|
||||
|
||||
// AvCodecFindEncoderByName finds a registered encoder with the specified name.
|
||||
func AvCodecFindEncoderByName(name string) *AvCodec {
|
||||
func AvCodecFindEncoderByName(name string) *AVCodec {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvCodec)(C.avcodec_find_encoder_by_name((*C.char)(namePtr)))
|
||||
return (*AVCodec)(C.avcodec_find_encoder_by_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvCodecIsEncoder returns a non-zero number if codec is an encoder, zero otherwise
|
||||
func AvCodecIsEncoder(codec *AvCodec) int32 {
|
||||
func AvCodecIsEncoder(codec *AVCodec) int32 {
|
||||
return (int32)(C.av_codec_is_encoder((*C.struct_AVCodec)(codec)))
|
||||
}
|
||||
|
||||
// AvCodecIsDecoder returns a non-zero number if codec is an decoder, zero otherwise
|
||||
func AvCodecIsDecoder(codec *AvCodec) int32 {
|
||||
func AvCodecIsDecoder(codec *AVCodec) int32 {
|
||||
return (int32)(C.av_codec_is_decoder((*C.struct_AVCodec)(codec)))
|
||||
}
|
||||
|
||||
@@ -212,10 +168,55 @@ const (
|
||||
AV_CODEC_HW_CONFIG_METHOD_AD_HOC = int32(C.AV_CODEC_HW_CONFIG_METHOD_AD_HOC)
|
||||
)
|
||||
|
||||
// AvCodecHWConfig
|
||||
type AvCodecHWConfig C.struct_AVCodecHWConfig
|
||||
// AVCodecHWConfig
|
||||
type AVCodecHWConfig C.struct_AVCodecHWConfig
|
||||
|
||||
// Custom: GetPixFmt gets `AVCodecHWConfig.pix_fmt` value.
|
||||
func (hwc *AVCodecHWConfig) GetPixFmt() AVPixelFormat {
|
||||
return (AVPixelFormat)(hwc.pix_fmt)
|
||||
}
|
||||
|
||||
// Custom: SetPixFmt sets `AVCodecHWConfig.pix_fmt` value.
|
||||
func (hwc *AVCodecHWConfig) SetPixFmt(v AVPixelFormat) {
|
||||
hwc.pix_fmt = (C.enum_AVPixelFormat)(v)
|
||||
}
|
||||
|
||||
// Custom: GetPixFmtAddr gets `AVCodecHWConfig.pix_fmt` address.
|
||||
func (hwc *AVCodecHWConfig) GetPixFmtAddr() *AVPixelFormat {
|
||||
return (*AVPixelFormat)(&hwc.pix_fmt)
|
||||
}
|
||||
|
||||
// Custom: GetMethods gets `AVCodecHWConfig.methods` value.
|
||||
func (hwc *AVCodecHWConfig) GetMethods() int32 {
|
||||
return (int32)(hwc.methods)
|
||||
}
|
||||
|
||||
// Custom: SetMethods sets `AVCodecHWConfig.methods` value.
|
||||
func (hwc *AVCodecHWConfig) SetMethods(v int32) {
|
||||
hwc.methods = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetMethodsAddr gets `AVCodecHWConfig.methods` address.
|
||||
func (hwc *AVCodecHWConfig) GetMethodsAddr() *int32 {
|
||||
return (*int32)(&hwc.methods)
|
||||
}
|
||||
|
||||
// Custom: GetDeviceType gets `AVCodecHWConfig.device_type` value.
|
||||
func (hwc *AVCodecHWConfig) GetDeviceType() AVHWDeviceType {
|
||||
return (AVHWDeviceType)(hwc.device_type)
|
||||
}
|
||||
|
||||
// Custom: SetDeviceType sets `AVCodecHWConfig.device_type` value.
|
||||
func (hwc *AVCodecHWConfig) SetDeviceType(v AVHWDeviceType) {
|
||||
hwc.device_type = (C.enum_AVHWDeviceType)(v)
|
||||
}
|
||||
|
||||
// Custom: GetDeviceTypeAddr gets `AVCodecHWConfig.device_type` address.
|
||||
func (hwc *AVCodecHWConfig) GetDeviceTypeAddr() *AVHWDeviceType {
|
||||
return (*AVHWDeviceType)(&hwc.device_type)
|
||||
}
|
||||
|
||||
// AvCodecGetHwConfig retrieves supported hardware configurations for a codec.
|
||||
func AvCodecGetHwConfig(codec *AvCodec, index int32) *AvCodecHWConfig {
|
||||
return (*AvCodecHWConfig)(C.avcodec_get_hw_config((*C.struct_AVCodec)(codec), (C.int)(index)))
|
||||
func AvCodecGetHwConfig[T HelperInteger](codec *AVCodec, index T) *AVCodecHWConfig {
|
||||
return (*AVCodecHWConfig)(C.avcodec_get_hw_config((*C.struct_AVCodec)(codec), (C.int)(index)))
|
||||
}
|
||||
|
Reference in New Issue
Block a user