-
Notifications
You must be signed in to change notification settings - Fork 370
/
avcodec.pxd
549 lines (450 loc) · 14.7 KB
/
avcodec.pxd
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
from libc.stdint cimport int8_t, int64_t, uint16_t, uint32_t
cdef extern from "libavcodec/codec.h":
struct AVCodecTag:
pass
cdef extern from "libavcodec/codec_id.h":
AVCodecID av_codec_get_id(const AVCodecTag *const *tags, uint32_t tag)
cdef extern from "libavutil/channel_layout.h":
ctypedef enum AVChannelOrder:
AV_CHANNEL_ORDER_UNSPEC
AV_CHANNEL_ORDER_NATIVE
AV_CHANNEL_ORDER_CUSTOM
AV_CHANNEL_ORDER_AMBISONIC
ctypedef enum AVChannel:
AV_CHAN_NONE = -1
AV_CHAN_FRONT_LEFT
AV_CHAN_FRONT_RIGHT
AV_CHAN_FRONT_CENTER
# ... other channel enum values ...
ctypedef struct AVChannelCustom:
AVChannel id
char name[16]
void *opaque
ctypedef struct AVChannelLayout:
AVChannelOrder order
int nb_channels
uint64_t mask
# union:
# uint64_t mask
# AVChannelCustom *map
void *opaque
int av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
int av_channel_name(char *buf, size_t buf_size, AVChannel channel_id)
int av_channel_description(char *buf, size_t buf_size, AVChannel channel_id)
AVChannel av_channel_layout_channel_from_index(AVChannelLayout *channel_layout, unsigned int idx)
cdef extern from "libavcodec/avcodec.h" nogil:
cdef set pyav_get_available_codecs()
cdef int avcodec_version()
cdef char* avcodec_configuration()
cdef char* avcodec_license()
cdef size_t AV_INPUT_BUFFER_PADDING_SIZE
cdef int64_t AV_NOPTS_VALUE
# AVCodecDescriptor.props
cdef enum:
AV_CODEC_PROP_INTRA_ONLY
AV_CODEC_PROP_LOSSY
AV_CODEC_PROP_LOSSLESS
AV_CODEC_PROP_REORDER
AV_CODEC_PROP_BITMAP_SUB
AV_CODEC_PROP_TEXT_SUB
# AVCodec.capabilities
cdef enum:
AV_CODEC_CAP_DRAW_HORIZ_BAND
AV_CODEC_CAP_DR1
# AV_CODEC_CAP_HWACCEL
AV_CODEC_CAP_DELAY
AV_CODEC_CAP_SMALL_LAST_FRAME
# AV_CODEC_CAP_HWACCEL_VDPAU
AV_CODEC_CAP_SUBFRAMES
AV_CODEC_CAP_EXPERIMENTAL
AV_CODEC_CAP_CHANNEL_CONF
# AV_CODEC_CAP_NEG_LINESIZES
AV_CODEC_CAP_FRAME_THREADS
AV_CODEC_CAP_SLICE_THREADS
AV_CODEC_CAP_PARAM_CHANGE
AV_CODEC_CAP_OTHER_THREADS
AV_CODEC_CAP_VARIABLE_FRAME_SIZE
AV_CODEC_CAP_AVOID_PROBING
AV_CODEC_CAP_HARDWARE
AV_CODEC_CAP_HYBRID
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
cdef enum:
FF_THREAD_FRAME
FF_THREAD_SLICE
cdef enum:
AV_CODEC_FLAG_UNALIGNED
AV_CODEC_FLAG_QSCALE
AV_CODEC_FLAG_4MV
AV_CODEC_FLAG_OUTPUT_CORRUPT
AV_CODEC_FLAG_QPEL
AV_CODEC_FLAG_DROPCHANGED
AV_CODEC_FLAG_RECON_FRAME
AV_CODEC_FLAG_COPY_OPAQUE
AV_CODEC_FLAG_FRAME_DURATION
AV_CODEC_FLAG_PASS1
AV_CODEC_FLAG_PASS2
AV_CODEC_FLAG_LOOP_FILTER
AV_CODEC_FLAG_GRAY
AV_CODEC_FLAG_PSNR
AV_CODEC_FLAG_INTERLACED_DCT
AV_CODEC_FLAG_LOW_DELAY
AV_CODEC_FLAG_GLOBAL_HEADER
AV_CODEC_FLAG_BITEXACT
AV_CODEC_FLAG_AC_PRED
AV_CODEC_FLAG_INTERLACED_ME
AV_CODEC_FLAG_CLOSED_GOP
cdef enum:
AV_CODEC_FLAG2_FAST
AV_CODEC_FLAG2_NO_OUTPUT
AV_CODEC_FLAG2_LOCAL_HEADER
AV_CODEC_FLAG2_CHUNKS
AV_CODEC_FLAG2_IGNORE_CROP
AV_CODEC_FLAG2_SHOW_ALL
AV_CODEC_FLAG2_EXPORT_MVS
AV_CODEC_FLAG2_SKIP_MANUAL
AV_CODEC_FLAG2_RO_FLUSH_NOOP
cdef enum:
AV_PKT_FLAG_KEY
AV_PKT_FLAG_CORRUPT
AV_PKT_FLAG_DISCARD
AV_PKT_FLAG_TRUSTED
AV_PKT_FLAG_DISPOSABLE
cdef enum:
AV_FRAME_FLAG_CORRUPT
AV_FRAME_FLAG_KEY
AV_FRAME_FLAG_DISCARD
AV_FRAME_FLAG_INTERLACED
cdef enum:
FF_COMPLIANCE_VERY_STRICT
FF_COMPLIANCE_STRICT
FF_COMPLIANCE_NORMAL
FF_COMPLIANCE_UNOFFICIAL
FF_COMPLIANCE_EXPERIMENTAL
cdef enum:
FF_PROFILE_UNKNOWN = -99
cdef enum AVCodecID:
AV_CODEC_ID_NONE
AV_CODEC_ID_MPEG2VIDEO
AV_CODEC_ID_MPEG1VIDEO
cdef enum AVDiscard:
AVDISCARD_NONE
AVDISCARD_DEFAULT
AVDISCARD_NONREF
AVDISCARD_BIDIR
AVDISCARD_NONINTRA
AVDISCARD_NONKEY
AVDISCARD_ALL
cdef struct AVCodec:
char *name
char *long_name
AVMediaType type
AVCodecID id
int capabilities
AVRational* supported_framerates
AVSampleFormat* sample_fmts
AVPixelFormat* pix_fmts
int* supported_samplerates
AVClass *priv_class
cdef int av_codec_is_encoder(AVCodec*)
cdef int av_codec_is_decoder(AVCodec*)
cdef struct AVProfile:
int profile
char *name
cdef struct AVCodecDescriptor:
AVCodecID id
char *name
char *long_name
int props
char **mime_types
AVProfile *profiles
AVCodecDescriptor* avcodec_descriptor_get(AVCodecID)
cdef struct AVCodecContext:
AVClass *av_class
AVMediaType codec_type
char codec_name[32]
unsigned int codec_tag
AVCodecID codec_id
int flags
int flags2
int thread_count
int thread_type
int profile
AVDiscard skip_frame
AVFrame* coded_frame
int bit_rate
int bit_rate_tolerance
int mb_decision
int bits_per_coded_sample
int global_quality
int compression_level
int qmin
int qmax
int rc_max_rate
int rc_min_rate
int rc_buffer_size
float rc_max_available_vbv_use
float rc_min_vbv_overflow_use
AVRational framerate
AVRational pkt_timebase
AVRational time_base
int extradata_size
uint8_t *extradata
int delay
AVCodec *codec
# Video.
int width
int height
int coded_width
int coded_height
AVPixelFormat pix_fmt
AVRational sample_aspect_ratio
int gop_size # The number of pictures in a group of pictures, or 0 for intra_only.
int max_b_frames
int has_b_frames
AVColorRange color_range
AVColorPrimaries color_primaries
AVColorTransferCharacteristic color_trc
AVColorSpace colorspace
# Audio.
AVSampleFormat sample_fmt
int sample_rate
AVChannelLayout ch_layout
int frame_size
#: .. todo:: ``get_buffer`` is deprecated for get_buffer2 in newer versions of FFmpeg.
int get_buffer(AVCodecContext *ctx, AVFrame *frame)
void release_buffer(AVCodecContext *ctx, AVFrame *frame)
# User Data
void *opaque
cdef AVCodecContext* avcodec_alloc_context3(AVCodec *codec)
cdef void avcodec_free_context(AVCodecContext **ctx)
cdef AVClass* avcodec_get_class()
cdef AVCodec* avcodec_find_decoder(AVCodecID id)
cdef AVCodec* avcodec_find_encoder(AVCodecID id)
cdef AVCodec* avcodec_find_decoder_by_name(char *name)
cdef AVCodec* avcodec_find_encoder_by_name(char *name)
cdef const AVCodec* av_codec_iterate(void **opaque)
cdef AVCodecDescriptor* avcodec_descriptor_get (AVCodecID id)
cdef AVCodecDescriptor* avcodec_descriptor_get_by_name (char *name)
cdef char* avcodec_get_name(AVCodecID id)
cdef char* av_get_profile_name(AVCodec *codec, int profile)
cdef int avcodec_open2(
AVCodecContext *ctx,
AVCodec *codec,
AVDictionary **options,
)
cdef int AV_NUM_DATA_POINTERS
cdef enum AVPacketSideDataType:
AV_PKT_DATA_PALETTE
AV_PKT_DATA_NEW_EXTRADATA
AV_PKT_DATA_PARAM_CHANGE
AV_PKT_DATA_H263_MB_INFO
AV_PKT_DATA_REPLAYGAIN
AV_PKT_DATA_DISPLAYMATRIX
AV_PKT_DATA_STEREO3D
AV_PKT_DATA_AUDIO_SERVICE_TYPE
AV_PKT_DATA_QUALITY_STATS
AV_PKT_DATA_FALLBACK_TRACK
AV_PKT_DATA_CPB_PROPERTIES
AV_PKT_DATA_SKIP_SAMPLES
AV_PKT_DATA_JP_DUALMONO
AV_PKT_DATA_STRINGS_METADATA
AV_PKT_DATA_SUBTITLE_POSITION
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
AV_PKT_DATA_WEBVTT_IDENTIFIER
AV_PKT_DATA_WEBVTT_SETTINGS
AV_PKT_DATA_METADATA_UPDATE
AV_PKT_DATA_MPEGTS_STREAM_ID
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
AV_PKT_DATA_SPHERICAL
AV_PKT_DATA_CONTENT_LIGHT_LEVEL
AV_PKT_DATA_A53_CC
AV_PKT_DATA_ENCRYPTION_INIT_INFO
AV_PKT_DATA_ENCRYPTION_INFO
AV_PKT_DATA_AFD
AV_PKT_DATA_PRFT
AV_PKT_DATA_ICC_PROFILE
AV_PKT_DATA_DOVI_CONF
AV_PKT_DATA_S12M_TIMECODE
AV_PKT_DATA_DYNAMIC_HDR10_PLUS
AV_PKT_DATA_NB
cdef struct AVPacketSideData:
uint8_t *data;
size_t size;
AVPacketSideDataType type;
cdef enum AVFrameSideDataType:
AV_FRAME_DATA_PANSCAN
AV_FRAME_DATA_A53_CC
AV_FRAME_DATA_STEREO3D
AV_FRAME_DATA_MATRIXENCODING
AV_FRAME_DATA_DOWNMIX_INFO
AV_FRAME_DATA_REPLAYGAIN
AV_FRAME_DATA_DISPLAYMATRIX
AV_FRAME_DATA_AFD
AV_FRAME_DATA_MOTION_VECTORS
AV_FRAME_DATA_SKIP_SAMPLES
AV_FRAME_DATA_AUDIO_SERVICE_TYPE
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
AV_FRAME_DATA_GOP_TIMECODE
AV_FRAME_DATA_SPHERICAL
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
AV_FRAME_DATA_ICC_PROFILE
AV_FRAME_DATA_S12M_TIMECODE
AV_FRAME_DATA_DYNAMIC_HDR_PLUS
AV_FRAME_DATA_REGIONS_OF_INTEREST
AV_FRAME_DATA_VIDEO_ENC_PARAMS
AV_FRAME_DATA_SEI_UNREGISTERED
AV_FRAME_DATA_FILM_GRAIN_PARAMS
AV_FRAME_DATA_DETECTION_BBOXES
AV_FRAME_DATA_DOVI_RPU_BUFFER
AV_FRAME_DATA_DOVI_METADATA
AV_FRAME_DATA_DYNAMIC_HDR_VIVID
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
AV_FRAME_DATA_VIDEO_HINT
cdef struct AVFrameSideData:
AVFrameSideDataType type
uint8_t *data
int size
AVDictionary *metadata
# See: http://ffmpeg.org/doxygen/trunk/structAVFrame.html
cdef struct AVFrame:
uint8_t *data[4]
int linesize[4]
uint8_t **extended_data
int format # Should be AVPixelFormat or AVSampleFormat
AVPictureType pict_type
int width
int height
int nb_side_data
AVFrameSideData **side_data
int nb_samples
int sample_rate
AVChannelLayout ch_layout
int64_t pts
int64_t pkt_dts
int pkt_size
uint8_t **base
void *opaque
AVBufferRef *opaque_ref
AVDictionary *metadata
int flags
int decode_error_flags
AVColorRange color_range
AVColorPrimaries color_primaries
AVColorTransferCharacteristic color_trc
AVColorSpace colorspace
cdef AVFrame* avcodec_alloc_frame()
cdef struct AVPacket:
int64_t pts
int64_t dts
uint8_t *data
int size
int stream_index
int flags
int duration
int64_t pos
void *opaque
AVBufferRef *opaque_ref
cdef int avcodec_fill_audio_frame(
AVFrame *frame,
int nb_channels,
AVSampleFormat sample_fmt,
uint8_t *buf,
int buf_size,
int align
)
cdef void avcodec_free_frame(AVFrame **frame)
cdef AVPacket* av_packet_alloc()
cdef void av_packet_free(AVPacket **)
cdef int av_new_packet(AVPacket*, int)
cdef int av_packet_ref(AVPacket *dst, const AVPacket *src)
cdef void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
cdef enum AVSubtitleType:
SUBTITLE_NONE
SUBTITLE_BITMAP
SUBTITLE_TEXT
SUBTITLE_ASS
cdef struct AVSubtitleRect:
int x
int y
int w
int h
int nb_colors
uint8_t *data[4]
int linesize[4]
AVSubtitleType type
char *text
char *ass
int flags
cdef struct AVSubtitle:
uint16_t format
uint32_t start_display_time
uint32_t end_display_time
unsigned int num_rects
AVSubtitleRect **rects
int64_t pts
cdef int avcodec_decode_subtitle2(
AVCodecContext *ctx,
AVSubtitle *sub,
int *done,
AVPacket *pkt,
)
cdef int avcodec_encode_subtitle(
AVCodecContext *avctx,
uint8_t *buf,
int buf_size,
AVSubtitle *sub
)
cdef void avsubtitle_free(AVSubtitle*)
cdef void avcodec_get_frame_defaults(AVFrame* frame)
cdef void avcodec_flush_buffers(AVCodecContext *ctx)
# TODO: avcodec_default_get_buffer is deprecated for avcodec_default_get_buffer2 in newer versions of FFmpeg
cdef int avcodec_default_get_buffer(AVCodecContext *ctx, AVFrame *frame)
cdef void avcodec_default_release_buffer(AVCodecContext *ctx, AVFrame *frame)
# === New-style Transcoding
cdef int avcodec_send_packet(AVCodecContext *avctx, AVPacket *packet)
cdef int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
cdef int avcodec_send_frame(AVCodecContext *avctx, AVFrame *frame)
cdef int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
# === Parsers
cdef struct AVCodecParser:
int codec_ids[5]
cdef AVCodecParser* av_parser_next(AVCodecParser *c)
cdef struct AVCodecParserContext:
pass
cdef AVCodecParserContext *av_parser_init(int codec_id)
cdef int av_parser_parse2(
AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size,
int64_t pts, int64_t dts,
int64_t pos
)
cdef int av_parser_change(
AVCodecParserContext *s,
AVCodecContext *avctx,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size,
int keyframe
)
cdef void av_parser_close(AVCodecParserContext *s)
cdef struct AVCodecParameters:
AVMediaType codec_type
AVCodecID codec_id
cdef int avcodec_parameters_copy(
AVCodecParameters *dst,
const AVCodecParameters *src
)
cdef int avcodec_parameters_from_context(
AVCodecParameters *par,
const AVCodecContext *codec,
)
cdef int avcodec_parameters_to_context(
AVCodecContext *codec,
const AVCodecParameters *par
)