]> git.sesse.net Git - ffmpeg/blob - libavfilter/framepool.h
avcodec/nvenc: Refactor timestamp generation logic
[ffmpeg] / libavfilter / framepool.h
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
27 /**
28  * Video frame pool. This structure is opaque and not meant to be accessed
29  * directly. It is allocated with ff_video_frame_pool_init() and freed with
30  * ff_video_frame_pool_uninit().
31  */
32 typedef struct FFVideoFramePool FFVideoFramePool;
33
34 /**
35  * Allocate and initialize a video frame pool.
36  *
37  * @param alloc a function that will be used to allocate new frame buffers when
38  * the pool is empty. May be NULL, then the default allocator will be used
39  * (av_buffer_alloc()).
40  * @param width width of each frame in this pool
41  * @param height height of each frame in this pool
42  * @param format format of each frame in this pool
43  * @param align buffers alignement of each frame in this pool
44  * @return newly created video frame pool on success, NULL on error.
45  */
46 FFVideoFramePool *ff_video_frame_pool_init(AVBufferRef* (*alloc)(int size),
47                                            int width,
48                                            int height,
49                                            enum AVPixelFormat format,
50                                            int align);
51
52 /**
53  * Deallocate the video frame pool. It is safe to call this function while
54  * some of the allocated video frame are still in use.
55  *
56  * @param pool pointer to the video frame pool to be freed. It will be set to NULL.
57  */
58 void ff_video_frame_pool_uninit(FFVideoFramePool **pool);
59
60 /**
61  * Get the video frame pool configuration.
62  *
63  * @param width width of each frame in this pool
64  * @param height height of each frame in this pool
65  * @param format format of each frame in this pool
66  * @param align buffers alignement of each frame in this pool
67  * @return 0 on success, a negative AVERROR otherwise.
68  */
69 int ff_video_frame_pool_get_config(FFVideoFramePool *pool,
70                                    int *width,
71                                    int *height,
72                                    enum AVPixelFormat *format,
73                                    int *align);
74
75 /**
76  * Allocate a new AVFrame, reussing old buffers from the pool when available.
77  * This function may be called simultaneously from multiple threads.
78  *
79  * @return a new AVFrame on success, NULL on error.
80  */
81 AVFrame *ff_video_frame_pool_get(FFVideoFramePool *pool);
82
83
84 #endif /* AVFILTER_FRAMEPOOL_H */