-
Notifications
You must be signed in to change notification settings - Fork 4
/
functions.gen.go
10949 lines (9303 loc) · 322 KB
/
functions.gen.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package ffmpeg
import "unsafe"
// #include <libavcodec/avcodec.h>
// #include <libavcodec/codec.h>
// #include <libavcodec/codec_desc.h>
// #include <libavcodec/codec_id.h>
// #include <libavcodec/codec_par.h>
// #include <libavcodec/defs.h>
// #include <libavcodec/packet.h>
// #include <libavcodec/version.h>
// #include <libavcodec/version_major.h>
// #include <libavdevice/version.h>
// #include <libavdevice/version_major.h>
// #include <libavfilter/avfilter.h>
// #include <libavfilter/buffersink.h>
// #include <libavfilter/buffersrc.h>
// #include <libavfilter/version.h>
// #include <libavfilter/version_major.h>
// #include <libavformat/avformat.h>
// #include <libavformat/avio.h>
// #include <libavformat/version.h>
// #include <libavformat/version_major.h>
// #include <libavutil/avutil.h>
// #include <libavutil/buffer.h>
// #include <libavutil/channel_layout.h>
// #include <libavutil/dict.h>
// #include <libavutil/error.h>
// #include <libavutil/frame.h>
// #include <libavutil/hwcontext.h>
// #include <libavutil/log.h>
// #include <libavutil/mathematics.h>
// #include <libavutil/mem.h>
// #include <libavutil/opt.h>
// #include <libavutil/pixfmt.h>
// #include <libavutil/rational.h>
// #include <libavutil/samplefmt.h>
// #include <libavutil/version.h>
// #include <libpostproc/version.h>
// #include <libpostproc/version_major.h>
// #include <libswresample/version.h>
// #include <libswresample/version_major.h>
// #include <libswscale/version.h>
// #include <libswscale/version_major.h>
import "C"
// --- Function avcodec_version ---
// AVCodecVersion wraps avcodec_version.
//
// Return the LIBAVCODEC_VERSION_INT constant.
func AVCodecVersion() uint {
ret := C.avcodec_version()
return uint(ret)
}
// --- Function avcodec_configuration ---
// AVCodecConfiguration wraps avcodec_configuration.
//
// Return the libavcodec build-time configuration.
func AVCodecConfiguration() *CStr {
ret := C.avcodec_configuration()
return wrapCStr(ret)
}
// --- Function avcodec_license ---
// AVCodecLicense wraps avcodec_license.
//
// Return the libavcodec license.
func AVCodecLicense() *CStr {
ret := C.avcodec_license()
return wrapCStr(ret)
}
// --- Function avcodec_alloc_context3 ---
// AVCodecAllocContext3 wraps avcodec_alloc_context3.
/*
Allocate an AVCodecContext and set its fields to default values. The
resulting struct should be freed with avcodec_free_context().
@param codec if non-NULL, allocate private data and initialize defaults
for the given codec. It is illegal to then call avcodec_open2()
with a different codec.
If NULL, then the codec-specific defaults won't be initialized,
which may result in suboptimal default settings (this is
important mainly for encoders, e.g. libx264).
@return An AVCodecContext filled with default values or NULL on failure.
*/
func AVCodecAllocContext3(codec *AVCodec) *AVCodecContext {
var tmpcodec *C.AVCodec
if codec != nil {
tmpcodec = codec.ptr
}
ret := C.avcodec_alloc_context3(tmpcodec)
var retMapped *AVCodecContext
if ret != nil {
retMapped = &AVCodecContext{ptr: ret}
}
return retMapped
}
// --- Function avcodec_free_context ---
// AVCodecFreeContext wraps avcodec_free_context.
/*
Free the codec context and everything associated with it and write NULL to
the provided pointer.
*/
func AVCodecFreeContext(avctx **AVCodecContext) {
var ptravctx **C.AVCodecContext
var tmpavctx *C.AVCodecContext
var oldTmpavctx *C.AVCodecContext
if avctx != nil {
inneravctx := *avctx
if inneravctx != nil {
tmpavctx = inneravctx.ptr
oldTmpavctx = tmpavctx
}
ptravctx = &tmpavctx
}
C.avcodec_free_context(ptravctx)
if tmpavctx != oldTmpavctx && avctx != nil {
if tmpavctx != nil {
*avctx = &AVCodecContext{ptr: tmpavctx}
} else {
*avctx = nil
}
}
}
// --- Function avcodec_get_class ---
// AVCodecGetClass wraps avcodec_get_class.
/*
Get the AVClass for AVCodecContext. It can be used in combination with
AV_OPT_SEARCH_FAKE_OBJ for examining options.
@see av_opt_find().
*/
func AVCodecGetClass() *AVClass {
ret := C.avcodec_get_class()
var retMapped *AVClass
if ret != nil {
retMapped = &AVClass{ptr: ret}
}
return retMapped
}
// --- Function avcodec_get_subtitle_rect_class ---
// AVCodecGetSubtitleRectClass wraps avcodec_get_subtitle_rect_class.
/*
Get the AVClass for AVSubtitleRect. It can be used in combination with
AV_OPT_SEARCH_FAKE_OBJ for examining options.
@see av_opt_find().
*/
func AVCodecGetSubtitleRectClass() *AVClass {
ret := C.avcodec_get_subtitle_rect_class()
var retMapped *AVClass
if ret != nil {
retMapped = &AVClass{ptr: ret}
}
return retMapped
}
// --- Function avcodec_parameters_from_context ---
// AVCodecParametersFromContext wraps avcodec_parameters_from_context.
/*
Fill the parameters struct based on the values from the supplied codec
context. Any allocated fields in par are freed and replaced with duplicates
of the corresponding fields in codec.
@return >= 0 on success, a negative AVERROR code on failure
*/
func AVCodecParametersFromContext(par *AVCodecParameters, codec *AVCodecContext) (int, error) {
var tmppar *C.AVCodecParameters
if par != nil {
tmppar = par.ptr
}
var tmpcodec *C.AVCodecContext
if codec != nil {
tmpcodec = codec.ptr
}
ret := C.avcodec_parameters_from_context(tmppar, tmpcodec)
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_parameters_to_context ---
// AVCodecParametersToContext wraps avcodec_parameters_to_context.
/*
Fill the codec context based on the values from the supplied codec
parameters. Any allocated fields in codec that have a corresponding field in
par are freed and replaced with duplicates of the corresponding field in par.
Fields in codec that do not have a counterpart in par are not touched.
@return >= 0 on success, a negative AVERROR code on failure.
*/
func AVCodecParametersToContext(codec *AVCodecContext, par *AVCodecParameters) (int, error) {
var tmpcodec *C.AVCodecContext
if codec != nil {
tmpcodec = codec.ptr
}
var tmppar *C.AVCodecParameters
if par != nil {
tmppar = par.ptr
}
ret := C.avcodec_parameters_to_context(tmpcodec, tmppar)
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_open2 ---
// AVCodecOpen2 wraps avcodec_open2.
/*
Initialize the AVCodecContext to use the given AVCodec. Prior to using this
function the context has to be allocated with avcodec_alloc_context3().
The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
retrieving a codec.
Depending on the codec, you might need to set options in the codec context
also for decoding (e.g. width, height, or the pixel or audio sample format in
the case the information is not available in the bitstream, as when decoding
raw audio or video).
Options in the codec context can be set either by setting them in the options
AVDictionary, or by setting the values in the context itself, directly or by
using the av_opt_set() API before calling this function.
Example:
@code
av_dict_set(&opts, "b", "2.5M", 0);
codec = avcodec_find_decoder(AV_CODEC_ID_H264);
if (!codec)
exit(1);
context = avcodec_alloc_context3(codec);
if (avcodec_open2(context, codec, opts) < 0)
exit(1);
@endcode
In the case AVCodecParameters are available (e.g. when demuxing a stream
using libavformat, and accessing the AVStream contained in the demuxer), the
codec parameters can be copied to the codec context using
avcodec_parameters_to_context(), as in the following example:
@code
AVStream *stream = ...;
context = avcodec_alloc_context3(codec);
if (avcodec_parameters_to_context(context, stream->codecpar) < 0)
exit(1);
if (avcodec_open2(context, codec, NULL) < 0)
exit(1);
@endcode
@note Always call this function before using decoding routines (such as
@ref avcodec_receive_frame()).
@param avctx The context to initialize.
@param codec The codec to open this context for. If a non-NULL codec has been
previously passed to avcodec_alloc_context3() or
for this context, then this parameter MUST be either NULL or
equal to the previously passed codec.
@param options A dictionary filled with AVCodecContext and codec-private
options, which are set on top of the options already set in
avctx, can be NULL. On return this object will be filled with
options that were not found in the avctx codec context.
@return zero on success, a negative value on error
@see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
av_dict_set(), av_opt_set(), av_opt_find(), avcodec_parameters_to_context()
*/
func AVCodecOpen2(avctx *AVCodecContext, codec *AVCodec, options **AVDictionary) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
var tmpcodec *C.AVCodec
if codec != nil {
tmpcodec = codec.ptr
}
var ptroptions **C.AVDictionary
var tmpoptions *C.AVDictionary
var oldTmpoptions *C.AVDictionary
if options != nil {
inneroptions := *options
if inneroptions != nil {
tmpoptions = inneroptions.ptr
oldTmpoptions = tmpoptions
}
ptroptions = &tmpoptions
}
ret := C.avcodec_open2(tmpavctx, tmpcodec, ptroptions)
if tmpoptions != oldTmpoptions && options != nil {
if tmpoptions != nil {
*options = &AVDictionary{ptr: tmpoptions}
} else {
*options = nil
}
}
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_close ---
// AVCodecClose wraps avcodec_close.
/*
Close a given AVCodecContext and free all the data associated with it
(but not the AVCodecContext itself).
Calling this function on an AVCodecContext that hasn't been opened will free
the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL
codec. Subsequent calls will do nothing.
@note Do not use this function. Use avcodec_free_context() to destroy a
codec context (either open or closed). Opening and closing a codec context
multiple times is not supported anymore -- use multiple codec contexts
instead.
*/
func AVCodecClose(avctx *AVCodecContext) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
ret := C.avcodec_close(tmpavctx)
return int(ret), WrapErr(int(ret))
}
// --- Function avsubtitle_free ---
// AVSubtitleFree wraps avsubtitle_free.
/*
Free all allocated data in the given subtitle struct.
@param sub AVSubtitle to free.
*/
func AVSubtitleFree(sub *AVSubtitle) {
var tmpsub *C.AVSubtitle
if sub != nil {
tmpsub = sub.ptr
}
C.avsubtitle_free(tmpsub)
}
// --- Function avcodec_default_get_buffer2 ---
// AVCodecDefaultGetBuffer2 wraps avcodec_default_get_buffer2.
/*
The default callback for AVCodecContext.get_buffer2(). It is made public so
it can be called by custom get_buffer2() implementations for decoders without
AV_CODEC_CAP_DR1 set.
*/
func AVCodecDefaultGetBuffer2(s *AVCodecContext, frame *AVFrame, flags int) (int, error) {
var tmps *C.AVCodecContext
if s != nil {
tmps = s.ptr
}
var tmpframe *C.AVFrame
if frame != nil {
tmpframe = frame.ptr
}
ret := C.avcodec_default_get_buffer2(tmps, tmpframe, C.int(flags))
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_default_get_encode_buffer ---
// AVCodecDefaultGetEncodeBuffer wraps avcodec_default_get_encode_buffer.
/*
The default callback for AVCodecContext.get_encode_buffer(). It is made public so
it can be called by custom get_encode_buffer() implementations for encoders without
AV_CODEC_CAP_DR1 set.
*/
func AVCodecDefaultGetEncodeBuffer(s *AVCodecContext, pkt *AVPacket, flags int) (int, error) {
var tmps *C.AVCodecContext
if s != nil {
tmps = s.ptr
}
var tmppkt *C.AVPacket
if pkt != nil {
tmppkt = pkt.ptr
}
ret := C.avcodec_default_get_encode_buffer(tmps, tmppkt, C.int(flags))
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_align_dimensions ---
// avcodec_align_dimensions skipped due to width
// --- Function avcodec_align_dimensions2 ---
// avcodec_align_dimensions2 skipped due to width
// --- Function avcodec_enum_to_chroma_pos ---
// avcodec_enum_to_chroma_pos skipped due to xpos
// --- Function avcodec_chroma_pos_to_enum ---
// AVCodecChromaPosToEnum wraps avcodec_chroma_pos_to_enum.
/*
Converts swscale x/y chroma position to AVChromaLocation.
The positions represent the chroma (0,0) position in a coordinates system
with luma (0,0) representing the origin and luma(1,1) representing 256,256
@param xpos horizontal chroma sample position
@param ypos vertical chroma sample position
@deprecated Use av_chroma_location_pos_to_enum() instead.
*/
func AVCodecChromaPosToEnum(xpos int, ypos int) AVChromaLocation {
ret := C.avcodec_chroma_pos_to_enum(C.int(xpos), C.int(ypos))
return AVChromaLocation(ret)
}
// --- Function avcodec_decode_subtitle2 ---
// avcodec_decode_subtitle2 skipped due to gotSubPtr
// --- Function avcodec_send_packet ---
// AVCodecSendPacket wraps avcodec_send_packet.
/*
Supply raw packet data as input to a decoder.
Internally, this call will copy relevant AVCodecContext fields, which can
influence decoding per-packet, and apply them when the packet is actually
decoded. (For example AVCodecContext.skip_frame, which might direct the
decoder to drop the frame contained by the packet sent with this function.)
@warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE
larger than the actual read bytes because some optimized bitstream
readers read 32 or 64 bits at once and could read over the end.
@note The AVCodecContext MUST have been opened with @ref avcodec_open2()
before packets may be fed to the decoder.
@param avctx codec context
@param[in] avpkt The input AVPacket. Usually, this will be a single video
frame, or several complete audio frames.
Ownership of the packet remains with the caller, and the
decoder will not write to the packet. The decoder may create
a reference to the packet data (or copy it if the packet is
not reference-counted).
Unlike with older APIs, the packet is always fully consumed,
and if it contains multiple frames (e.g. some audio codecs),
will require you to call avcodec_receive_frame() multiple
times afterwards before you can send a new packet.
It can be NULL (or an AVPacket with data set to NULL and
size set to 0); in this case, it is considered a flush
packet, which signals the end of the stream. Sending the
first flush packet will return success. Subsequent ones are
unnecessary and will return AVERROR_EOF. If the decoder
still has frames buffered, it will return them after sending
a flush packet.
@retval 0 success
@retval AVERROR(EAGAIN) input is not accepted in the current state - user
must read output with avcodec_receive_frame() (once
all output is read, the packet should be resent,
and the call will not fail with EAGAIN).
@retval AVERROR_EOF the decoder has been flushed, and no new packets can be
sent to it (also returned if more than 1 flush
packet is sent)
@retval AVERROR(EINVAL) codec not opened, it is an encoder, or requires flush
@retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar
@retval "another negative error code" legitimate decoding errors
*/
func AVCodecSendPacket(avctx *AVCodecContext, avpkt *AVPacket) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
var tmpavpkt *C.AVPacket
if avpkt != nil {
tmpavpkt = avpkt.ptr
}
ret := C.avcodec_send_packet(tmpavctx, tmpavpkt)
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_receive_frame ---
// AVCodecReceiveFrame wraps avcodec_receive_frame.
/*
Return decoded output data from a decoder or encoder (when the
@ref AV_CODEC_FLAG_RECON_FRAME flag is used).
@param avctx codec context
@param frame This will be set to a reference-counted video or audio
frame (depending on the decoder type) allocated by the
codec. Note that the function will always call
av_frame_unref(frame) before doing anything else.
@retval 0 success, a frame was returned
@retval AVERROR(EAGAIN) output is not available in this state - user must
try to send new input
@retval AVERROR_EOF the codec has been fully flushed, and there will be
no more output frames
@retval AVERROR(EINVAL) codec not opened, or it is an encoder without the
@ref AV_CODEC_FLAG_RECON_FRAME flag enabled
@retval "other negative error code" legitimate decoding errors
*/
func AVCodecReceiveFrame(avctx *AVCodecContext, frame *AVFrame) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
var tmpframe *C.AVFrame
if frame != nil {
tmpframe = frame.ptr
}
ret := C.avcodec_receive_frame(tmpavctx, tmpframe)
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_send_frame ---
// AVCodecSendFrame wraps avcodec_send_frame.
/*
Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet()
to retrieve buffered output packets.
@param avctx codec context
@param[in] frame AVFrame containing the raw audio or video frame to be encoded.
Ownership of the frame remains with the caller, and the
encoder will not write to the frame. The encoder may create
a reference to the frame data (or copy it if the frame is
not reference-counted).
It can be NULL, in which case it is considered a flush
packet. This signals the end of the stream. If the encoder
still has packets buffered, it will return them after this
call. Once flushing mode has been entered, additional flush
packets are ignored, and sending frames will return
AVERROR_EOF.
For audio:
If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
can have any number of samples.
If it is not set, frame->nb_samples must be equal to
avctx->frame_size for all frames except the last.
The final frame may be smaller than avctx->frame_size.
@retval 0 success
@retval AVERROR(EAGAIN) input is not accepted in the current state - user must
read output with avcodec_receive_packet() (once all
output is read, the packet should be resent, and the
call will not fail with EAGAIN).
@retval AVERROR_EOF the encoder has been flushed, and no new frames can
be sent to it
@retval AVERROR(EINVAL) codec not opened, it is a decoder, or requires flush
@retval AVERROR(ENOMEM) failed to add packet to internal queue, or similar
@retval "another negative error code" legitimate encoding errors
*/
func AVCodecSendFrame(avctx *AVCodecContext, frame *AVFrame) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
var tmpframe *C.AVFrame
if frame != nil {
tmpframe = frame.ptr
}
ret := C.avcodec_send_frame(tmpavctx, tmpframe)
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_receive_packet ---
// AVCodecReceivePacket wraps avcodec_receive_packet.
/*
Read encoded data from the encoder.
@param avctx codec context
@param avpkt This will be set to a reference-counted packet allocated by the
encoder. Note that the function will always call
av_packet_unref(avpkt) before doing anything else.
@retval 0 success
@retval AVERROR(EAGAIN) output is not available in the current state - user must
try to send input
@retval AVERROR_EOF the encoder has been fully flushed, and there will be no
more output packets
@retval AVERROR(EINVAL) codec not opened, or it is a decoder
@retval "another negative error code" legitimate encoding errors
*/
func AVCodecReceivePacket(avctx *AVCodecContext, avpkt *AVPacket) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
var tmpavpkt *C.AVPacket
if avpkt != nil {
tmpavpkt = avpkt.ptr
}
ret := C.avcodec_receive_packet(tmpavctx, tmpavpkt)
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_get_hw_frames_parameters ---
// AVCodecGetHWFramesParameters wraps avcodec_get_hw_frames_parameters.
/*
Create and return a AVHWFramesContext with values adequate for hardware
decoding. This is meant to get called from the get_format callback, and is
a helper for preparing a AVHWFramesContext for AVCodecContext.hw_frames_ctx.
This API is for decoding with certain hardware acceleration modes/APIs only.
The returned AVHWFramesContext is not initialized. The caller must do this
with av_hwframe_ctx_init().
Calling this function is not a requirement, but makes it simpler to avoid
codec or hardware API specific details when manually allocating frames.
Alternatively to this, an API user can set AVCodecContext.hw_device_ctx,
which sets up AVCodecContext.hw_frames_ctx fully automatically, and makes
it unnecessary to call this function or having to care about
AVHWFramesContext initialization at all.
There are a number of requirements for calling this function:
- It must be called from get_format with the same avctx parameter that was
passed to get_format. Calling it outside of get_format is not allowed, and
can trigger undefined behavior.
- The function is not always supported (see description of return values).
Even if this function returns successfully, hwaccel initialization could
fail later. (The degree to which implementations check whether the stream
is actually supported varies. Some do this check only after the user's
get_format callback returns.)
- The hw_pix_fmt must be one of the choices suggested by get_format. If the
user decides to use a AVHWFramesContext prepared with this API function,
the user must return the same hw_pix_fmt from get_format.
- The device_ref passed to this function must support the given hw_pix_fmt.
- After calling this API function, it is the user's responsibility to
initialize the AVHWFramesContext (returned by the out_frames_ref parameter),
and to set AVCodecContext.hw_frames_ctx to it. If done, this must be done
before returning from get_format (this is implied by the normal
AVCodecContext.hw_frames_ctx API rules).
- The AVHWFramesContext parameters may change every time time get_format is
called. Also, AVCodecContext.hw_frames_ctx is reset before get_format. So
you are inherently required to go through this process again on every
get_format call.
- It is perfectly possible to call this function without actually using
the resulting AVHWFramesContext. One use-case might be trying to reuse a
previously initialized AVHWFramesContext, and calling this API function
only to test whether the required frame parameters have changed.
- Fields that use dynamically allocated values of any kind must not be set
by the user unless setting them is explicitly allowed by the documentation.
If the user sets AVHWFramesContext.free and AVHWFramesContext.user_opaque,
the new free callback must call the potentially set previous free callback.
This API call may set any dynamically allocated fields, including the free
callback.
The function will set at least the following fields on AVHWFramesContext
(potentially more, depending on hwaccel API):
- All fields set by av_hwframe_ctx_alloc().
- Set the format field to hw_pix_fmt.
- Set the sw_format field to the most suited and most versatile format. (An
implication is that this will prefer generic formats over opaque formats
with arbitrary restrictions, if possible.)
- Set the width/height fields to the coded frame size, rounded up to the
API-specific minimum alignment.
- Only _if_ the hwaccel requires a pre-allocated pool: set the initial_pool_size
field to the number of maximum reference surfaces possible with the codec,
plus 1 surface for the user to work (meaning the user can safely reference
at most 1 decoded surface at a time), plus additional buffering introduced
by frame threading. If the hwaccel does not require pre-allocation, the
field is left to 0, and the decoder will allocate new surfaces on demand
during decoding.
- Possibly AVHWFramesContext.hwctx fields, depending on the underlying
hardware API.
Essentially, out_frames_ref returns the same as av_hwframe_ctx_alloc(), but
with basic frame parameters set.
The function is stateless, and does not change the AVCodecContext or the
device_ref AVHWDeviceContext.
@param avctx The context which is currently calling get_format, and which
implicitly contains all state needed for filling the returned
AVHWFramesContext properly.
@param device_ref A reference to the AVHWDeviceContext describing the device
which will be used by the hardware decoder.
@param hw_pix_fmt The hwaccel format you are going to return from get_format.
@param out_frames_ref On success, set to a reference to an _uninitialized_
AVHWFramesContext, created from the given device_ref.
Fields will be set to values required for decoding.
Not changed if an error is returned.
@return zero on success, a negative value on error. The following error codes
have special semantics:
AVERROR(ENOENT): the decoder does not support this functionality. Setup
is always manual, or it is a decoder which does not
support setting AVCodecContext.hw_frames_ctx at all,
or it is a software format.
AVERROR(EINVAL): it is known that hardware decoding is not supported for
this configuration, or the device_ref is not supported
for the hwaccel referenced by hw_pix_fmt.
*/
func AVCodecGetHWFramesParameters(avctx *AVCodecContext, deviceRef *AVBufferRef, hwPixFmt AVPixelFormat, outFramesRef **AVBufferRef) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
var tmpdeviceRef *C.AVBufferRef
if deviceRef != nil {
tmpdeviceRef = deviceRef.ptr
}
var ptroutFramesRef **C.AVBufferRef
var tmpoutFramesRef *C.AVBufferRef
var oldTmpoutFramesRef *C.AVBufferRef
if outFramesRef != nil {
inneroutFramesRef := *outFramesRef
if inneroutFramesRef != nil {
tmpoutFramesRef = inneroutFramesRef.ptr
oldTmpoutFramesRef = tmpoutFramesRef
}
ptroutFramesRef = &tmpoutFramesRef
}
ret := C.avcodec_get_hw_frames_parameters(tmpavctx, tmpdeviceRef, C.enum_AVPixelFormat(hwPixFmt), ptroutFramesRef)
if tmpoutFramesRef != oldTmpoutFramesRef && outFramesRef != nil {
if tmpoutFramesRef != nil {
*outFramesRef = &AVBufferRef{ptr: tmpoutFramesRef}
} else {
*outFramesRef = nil
}
}
return int(ret), WrapErr(int(ret))
}
// --- Function av_parser_iterate ---
// av_parser_iterate skipped due to opaque
// --- Function av_parser_init ---
// AVParserInit wraps av_parser_init.
func AVParserInit(codecId int) *AVCodecParserContext {
ret := C.av_parser_init(C.int(codecId))
var retMapped *AVCodecParserContext
if ret != nil {
retMapped = &AVCodecParserContext{ptr: ret}
}
return retMapped
}
// --- Function av_parser_parse2 ---
// av_parser_parse2 skipped due to poutbuf
// --- Function av_parser_close ---
// AVParserClose wraps av_parser_close.
func AVParserClose(s *AVCodecParserContext) {
var tmps *C.AVCodecParserContext
if s != nil {
tmps = s.ptr
}
C.av_parser_close(tmps)
}
// --- Function avcodec_encode_subtitle ---
// AVCodecEncodeSubtitle wraps avcodec_encode_subtitle.
func AVCodecEncodeSubtitle(avctx *AVCodecContext, buf unsafe.Pointer, bufSize int, sub *AVSubtitle) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
var tmpsub *C.AVSubtitle
if sub != nil {
tmpsub = sub.ptr
}
ret := C.avcodec_encode_subtitle(tmpavctx, (*C.uint8_t)(buf), C.int(bufSize), tmpsub)
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_pix_fmt_to_codec_tag ---
// AVCodecPixFmtToCodecTag wraps avcodec_pix_fmt_to_codec_tag.
/*
Return a value representing the fourCC code associated to the
pixel format pix_fmt, or 0 if no associated fourCC code can be
found.
*/
func AVCodecPixFmtToCodecTag(pixFmt AVPixelFormat) uint {
ret := C.avcodec_pix_fmt_to_codec_tag(C.enum_AVPixelFormat(pixFmt))
return uint(ret)
}
// --- Function avcodec_find_best_pix_fmt_of_list ---
// avcodec_find_best_pix_fmt_of_list skipped due to pixFmtList
// --- Function avcodec_default_get_format ---
// avcodec_default_get_format skipped due to fmt
// --- Function avcodec_string ---
// AVCodecString wraps avcodec_string.
func AVCodecString(buf *CStr, bufSize int, enc *AVCodecContext, encode int) {
var tmpbuf *C.char
if buf != nil {
tmpbuf = buf.ptr
}
var tmpenc *C.AVCodecContext
if enc != nil {
tmpenc = enc.ptr
}
C.avcodec_string(tmpbuf, C.int(bufSize), tmpenc, C.int(encode))
}
// --- Function avcodec_default_execute ---
// avcodec_default_execute skipped due to func.
// --- Function avcodec_default_execute2 ---
// avcodec_default_execute2 skipped due to func.
// --- Function avcodec_fill_audio_frame ---
// AVCodecFillAudioFrame wraps avcodec_fill_audio_frame.
/*
Fill AVFrame audio data and linesize pointers.
The buffer buf must be a preallocated buffer with a size big enough
to contain the specified samples amount. The filled AVFrame data
pointers will point to this buffer.
AVFrame extended_data channel pointers are allocated if necessary for
planar audio.
@param frame the AVFrame
frame->nb_samples must be set prior to calling the
function. This function fills in frame->data,
frame->extended_data, frame->linesize[0].
@param nb_channels channel count
@param sample_fmt sample format
@param buf buffer to use for frame data
@param buf_size size of buffer
@param align plane size sample alignment (0 = default)
@return >=0 on success, negative error code on failure
@todo return the size in bytes required to store the samples in
case of success, at the next libavutil bump
*/
func AVCodecFillAudioFrame(frame *AVFrame, nbChannels int, sampleFmt AVSampleFormat, buf unsafe.Pointer, bufSize int, align int) (int, error) {
var tmpframe *C.AVFrame
if frame != nil {
tmpframe = frame.ptr
}
ret := C.avcodec_fill_audio_frame(tmpframe, C.int(nbChannels), C.enum_AVSampleFormat(sampleFmt), (*C.uint8_t)(buf), C.int(bufSize), C.int(align))
return int(ret), WrapErr(int(ret))
}
// --- Function avcodec_flush_buffers ---
// AVCodecFlushBuffers wraps avcodec_flush_buffers.
/*
Reset the internal codec state / flush internal buffers. Should be called
e.g. when seeking or when switching to a different stream.
@note for decoders, this function just releases any references the decoder
might keep internally, but the caller's references remain valid.
@note for encoders, this function will only do something if the encoder
declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder
will drain any remaining packets, and can then be re-used for a different
stream (as opposed to sending a null frame which will leave the encoder
in a permanent EOF state after draining). This can be desirable if the
cost of tearing down and replacing the encoder instance is high.
*/
func AVCodecFlushBuffers(avctx *AVCodecContext) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
C.avcodec_flush_buffers(tmpavctx)
}
// --- Function av_get_audio_frame_duration ---
// AVGetAudioFrameDuration wraps av_get_audio_frame_duration.
/*
Return audio frame duration.
@param avctx codec context
@param frame_bytes size of the frame, or 0 if unknown
@return frame duration, in samples, if known. 0 if not able to
determine.
*/
func AVGetAudioFrameDuration(avctx *AVCodecContext, frameBytes int) (int, error) {
var tmpavctx *C.AVCodecContext
if avctx != nil {
tmpavctx = avctx.ptr
}
ret := C.av_get_audio_frame_duration(tmpavctx, C.int(frameBytes))
return int(ret), WrapErr(int(ret))
}
// --- Function av_fast_padded_malloc ---
// av_fast_padded_malloc skipped due to size
// --- Function av_fast_padded_mallocz ---
// av_fast_padded_mallocz skipped due to size
// --- Function avcodec_is_open ---
// AVCodecIsOpen wraps avcodec_is_open.
/*
@return a positive value if s is open (i.e. avcodec_open2() was called on it
with no corresponding avcodec_close()), 0 otherwise.
*/
func AVCodecIsOpen(s *AVCodecContext) (int, error) {
var tmps *C.AVCodecContext
if s != nil {
tmps = s.ptr
}
ret := C.avcodec_is_open(tmps)
return int(ret), WrapErr(int(ret))
}
// --- Function av_codec_iterate ---
// av_codec_iterate skipped due to opaque
// --- Function avcodec_find_decoder ---
// AVCodecFindDecoder wraps avcodec_find_decoder.
/*
Find a registered decoder with a matching codec ID.
@param id AVCodecID of the requested decoder
@return A decoder if one was found, NULL otherwise.
*/
func AVCodecFindDecoder(id AVCodecID) *AVCodec {
ret := C.avcodec_find_decoder(C.enum_AVCodecID(id))
var retMapped *AVCodec
if ret != nil {
retMapped = &AVCodec{ptr: ret}
}
return retMapped
}
// --- Function avcodec_find_decoder_by_name ---
// AVCodecFindDecoderByName wraps avcodec_find_decoder_by_name.
/*
Find a registered decoder with the specified name.
@param name name of the requested decoder
@return A decoder if one was found, NULL otherwise.
*/
func AVCodecFindDecoderByName(name *CStr) *AVCodec {
var tmpname *C.char
if name != nil {
tmpname = name.ptr
}
ret := C.avcodec_find_decoder_by_name(tmpname)
var retMapped *AVCodec
if ret != nil {
retMapped = &AVCodec{ptr: ret}
}
return retMapped
}
// --- Function avcodec_find_encoder ---
// AVCodecFindEncoder wraps avcodec_find_encoder.
/*
Find a registered encoder with a matching codec ID.
@param id AVCodecID of the requested encoder
@return An encoder if one was found, NULL otherwise.
*/
func AVCodecFindEncoder(id AVCodecID) *AVCodec {
ret := C.avcodec_find_encoder(C.enum_AVCodecID(id))
var retMapped *AVCodec
if ret != nil {
retMapped = &AVCodec{ptr: ret}
}
return retMapped
}
// --- Function avcodec_find_encoder_by_name ---
// AVCodecFindEncoderByName wraps avcodec_find_encoder_by_name.
/*