FFmpeg
get_buffer.c
Go to the documentation of this file.
1 /*
2  * The default get_buffer2() implementation
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <stdint.h>
22 
23 #include "libavutil/avassert.h"
24 #include "libavutil/avutil.h"
25 #include "libavutil/buffer.h"
26 #include "libavutil/frame.h"
27 #include "libavutil/hwcontext.h"
28 #include "libavutil/imgutils.h"
29 #include "libavutil/mem.h"
30 #include "libavutil/samplefmt.h"
31 #include "libavutil/version.h"
32 
33 #include "avcodec.h"
34 #include "internal.h"
35 #include "refstruct.h"
36 
37 typedef struct FramePool {
38  /**
39  * Pools for each data plane. For audio all the planes have the same size,
40  * so only pools[0] is used.
41  */
43 
44  /*
45  * Pool parameters
46  */
47  int format;
48  int width, height;
50  int linesize[4];
51  int planes;
52  int channels;
53  int samples;
54 } FramePool;
55 
56 static void frame_pool_free(FFRefStructOpaque unused, void *obj)
57 {
58  FramePool *pool = obj;
59  int i;
60 
61  for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
62  av_buffer_pool_uninit(&pool->pools[i]);
63 }
64 
66 {
67  FramePool *pool = avctx->internal->pool;
68  int i, ret, ch, planes;
69 
70  if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
73 #if FF_API_OLD_CHANNEL_LAYOUT
75  if (!ch)
76  ch = frame->channels;
78 #endif
79  planes = planar ? ch : 1;
80  }
81 
82  if (pool && pool->format == frame->format) {
83  if (avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
84  pool->width == frame->width && pool->height == frame->height)
85  return 0;
86  if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && pool->planes == planes &&
87  pool->channels == ch && frame->nb_samples == pool->samples)
88  return 0;
89  }
90 
91  pool = ff_refstruct_alloc_ext(sizeof(*pool), 0, NULL, frame_pool_free);
92  if (!pool)
93  return AVERROR(ENOMEM);
94 
95  switch (avctx->codec_type) {
96  case AVMEDIA_TYPE_VIDEO: {
97  int linesize[4];
98  int w = frame->width;
99  int h = frame->height;
100  int unaligned;
101  ptrdiff_t linesize1[4];
102  size_t size[4];
103 
104  avcodec_align_dimensions2(avctx, &w, &h, pool->stride_align);
105 
106  do {
107  // NOTE: do not align linesizes individually, this breaks e.g. assumptions
108  // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2
109  ret = av_image_fill_linesizes(linesize, avctx->pix_fmt, w);
110  if (ret < 0)
111  goto fail;
112  // increase alignment of w for next try (rhs gives the lowest bit set in w)
113  w += w & ~(w - 1);
114 
115  unaligned = 0;
116  for (i = 0; i < 4; i++)
117  unaligned |= linesize[i] % pool->stride_align[i];
118  } while (unaligned);
119 
120  for (i = 0; i < 4; i++)
121  linesize1[i] = linesize[i];
122  ret = av_image_fill_plane_sizes(size, avctx->pix_fmt, h, linesize1);
123  if (ret < 0)
124  goto fail;
125 
126  for (i = 0; i < 4; i++) {
127  pool->linesize[i] = linesize[i];
128  if (size[i]) {
129  if (size[i] > INT_MAX - (16 + STRIDE_ALIGN - 1)) {
130  ret = AVERROR(EINVAL);
131  goto fail;
132  }
133  pool->pools[i] = av_buffer_pool_init(size[i] + 16 + STRIDE_ALIGN - 1,
134  CONFIG_MEMORY_POISONING ?
135  NULL :
137  if (!pool->pools[i]) {
138  ret = AVERROR(ENOMEM);
139  goto fail;
140  }
141  }
142  }
143  pool->format = frame->format;
144  pool->width = frame->width;
145  pool->height = frame->height;
146 
147  break;
148  }
149  case AVMEDIA_TYPE_AUDIO: {
150  ret = av_samples_get_buffer_size(&pool->linesize[0], ch,
151  frame->nb_samples, frame->format, 0);
152  if (ret < 0)
153  goto fail;
154 
155  pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL);
156  if (!pool->pools[0]) {
157  ret = AVERROR(ENOMEM);
158  goto fail;
159  }
160 
161  pool->format = frame->format;
162  pool->planes = planes;
163  pool->channels = ch;
164  pool->samples = frame->nb_samples;
165  break;
166  }
167  default: av_assert0(0);
168  }
169 
170  ff_refstruct_unref(&avctx->internal->pool);
171  avctx->internal->pool = pool;
172 
173  return 0;
174 fail:
175  ff_refstruct_unref(&pool);
176  return ret;
177 }
178 
180 {
181  FramePool *pool = avctx->internal->pool;
182  int planes = pool->planes;
183  int i;
184 
185  frame->linesize[0] = pool->linesize[0];
186 
191  sizeof(*frame->extended_buf));
192  if (!frame->extended_data || !frame->extended_buf) {
195  return AVERROR(ENOMEM);
196  }
197  } else {
200  }
201 
202  for (i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) {
203  frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
204  if (!frame->buf[i])
205  goto fail;
206  frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;
207  }
208  for (i = 0; i < frame->nb_extended_buf; i++) {
210  if (!frame->extended_buf[i])
211  goto fail;
213  }
214 
215  if (avctx->debug & FF_DEBUG_BUFFERS)
216  av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p", frame);
217 
218  return 0;
219 fail:
221  return AVERROR(ENOMEM);
222 }
223 
225 {
226  FramePool *pool = s->internal->pool;
227  int i;
228 
229  if (pic->data[0] || pic->data[1] || pic->data[2] || pic->data[3]) {
230  av_log(s, AV_LOG_ERROR, "pic->data[*]!=NULL in avcodec_default_get_buffer\n");
231  return -1;
232  }
233 
234  memset(pic->data, 0, sizeof(pic->data));
235  pic->extended_data = pic->data;
236 
237  for (i = 0; i < 4 && pool->pools[i]; i++) {
238  pic->linesize[i] = pool->linesize[i];
239 
240  pic->buf[i] = av_buffer_pool_get(pool->pools[i]);
241  if (!pic->buf[i])
242  goto fail;
243 
244  pic->data[i] = pic->buf[i]->data;
245  }
246  for (; i < AV_NUM_DATA_POINTERS; i++) {
247  pic->data[i] = NULL;
248  pic->linesize[i] = 0;
249  }
250 
251  if (s->debug & FF_DEBUG_BUFFERS)
252  av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p\n", pic);
253 
254  return 0;
255 fail:
256  av_frame_unref(pic);
257  return AVERROR(ENOMEM);
258 }
259 
261 {
262  int ret;
263 
264  if (avctx->hw_frames_ctx) {
266  frame->width = avctx->coded_width;
267  frame->height = avctx->coded_height;
268  return ret;
269  }
270 
271  if ((ret = update_frame_pool(avctx, frame)) < 0)
272  return ret;
273 
274  switch (avctx->codec_type) {
275  case AVMEDIA_TYPE_VIDEO:
276  return video_get_buffer(avctx, frame);
277  case AVMEDIA_TYPE_AUDIO:
278  return audio_get_buffer(avctx, frame);
279  default:
280  return -1;
281  }
282 }
AVFrame::extended_buf
AVBufferRef ** extended_buf
For planar audio which requires more than AV_NUM_DATA_POINTERS AVBufferRef pointers,...
Definition: frame.h:604
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
av_buffer_pool_init
AVBufferPool * av_buffer_pool_init(size_t size, AVBufferRef *(*alloc)(size_t size))
Allocate and initialize a buffer pool.
Definition: buffer.c:280
frame_pool_free
static void frame_pool_free(FFRefStructOpaque unused, void *obj)
Definition: get_buffer.c:56
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVBufferPool
The buffer pool.
Definition: buffer_internal.h:88
FramePool::planes
int planes
Definition: get_buffer.c:51
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
ff_refstruct_alloc_ext
static void * ff_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(FFRefStructOpaque opaque, void *obj))
A wrapper around ff_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
Definition: refstruct.h:94
video_get_buffer
static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
Definition: get_buffer.c:224
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
FramePool::pools
AVBufferPool * pools[4]
Pools for each data plane.
Definition: get_buffer.c:42
AVFrame::width
int width
Definition: frame.h:412
w
uint8_t w
Definition: llviddspenc.c:38
internal.h
FramePool::channels
int channels
Definition: get_buffer.c:52
FramePool::height
int height
Definition: get_buffer.c:48
FFRefStructOpaque
RefStruct is an API for creating reference-counted objects with minimal overhead.
Definition: refstruct.h:58
FramePool::stride_align
int stride_align[AV_NUM_DATA_POINTERS]
Definition: get_buffer.c:49
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:317
AVFrame::buf
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:590
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
STRIDE_ALIGN
#define STRIDE_ALIGN
Definition: internal.h:49
fail
#define fail()
Definition: checkasm.h:138
samplefmt.h
AVFrame::ch_layout
AVChannelLayout ch_layout
Channel layout of the audio data.
Definition: frame.h:802
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:636
AVFrame::channels
attribute_deprecated int channels
number of audio channels, only used for audio.
Definition: frame.h:731
planar
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1<< 16)) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out->ch+ch,(const uint8_t **) in->ch+ch, off *(out-> planar
Definition: audioconvert.c:56
refstruct.h
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_buffer_pool_get
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
Definition: buffer.c:384
av_image_fill_linesizes
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVCodecInternal::pool
struct FramePool * pool
Definition: internal.h:65
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
av_sample_fmt_is_planar
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:114
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
avcodec_align_dimensions2
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS])
Modify width and height values so that they will result in a memory buffer that is acceptable for the...
Definition: utils.c:144
FramePool::format
int format
Definition: get_buffer.c:47
frame
static AVFrame * frame
Definition: demux_decode.c:54
FramePool::width
int width
Definition: get_buffer.c:48
NULL
#define NULL
Definition: coverity.c:32
av_image_fill_plane_sizes
int av_image_fill_plane_sizes(size_t sizes[4], enum AVPixelFormat pix_fmt, int height, const ptrdiff_t linesizes[4])
Fill plane sizes for an image with pixel format pix_fmt and height height.
Definition: imgutils.c:111
AVCodecContext::internal
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:476
av_buffer_pool_uninit
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
Definition: buffer.c:322
FramePool::linesize
int linesize[4]
Definition: get_buffer.c:50
FF_DEBUG_BUFFERS
#define FF_DEBUG_BUFFERS
Definition: avcodec.h:1400
audio_get_buffer
static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Definition: get_buffer.c:179
size
int size
Definition: twinvq_data.h:10344
AV_NUM_DATA_POINTERS
#define AV_NUM_DATA_POINTERS
Definition: frame.h:341
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:427
frame.h
buffer.h
avcodec_default_get_buffer2
int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
Definition: get_buffer.c:260
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:401
planes
static const struct @363 planes[]
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:622
av_samples_get_buffer_size
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
Definition: samplefmt.c:121
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:658
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
AVCodecContext::hw_frames_ctx
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
Definition: avcodec.h:1940
avcodec.h
version.h
av_buffer_allocz
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:93
ret
ret
Definition: filter_design.txt:187
FramePool
Definition: get_buffer.c:37
AVCodecContext
main external API structure.
Definition: avcodec.h:441
AVFrame::height
int height
Definition: frame.h:412
update_frame_pool
static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
Definition: get_buffer.c:65
AVCodecContext::debug
int debug
debug
Definition: avcodec.h:1388
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:636
AVCodecContext::codec_type
enum AVMediaType codec_type
Definition: avcodec.h:449
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
avutil.h
mem.h
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
hwcontext.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:385
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2038
av_hwframe_get_buffer
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
Definition: hwcontext.c:507
FramePool::samples
int samples
Definition: get_buffer.c:53
ff_refstruct_unref
void ff_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition: refstruct.c:116
AVFrame::nb_extended_buf
int nb_extended_buf
Number of elements in extended_buf.
Definition: frame.h:608