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
33
45
46 #define REASONABLE_SIZE 1024
47
48 #define OFFSET(x) offsetof(TileContext, x)
49 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
50
53 {.str =
"6x5"}, 0, 0,
FLAGS },
54 {
"nb_frames",
"set maximum number of frame to render",
OFFSET(nb_frames),
56 {
"margin",
"set outer border margin in pixels",
OFFSET(margin),
58 {
"padding",
"set inner border thickness in pixels",
OFFSET(padding),
60 {NULL},
61 };
62
64
66 {
68
73 }
74
79 tile->
w, tile->
h, tile->
w * tile->
h);
81 }
82
83 return 0;
84 }
85
87 {
89 return 0;
90 }
91
93 {
97 const unsigned total_margin_w = (tile->
w - 1) * tile->
padding + 2*tile->
margin;
98 const unsigned total_margin_h = (tile->
h - 1) * tile->
padding + 2*tile->
margin;
99
100 if (inlink->
w > (INT_MAX - total_margin_w) / tile->
w) {
104 }
105 if (inlink->
h > (INT_MAX - total_margin_h) / tile->
h) {
109 }
110 outlink->
w = tile->
w * inlink->
w + total_margin_w;
111 outlink->
h = tile->
h * inlink->
h + total_margin_h;
116 /* TODO make the color an option, or find an unified way of choosing it */
118
120
121 return 0;
122 }
123
125 {
128 const unsigned tx = tile->
current % tile->
w;
129 const unsigned ty = tile->
current / tile->
w;
130
133 }
134
136 {
139 unsigned x0, y0;
140
144 x0, y0, inlink->
w, inlink->
h);
146 }
148 {
153
159 }
160
161 /* Note: direct rendering is not possible since there is no guarantee that
162 * buffers are fed to filter_frame in the order they were obtained from
163 * get_buffer (think B-frames). */
164
166 {
170 unsigned x0, y0;
171
179
180 /* fill surface once for margin/padding */
185 0, 0, outlink->
w, outlink->
h);
186 }
187
192 x0, y0, 0, 0, inlink->
w, inlink->
h);
193
197
198 return 0;
199 }
200
202 {
207
212 }
213
215 {
219 },
220 { NULL }
221 };
222
224 {
229 },
230 { NULL }
231 };
232
241 .priv_class = &tile_class,
242 };