Debian Codegraph @

av/codec/context.pxd

raw
1 cimport libav as lib
2 from libc.stdint cimport int64_t, uint8_t
3
4 from av.buffer cimport ByteSource
5 from av.codec.codec cimport Codec
6 from av.codec.hwaccel cimport HWAccel
7 from av.frame cimport Frame
8 from av.packet cimport Packet
9
10
11 cdef class CodecContext:
12 cdef lib.AVCodecContext *ptr
13
14 # Used as a signal that this is within a stream, and also for us to access that
15 # stream. This is set "manually" by the stream after constructing this object.
16 cdef int stream_index
17
18 cdef lib.AVCodecParserContext *parser
19 cdef _init(self, lib.AVCodecContext *ptr, const lib.AVCodec *codec, HWAccel hwaccel)
20
21 # Public API.
22 cdef readonly bint is_open
23 cdef readonly Codec codec
24 cdef readonly HWAccel hwaccel
25 cdef public dict options
26 cpdef open(self, bint strict=?)
27
28 # Wraps both versions of the transcode API, returning lists.
29 cpdef encode(self, Frame frame=?)
30 cpdef decode(self, Packet packet=?)
31 cpdef flush_buffers(self)
32
33 # Used by hardware-accelerated decode.
34 cdef HWAccel hwaccel_ctx
35
36 cdef uint8_t _ctxflags # ctxEnum: template_initialized
37 # True when created via add_stream_from_template(); start_encoding() skips
38 # avcodec_open2() and lets encode()/decode() open the codec lazily if needed.
39
40 # Used by both transcode APIs to setup user-land objects.
41 # TODO: Remove the `Packet` from `_setup_decoded_frame` (because flushing packets
42 # are bogus). It should take all info it needs from the context and/or stream.
43 cdef _prepare_and_time_rebase_frames_for_encode(self, Frame frame)
44 cdef list _prepare_frames_for_encode(self, Frame frame)
45 cdef _setup_encoded_packet(self, Packet)
46 cdef _setup_decoded_frame(self, Frame, Packet)
47
48 # Implemented by base for the generic send/recv API.
49 # Note that the user cannot send without receiving. This is because
50 # `_prepare_frames_for_encode` may expand a frame into multiple (e.g. when
51 # resampling audio to a higher rate but with fixed size frames), and the
52 # send/recv buffer may be limited to a single frame. Ergo, we need to flush
53 # the buffer as often as possible.
54 cdef _recv_packet(self)
55 cdef _recv_frame(self)
56
57 cdef _transfer_hwframe(self, Frame frame)
58
59 # Implemented by children for the generic send/recv API, so we have the
60 # correct subclass of Frame.
61 cdef Frame _next_frame
62 cdef Frame _alloc_next_frame(self)
63
64 cdef CodecContext wrap_codec_context(lib.AVCodecContext*, const lib.AVCodec*, HWAccel hwaccel)