-
Notifications
You must be signed in to change notification settings - Fork 46
/
codec_parameters.go
230 lines (185 loc) · 8.25 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package astiav
//#include <libavcodec/avcodec.h>
import "C"
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html
type CodecParameters struct {
c *C.AVCodecParameters
}
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga647755ab2252e93221bb345f3d5e414f
func AllocCodecParameters() *CodecParameters {
return newCodecParametersFromC(C.avcodec_parameters_alloc())
}
func newCodecParametersFromC(c *C.AVCodecParameters) *CodecParameters {
if c == nil {
return nil
}
return &CodecParameters{c: c}
}
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga950c8da55b8112077e640b6a0cb8cf36
func (cp *CodecParameters) Free() {
C.avcodec_parameters_free(&cp.c)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a5268fcf4ae8ed27edef54f836b926d93
func (cp *CodecParameters) BitRate() int64 {
return int64(cp.c.bit_rate)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a4d581c205b18108a4f00e8fb3a2b26f9
func (cp *CodecParameters) ChannelLayout() ChannelLayout {
l, _ := newChannelLayoutFromC(&cp.c.ch_layout).clone()
return l
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a4d581c205b18108a4f00e8fb3a2b26f9
func (cp *CodecParameters) SetChannelLayout(l ChannelLayout) {
l.copy(&cp.c.ch_layout) //nolint: errcheck
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9f76f2475ef24ff4c9771dd53072d040
func (cp *CodecParameters) CodecID() CodecID {
return CodecID(cp.c.codec_id)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9f76f2475ef24ff4c9771dd53072d040
func (cp *CodecParameters) SetCodecID(i CodecID) {
cp.c.codec_id = uint32(i)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9b6f7d220d100ba73defab295623356b
func (cp *CodecParameters) CodecTag() CodecTag {
return CodecTag(cp.c.codec_tag)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9b6f7d220d100ba73defab295623356b
func (cp *CodecParameters) SetCodecTag(t CodecTag) {
cp.c.codec_tag = C.uint(t)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#ae4c7ac718a75adb31b5f2076a02fdedf
func (cp *CodecParameters) ChromaLocation() ChromaLocation {
return ChromaLocation(cp.c.chroma_location)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#aa884cae3fd16b30c61201a686664f96b
func (cp *CodecParameters) ColorPrimaries() ColorPrimaries {
return ColorPrimaries(cp.c.color_primaries)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#afa6744d9b8766db47a5ff7bddf0f2404
func (cp *CodecParameters) ColorRange() ColorRange {
return ColorRange(cp.c.color_range)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#afa6744d9b8766db47a5ff7bddf0f2404
func (cp *CodecParameters) SetColorRange(r ColorRange) {
cp.c.color_range = C.enum_AVColorRange(r)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a020398a4963e932853cefc169d90456d
func (cp *CodecParameters) ColorSpace() ColorSpace {
return ColorSpace(cp.c.color_space)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a020398a4963e932853cefc169d90456d
func (cp *CodecParameters) SetColorSpace(s ColorSpace) {
cp.c.color_space = C.enum_AVColorSpace(s)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#ac25ed8394e1efdbbcf28932ff0020893
func (cp *CodecParameters) ColorTransferCharacteristic() ColorTransferCharacteristic {
return ColorTransferCharacteristic(cp.c.color_trc)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9befe0b86412646017afb0051d144d13
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
})
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9befe0b86412646017afb0051d144d13
func (cp *CodecParameters) SetExtraData(b []byte) error {
return setBytesWithIntSizeInC(b, &cp.c.extradata, &cp.c.extradata_size)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a0ce9631123719789e4c7b0c23c66d534
func (cp *CodecParameters) FrameSize() int {
return int(cp.c.frame_size)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a0ce9631123719789e4c7b0c23c66d534
func (cp *CodecParameters) SetFrameSize(i int) {
cp.c.frame_size = C.int(i)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a1ec57ee84f19cf65d00eaa4d2a2253ce
func (cp *CodecParameters) Height() int {
return int(cp.c.height)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a1ec57ee84f19cf65d00eaa4d2a2253ce
func (cp *CodecParameters) SetHeight(h int) {
cp.c.height = C.int(h)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a26ae48eeaf8b315eca03b207e11edc7c
func (cp *CodecParameters) Level() Level {
return Level(cp.c.level)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a26ae48eeaf8b315eca03b207e11edc7c
func (cp *CodecParameters) SetLevel(l Level) {
cp.c.level = C.int(l)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a58369c3a8a986935b572df5aa6361ce2
func (cp *CodecParameters) MediaType() MediaType {
return MediaType(cp.c.codec_type)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a58369c3a8a986935b572df5aa6361ce2
func (cp *CodecParameters) SetMediaType(t MediaType) {
cp.c.codec_type = C.enum_AVMediaType(t)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abee943e65d98f9763fa6602a356e774f
func (cp *CodecParameters) PixelFormat() PixelFormat {
return PixelFormat(cp.c.format)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abee943e65d98f9763fa6602a356e774f
func (cp *CodecParameters) SetPixelFormat(f PixelFormat) {
cp.c.format = C.int(f)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a6b13b8a226ed923085718cd1323bfcb5
func (cp *CodecParameters) Profile() Profile {
return Profile(cp.c.profile)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a6b13b8a226ed923085718cd1323bfcb5
func (cp *CodecParameters) SetProfile(p Profile) {
cp.c.profile = C.int(p)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a7d6ef91120ffe80040c699e747a1ad68
func (cp *CodecParameters) SampleAspectRatio() Rational {
return newRationalFromC(cp.c.sample_aspect_ratio)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a7d6ef91120ffe80040c699e747a1ad68
func (cp *CodecParameters) SetSampleAspectRatio(r Rational) {
cp.c.sample_aspect_ratio = r.c
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#ad54da9241deabb3601e6e0e8fa832c19
func (cp *CodecParameters) SideData() *PacketSideData {
return newPacketSideDataFromC(&cp.c.coded_side_data, &cp.c.nb_coded_side_data)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abee943e65d98f9763fa6602a356e774f
func (cp *CodecParameters) SampleFormat() SampleFormat {
return SampleFormat(cp.c.format)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abee943e65d98f9763fa6602a356e774f
func (cp *CodecParameters) SetSampleFormat(f SampleFormat) {
cp.c.format = C.int(f)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abfc9b0aa975206f7e77a125e6b78536e
func (cp *CodecParameters) SampleRate() int {
return int(cp.c.sample_rate)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abfc9b0aa975206f7e77a125e6b78536e
func (cp *CodecParameters) SetSampleRate(r int) {
cp.c.sample_rate = C.int(r)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a51639f88aef9f4f283f538a0c033fbb8
func (cp *CodecParameters) Width() int {
return int(cp.c.width)
}
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a51639f88aef9f4f283f538a0c033fbb8
func (cp *CodecParameters) SetWidth(w int) {
cp.c.width = C.int(w)
}
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga506c1c185ac48bb0086c61e267fc085c
func (cp *CodecParameters) FromCodecContext(cc *CodecContext) error {
return newError(C.avcodec_parameters_from_context(cp.c, cc.c))
}
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga8a4998c9d1695abb01d379539d313227
func (cp *CodecParameters) ToCodecContext(cc *CodecContext) error {
return newError(C.avcodec_parameters_to_context(cc.c, cp.c))
}
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga6d02e640ccc12c783841ce51d09b9fa7
func (cp *CodecParameters) Copy(dst *CodecParameters) error {
return newError(C.avcodec_parameters_copy(dst.c, cp.c))
}