Files
go-astiav/hardware_frames_constraints.go
Tryanks a541263dfd Now compatible with n8.0 (#178)
* n7.1: Migrate deprecated methods, fields, and definitions

* n7.1: Add new definitions

* n7.1: Add new field

* n7.1: Update doxygen url

* n8.0: Clean up remaining n7.x deprecations

* n8.0: Add new CodecIDs and fields

* n8.0: Migration to n8.0

* n8.0: Refactor swscale with Publicly expose struct SwsContext, enum SwsDither, and enum SwsAlphaBlend

n8.0: Stash commit

* n8.0: Update doxygen url

* n8.0: Fix windows.patch to apply new library.mak in n8.0

* n8.0: Clean up and organize the APIs, remove redundant implementations, and reorder the enum fields

* n8.0: Refactor SoftwareScaleContext to simplify and optimize update logic and remove redundant code

* Add tests for supported sample rates and frame rates in codec encoders

* Revert changes in `Free` and `Class`, other minor improvements

* Adapt the examples to the current library

* Update breaking changes
2026-01-13 15:10:38 +01:00

71 lines
2.1 KiB
Go

package astiav
//#include <libavutil/hwcontext.h>
import "C"
import "unsafe"
// https://ffmpeg.org/doxygen/8.0/structAVHWFramesConstraints.html
type HardwareFramesConstraints struct {
c *C.AVHWFramesConstraints
}
func newHardwareFramesConstraintsFromC(c *C.AVHWFramesConstraints) *HardwareFramesConstraints {
if c == nil {
return nil
}
return &HardwareFramesConstraints{c: c}
}
func (hfc *HardwareFramesConstraints) pixelFormats(formats *C.enum_AVPixelFormat) (o []PixelFormat) {
if formats == nil {
return nil
}
size := unsafe.Sizeof(*formats)
for i := 0; ; i++ {
p := *(*C.int)(unsafe.Pointer(uintptr(unsafe.Pointer(formats)) + uintptr(i)*size))
if p == C.AV_PIX_FMT_NONE {
break
}
o = append(o, PixelFormat(p))
}
return
}
// https://ffmpeg.org/doxygen/8.0/structAVHWFramesConstraints.html#a4258bbe81f927b76b7ca5af44ba7ef6b
func (hfc *HardwareFramesConstraints) ValidHardwarePixelFormats() (o []PixelFormat) {
return hfc.pixelFormats(hfc.c.valid_hw_formats)
}
// https://ffmpeg.org/doxygen/8.0/structAVHWFramesConstraints.html#aabea88093c6f85d6185ffb0852a2217f
func (hfc *HardwareFramesConstraints) ValidSoftwarePixelFormats() (o []PixelFormat) {
return hfc.pixelFormats(hfc.c.valid_sw_formats)
}
// https://ffmpeg.org/doxygen/8.0/structAVHWFramesConstraints.html#af220776925452091085139081d5d7251
func (hfc *HardwareFramesConstraints) MinWidth() int {
return int(hfc.c.min_width)
}
// https://ffmpeg.org/doxygen/8.0/structAVHWFramesConstraints.html#a3f1aec6d1c90f77837875c2a3598be46
func (hfc *HardwareFramesConstraints) MinHeight() int {
return int(hfc.c.min_height)
}
// https://ffmpeg.org/doxygen/8.0/structAVHWFramesConstraints.html#a34e06e3397af2b83de9d78f893bf4168
func (hfc *HardwareFramesConstraints) MaxWidth() int {
return int(hfc.c.max_width)
}
// https://ffmpeg.org/doxygen/8.0/structAVHWFramesConstraints.html#af5d3a683727f7b92abca7b7114d4e15c
func (hfc *HardwareFramesConstraints) MaxHeight() int {
return int(hfc.c.max_height)
}
// https://ffmpeg.org/doxygen/8.0/hwcontext_8c.html#a29da7fa7ffa73266d1cbfccb116ed634
func (hfc *HardwareFramesConstraints) Free() {
if hfc.c != nil {
C.av_hwframe_constraints_free(&hfc.c)
hfc.c = nil
}
}