• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

asticode / go-astiav / 5852907926

14 Aug 2023 07:11AM UTC coverage: 14.42% (-75.8%) from 90.229%
5852907926

push

github

asticode
Test

214 of 1484 relevant lines covered (14.42%)

0.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/codec_context.go
1
package astiav
2

3
//#cgo pkg-config: libavcodec libavutil
4
//#include <libavcodec/avcodec.h>
5
//#include <libavutil/frame.h>
6
import "C"
7

8
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L383
9
type CodecContext struct {
10
        c *C.struct_AVCodecContext
11
}
12

13
func AllocCodecContext(c *Codec) *CodecContext {
×
14
        var cc *C.struct_AVCodec
×
15
        if c != nil {
×
16
                cc = c.c
×
17
        }
×
18
        return newCodecContextFromC(C.avcodec_alloc_context3(cc))
×
19
}
20

21
func newCodecContextFromC(c *C.struct_AVCodecContext) *CodecContext {
×
22
        if c == nil {
×
23
                return nil
×
24
        }
×
25
        return &CodecContext{c: c}
×
26
}
27

28
func (cc *CodecContext) Free() {
×
29
        C.avcodec_free_context(&cc.c)
×
30
}
×
31

32
func (cc *CodecContext) String() string {
×
33
        s, _ := stringFromC(255, func(buf *C.char, size C.size_t) error {
×
34
                C.avcodec_string(buf, C.int(size), cc.c, C.int(0))
×
35
                return nil
×
36
        })
×
37
        return s
×
38
}
39

40
func (cc *CodecContext) BitRate() int64 {
×
41
        return int64(cc.c.bit_rate)
×
42
}
×
43

44
func (cc *CodecContext) SetBitRate(bitRate int64) {
×
45
        cc.c.bit_rate = C.int64_t(bitRate)
×
46
}
×
47

48
func (cc *CodecContext) Channels() int {
×
49
        return int(cc.c.channels)
×
50
}
×
51

52
func (cc *CodecContext) SetChannels(channels int) {
×
53
        cc.c.channels = C.int(channels)
×
54
}
×
55

56
func (cc *CodecContext) ChannelLayout() *ChannelLayout {
×
57
        return newChannelLayoutFromC(&cc.c.ch_layout)
×
58
}
×
59

60
func (cc *CodecContext) SetChannelLayout(l *ChannelLayout) {
×
61
        l.copy(&cc.c.ch_layout) //nolint: errcheck
×
62
}
×
63

64
func (cc *CodecContext) ChromaLocation() ChromaLocation {
×
65
        return ChromaLocation(cc.c.chroma_sample_location)
×
66
}
×
67

68
func (cc *CodecContext) CodecID() CodecID {
×
69
        return CodecID(cc.c.codec_id)
×
70
}
×
71

72
func (cc *CodecContext) ColorPrimaries() ColorPrimaries {
×
73
        return ColorPrimaries(cc.c.color_primaries)
×
74
}
×
75

76
func (cc *CodecContext) ColorRange() ColorRange {
×
77
        return ColorRange(cc.c.color_range)
×
78
}
×
79

80
func (cc *CodecContext) ColorSpace() ColorSpace {
×
81
        return ColorSpace(cc.c.colorspace)
×
82
}
×
83

84
func (cc *CodecContext) ColorTransferCharacteristic() ColorTransferCharacteristic {
×
85
        return ColorTransferCharacteristic(cc.c.color_trc)
×
86
}
×
87

88
func (cc *CodecContext) Flags() CodecContextFlags {
×
89
        return CodecContextFlags(cc.c.flags)
×
90
}
×
91

92
func (cc *CodecContext) SetFlags(fs CodecContextFlags) {
×
93
        cc.c.flags = C.int(fs)
×
94
}
×
95

96
func (cc *CodecContext) Flags2() CodecContextFlags2 {
×
97
        return CodecContextFlags2(cc.c.flags2)
×
98
}
×
99

100
func (cc *CodecContext) SetFlags2(fs CodecContextFlags2) {
×
101
        cc.c.flags2 = C.int(fs)
×
102
}
×
103

104
func (cc *CodecContext) Framerate() Rational {
×
105
        return newRationalFromC(cc.c.framerate)
×
106
}
×
107

108
func (cc *CodecContext) SetFramerate(f Rational) {
×
109
        cc.c.framerate = f.c
×
110
}
×
111

112
func (cc *CodecContext) FrameSize() int {
×
113
        return int(cc.c.frame_size)
×
114
}
×
115

116
func (cc *CodecContext) GopSize() int {
×
117
        return int(cc.c.gop_size)
×
118
}
×
119

120
func (cc *CodecContext) SetGopSize(gopSize int) {
×
121
        cc.c.gop_size = C.int(gopSize)
×
122
}
×
123

124
func (cc *CodecContext) Height() int {
×
125
        return int(cc.c.height)
×
126
}
×
127

128
func (cc *CodecContext) SetHeight(height int) {
×
129
        cc.c.height = C.int(height)
×
130
}
×
131

132
func (cc *CodecContext) Level() Level {
×
133
        return Level(cc.c.level)
×
134
}
×
135

136
func (cc *CodecContext) MediaType() MediaType {
×
137
        return MediaType(cc.c.codec_type)
×
138
}
×
139

140
func (cc *CodecContext) PixelFormat() PixelFormat {
×
141
        return PixelFormat(cc.c.pix_fmt)
×
142
}
×
143

144
func (cc *CodecContext) SetPixelFormat(pixFmt PixelFormat) {
×
145
        cc.c.pix_fmt = C.enum_AVPixelFormat(pixFmt)
×
146
}
×
147

148
func (cc *CodecContext) Profile() Profile {
×
149
        return Profile(cc.c.profile)
×
150
}
×
151

152
func (cc *CodecContext) Qmin() int {
×
153
        return int(cc.c.qmin)
×
154
}
×
155

156
func (cc *CodecContext) SetQmin(qmin int) {
×
157
        cc.c.qmin = C.int(qmin)
×
158
}
×
159

160
func (cc *CodecContext) SampleAspectRatio() Rational {
×
161
        return newRationalFromC(cc.c.sample_aspect_ratio)
×
162
}
×
163

164
func (cc *CodecContext) SetSampleAspectRatio(r Rational) {
×
165
        cc.c.sample_aspect_ratio = r.c
×
166
}
×
167

168
func (cc *CodecContext) SampleFormat() SampleFormat {
×
169
        return SampleFormat(cc.c.sample_fmt)
×
170
}
×
171

172
func (cc *CodecContext) SetSampleFormat(f SampleFormat) {
×
173
        cc.c.sample_fmt = C.enum_AVSampleFormat(f)
×
174
}
×
175

176
func (cc *CodecContext) SampleRate() int {
×
177
        return int(cc.c.sample_rate)
×
178
}
×
179

180
func (cc *CodecContext) SetSampleRate(sampleRate int) {
×
181
        cc.c.sample_rate = C.int(sampleRate)
×
182
}
×
183

184
func (cc *CodecContext) StrictStdCompliance() StrictStdCompliance {
×
185
        return StrictStdCompliance(cc.c.strict_std_compliance)
×
186
}
×
187

188
func (cc *CodecContext) SetStrictStdCompliance(c StrictStdCompliance) {
×
189
        cc.c.strict_std_compliance = C.int(c)
×
190
}
×
191

192
func (cc *CodecContext) TimeBase() Rational {
×
193
        return newRationalFromC(cc.c.time_base)
×
194
}
×
195

196
func (cc *CodecContext) SetTimeBase(r Rational) {
×
197
        cc.c.time_base = r.c
×
198
}
×
199

200
func (cc *CodecContext) ThreadCount() int {
×
201
        return int(cc.c.thread_count)
×
202
}
×
203

204
func (cc *CodecContext) SetThreadCount(threadCount int) {
×
205
        cc.c.thread_count = C.int(threadCount)
×
206
}
×
207

208
func (cc *CodecContext) ThreadType() ThreadType {
×
209
        return ThreadType(cc.c.thread_type)
×
210
}
×
211

212
func (cc *CodecContext) SetThreadType(t ThreadType) {
×
213
        cc.c.thread_type = C.int(t)
×
214
}
×
215

216
func (cc *CodecContext) Width() int {
×
217
        return int(cc.c.width)
×
218
}
×
219

220
func (cc *CodecContext) SetWidth(width int) {
×
221
        cc.c.width = C.int(width)
×
222
}
×
223

224
func (cc *CodecContext) Open(c *Codec, d *Dictionary) error {
×
225
        var dc **C.struct_AVDictionary
×
226
        if d != nil {
×
227
                dc = &d.c
×
228
        }
×
229
        return newError(C.avcodec_open2(cc.c, c.c, dc))
×
230
}
231

232
func (cc *CodecContext) ReceivePacket(p *Packet) error {
×
233
        var pc *C.struct_AVPacket
×
234
        if p != nil {
×
235
                pc = p.c
×
236
        }
×
237
        return newError(C.avcodec_receive_packet(cc.c, pc))
×
238
}
239

240
func (cc *CodecContext) SendPacket(p *Packet) error {
×
241
        var pc *C.struct_AVPacket
×
242
        if p != nil {
×
243
                pc = p.c
×
244
        }
×
245
        return newError(C.avcodec_send_packet(cc.c, pc))
×
246
}
247

248
func (cc *CodecContext) ReceiveFrame(f *Frame) error {
×
249
        var fc *C.struct_AVFrame
×
250
        if f != nil {
×
251
                fc = f.c
×
252
        }
×
253
        return newError(C.avcodec_receive_frame(cc.c, fc))
×
254
}
255

256
func (cc *CodecContext) SendFrame(f *Frame) error {
×
257
        var fc *C.struct_AVFrame
×
258
        if f != nil {
×
259
                fc = f.c
×
260
        }
×
261
        return newError(C.avcodec_send_frame(cc.c, fc))
×
262
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc