]> git.sesse.net Git - ffmpeg/blob - libavfilter/buffersrc.h
avprobe: add local per-file state
[ffmpeg] / libavfilter / buffersrc.h
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
19 #ifndef AVFILTER_BUFFERSRC_H
20 #define AVFILTER_BUFFERSRC_H
21
22 /**
23  * @file
24  * @ingroup lavfi_buffersrc
25  * Memory buffer source API.
26  */
27
28 #include "avfilter.h"
29
30 /**
31  * @defgroup lavfi_buffersrc Buffer source API
32  * @ingroup lavfi
33  * @{
34  */
35
36 /**
37  * This structure contains the parameters describing the frames that will be
38  * passed to this filter.
39  *
40  * It should be allocated with av_buffersrc_parameters_alloc() and freed with
41  * av_free(). All the allocated fields in it remain owned by the caller.
42  */
43 typedef struct AVBufferSrcParameters {
44     /**
45      * video: the pixel format, value corresponds to enum AVPixelFormat
46      * audio: the sample format, value corresponds to enum AVSampleFormat
47      */
48     int format;
49     /**
50      * The timebase to be used for the timestamps on the input frames.
51      */
52     AVRational time_base;
53
54     /**
55      * Video only, the display dimensions of the input frames.
56      */
57     int width, height;
58
59     /**
60      * Video only, the sample (pixel) aspect ratio.
61      */
62     AVRational sample_aspect_ratio;
63
64     /**
65      * Video only, the frame rate of the input video. This field must only be
66      * set to a non-zero value if input stream has a known constant framerate
67      * and should be left at its initial value if the framerate is variable or
68      * unknown.
69      */
70     AVRational frame_rate;
71
72     /**
73      * Video with a hwaccel pixel format only. This should be a reference to an
74      * AVHWFramesContext instance describing the input frames.
75      */
76     AVBufferRef *hw_frames_ctx;
77
78     /**
79      * Audio only, the audio sampling rate in samples per secon.
80      */
81     int sample_rate;
82
83     /**
84      * Audio only, the audio channel layout
85      */
86     uint64_t channel_layout;
87 } AVBufferSrcParameters;
88
89 /**
90  * Allocate a new AVBufferSrcParameters instance. It should be freed by the
91  * caller with av_free().
92  */
93 AVBufferSrcParameters *av_buffersrc_parameters_alloc(void);
94
95 /**
96  * Initialize the buffersrc or abuffersrc filter with the provided parameters.
97  * This function may be called multiple times, the later calls override the
98  * previous ones. Some of the parameters may also be set through AVOptions, then
99  * whatever method is used last takes precedence.
100  *
101  * @param ctx an instance of the buffersrc or abuffersrc filter
102  * @param param the stream parameters. The frames later passed to this filter
103  *              must conform to those parameters. All the allocated fields in
104  *              param remain owned by the caller, libavfilter will make internal
105  *              copies or references when necessary.
106  * @return 0 on success, a negative AVERROR code on failure.
107  */
108 int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param);
109
110 /**
111  * Add a frame to the buffer source.
112  *
113  * @param ctx   an instance of the buffersrc filter
114  * @param frame frame to be added. If the frame is reference counted, this
115  * function will make a new reference to it. Otherwise the frame data will be
116  * copied.
117  *
118  * @return 0 on success, a negative AVERROR on error
119  */
120 int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame);
121
122 /**
123  * Add a frame to the buffer source.
124  *
125  * @param ctx   an instance of the buffersrc filter
126  * @param frame frame to be added. If the frame is reference counted, this
127  * function will take ownership of the reference(s) and reset the frame.
128  * Otherwise the frame data will be copied. If this function returns an error,
129  * the input frame is not touched.
130  *
131  * @return 0 on success, a negative AVERROR on error.
132  *
133  * @note the difference between this function and av_buffersrc_write_frame() is
134  * that av_buffersrc_write_frame() creates a new reference to the input frame,
135  * while this function takes ownership of the reference passed to it.
136  */
137 int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
138
139 /**
140  * @}
141  */
142
143 #endif /* AVFILTER_BUFFERSRC_H */