forked from asticode/go-astiav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec_parameters.go
196 lines (149 loc) · 4.48 KB
/
codec_parameters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
package astiav
//#include <libavcodec/avcodec.h>
import "C"
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec_par.h#L52
type CodecParameters struct {
c *C.AVCodecParameters
}
func AllocCodecParameters() *CodecParameters {
return newCodecParametersFromC(C.avcodec_parameters_alloc())
}
func newCodecParametersFromC(c *C.AVCodecParameters) *CodecParameters {
if c == nil {
return nil
}
return &CodecParameters{c: c}
}
func (cp *CodecParameters) Free() {
C.avcodec_parameters_free(&cp.c)
}
func (cp *CodecParameters) BitRate() int64 {
return int64(cp.c.bit_rate)
}
func (cp *CodecParameters) ChannelLayout() ChannelLayout {
l, _ := newChannelLayoutFromC(&cp.c.ch_layout).clone()
return l
}
func (cp *CodecParameters) SetChannelLayout(l ChannelLayout) {
l.copy(&cp.c.ch_layout) //nolint: errcheck
}
func (cp *CodecParameters) CodecID() CodecID {
return CodecID(cp.c.codec_id)
}
func (cp *CodecParameters) SetCodecID(i CodecID) {
cp.c.codec_id = uint32(i)
}
func (cp *CodecParameters) CodecTag() CodecTag {
return CodecTag(cp.c.codec_tag)
}
func (cp *CodecParameters) SetCodecTag(t CodecTag) {
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 {
return ChromaLocation(cp.c.chroma_location)
}
func (cp *CodecParameters) ColorPrimaries() ColorPrimaries {
return ColorPrimaries(cp.c.color_primaries)
}
func (cp *CodecParameters) ColorRange() ColorRange {
return ColorRange(cp.c.color_range)
}
func (cp *CodecParameters) SetColorRange(r ColorRange) {
cp.c.color_range = C.enum_AVColorRange(r)
}
func (cp *CodecParameters) ColorSpace() ColorSpace {
return ColorSpace(cp.c.color_space)
}
func (cp *CodecParameters) SetColorSpace(s ColorSpace) {
cp.c.color_space = C.enum_AVColorSpace(s)
}
func (cp *CodecParameters) ColorTransferCharacteristic() ColorTransferCharacteristic {
return ColorTransferCharacteristic(cp.c.color_trc)
}
func (cp *CodecParameters) ExtraData() []byte {
return bytesFromC(func(size *C.size_t) *C.uint8_t {
*size = C.size_t(cp.c.extradata_size)
return cp.c.extradata
})
}
func (cp *CodecParameters) SetExtraData(b []byte) error {
return setBytesWithIntSizeInC(b, &cp.c.extradata, &cp.c.extradata_size)
}
func (cp *CodecParameters) FrameSize() int {
return int(cp.c.frame_size)
}
func (cp *CodecParameters) SetFrameSize(i int) {
cp.c.frame_size = C.int(i)
}
func (cp *CodecParameters) Height() int {
return int(cp.c.height)
}
func (cp *CodecParameters) SetHeight(h int) {
cp.c.height = C.int(h)
}
func (cp *CodecParameters) Level() Level {
return Level(cp.c.level)
}
func (cp *CodecParameters) SetLevel(l Level) {
cp.c.level = C.int(l)
}
func (cp *CodecParameters) MediaType() MediaType {
return MediaType(cp.c.codec_type)
}
func (cp *CodecParameters) SetMediaType(t MediaType) {
cp.c.codec_type = C.enum_AVMediaType(t)
}
func (cp *CodecParameters) PixelFormat() PixelFormat {
return PixelFormat(cp.c.format)
}
func (cp *CodecParameters) SetPixelFormat(f PixelFormat) {
cp.c.format = C.int(f)
}
func (cp *CodecParameters) Profile() Profile {
return Profile(cp.c.profile)
}
func (cp *CodecParameters) SetProfile(p Profile) {
cp.c.profile = C.int(p)
}
func (cp *CodecParameters) SampleAspectRatio() Rational {
return newRationalFromC(cp.c.sample_aspect_ratio)
}
func (cp *CodecParameters) SetSampleAspectRatio(r Rational) {
cp.c.sample_aspect_ratio = r.c
}
func (cp *CodecParameters) SideData() *PacketSideData {
return newPacketSideDataFromC(&cp.c.coded_side_data, &cp.c.nb_coded_side_data)
}
func (cp *CodecParameters) SampleFormat() SampleFormat {
return SampleFormat(cp.c.format)
}
func (cp *CodecParameters) SetSampleFormat(f SampleFormat) {
cp.c.format = C.int(f)
}
func (cp *CodecParameters) SampleRate() int {
return int(cp.c.sample_rate)
}
func (cp *CodecParameters) SetSampleRate(r int) {
cp.c.sample_rate = C.int(r)
}
func (cp *CodecParameters) Width() int {
return int(cp.c.width)
}
func (cp *CodecParameters) SetWidth(w int) {
cp.c.width = C.int(w)
}
func (cp *CodecParameters) FromCodecContext(cc *CodecContext) error {
return newError(C.avcodec_parameters_from_context(cp.c, cc.c))
}
func (cp *CodecParameters) ToCodecContext(cc *CodecContext) error {
return newError(C.avcodec_parameters_to_context(cc.c, cp.c))
}
func (cp *CodecParameters) Copy(dst *CodecParameters) error {
return newError(C.avcodec_parameters_copy(dst.c, cp.c))
}