FFmpeg
avcodec_internal.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20  * APIs internal to the generic codec layer.
21  *
22  * MUST NOT be included by individual encoders or decoders.
23  */
24 
25 #ifndef AVCODEC_AVCODEC_INTERNAL_H
26 #define AVCODEC_AVCODEC_INTERNAL_H
27 
28 #include "libavutil/frame.h"
29 
30 #include "packet.h"
31 
32 struct AVCodecContext;
33 
34 typedef struct SideDataMap {
37 } SideDataMap;
38 
39 /**
40  * A map between packet and frame side data types.
41  * Terminated with an entry where packet=AV_PKT_DATA_NB.
42  */
43 extern const SideDataMap ff_sd_global_map[];
44 
45 /**
46  * avcodec_receive_frame() implementation for decoders.
47  */
48 int ff_decode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame);
49 
50 /**
51  * avcodec_receive_frame() implementation for encoders.
52  */
53 int ff_encode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame);
54 
55 /*
56  * Perform encoder initialization and validation.
57  * Called when opening the encoder, before the FFCodec.init() call.
58  */
59 int ff_encode_preinit(struct AVCodecContext *avctx);
60 
61 /**
62  * Perform decoder initialization and validation.
63  * Called when opening the decoder, before the FFCodec.init() call.
64  */
65 int ff_decode_preinit(struct AVCodecContext *avctx);
66 
67 void ff_decode_flush_buffers(struct AVCodecContext *avctx);
68 void ff_encode_flush_buffers(struct AVCodecContext *avctx);
69 
72  const struct AVCodecContext *src);
73 void ff_decode_internal_uninit(struct AVCodecContext *avctx);
74 
76 
77 void ff_codec_close(struct AVCodecContext *avctx);
78 
79 int ff_thread_init(struct AVCodecContext *s);
80 void ff_thread_free(struct AVCodecContext *s);
81 
82 /**
83  * Wait for decoding threads to finish and reset internal state.
84  * Called by avcodec_flush_buffers().
85  *
86  * @param avctx The context.
87  */
88 void ff_thread_flush(struct AVCodecContext *avctx);
89 
90 /**
91  * Submit available packets for decoding to worker threads, return a
92  * decoded frame if available. Returns AVERROR(EAGAIN) if none is available.
93  *
94  * Parameters are the same as FFCodec.receive_frame.
95  */
97 
98 /**
99  * Do the actual decoding and obtain a decoded frame from the decoder, if
100  * available. When frame threading is used, this is invoked by the worker
101  * threads, otherwise by the top layer directly.
102  */
104 
105 /**
106  * Get a packet for decoding. This gets invoked by the worker threads.
107  */
108 int ff_thread_get_packet(struct AVCodecContext *avctx, AVPacket *pkt);
109 
110 #endif // AVCODEC_AVCODEC_INTERNAL_H
ff_thread_receive_frame
int ff_thread_receive_frame(struct AVCodecContext *avctx, AVFrame *frame)
Submit available packets for decoding to worker threads, return a decoded frame if available.
Definition: pthread_frame.c:566
ff_thread_free
void ff_thread_free(struct AVCodecContext *s)
Definition: pthread.c:84
ff_decode_receive_frame
int ff_decode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame)
avcodec_receive_frame() implementation for decoders.
Definition: decode.c:815
ff_thread_flush
void ff_thread_flush(struct AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
Definition: pthread_frame.c:984
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
ff_encode_preinit
int ff_encode_preinit(struct AVCodecContext *avctx)
Definition: encode.c:756
ff_encode_internal_alloc
struct AVCodecInternal * ff_encode_internal_alloc(void)
Definition: encode.c:904
AVFrameSideDataType
AVFrameSideDataType
Definition: frame.h:49
pkt
AVPacket * pkt
Definition: movenc.c:60
ff_encode_flush_buffers
void ff_encode_flush_buffers(struct AVCodecContext *avctx)
Definition: encode.c:894
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_decode_preinit
int ff_decode_preinit(struct AVCodecContext *avctx)
Perform decoder initialization and validation.
Definition: decode.c:1943
ff_decode_internal_sync
void ff_decode_internal_sync(struct AVCodecContext *dst, const struct AVCodecContext *src)
SideDataMap::packet
enum AVPacketSideDataType packet
Definition: avcodec_internal.h:35
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
frame.h
SideDataMap::frame
enum AVFrameSideDataType frame
Definition: avcodec_internal.h:36
AVCodecInternal
Definition: internal.h:49
ff_decode_receive_frame_internal
int ff_decode_receive_frame_internal(struct AVCodecContext *avctx, AVFrame *frame)
Do the actual decoding and obtain a decoded frame from the decoder, if available.
Definition: decode.c:621
packet.h
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
ff_decode_internal_alloc
struct AVCodecInternal * ff_decode_internal_alloc(void)
Definition: decode.c:2298
ff_decode_flush_buffers
void ff_decode_flush_buffers(struct AVCodecContext *avctx)
Definition: decode.c:2280
AVCodecContext
main external API structure.
Definition: avcodec.h:451
AVPacketSideDataType
AVPacketSideDataType
Definition: packet.h:41
ff_thread_get_packet
int ff_thread_get_packet(struct AVCodecContext *avctx, AVPacket *pkt)
Get a packet for decoding.
Definition: pthread_frame.c:1106
SideDataMap
Definition: avcodec_internal.h:34
AVPacket
This structure stores compressed data.
Definition: packet.h:516
ff_encode_receive_frame
int ff_encode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame)
avcodec_receive_frame() implementation for encoders.
Definition: encode.c:881
ff_codec_close
void ff_codec_close(struct AVCodecContext *avctx)
Definition: avcodec.c:428
ff_decode_internal_uninit
void ff_decode_internal_uninit(struct AVCodecContext *avctx)
Definition: decode.c:2311
ff_thread_init
int ff_thread_init(struct AVCodecContext *s)
Definition: pthread.c:72
ff_sd_global_map
const SideDataMap ff_sd_global_map[]
A map between packet and frame side data types.
Definition: avcodec.c:58
src
#define src
Definition: vp8dsp.c:248