mirror of
https://github.com/asticode/go-astiav.git
synced 2025-10-05 16:16:50 +08:00
Added codec parameters setters
This commit is contained in:
@@ -40,6 +40,10 @@ func (cp *CodecParameters) CodecID() CodecID {
|
|||||||
return CodecID(cp.c.codec_id)
|
return CodecID(cp.c.codec_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cp *CodecParameters) SetCodecID(i CodecID) {
|
||||||
|
cp.c.codec_id = uint32(i)
|
||||||
|
}
|
||||||
|
|
||||||
func (cp *CodecParameters) CodecTag() CodecTag {
|
func (cp *CodecParameters) CodecTag() CodecTag {
|
||||||
return CodecTag(cp.c.codec_tag)
|
return CodecTag(cp.c.codec_tag)
|
||||||
}
|
}
|
||||||
@@ -48,6 +52,14 @@ func (cp *CodecParameters) SetCodecTag(t CodecTag) {
|
|||||||
cp.c.codec_tag = C.uint(t)
|
cp.c.codec_tag = C.uint(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cp *CodecParameters) CodecType() MediaType {
|
||||||
|
return MediaType(cp.c.codec_type)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cp *CodecParameters) SetCodecType(t MediaType) {
|
||||||
|
cp.c.codec_type = int32(t)
|
||||||
|
}
|
||||||
|
|
||||||
func (cp *CodecParameters) ChromaLocation() ChromaLocation {
|
func (cp *CodecParameters) ChromaLocation() ChromaLocation {
|
||||||
return ChromaLocation(cp.c.chroma_location)
|
return ChromaLocation(cp.c.chroma_location)
|
||||||
}
|
}
|
||||||
@@ -76,6 +88,10 @@ func (cp *CodecParameters) Height() int {
|
|||||||
return int(cp.c.height)
|
return int(cp.c.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cp *CodecParameters) SetHeight(h int) {
|
||||||
|
cp.c.height = C.int(h)
|
||||||
|
}
|
||||||
|
|
||||||
func (cp *CodecParameters) Level() Level {
|
func (cp *CodecParameters) Level() Level {
|
||||||
return Level(cp.c.level)
|
return Level(cp.c.level)
|
||||||
}
|
}
|
||||||
@@ -88,6 +104,10 @@ func (cp *CodecParameters) PixelFormat() PixelFormat {
|
|||||||
return PixelFormat(cp.c.format)
|
return PixelFormat(cp.c.format)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cp *CodecParameters) SetPixelFormat(f PixelFormat) {
|
||||||
|
cp.c.format = C.int(f)
|
||||||
|
}
|
||||||
|
|
||||||
func (cp *CodecParameters) Profile() Profile {
|
func (cp *CodecParameters) Profile() Profile {
|
||||||
return Profile(cp.c.profile)
|
return Profile(cp.c.profile)
|
||||||
}
|
}
|
||||||
@@ -96,6 +116,10 @@ func (cp *CodecParameters) SampleAspectRatio() Rational {
|
|||||||
return newRationalFromC(cp.c.sample_aspect_ratio)
|
return newRationalFromC(cp.c.sample_aspect_ratio)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cp *CodecParameters) SetSampleAspectRatio(r Rational) {
|
||||||
|
cp.c.sample_aspect_ratio = r.c
|
||||||
|
}
|
||||||
|
|
||||||
func (cp *CodecParameters) SampleFormat() SampleFormat {
|
func (cp *CodecParameters) SampleFormat() SampleFormat {
|
||||||
return SampleFormat(cp.c.format)
|
return SampleFormat(cp.c.format)
|
||||||
}
|
}
|
||||||
@@ -108,6 +132,10 @@ func (cp *CodecParameters) Width() int {
|
|||||||
return int(cp.c.width)
|
return int(cp.c.width)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cp *CodecParameters) SetWidth(w int) {
|
||||||
|
cp.c.width = C.int(w)
|
||||||
|
}
|
||||||
|
|
||||||
func (cp *CodecParameters) FromCodecContext(cc *CodecContext) error {
|
func (cp *CodecParameters) FromCodecContext(cc *CodecContext) error {
|
||||||
return newError(C.avcodec_parameters_from_context(cp.c, cc.c))
|
return newError(C.avcodec_parameters_from_context(cp.c, cc.c))
|
||||||
}
|
}
|
||||||
|
@@ -63,6 +63,18 @@ func TestCodecParameters(t *testing.T) {
|
|||||||
cp6 := astiav.AllocCodecParameters()
|
cp6 := astiav.AllocCodecParameters()
|
||||||
require.NotNil(t, cp6)
|
require.NotNil(t, cp6)
|
||||||
defer cp6.Free()
|
defer cp6.Free()
|
||||||
|
cp6.SetCodecID(astiav.CodecIDRawvideo)
|
||||||
|
require.Equal(t, astiav.CodecIDRawvideo, cp6.CodecID())
|
||||||
cp6.SetCodecTag(astiav.CodecTag(2))
|
cp6.SetCodecTag(astiav.CodecTag(2))
|
||||||
require.Equal(t, astiav.CodecTag(2), cp6.CodecTag())
|
require.Equal(t, astiav.CodecTag(2), cp6.CodecTag())
|
||||||
|
cp6.SetCodecType(astiav.MediaTypeAudio)
|
||||||
|
require.Equal(t, astiav.MediaTypeAudio, cp6.CodecType())
|
||||||
|
cp6.SetHeight(1)
|
||||||
|
require.Equal(t, 1, cp6.Height())
|
||||||
|
cp6.SetPixelFormat(astiav.PixelFormat0Bgr)
|
||||||
|
require.Equal(t, astiav.PixelFormat0Bgr, cp6.PixelFormat())
|
||||||
|
cp6.SetSampleAspectRatio(astiav.NewRational(1, 2))
|
||||||
|
require.Equal(t, astiav.NewRational(1, 2), cp6.SampleAspectRatio())
|
||||||
|
cp6.SetWidth(2)
|
||||||
|
require.Equal(t, 2, cp6.Width())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user