FFmpeg
framepool.h
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 #ifndef AVFILTER_FRAMEPOOL_H
22 #define AVFILTER_FRAMEPOOL_H
23 
24 #include "libavutil/buffer.h"
25 #include "libavutil/frame.h"
26 #include "libavutil/internal.h"
27 
28 /**
29  * Frame pool. This structure is opaque and not meant to be accessed
30  * directly. It is allocated with ff_frame_pool_init() and freed with
31  * ff_frame_pool_uninit().
32  */
33 typedef struct FFFramePool FFFramePool;
34 
35 /**
36  * Allocate and initialize a video frame pool.
37  *
38  * @param alloc a function that will be used to allocate new frame buffers when
39  * the pool is empty. May be NULL, then the default allocator will be used
40  * (av_buffer_alloc()).
41  * @param width width of each frame in this pool
42  * @param height height of each frame in this pool
43  * @param format format of each frame in this pool
44  * @param align buffers alignement of each frame in this pool
45  * @return newly created video frame pool on success, NULL on error.
46  */
48  int width,
49  int height,
50  enum AVPixelFormat format,
51  int align);
52 
53 /**
54  * Allocate and initialize an audio frame pool.
55  *
56  * @param alloc a function that will be used to allocate new frame buffers when
57  * the pool is empty. May be NULL, then the default allocator will be used
58  * (av_buffer_alloc()).
59  * @param channels channels of each frame in this pool
60  * @param nb_samples number of samples of each frame in this pool
61  * @param format format of each frame in this pool
62  * @param align buffers alignement of each frame in this pool
63  * @return newly created audio frame pool on success, NULL on error.
64  */
66  int channels,
67  int samples,
69  int align);
70 
71 /**
72  * Deallocate the frame pool. It is safe to call this function while
73  * some of the allocated frame are still in use.
74  *
75  * @param pool pointer to the frame pool to be freed. It will be set to NULL.
76  */
78 
79 /**
80  * Get the video frame pool configuration.
81  *
82  * @param width width of each frame in this pool
83  * @param height height of each frame in this pool
84  * @param format format of each frame in this pool
85  * @param align buffers alignement of each frame in this pool
86  * @return 0 on success, a negative AVERROR otherwise.
87  */
89  int *width,
90  int *height,
91  enum AVPixelFormat *format,
92  int *align);
93 
94 /**
95  * Get the audio frame pool configuration.
96  *
97  * @param channels channels of each frame in this pool
98  * @param nb_samples number of samples of each frame in this pool
99  * @param format format of each frame in this pool
100  * @param align buffers alignement of each frame in this pool
101  * @return 0 on success, a negative AVERROR otherwise.
102  */
104  int *channels,
105  int *nb_samples,
106  enum AVSampleFormat *format,
107  int *align);
108 
109 
110 /**
111  * Allocate a new AVFrame, reussing old buffers from the pool when available.
112  * This function may be called simultaneously from multiple threads.
113  *
114  * @return a new AVFrame on success, NULL on error.
115  */
117 
118 
119 #endif /* AVFILTER_FRAMEPOOL_H */
ff_frame_pool_audio_init
FFFramePool * ff_frame_pool_audio_init(AVBufferRef *(*alloc)(size_t size), int channels, int samples, enum AVSampleFormat format, int align)
Allocate and initialize an audio frame pool.
Definition: framepool.c:114
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
FFFramePool::nb_samples
int nb_samples
Definition: framepool.c:41
FFFramePool
Frame pool.
Definition: framepool.c:30
width
#define width
format
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
channels
channels
Definition: aptx.h:31
ff_frame_pool_get
AVFrame * ff_frame_pool_get(FFFramePool *pool)
Allocate a new AVFrame, reussing old buffers from the pool when available.
Definition: framepool.c:190
ff_frame_pool_video_init
FFFramePool * ff_frame_pool_video_init(AVBufferRef *(*alloc)(size_t size), int width, int height, enum AVPixelFormat format, int align)
Allocate and initialize a video frame pool.
Definition: framepool.c:51
size
int size
Definition: twinvq_data.h:10344
frame.h
buffer.h
align
static const uint8_t *BS_FUNC() align(BSCTX *bc)
Skip bits to a byte boundary.
Definition: bitstream_template.h:411
height
#define height
ff_frame_pool_get_audio_config
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:171
ff_frame_pool_get_video_config
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:152
internal.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
ff_frame_pool_uninit
void ff_frame_pool_uninit(FFFramePool **pool)
Deallocate the frame pool.
Definition: framepool.c:283