2 * filter to tile a serie of image in a single, bigger, image
6 * xtile: number of tile on the x axis (5)
7 * ytile: number of tile on the y axis (5)
8 * xytile: when write the image, it can be different then xtile * ytile
9 * (for example you can write 8 * 7 tile, writing the file every
10 * 50 frame, to have one image every 2 seconds @ 25 fps ).
11 * start: pixel at the start (x/y), default 2
12 * delta: pixel between 2 tile, (x/y), default 4
14 * For example a valid command line is:
15 * ... -vf tile=10:5:-1:4:8 ...
16 * that make images of 10 * 5 tiles, with 4 pixel at the beginning and
17 * 8 pixel between tiles.
19 * The default command is:
20 * ... -vf tile=5:5:25:2:4
22 * If you omit a parameter or put a value less then 0, the default is used.
23 * ... -vf tile=10:5::-1:10
25 * You can also stop when you're ok
27 * (and this is probably the option you will use more often ...)
29 * Probably is good to put the scale filter before the tile :-)
31 * copyright (c) 2003 Daniele Forghieri ( guru@digitalfantasy.it )
33 * This file is part of MPlayer.
35 * MPlayer is free software; you can redistribute it and/or modify
36 * it under the terms of the GNU General Public License as published by
37 * the Free Software Foundation; either version 2 of the License, or
38 * (at your option) any later version.
40 * MPlayer is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 * GNU General Public License for more details.
45 * You should have received a copy of the GNU General Public License along
46 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
47 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
58 #include "cpudetect.h"
60 #include "img_format.h"
64 #include "libvo/fastmemcpy.h"
68 /* configuration data */
69 /* Number on hor/ver tiles */
72 /* When write the whole frame (default = xtile * ytile) */
74 /* pixel at start / end (default = 4) */
76 /* pixel between image (default = 2) */
78 // /* Background color, in destination format */
87 static int config(struct vf_instance
*vf
,
88 int width
, int height
, int d_width
, int d_height
,
89 unsigned int flags
, unsigned int outfmt
){
91 struct vf_priv_s
*priv
;
95 /* Calculate new destination size */
97 xw
= priv
->start
* 2 +
99 (priv
->xtile
- 1) * priv
->delta
;
100 yh
= priv
->start
* 2 +
101 priv
->ytile
* height
+
102 (priv
->ytile
- 1) * priv
->delta
;
104 mp_msg(MSGT_VFILTER
,MSGL_V
,"vf_tile:config size set to %d * %d\n", xw
, yh
);
106 return vf_next_config(vf
, xw
, yh
, xw
, yh
, flags
, outfmt
);
110 static int put_image(struct vf_instance
*vf
, mp_image_t
*mpi
, double pts
)
113 struct vf_priv_s
*priv
;
122 /* Calculate new size */
124 xw
= priv
->start
* 2 +
125 priv
->xtile
* mpi
->w
+
126 (priv
->xtile
- 1) * priv
->delta
;
127 yh
= priv
->start
* 2 +
128 priv
->ytile
* mpi
->h
+
129 (priv
->ytile
- 1) * priv
->delta
;
131 /* Get the big image! */
132 dmpi
=vf_get_image(vf
->next
, mpi
->imgfmt
,
133 MP_IMGTYPE_STATIC
, MP_IMGFLAG_ACCEPT_STRIDE
,
136 /* bytes x pixel & bytes x line */
137 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
142 by
= (mpi
->bpp
+ 7) / 8;
146 t
= priv
->frame_cur
% priv
->xytile
;
147 // if ((t == 0) && (bkg != 0)) {
148 // /* First frame, delete the background */
152 priv
->start_pts
= pts
;
154 /* Position of image */
155 xi
= priv
->start
+ (mpi
->w
+ priv
->delta
) * (t
% priv
->xtile
);
156 yi
= priv
->start
+ (mpi
->h
+ priv
->delta
) * (t
/ priv
->xtile
);
158 /* Copy first (or only) plane */
159 memcpy_pic( dmpi
->planes
[0] + xi
* by
+ yi
* dmpi
->stride
[0],
166 if (mpi
->flags
& MP_IMGFLAG_PLANAR
) {
167 /* Copy the other 2 planes */
168 memcpy_pic( dmpi
->planes
[1] + (xi
>> mpi
->chroma_x_shift
) + (yi
>> mpi
->chroma_y_shift
) * dmpi
->stride
[1],
174 memcpy_pic( dmpi
->planes
[2] + (xi
>> mpi
->chroma_x_shift
) + (yi
>> mpi
->chroma_y_shift
) * dmpi
->stride
[2],
182 /* Increment current frame */
185 if (t
== priv
->xytile
- 1) {
186 /* Display the composition */
189 return vf_next_put_image(vf
, dmpi
, priv
->start_pts
);
197 static void uninit(struct vf_instance
*vf
)
199 /* free local data */
203 /* rgb/bgr 12->32 supported & some Yxxx */
204 static int query_format(struct vf_instance
*vf
, unsigned int fmt
)
207 /* rgb 12...32 bit */
213 /* bgr 12...32 bit */
219 /* Various Yxxx Formats */
229 return vf_next_query_format(vf
, fmt
);
234 /* Get an integer from the string pointed by s, adjusting s.
235 * If the value is less then 0 def_val is used.
238 * Look below ( in vf_open(...) ) for a use ...
240 static int parse_int(char **s
, int *rt
, int def_val
)
246 /* Get value (dec, hex or octal) */
247 t
= strtol( *s
, s
, 0 );
255 /* Point to next character (problably a digit) */
258 else if (**s
!= '\0') {
259 /* Error, we got some wrong char */
272 /* Main entry funct for the filter */
273 static int vf_open(vf_instance_t
*vf
, char *args
)
278 vf
->put_image
= put_image
;
279 vf
->query_format
= query_format
;
282 vf
->default_reqs
= VFCAP_ACCEPT_STRIDE
;
284 vf
->priv
= p
= calloc(1, sizeof(struct vf_priv_s
));
290 /* Use the default */
293 /* Parse all the arguments */
294 er
= parse_int( &args
, &p
->xtile
, 5 );
295 er
|= parse_int( &args
, &p
->ytile
, 5 );
296 er
|= parse_int( &args
, &p
->xytile
, 0 );
297 er
|= parse_int( &args
, &p
->start
, 2 );
298 er
|= parse_int( &args
, &p
->delta
, 4 );
299 // er |= parse_int( &args, &p->bkgSet, 0 );
302 mp_tmsg(MSGT_VFILTER
, MSGL_ERR
, "[VF_FRAMESTEP] Error parsing argument.\n");
305 /* Load some default */
306 if ((p
->xytile
<= 0) || (p
->xytile
> p
->xtile
* p
->ytile
)) {
307 p
->xytile
= p
->xtile
* p
->ytile
;
310 /* Say what happen: use mp_msg(...)? */
311 if ( mp_msg_test(MSGT_VFILTER
,MSGL_V
) ) {
312 printf("vf_tile: tiling %d * %d, output every %d frames\n",
316 printf("vf_tile: start pixel %d, delta pixel %d\n",
319 // printf("vf_tile: background 0x%x\n",
325 const vf_info_t vf_info_tile
= {
326 "Make a single image tiling x/y images",