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
46
47 #define REASONABLE_SIZE 1024
48
49 #define OFFSET(x) offsetof(TileContext, x)
50 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
51
54 {.str =
"6x5"}, 0, 0,
FLAGS },
55 {
"nb_frames",
"set maximum number of frame to render",
OFFSET(nb_frames),
57 {
"margin",
"set outer border margin in pixels",
OFFSET(margin),
59 {
"padding",
"set inner border thickness in pixels",
OFFSET(padding),
62 { NULL }
63 };
64
66
68 {
70
75 }
76
81 tile->
w, tile->
h, tile->
w * tile->
h);
83 }
84
85 return 0;
86 }
87
89 {
91 return 0;
92 }
93
95 {
99 const unsigned total_margin_w = (tile->
w - 1) * tile->
padding + 2*tile->
margin;
100 const unsigned total_margin_h = (tile->
h - 1) * tile->
padding + 2*tile->
margin;
101
102 if (inlink->
w > (INT_MAX - total_margin_w) / tile->
w) {
106 }
107 if (inlink->
h > (INT_MAX - total_margin_h) / tile->
h) {
111 }
112 outlink->
w = tile->
w * inlink->
w + total_margin_w;
113 outlink->
h = tile->
h * inlink->
h + total_margin_h;
119
121
122 return 0;
123 }
124
126 {
129 const unsigned tx = tile->
current % tile->
w;
130 const unsigned ty = tile->
current / tile->
w;
131
134 }
135
137 {
140 unsigned x0, y0;
141
145 x0, y0, inlink->
w, inlink->
h);
147 }
149 {
154
160 }
161
162 /* Note: direct rendering is not possible since there is no guarantee that
163 * buffers are fed to filter_frame in the order they were obtained from
164 * get_buffer (think B-frames). */
165
167 {
171 unsigned x0, y0;
172
178 }
182
183 /* fill surface once for margin/padding */
188 0, 0, outlink->
w, outlink->
h);
189 }
190
195 x0, y0, 0, 0, inlink->
w, inlink->
h);
196
200
201 return 0;
202 }
203
205 {
210
215 }
216
218 {
222 },
223 { NULL }
224 };
225
227 {
232 },
233 { NULL }
234 };
235
244 .priv_class = &tile_class,
245 };