Libav
internal.h
Go to the documentation of this file.
1 /*
2  * This file is part of Libav.
3  *
4  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
24 #ifndef AVCODEC_INTERNAL_H
25 #define AVCODEC_INTERNAL_H
26 
27 #include <stdint.h>
28 
29 #include "libavutil/buffer.h"
31 #include "libavutil/mathematics.h"
32 #include "libavutil/pixfmt.h"
33 #include "avcodec.h"
34 #include "config.h"
35 
36 #define FF_SANE_NB_CHANNELS 63U
37 
38 #define FF_SIGNBIT(x) (x >> CHAR_BIT * sizeof(x) - 1)
39 
40 typedef struct FramePool {
46 
47  /*
48  * Pool parameters
49  */
50  int format;
51  int width, height;
53  int linesize[4];
54  int planes;
55  int channels;
56  int samples;
57 } FramePool;
58 
59 typedef struct AVCodecInternal {
66  int is_copy;
67 
82 
88 
90 
92 
93  void *thread_ctx;
94 
100 
106 
108  const uint8_t *key;
109  const uint8_t *value;
110 };
111 
116 int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
117 
118 unsigned int avpriv_toupper4(unsigned int x);
119 
120 int avpriv_lock_avformat(void);
121 int avpriv_unlock_avformat(void);
122 
128 #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - FF_INPUT_BUFFER_PADDING_SIZE)
129 
146 int ff_alloc_packet(AVPacket *avpkt, int size);
147 
152  int64_t samples)
153 {
154  return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate },
155  avctx->time_base);
156 }
157 
163 int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags);
164 
169 int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame);
170 
172  const uint8_t *end,
173  uint32_t *restrict state);
174 
179 int ff_set_dimensions(AVCodecContext *s, int width, int height);
180 
185 int ff_set_sar(AVCodecContext *avctx, AVRational sar);
186 
191  enum AVMatrixEncoding matrix_encoding);
192 
198 int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
199 
203 int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame);
204 
205 #endif /* AVCODEC_INTERNAL_H */
#define AV_NUM_DATA_POINTERS
Definition: frame.h:136
int size
This structure describes decoded (raw) audio or video data.
Definition: frame.h:135
int avpriv_unlock_avformat(void)
Definition: utils.c:2311
int stride_align[AV_NUM_DATA_POINTERS]
Definition: internal.h:52
AVFrame * to_free
Definition: internal.h:89
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:133
int width
Definition: internal.h:51
AVPacket * pkt
Current packet as passed into the decoder, to avoid having to pass the packet into every function...
Definition: internal.h:99
int samples
Definition: internal.h:56
AVBufferPool * pools[4]
Pools for each data plane.
Definition: internal.h:45
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:1175
int height
Definition: internal.h:51
uint8_t
void * thread_ctx
Definition: internal.h:93
#define b
Definition: input.c:52
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
Definition: utils.c:560
int planes
Definition: internal.h:54
static int flags
Definition: log.c:44
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
Definition: utils.c:145
The buffer pool.
FramePool * pool
Definition: internal.h:91
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:129
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
Definition: internal.h:66
int avpriv_lock_avformat(void)
Definition: utils.c:2302
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
Definition: utils.c:808
audio channel layout utility functions
int channels
Definition: internal.h:55
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
Definition: utils.c:1245
int linesize[4]
Definition: internal.h:53
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
Definition: utils.c:160
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
Definition: utils.c:902
static int width
Definition: utils.c:156
Libavcodec external API header.
int sample_rate
samples per second
Definition: avcodec.h:1791
main external API structure.
Definition: avcodec.h:1050
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: utils.c:612
unsigned int avpriv_toupper4(unsigned int x)
Definition: utils.c:2320
rational number numerator/denominator
Definition: rational.h:43
refcounted data buffer API
int allocate_progress
Whether to allocate progress for frame threading.
Definition: internal.h:81
static uint32_t state
Definition: trasher.c:27
const uint8_t * key
Definition: internal.h:108
const uint8_t * avpriv_find_start_code(const uint8_t *restrict p, const uint8_t *end, uint32_t *restrict state)
Definition: utils.c:2394
int height
Definition: gxfenc.c:72
const uint8_t * value
Definition: internal.h:109
#define restrict
Definition: config.h:8
void * hwaccel_priv_data
hwaccel-specific private data
Definition: internal.h:104
pixel format definitions
static const struct twinvq_data tab
#define av_always_inline
Definition: attributes.h:40
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
Definition: internal.h:151
AVMatrixEncoding
int format
Definition: internal.h:50
AVPixelFormat
Pixel format.
Definition: pixfmt.h:63
This structure stores compressed data.
Definition: avcodec.h:950
int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
Definition: utils.c:2230
int last_audio_frame
An audio frame with less than required samples has been submitted and padded with silence...
Definition: internal.h:87