FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
framepool.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * Copyright (c) 2015 Matthieu Bouron <matthieu.bouron stupeflix.com>
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 "framepool.h"
22 #include "libavutil/avassert.h"
23 #include "libavutil/avutil.h"
24 #include "libavutil/buffer.h"
25 #include "libavutil/frame.h"
26 #include "libavutil/imgutils.h"
27 #include "libavutil/mem.h"
28 #include "libavutil/pixfmt.h"
29 
30 struct FFFramePool {
31 
33 
34  /* video */
35  int width;
36  int height;
37 
38  /* audio */
39  int planes;
40  int channels;
42 
43  /* common */
44  int format;
45  int align;
46  int linesize[4];
48 
49 };
50 
52  int width,
53  int height,
54  enum AVPixelFormat format,
55  int align)
56 {
57  int i, ret;
58  FFFramePool *pool;
60 
61  if (!desc)
62  return NULL;
63 
64  pool = av_mallocz(sizeof(FFFramePool));
65  if (!pool)
66  return NULL;
67 
68  pool->type = AVMEDIA_TYPE_VIDEO;
69  pool->width = width;
70  pool->height = height;
71  pool->format = format;
72  pool->align = align;
73 
74  if ((ret = av_image_check_size2(width, height, INT64_MAX, format, 0, NULL)) < 0) {
75  goto fail;
76  }
77 
78  if (!pool->linesize[0]) {
79  for(i = 1; i <= align; i += i) {
80  ret = av_image_fill_linesizes(pool->linesize, pool->format,
81  FFALIGN(pool->width, i));
82  if (ret < 0) {
83  goto fail;
84  }
85  if (!(pool->linesize[0] & (pool->align - 1)))
86  break;
87  }
88 
89  for (i = 0; i < 4 && pool->linesize[i]; i++) {
90  pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
91  }
92  }
93 
94  for (i = 0; i < 4 && pool->linesize[i]; i++) {
95  int h = FFALIGN(pool->height, 32);
96  if (i == 1 || i == 2)
97  h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
98 
99  pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16 - 1,
100  alloc);
101  if (!pool->pools[i])
102  goto fail;
103  }
104 
105  if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
106  desc->flags & FF_PSEUDOPAL) {
107  pool->pools[1] = av_buffer_pool_init(AVPALETTE_SIZE, alloc);
108  if (!pool->pools[1])
109  goto fail;
110  }
111 
112  return pool;
113 
114 fail:
115  ff_frame_pool_uninit(&pool);
116  return NULL;
117 }
118 
120  int channels,
121  int nb_samples,
122  enum AVSampleFormat format,
123  int align)
124 {
125  int ret, planar;
126  FFFramePool *pool;
127 
128  pool = av_mallocz(sizeof(FFFramePool));
129  if (!pool)
130  return NULL;
131 
132  planar = av_sample_fmt_is_planar(format);
133 
134  pool->type = AVMEDIA_TYPE_AUDIO;
135  pool->planes = planar ? channels : 1;
136  pool->channels = channels;
137  pool->nb_samples = nb_samples;
138  pool->format = format;
139  pool->align = align;
140 
141  ret = av_samples_get_buffer_size(&pool->linesize[0], channels,
142  nb_samples, format, 0);
143  if (ret < 0)
144  goto fail;
145 
146  pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL);
147  if (!pool->pools[0])
148  goto fail;
149 
150  return pool;
151 
152 fail:
153  ff_frame_pool_uninit(&pool);
154  return NULL;
155 }
156 
158  int *width,
159  int *height,
160  enum AVPixelFormat *format,
161  int *align)
162 {
163  if (!pool)
164  return AVERROR(EINVAL);
165 
167 
168  *width = pool->width;
169  *height = pool->height;
170  *format = pool->format;
171  *align = pool->align;
172 
173  return 0;
174 }
175 
177  int *channels,
178  int *nb_samples,
179  enum AVSampleFormat *format,
180  int *align)
181 {
182  if (!pool)
183  return AVERROR(EINVAL);
184 
186 
187  *channels = pool->channels;
188  *nb_samples = pool->nb_samples;
189  *format = pool->format;
190  *align = pool->align;
191 
192  return 0;
193 }
194 
196 {
197  int i;
198  AVFrame *frame;
199  const AVPixFmtDescriptor *desc;
200 
201  frame = av_frame_alloc();
202  if (!frame) {
203  return NULL;
204  }
205 
206  switch(pool->type) {
207  case AVMEDIA_TYPE_VIDEO:
208  desc = av_pix_fmt_desc_get(pool->format);
209  if (!desc) {
210  goto fail;
211  }
212 
213  frame->width = pool->width;
214  frame->height = pool->height;
215  frame->format = pool->format;
216 
217  for (i = 0; i < 4; i++) {
218  frame->linesize[i] = pool->linesize[i];
219  if (!pool->pools[i])
220  break;
221 
222  frame->buf[i] = av_buffer_pool_get(pool->pools[i]);
223  if (!frame->buf[i])
224  goto fail;
225 
226  frame->data[i] = frame->buf[i]->data;
227  }
228 
229  if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
230  desc->flags & FF_PSEUDOPAL) {
231  enum AVPixelFormat format =
232  pool->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : pool->format;
233 
234  av_assert0(frame->data[1] != NULL);
235  if (avpriv_set_systematic_pal2((uint32_t *)frame->data[1], format) < 0)
236  goto fail;
237  }
238 
239  frame->extended_data = frame->data;
240  break;
241  case AVMEDIA_TYPE_AUDIO:
242  frame->nb_samples = pool->nb_samples;
243  frame->channels = pool->channels;
244  frame->format = pool->format;
245  frame->linesize[0] = pool->linesize[0];
246 
247  if (pool->planes > AV_NUM_DATA_POINTERS) {
248  frame->extended_data = av_mallocz_array(pool->planes,
249  sizeof(*frame->extended_data));
252  sizeof(*frame->extended_buf));
253  if (!frame->extended_data || !frame->extended_buf)
254  goto fail;
255  } else {
256  frame->extended_data = frame->data;
257  av_assert0(frame->nb_extended_buf == 0);
258  }
259 
260  for (i = 0; i < FFMIN(pool->planes, AV_NUM_DATA_POINTERS); i++) {
261  frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
262  if (!frame->buf[i])
263  goto fail;
264  frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;
265  }
266  for (i = 0; i < frame->nb_extended_buf; i++) {
267  frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]);
268  if (!frame->extended_buf[i])
269  goto fail;
270  frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data;
271  }
272 
273  break;
274  default:
275  av_assert0(0);
276  }
277 
278  return frame;
279 fail:
280  av_frame_free(&frame);
281  return NULL;
282 }
283 
285 {
286  int i;
287 
288  if (!pool || !*pool)
289  return;
290 
291  for (i = 0; i < 4; i++) {
292  av_buffer_pool_uninit(&(*pool)->pools[i]);
293  }
294 
295  av_freep(pool);
296 }
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:132
#define NULL
Definition: coverity.c:32
#define AV_NUM_DATA_POINTERS
Definition: frame.h:219
static const char * format[]
Definition: af_aiir.c:311
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2363
FFFramePool * ff_frame_pool_audio_init(AVBufferRef *(*alloc)(int size), int channels, int nb_samples, enum AVSampleFormat format, int align)
Allocate and initialize an audio frame pool.
Definition: framepool.c:119
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
misc image utilities
AVFrame * ff_frame_pool_get(FFFramePool *pool)
Allocate a new AVFrame, reussing old buffers from the pool when available.
Definition: framepool.c:195
Memory handling functions.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:410
const char * desc
Definition: nvenc.c:65
channels
Definition: aptx.c:30
int nb_extended_buf
Number of elements in extended_buf.
Definition: frame.h:428
Convenience header that includes libavutil's core.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:236
enum AVMediaType type
Definition: framepool.c:32
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
void ff_frame_pool_uninit(FFFramePool **pool)
Deallocate the frame pool.
Definition: framepool.c:284
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:189
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:73
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
Definition: imgutils.c:152
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
int ff_frame_pool_get_audio_config(FFFramePool *pool, int *channels, int *nb_samples, enum AVSampleFormat *format, int *align)
Get the audio frame pool configuration.
Definition: framepool.c:176
static AVFrame * frame
#define height
ptrdiff_t size
Definition: opengl_enc.c:101
#define FFALIGN(x, a)
Definition: macros.h:48
The buffer pool.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:112
int planes
Definition: framepool.c:39
int width
Definition: frame.h:276
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
AVBufferPool * pools[4]
Definition: framepool.c:47
uint16_t width
Definition: gdv.c:47
simple assert() macros that are a bit more flexible than ISO C assert().
FFFramePool * ff_frame_pool_video_init(AVBufferRef *(*alloc)(int size), int width, int height, enum AVPixelFormat format, int align)
Allocate and initialize a video frame pool.
Definition: framepool.c:51
Frame pool.
Definition: framepool.c:30
#define fail()
Definition: checkasm.h:116
reference-counted frame API
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
int height
Definition: framepool.c:36
int channels
number of audio channels, only used for audio.
Definition: frame.h:523
#define FFMIN(a, b)
Definition: common.h:96
AVBufferRef ** extended_buf
For planar audio which requires more than AV_NUM_DATA_POINTERS AVBufferRef pointers, this array will hold all the references which cannot fit into AVFrame.buf.
Definition: frame.h:424
int nb_samples
Definition: framepool.c:41
int format
Definition: framepool.c:44
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:291
const AVS_VideoInfo int align
Definition: avisynth_c.h:795
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:79
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:249
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
uint8_t * data
The data buffer.
Definition: buffer.h:89
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_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),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){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) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;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)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch const uint8_t **in ch off *out planar
Definition: audioconvert.c:56
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
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
Definition: buffer.c:275
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:119
AVMediaType
Definition: avutil.h:199
refcounted data buffer API
int channels
Definition: framepool.c:40
int ff_frame_pool_get_video_config(FFFramePool *pool, int *width, int *height, enum AVPixelFormat *format, int *align)
Get the video frame pool configuration.
Definition: framepool.c:157
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:232
A reference to a data buffer.
Definition: buffer.h:81
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
Definition: buffer.c:238
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
Definition: imgutils.c:253
#define FF_PSEUDOPAL
Definition: internal.h:367
pixel format definitions
int height
Definition: frame.h:276
#define av_freep(p)
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
Definition: buffer.c:334
int linesize[4]
Definition: framepool.c:46
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:265
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:284
void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.c:191
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58