1 /* 2 * This file is part of FFmpeg. 3 * 4 * FFmpeg 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 * FFmpeg 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 FFmpeg; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19 module ffmpeg.libavfilter.buffersrc; 20 21 import ffmpeg.libavfilter.avfilter; 22 23 extern (C): 24 import ffmpeg; @nogc nothrow: 25 26 /** 27 * @file 28 * @ingroup lavfi_buffersrc 29 * Memory buffer source API. 30 */ 31 32 /** 33 * @defgroup lavfi_buffersrc Buffer source API 34 * @ingroup lavfi 35 * @{ 36 */ 37 38 enum 39 { 40 /** 41 * Do not check for format changes. 42 */ 43 AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT = 1, 44 45 /** 46 * Immediately push the frame to the output. 47 */ 48 AV_BUFFERSRC_FLAG_PUSH = 4, 49 50 /** 51 * Keep a reference to the frame. 52 * If the frame if reference-counted, create a new reference; otherwise 53 * copy the frame data. 54 */ 55 AV_BUFFERSRC_FLAG_KEEP_REF = 8 56 } 57 58 /** 59 * Get the number of failed requests. 60 * 61 * A failed request is when the request_frame method is called while no 62 * frame is present in the buffer. 63 * The number is reset when a frame is added. 64 */ 65 uint av_buffersrc_get_nb_failed_requests (AVFilterContext* buffer_src); 66 67 /** 68 * This structure contains the parameters describing the frames that will be 69 * passed to this filter. 70 * 71 * It should be allocated with av_buffersrc_parameters_alloc() and freed with 72 * av_free(). All the allocated fields in it remain owned by the caller. 73 */ 74 struct AVBufferSrcParameters 75 { 76 /** 77 * video: the pixel format, value corresponds to enum AVPixelFormat 78 * audio: the sample format, value corresponds to enum AVSampleFormat 79 */ 80 int format; 81 /** 82 * The timebase to be used for the timestamps on the input frames. 83 */ 84 AVRational time_base; 85 86 /** 87 * Video only, the display dimensions of the input frames. 88 */ 89 int width; 90 int height; 91 92 /** 93 * Video only, the sample (pixel) aspect ratio. 94 */ 95 AVRational sample_aspect_ratio; 96 97 /** 98 * Video only, the frame rate of the input video. This field must only be 99 * set to a non-zero value if input stream has a known constant framerate 100 * and should be left at its initial value if the framerate is variable or 101 * unknown. 102 */ 103 AVRational frame_rate; 104 105 /** 106 * Video with a hwaccel pixel format only. This should be a reference to an 107 * AVHWFramesContext instance describing the input frames. 108 */ 109 AVBufferRef* hw_frames_ctx; 110 111 /** 112 * Audio only, the audio sampling rate in samples per second. 113 */ 114 int sample_rate; 115 116 /** 117 * Audio only, the audio channel layout 118 */ 119 ulong channel_layout; 120 } 121 122 /** 123 * Allocate a new AVBufferSrcParameters instance. It should be freed by the 124 * caller with av_free(). 125 */ 126 AVBufferSrcParameters* av_buffersrc_parameters_alloc (); 127 128 /** 129 * Initialize the buffersrc or abuffersrc filter with the provided parameters. 130 * This function may be called multiple times, the later calls override the 131 * previous ones. Some of the parameters may also be set through AVOptions, then 132 * whatever method is used last takes precedence. 133 * 134 * @param ctx an instance of the buffersrc or abuffersrc filter 135 * @param param the stream parameters. The frames later passed to this filter 136 * must conform to those parameters. All the allocated fields in 137 * param remain owned by the caller, libavfilter will make internal 138 * copies or references when necessary. 139 * @return 0 on success, a negative AVERROR code on failure. 140 */ 141 int av_buffersrc_parameters_set (AVFilterContext* ctx, AVBufferSrcParameters* param); 142 143 /** 144 * Add a frame to the buffer source. 145 * 146 * @param ctx an instance of the buffersrc filter 147 * @param frame frame to be added. If the frame is reference counted, this 148 * function will make a new reference to it. Otherwise the frame data will be 149 * copied. 150 * 151 * @return 0 on success, a negative AVERROR on error 152 * 153 * This function is equivalent to av_buffersrc_add_frame_flags() with the 154 * AV_BUFFERSRC_FLAG_KEEP_REF flag. 155 */ 156 int av_buffersrc_write_frame (AVFilterContext* ctx, const(AVFrame)* frame); 157 158 /** 159 * Add a frame to the buffer source. 160 * 161 * @param ctx an instance of the buffersrc filter 162 * @param frame frame to be added. If the frame is reference counted, this 163 * function will take ownership of the reference(s) and reset the frame. 164 * Otherwise the frame data will be copied. If this function returns an error, 165 * the input frame is not touched. 166 * 167 * @return 0 on success, a negative AVERROR on error. 168 * 169 * @note the difference between this function and av_buffersrc_write_frame() is 170 * that av_buffersrc_write_frame() creates a new reference to the input frame, 171 * while this function takes ownership of the reference passed to it. 172 * 173 * This function is equivalent to av_buffersrc_add_frame_flags() without the 174 * AV_BUFFERSRC_FLAG_KEEP_REF flag. 175 */ 176 int av_buffersrc_add_frame (AVFilterContext* ctx, AVFrame* frame); 177 178 /** 179 * Add a frame to the buffer source. 180 * 181 * By default, if the frame is reference-counted, this function will take 182 * ownership of the reference(s) and reset the frame. This can be controlled 183 * using the flags. 184 * 185 * If this function returns an error, the input frame is not touched. 186 * 187 * @param buffer_src pointer to a buffer source context 188 * @param frame a frame, or NULL to mark EOF 189 * @param flags a combination of AV_BUFFERSRC_FLAG_* 190 * @return >= 0 in case of success, a negative AVERROR code 191 * in case of failure 192 */ 193 int av_buffersrc_add_frame_flags ( 194 AVFilterContext* buffer_src, 195 AVFrame* frame, 196 int flags); 197 198 /** 199 * Close the buffer source after EOF. 200 * 201 * This is similar to passing NULL to av_buffersrc_add_frame_flags() 202 * except it takes the timestamp of the EOF, i.e. the timestamp of the end 203 * of the last frame. 204 */ 205 int av_buffersrc_close (AVFilterContext* ctx, long pts, uint flags); 206 207 /** 208 * @} 209 */ 210 211 /* AVFILTER_BUFFERSRC_H */