FFmpeg: libavfilter/vf_tile.c Source File
Go to the documentation of this file. 1 /*
2 * Copyright (c) 2012 Nicolas George
3 *
4 * This file is part of FFmpeg.
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 /**
22 * @file
23 * tile video filter
24 */
25
34
50
51 #define OFFSET(x) offsetof(TileContext, x)
52 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
53
56 {.str =
"6x5"}, 0, 0,
FLAGS },
57 {
"nb_frames",
"set maximum number of frame to render",
OFFSET(nb_frames),
59 {
"margin",
"set outer border margin in pixels",
OFFSET(margin),
61 {
"padding",
"set inner border thickness in pixels",
OFFSET(padding),
64 {
"overlap",
"set how many frames to overlap for each render",
OFFSET(overlap),
66 {
"init_padding",
"set how many frames to initially pad",
OFFSET(init_padding),
69 };
70
72
74 {
76
77 if (tile->
w > UINT_MAX / tile->
h) {
81 }
82
84 if ((tile->
w - 1 > (UINT32_MAX - 2 * tile->
margin) / tile->
padding) ||
89 }
90 }
91
96 tile->
w, tile->
h, tile->
w * tile->
h);
98 }
99
103 }
104
107 } else {
109 }
110
111 return 0;
112 }
113
115 {
117 }
118
120 {
124 const unsigned total_margin_w = (tile->
w - 1) * tile->
padding + 2*tile->
margin;
125 const unsigned total_margin_h = (tile->
h - 1) * tile->
padding + 2*tile->
margin;
126
127 if (
inlink->w > (INT_MAX - total_margin_w) / tile->
w) {
131 }
132 if (
inlink->h > (INT_MAX - total_margin_h) / tile->
h) {
136 }
137 outlink->
w = tile->
w *
inlink->w + total_margin_w;
138 outlink->
h = tile->
h *
inlink->h + total_margin_h;
144
145 return 0;
146 }
147
149 {
152 const unsigned tx = current % tile->
w;
153 const unsigned ty = current / tile->
w;
154
157 }
158
160 {
163 unsigned x0, y0;
164
170 }
171
173 {
178
185 }
189 }
190
191 /* Note: direct rendering is not possible since there is no guarantee that
192 * buffers are fed to filter_frame in the order they were obtained from
193 * get_buffer (think B-frames). */
194
196 {
200 unsigned x0, y0;
201
207 }
211
212 /* fill surface once for margin/padding */
217 0, 0, outlink->
w, outlink->
h);
219 }
220
223
231
232 }
233 }
234
240
244
245 return 0;
246 }
247
249 {
254
259 }
260
262 {
264
267 }
268
270 {
274 },
275 };
276
278 {
283 },
284 };
285
295 .priv_class = &tile_class,
296 };
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
static int query_formats(AVFilterContext *ctx)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_LOG_WARNING
Something somehow does not look correct.
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
static const AVFilterPad tile_outputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
static av_cold void uninit(AVFilterContext *ctx)
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.
static int config_props(AVFilterLink *outlink)
#define FILTER_QUERY_FUNC(func)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
void ff_copy_rectangle2(FFDrawContext *draw, uint8_t *dst[], int dst_linesize[], uint8_t *src[], int src_linesize[], int dst_x, int dst_y, int src_x, int src_y, int w, int h)
Copy a rectangle from an image to another.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
const AVFilter ff_vf_tile
#define FILTER_INPUTS(array)
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.
static const AVOption tile_options[]
static void get_tile_pos(AVFilterContext *ctx, unsigned *x, unsigned *y, unsigned current)
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
static const AVFilterPad tile_inputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static AVRational av_make_q(int num, int den)
Create an AVRational.
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
AVFilterContext * src
source filter
static int request_frame(AVFilterLink *outlink)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
static av_cold int init(AVFilterContext *ctx)
const char * name
Pad name.
static int end_last_frame(AVFilterContext *ctx)
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
int h
agreed upon image height
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static void draw_blank_frame(AVFilterContext *ctx, AVFrame *out_buf)
AVFILTER_DEFINE_CLASS(tile)
#define FILTER_OUTPUTS(array)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Generated on Wed Aug 24 2022 21:38:17 for FFmpeg by
doxygen
1.8.17