FFmpeg: libavfilter/vf_feedback.c Source File
Go to the documentation of this file. 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 /**
20 * @file
21 * feedback video filter
22 */
23
32
35
38
41
43
46
48 {
49 if (
s->x +
s->w >
ctx->inputs[0]->w)
50 s->x =
ctx->inputs[0]->w -
s->w;
51 if (
s->y +
s->h >
ctx->inputs[0]->h)
52 s->y =
ctx->inputs[0]->h -
s->h;
53 }
54
56 {
57 if (
s->x >=
ctx->inputs[0]->w)
59 if (
s->y >=
ctx->inputs[0]->h)
61
63 s->w =
ctx->inputs[0]->w -
s->x;
65 s->h =
ctx->inputs[0]->h -
s->y;
66
67 if (
s->w >
ctx->inputs[0]->w)
68 s->w =
ctx->inputs[0]->w;
69 if (
s->h >
ctx->inputs[0]->h)
70 s->h =
ctx->inputs[0]->h;
71
73 }
74
76 {
80
83
85
87
88 ctx->inputs[1]->w =
s->w;
89 ctx->inputs[1]->h =
s->h;
90
91 return 0;
92 }
93
95 {
98
100
101 ctx->outputs[0]->w =
ctx->inputs[0]->w;
102 ctx->outputs[0]->h =
ctx->inputs[0]->h;
103 ctx->outputs[1]->w =
s->w;
104 ctx->outputs[1]->h =
s->h;
105
106 return 0;
107 }
108
110 {
114 }
115
117 {
121
123
124 for (
int i = 0;
i <
ctx->nb_outputs;
i++)
126
131 }
132
136
138 if (!dst)
140
143
147 }
148
154 }
155
159 }
160
161 for (
int y = 0; y <
src->height; y++) {
162 memmove(dst->
data[0] + (
s->y + y) * dst->
linesize[0] +
s->x *
s->max_step[0],
163 src->data[0] + y *
src->linesize[0],
src->width *
s->max_step[0]);
164 }
165
166 for (
int i = 1;
i < 3;
i ++) {
168 for (
int y = 0; y <
src->height; y++) {
169 memmove(dst->
data[
i] + ((
s->y + y) >>
s->vsub) * dst->
linesize[
i] + ((
s->x *
s->max_step[
i]) >>
s->hsub),
170 src->data[
i] + (y >>
s->vsub) *
src->linesize[
i], (
src->width *
s->max_step[
i]) >>
s->hsub);
171 }
172 }
173 }
174
176 for (
int y = 0; y <
src->height; y++) {
177 memmove(dst->
data[3] + (
s->y + y) * dst->
linesize[3] +
s->x *
s->max_step[3],
178 src->data[3] + y *
src->linesize[3],
src->width *
s->max_step[3]);
179 }
180 }
181
185 }
186
189
193
196
201 }
202
206
209
211 frame->data[0] +=
s->x *
s->max_step[0];
212
213 for (
int i = 1;
i < 3;
i ++) {
216 frame->data[
i] += (
s->x *
s->max_step[
i]) >>
s->hsub;
217 }
218 }
219
220 if (
frame->data[3]) {
222 frame->data[3] +=
s->x *
s->max_step[3];
223 }
224
226 }
227 }
228
232 return 0;
233 }
234
238 return 0;
239 }
240
245 return 0;
246 }
247 }
248
250 }
251
253 {
255
259
260 return 0;
261 }
262
264 {
268
269 for (
size_t n = 0; n <
size; n++) {
271
273
275 }
276
278 }
279 }
280
282 {
286 },
287 {
288 .name = "feedin",
291 },
292 };
293
295 {
299 },
300 {
301 .name = "feedout",
304 },
305 };
306
307 #define OFFSET(x) offsetof(FeedbackContext, x)
308 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
309 #define TFLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM)
310
317 };
318
320
324 .priv_class = &feedback_class,
333 };
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int config_input(AVFilterLink *inlink)
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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 they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
size_t av_fifo_can_read(const AVFifo *f)
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
#define FILTER_QUERY_FUNC(func)
static int query_formats(AVFilterContext *ctx)
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
static int activate(AVFilterContext *ctx)
A filter pad used for either input or output.
static void adjust_parameters(AVFilterContext *ctx, FeedbackContext *s)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
#define FILTER_INPUTS(array)
const AVFilter ff_vf_feedback
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFILTER_DEFINE_CLASS(feedback)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
static const AVOption feedback_options[]
static int config_output(AVFilterLink *outlink)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
AVFilterContext * src
source filter
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
#define i(width, name, range_min, range_max)
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
static const AVFilterPad inputs[]
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
const char * name
Pad name.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
static av_cold int init(AVFilterContext *ctx)
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
static const AVFilterPad outputs[]
static void adjust_pos(AVFilterContext *ctx, FeedbackContext *s)
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static av_cold void uninit(AVFilterContext *ctx)
Generated on Wed Aug 24 2022 21:42:05 for FFmpeg by
doxygen
1.8.17