annotate libmpcodecs/vf_tile.c @ 29248:6ebc9e7ffa12

Get rid of some more trailing whitespace
author reynaldo
date Tue, 12 May 2009 02:29:29 +0000
parents d5d66bff938a
children bbb6ebec87a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
1 /*
28924
d5d66bff938a cosmetics: Remove file names from file header, it only causes trouble.
diego
parents: 26754
diff changeset
2 * filter to tile a serie of image in a single, bigger, image
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
3 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
4 * The parameters are:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
5 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
6 * xtile: number of tile on the x axis (5)
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
7 * ytile: number of tile on the y axis (5)
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
8 * xytile: when write the image, it can be different then xtile * ytile
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
9 * (for example you can write 8 * 7 tile, writing the file every
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
10 * 50 frame, to have one image every 2 seconds @ 25 fps ).
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
11 * start: pixel at the start (x/y), default 2
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
12 * delta: pixel between 2 tile, (x/y), default 4
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
13 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
14 * For example a valid command line is:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
15 * ... -vf tile=10:5:-1:4:8 ...
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
16 * that make images of 10 * 5 tiles, with 4 pixel at the beginning and
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
17 * 8 pixel between tiles.
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
18 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
19 * The default command is:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
20 * ... -vf tile=5:5:25:2:4
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
21 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
22 * If you omit a parameter or put a value less then 0, the default is used.
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
23 * ... -vf tile=10:5::-1:10
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
24 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
25 * You can also stop when you're ok
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
26 * ... -vf tile=10:5
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
27 * (and this is probably the option you will use more often ...)
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
28 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
29 * Probably is good to put the scale filter before the tile :-)
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
30 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
31 * Daniele Forghieri ( guru@digitalfantasy.it )
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
32 */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
33
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
34 // strtoi memcpy_pic
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
35
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
36 #include <stdio.h>
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
37 #include <stdlib.h>
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
38 #include <string.h>
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
39
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 10751
diff changeset
40 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 10751
diff changeset
41 #include "mp_msg.h"
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
42 #include "help_mp.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 10751
diff changeset
43 #include "cpudetect.h"
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
44
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
45 #include "img_format.h"
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
46 #include "mp_image.h"
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
47 #include "vf.h"
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
48
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 10751
diff changeset
49 #include "libvo/fastmemcpy.h"
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
50
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
51 /* private data */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
52 struct vf_priv_s {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
53 /* configuration data */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
54 /* Number on hor/ver tiles */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
55 int xtile;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
56 int ytile;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
57 /* When write the whole frame (default = xtile * ytile) */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
58 int xytile;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
59 /* pixel at start / end (default = 4) */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
60 int start;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
61 /* pixel between image (default = 2) */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
62 int delta;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
63 // /* Background color, in destination format */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
64 // int bkgSet;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
65
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
66 /* Work data */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
67 int frame_cur;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
68 };
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
69
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
70
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
71 static int config(struct vf_instance_s* vf,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
72 int width, int height, int d_width, int d_height,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
73 unsigned int flags, unsigned int outfmt){
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
74
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
75 struct vf_priv_s *priv;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
76 int xw;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
77 int yh;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
78
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
79 /* Calculate new destination size */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
80 priv = vf->priv;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
81 xw = priv->start * 2 +
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
82 priv->xtile * width +
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
83 (priv->xtile - 1) * priv->delta;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
84 yh = priv->start * 2 +
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
85 priv->ytile * height +
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
86 (priv->ytile - 1) * priv->delta;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
87
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
88 mp_msg(MSGT_VFILTER,MSGL_V,"vf_tile:config size set to %d * %d\n", xw, yh);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
89
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
90 return vf_next_config(vf, xw, yh, xw, yh, flags, outfmt);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
91 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
92
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
93 /* Filter handler */
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
94 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
95 {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
96 mp_image_t *dmpi;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
97 struct vf_priv_s *priv;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
98 int t;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
99 int xw;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
100 int yh;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
101 int xi;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
102 int yi;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
103 int by;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
104 int dw;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
105
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
106 /* Calculate new size */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
107 priv = vf->priv;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
108 xw = priv->start * 2 +
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
109 priv->xtile * mpi->w +
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
110 (priv->xtile - 1) * priv->delta;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
111 yh = priv->start * 2 +
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
112 priv->ytile * mpi->h+
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
113 (priv->ytile - 1) * priv->delta;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
114
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
115 /* Get the big image! */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
116 dmpi=vf_get_image(vf->next, mpi->imgfmt,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
117 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
118 xw, yh);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
119
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
120 /* bytes x pixel & bytes x line */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
121 if (mpi->flags & MP_IMGFLAG_PLANAR) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
122 by = 1;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
123 dw = mpi->w;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
124 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
125 else {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
126 by = (mpi->bpp + 7) / 8;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
127 dw = mpi->w * by;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
128 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
129 /* Index position */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
130 t = priv->frame_cur % priv->xytile;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
131 // if ((t == 0) && (bkg != 0)) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
132 // /* First frame, delete the background */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
133 //
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
134 // }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
135
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
136 /* Position of image */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
137 xi = priv->start + (mpi->w + priv->delta) * (t % priv->xtile);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
138 yi = priv->start + (mpi->h + priv->delta) * (t / priv->xtile);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
139
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
140 /* Copy first (or only) plane */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
141 memcpy_pic( dmpi->planes[0] + xi * by + yi * dmpi->stride[0],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
142 mpi->planes[0],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
143 dw,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
144 mpi->h,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
145 dmpi->stride[0],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
146 mpi->stride[0]);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
147
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
148 if (mpi->flags & MP_IMGFLAG_PLANAR) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
149 /* Copy the other 2 planes */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
150 memcpy_pic( dmpi->planes[1] + (xi >> mpi->chroma_x_shift) + (yi >> mpi->chroma_y_shift) * dmpi->stride[1],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
151 mpi->planes[1],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
152 mpi->chroma_width,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
153 mpi->chroma_height,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
154 dmpi->stride[1],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
155 mpi->stride[1]);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
156 memcpy_pic( dmpi->planes[2] + (xi >> mpi->chroma_x_shift) + (yi >> mpi->chroma_y_shift) * dmpi->stride[2],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
157 mpi->planes[2],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
158 mpi->chroma_width,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
159 mpi->chroma_height,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
160 dmpi->stride[2],
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
161 mpi->stride[2]);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
162 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
163
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
164 /* Increment current frame */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
165 ++priv->frame_cur;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
166
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
167 if (t == priv->xytile - 1) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
168 /* Display the composition */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
169 dmpi->width = xw;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
170 dmpi->height = yh;
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17012
diff changeset
171 return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
172 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
173 else {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
174 /* Skip the frame */
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 25221
diff changeset
175 return 0;
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
176 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
177 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
178
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
179 static void uninit(struct vf_instance_s* vf)
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
180 {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
181 /* free local data */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
182 free(vf->priv);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
183 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
184
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
185 /* rgb/bgr 15->32 supported & some Yxxx */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
186 static int query_format(struct vf_instance_s* vf, unsigned int fmt)
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
187 {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
188 switch (fmt) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
189 /* rgb 15 -> 32 bit */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
190 case IMGFMT_RGB15:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
191 case IMGFMT_RGB16:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
192 case IMGFMT_RGB24:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
193 case IMGFMT_RGB32:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
194 /* bgr 15 -> 32 bit */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
195 case IMGFMT_BGR15:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
196 case IMGFMT_BGR16:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
197 case IMGFMT_BGR24:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
198 case IMGFMT_BGR32:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
199 /* Various Yxxx Formats */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
200 case IMGFMT_444P:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
201 case IMGFMT_422P:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
202 case IMGFMT_411P:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
203 case IMGFMT_YUY2:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
204 case IMGFMT_YV12:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
205 case IMGFMT_I420:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
206 case IMGFMT_YVU9:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
207 case IMGFMT_IF09:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
208 case IMGFMT_IYUV:
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
209 return vf_next_query_format(vf, fmt);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
210 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
211 return 0;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
212 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
213
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
214 /* Get an integer from the string pointed by s, adjusting s.
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
215 * If the value is less then 0 def_val is used.
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
216 * Return 0 for ok
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
217 *
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
218 * Look below ( in open(...) ) for a use ...
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
219 */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
220 static int parse_int(char **s, int *rt, int def_val)
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
221 {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
222
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
223 int t = 0;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
224
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
225 if (**s) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
226 /* Get value (dec, hex or octal) */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
227 t = strtol( *s, s, 0 );
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
228
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
229 /* Use default */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
230 if (t < 0) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
231 t = def_val;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
232 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
233
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
234 if (**s == ':') {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
235 /* Point to next character (problably a digit) */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
236 ++(*s);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
237 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
238 else if (**s != '\0') {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
239 /* Error, we got some wrong char */
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 25221
diff changeset
240 return 1;
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
241 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
242 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
243 else {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
244 t = def_val;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
245 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
246
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
247 *rt = t;
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 25221
diff changeset
248 return 0;
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
249
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
250 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
251
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
252 /* Main entry funct for the filter */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
253 static int open(vf_instance_t *vf, char* args)
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
254 {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
255 struct vf_priv_s *p;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
256 int er;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
257
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
258 vf->put_image = put_image;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
259 vf->query_format = query_format;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
260 vf->config = config;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
261 vf->uninit = uninit;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
262 vf->default_reqs = VFCAP_ACCEPT_STRIDE;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
263 /* Private data */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
264 vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
265 if (p == NULL) {
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 25221
diff changeset
266 return 0;
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
267 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
268
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
269 if (args == NULL) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
270 /* Use the default */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
271 args = "";
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
272 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
273 /* Parse all the arguments */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
274 er = parse_int( &args, &p->xtile, 5 );
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
275 er |= parse_int( &args, &p->ytile, 5 );
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
276 er |= parse_int( &args, &p->xytile, 0 );
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
277 er |= parse_int( &args, &p->start, 2 );
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
278 er |= parse_int( &args, &p->delta, 4 );
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
279 // er |= parse_int( &args, &p->bkgSet, 0 );
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
280
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
281 if (er) {
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17969
diff changeset
282 mp_msg(MSGT_VFILTER, MSGL_ERR, MSGTR_MPCODECS_ErrorParsingArgument);
26754
63630c09e237 cosmetics: Remove pointless parentheses from return calls.
diego
parents: 25221
diff changeset
283 return 0;
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
284 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
285 /* Load some default */
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
286 if ((p->xytile <= 0) || (p->xytile > p->xtile * p->ytile)) {
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
287 p->xytile = p->xtile * p->ytile;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
288 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
289
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
290 /* Say what happen: use mp_msg(...)? */
17969
843e0427b5b9 Change 'if(verbose)' to the more appropriate mp_msg_test.
diego
parents: 17906
diff changeset
291 if ( mp_msg_test(MSGT_VFILTER,MSGL_V) ) {
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
292 printf("vf_tile: tiling %d * %d, output every %d frames\n",
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
293 p->xtile,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
294 p->ytile,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
295 p->xytile);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
296 printf("vf_tile: start pixel %d, delta pixel %d\n",
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
297 p->start,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
298 p->delta);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
299 // printf("vf_tile: background 0x%x\n",
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
300 // p->bkgSet);
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
301 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
302 return 1;
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
303 }
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
304
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 18004
diff changeset
305 const vf_info_t vf_info_tile = {
10751
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
306 "Make a single image tiling x/y images",
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
307 "tile",
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
308 "Daniele Forghieri",
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
309 "",
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
310 open,
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
311 NULL
81d03cb2cd64 2 new filters: tile & framestep
arpi
parents:
diff changeset
312 };