annotate libmpcodecs/vf_delogo.c @ 26273:8c92e7e4ccd9

command.h: Remove unnecessary includes Remove #include of "mp_core.h" and "input/input.h". Their only use was that functions declared in command.h took pointers to structs defined in those headers. Declare the structs directly as incomplete types instead.
author uau
date Mon, 31 Mar 2008 04:10:54 +0000
parents 00fff9a3b735
children 82601a38e2a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
1 /*
20646
ab2a5307c029 changed email address
henry
parents: 17906
diff changeset
2 Copyright (C) 2002 Jindrich Makovicka <makovick@gmail.com>
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
3
304c94c89359 simple logo remover
henry
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
304c94c89359 simple logo remover
henry
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
304c94c89359 simple logo remover
henry
parents:
diff changeset
6 the Free Software Foundation; either version 2 of the License, or
304c94c89359 simple logo remover
henry
parents:
diff changeset
7 (at your option) any later version.
304c94c89359 simple logo remover
henry
parents:
diff changeset
8
304c94c89359 simple logo remover
henry
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
304c94c89359 simple logo remover
henry
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
304c94c89359 simple logo remover
henry
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304c94c89359 simple logo remover
henry
parents:
diff changeset
12 GNU General Public License for more details.
304c94c89359 simple logo remover
henry
parents:
diff changeset
13
304c94c89359 simple logo remover
henry
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
304c94c89359 simple logo remover
henry
parents:
diff changeset
15 along with this program; if not, write to the Free Software
17367
401b440a6d76 Update licensing information: The FSF changed postal address.
diego
parents: 17012
diff changeset
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
17 */
304c94c89359 simple logo remover
henry
parents:
diff changeset
18
304c94c89359 simple logo remover
henry
parents:
diff changeset
19 /* A very simple tv station logo remover */
304c94c89359 simple logo remover
henry
parents:
diff changeset
20
304c94c89359 simple logo remover
henry
parents:
diff changeset
21 #include <stdio.h>
304c94c89359 simple logo remover
henry
parents:
diff changeset
22 #include <stdlib.h>
304c94c89359 simple logo remover
henry
parents:
diff changeset
23 #include <string.h>
304c94c89359 simple logo remover
henry
parents:
diff changeset
24 #include <inttypes.h>
304c94c89359 simple logo remover
henry
parents:
diff changeset
25 #include <math.h>
304c94c89359 simple logo remover
henry
parents:
diff changeset
26
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11029
diff changeset
27 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11029
diff changeset
28 #include "mp_msg.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11029
diff changeset
29 #include "cpudetect.h"
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
30
304c94c89359 simple logo remover
henry
parents:
diff changeset
31 #ifdef HAVE_MALLOC_H
304c94c89359 simple logo remover
henry
parents:
diff changeset
32 #include <malloc.h>
304c94c89359 simple logo remover
henry
parents:
diff changeset
33 #endif
304c94c89359 simple logo remover
henry
parents:
diff changeset
34
304c94c89359 simple logo remover
henry
parents:
diff changeset
35 #include "img_format.h"
304c94c89359 simple logo remover
henry
parents:
diff changeset
36 #include "mp_image.h"
304c94c89359 simple logo remover
henry
parents:
diff changeset
37 #include "vf.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 11029
diff changeset
38 #include "libvo/fastmemcpy.h"
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
39
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
40 #include "m_option.h"
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
41 #include "m_struct.h"
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
42
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
43 //===========================================================================//
304c94c89359 simple logo remover
henry
parents:
diff changeset
44
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
45 static struct vf_priv_s {
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
46 unsigned int outfmt;
304c94c89359 simple logo remover
henry
parents:
diff changeset
47 int xoff, yoff, lw, lh, band, show;
22027
0b262e00bc99 Mark m_struct_t defaults as const
reimar
parents: 20646
diff changeset
48 } const vf_priv_dflt = {
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
49 0,
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
50 0, 0, 0, 0, 0, 0
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
51 };
304c94c89359 simple logo remover
henry
parents:
diff changeset
52
304c94c89359 simple logo remover
henry
parents:
diff changeset
53 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
304c94c89359 simple logo remover
henry
parents:
diff changeset
54 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
304c94c89359 simple logo remover
henry
parents:
diff changeset
55
304c94c89359 simple logo remover
henry
parents:
diff changeset
56 static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height,
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
57 int logo_x, int logo_y, int logo_w, int logo_h, int band, int show, int direct) {
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
58 int y, x;
304c94c89359 simple logo remover
henry
parents:
diff changeset
59 int interp, dist;
304c94c89359 simple logo remover
henry
parents:
diff changeset
60 uint8_t *xdst, *xsrc;
304c94c89359 simple logo remover
henry
parents:
diff changeset
61
304c94c89359 simple logo remover
henry
parents:
diff changeset
62 uint8_t *topleft, *botleft, *topright;
304c94c89359 simple logo remover
henry
parents:
diff changeset
63 int xclipl, xclipr, yclipt, yclipb;
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
64 int logo_x1, logo_x2, logo_y1, logo_y2;
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
65
304c94c89359 simple logo remover
henry
parents:
diff changeset
66 xclipl = MAX(-logo_x, 0);
304c94c89359 simple logo remover
henry
parents:
diff changeset
67 xclipr = MAX(logo_x+logo_w-width, 0);
304c94c89359 simple logo remover
henry
parents:
diff changeset
68 yclipt = MAX(-logo_y, 0);
304c94c89359 simple logo remover
henry
parents:
diff changeset
69 yclipb = MAX(logo_y+logo_h-height, 0);
304c94c89359 simple logo remover
henry
parents:
diff changeset
70
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
71 logo_x1 = logo_x + xclipl;
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
72 logo_x2 = logo_x + logo_w - xclipr;
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
73 logo_y1 = logo_y + yclipt;
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
74 logo_y2 = logo_y + logo_h - yclipb;
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
75
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
76 topleft = src+logo_y1*srcStride+logo_x1;
11029
bdf37ec99325 bug found by Alexander Stege
nexus
parents: 10816
diff changeset
77 topright = src+logo_y1*srcStride+logo_x2-1;
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
78 botleft = src+(logo_y2-1)*srcStride+logo_x1;
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
79
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
80 if (!direct) memcpy_pic(dst, src, width, height, dstStride, srcStride);
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
81
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
82 dst += (logo_y1+1)*dstStride;
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
83 src += (logo_y1+1)*srcStride;
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
84
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
85 for(y = logo_y1+1; y < logo_y2-1; y++)
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
86 {
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
87 for (x = logo_x1+1, xdst = dst+logo_x1+1, xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
88 interp = ((topleft[srcStride*(y-logo_y-yclipt)]
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
89 + topleft[srcStride*(y-logo_y-1-yclipt)]
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
90 + topleft[srcStride*(y-logo_y+1-yclipt)])*(logo_w-(x-logo_x))/logo_w
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
91 + (topright[srcStride*(y-logo_y-yclipt)]
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
92 + topright[srcStride*(y-logo_y-1-yclipt)]
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
93 + topright[srcStride*(y-logo_y+1-yclipt)])*(x-logo_x)/logo_w
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
94 + (topleft[x-logo_x-xclipl]
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
95 + topleft[x-logo_x-1-xclipl]
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
96 + topleft[x-logo_x+1-xclipl])*(logo_h-(y-logo_y))/logo_h
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
97 + (botleft[x-logo_x-xclipl]
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
98 + botleft[x-logo_x-1-xclipl]
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
99 + botleft[x-logo_x+1-xclipl])*(y-logo_y)/logo_h
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
100 )/6;
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
101 /* interp = (topleft[srcStride*(y-logo_y)]*(logo_w-(x-logo_x))/logo_w
304c94c89359 simple logo remover
henry
parents:
diff changeset
102 + topright[srcStride*(y-logo_y)]*(x-logo_x)/logo_w
304c94c89359 simple logo remover
henry
parents:
diff changeset
103 + topleft[x-logo_x]*(logo_h-(y-logo_y))/logo_h
304c94c89359 simple logo remover
henry
parents:
diff changeset
104 + botleft[x-logo_x]*(y-logo_y)/logo_h
304c94c89359 simple logo remover
henry
parents:
diff changeset
105 )/2;*/
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
106 if (y >= logo_y+band && y < logo_y+logo_h-band && x >= logo_x+band && x < logo_x+logo_w-band) {
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
107 *xdst = interp;
304c94c89359 simple logo remover
henry
parents:
diff changeset
108 } else {
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
109 dist = 0;
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
110 if (x < logo_x+band) dist = MAX(dist, logo_x-x+band);
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
111 else if (x >= logo_x+logo_w-band) dist = MAX(dist, x-(logo_x+logo_w-1-band));
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
112 if (y < logo_y+band) dist = MAX(dist, logo_y-y+band);
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
113 else if (y >= logo_y+logo_h-band) dist = MAX(dist, y-(logo_y+logo_h-1-band));
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
114 *xdst = (*xsrc*dist + interp*(band-dist))/band;
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
115 if (show && (dist == band-1)) *xdst = 0;
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
116 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
117 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
118
304c94c89359 simple logo remover
henry
parents:
diff changeset
119 dst+= dstStride;
304c94c89359 simple logo remover
henry
parents:
diff changeset
120 src+= srcStride;
304c94c89359 simple logo remover
henry
parents:
diff changeset
121 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
122 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
123
304c94c89359 simple logo remover
henry
parents:
diff changeset
124 static int config(struct vf_instance_s* vf,
304c94c89359 simple logo remover
henry
parents:
diff changeset
125 int width, int height, int d_width, int d_height,
304c94c89359 simple logo remover
henry
parents:
diff changeset
126 unsigned int flags, unsigned int outfmt){
304c94c89359 simple logo remover
henry
parents:
diff changeset
127
304c94c89359 simple logo remover
henry
parents:
diff changeset
128 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
304c94c89359 simple logo remover
henry
parents:
diff changeset
129 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
130
304c94c89359 simple logo remover
henry
parents:
diff changeset
131
304c94c89359 simple logo remover
henry
parents:
diff changeset
132 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
304c94c89359 simple logo remover
henry
parents:
diff changeset
133 if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
304c94c89359 simple logo remover
henry
parents:
diff changeset
134 if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ
304c94c89359 simple logo remover
henry
parents:
diff changeset
135 // ok, we can do pp in-place (or pp disabled):
304c94c89359 simple logo remover
henry
parents:
diff changeset
136 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
304c94c89359 simple logo remover
henry
parents:
diff changeset
137 mpi->type, mpi->flags, mpi->w, mpi->h);
304c94c89359 simple logo remover
henry
parents:
diff changeset
138 mpi->planes[0]=vf->dmpi->planes[0];
304c94c89359 simple logo remover
henry
parents:
diff changeset
139 mpi->stride[0]=vf->dmpi->stride[0];
304c94c89359 simple logo remover
henry
parents:
diff changeset
140 mpi->width=vf->dmpi->width;
304c94c89359 simple logo remover
henry
parents:
diff changeset
141 if(mpi->flags&MP_IMGFLAG_PLANAR){
304c94c89359 simple logo remover
henry
parents:
diff changeset
142 mpi->planes[1]=vf->dmpi->planes[1];
304c94c89359 simple logo remover
henry
parents:
diff changeset
143 mpi->planes[2]=vf->dmpi->planes[2];
304c94c89359 simple logo remover
henry
parents:
diff changeset
144 mpi->stride[1]=vf->dmpi->stride[1];
304c94c89359 simple logo remover
henry
parents:
diff changeset
145 mpi->stride[2]=vf->dmpi->stride[2];
304c94c89359 simple logo remover
henry
parents:
diff changeset
146 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
147 mpi->flags|=MP_IMGFLAG_DIRECT;
304c94c89359 simple logo remover
henry
parents:
diff changeset
148 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
149
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
150 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
151 mp_image_t *dmpi;
304c94c89359 simple logo remover
henry
parents:
diff changeset
152
304c94c89359 simple logo remover
henry
parents:
diff changeset
153 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
304c94c89359 simple logo remover
henry
parents:
diff changeset
154 // no DR, so get a new image! hope we'll get DR buffer:
304c94c89359 simple logo remover
henry
parents:
diff changeset
155 vf->dmpi=vf_get_image(vf->next,vf->priv->outfmt,
304c94c89359 simple logo remover
henry
parents:
diff changeset
156 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
304c94c89359 simple logo remover
henry
parents:
diff changeset
157 mpi->w,mpi->h);
304c94c89359 simple logo remover
henry
parents:
diff changeset
158 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
159 dmpi= vf->dmpi;
304c94c89359 simple logo remover
henry
parents:
diff changeset
160
304c94c89359 simple logo remover
henry
parents:
diff changeset
161 delogo(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h,
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
162 vf->priv->xoff, vf->priv->yoff, vf->priv->lw, vf->priv->lh, vf->priv->band, vf->priv->show,
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
163 mpi->flags&MP_IMGFLAG_DIRECT);
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
164 delogo(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2,
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
165 vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show,
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
166 mpi->flags&MP_IMGFLAG_DIRECT);
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
167 delogo(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2,
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
168 vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show,
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
169 mpi->flags&MP_IMGFLAG_DIRECT);
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
170
304c94c89359 simple logo remover
henry
parents:
diff changeset
171 vf_clone_mpi_attributes(dmpi, mpi);
304c94c89359 simple logo remover
henry
parents:
diff changeset
172
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17367
diff changeset
173 return vf_next_put_image(vf,dmpi, pts);
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
174 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
175
304c94c89359 simple logo remover
henry
parents:
diff changeset
176 static void uninit(struct vf_instance_s* vf){
304c94c89359 simple logo remover
henry
parents:
diff changeset
177 if(!vf->priv) return;
304c94c89359 simple logo remover
henry
parents:
diff changeset
178
304c94c89359 simple logo remover
henry
parents:
diff changeset
179 free(vf->priv);
304c94c89359 simple logo remover
henry
parents:
diff changeset
180 vf->priv=NULL;
304c94c89359 simple logo remover
henry
parents:
diff changeset
181 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
182
304c94c89359 simple logo remover
henry
parents:
diff changeset
183 //===========================================================================//
304c94c89359 simple logo remover
henry
parents:
diff changeset
184
304c94c89359 simple logo remover
henry
parents:
diff changeset
185 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
304c94c89359 simple logo remover
henry
parents:
diff changeset
186 switch(fmt)
304c94c89359 simple logo remover
henry
parents:
diff changeset
187 {
304c94c89359 simple logo remover
henry
parents:
diff changeset
188 case IMGFMT_YV12:
304c94c89359 simple logo remover
henry
parents:
diff changeset
189 case IMGFMT_I420:
304c94c89359 simple logo remover
henry
parents:
diff changeset
190 case IMGFMT_IYUV:
304c94c89359 simple logo remover
henry
parents:
diff changeset
191 return vf_next_query_format(vf,vf->priv->outfmt);
304c94c89359 simple logo remover
henry
parents:
diff changeset
192 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
193 return 0;
304c94c89359 simple logo remover
henry
parents:
diff changeset
194 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
195
304c94c89359 simple logo remover
henry
parents:
diff changeset
196 static unsigned int fmt_list[]={
304c94c89359 simple logo remover
henry
parents:
diff changeset
197 IMGFMT_YV12,
304c94c89359 simple logo remover
henry
parents:
diff changeset
198 IMGFMT_I420,
304c94c89359 simple logo remover
henry
parents:
diff changeset
199 IMGFMT_IYUV,
304c94c89359 simple logo remover
henry
parents:
diff changeset
200 0
304c94c89359 simple logo remover
henry
parents:
diff changeset
201 };
304c94c89359 simple logo remover
henry
parents:
diff changeset
202
304c94c89359 simple logo remover
henry
parents:
diff changeset
203 static int open(vf_instance_t *vf, char* args){
304c94c89359 simple logo remover
henry
parents:
diff changeset
204 int res;
304c94c89359 simple logo remover
henry
parents:
diff changeset
205
304c94c89359 simple logo remover
henry
parents:
diff changeset
206 vf->config=config;
304c94c89359 simple logo remover
henry
parents:
diff changeset
207 vf->put_image=put_image;
304c94c89359 simple logo remover
henry
parents:
diff changeset
208 vf->get_image=get_image;
304c94c89359 simple logo remover
henry
parents:
diff changeset
209 vf->query_format=query_format;
304c94c89359 simple logo remover
henry
parents:
diff changeset
210 vf->uninit=uninit;
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
211 if (!vf->priv)
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
212 {
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
213 vf->priv=malloc(sizeof(struct vf_priv_s));
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
214 memset(vf->priv, 0, sizeof(struct vf_priv_s));
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
215 }
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
216
304c94c89359 simple logo remover
henry
parents:
diff changeset
217 if (args) res = sscanf(args, "%d:%d:%d:%d:%d",
304c94c89359 simple logo remover
henry
parents:
diff changeset
218 &vf->priv->xoff, &vf->priv->yoff,
304c94c89359 simple logo remover
henry
parents:
diff changeset
219 &vf->priv->lw, &vf->priv->lh,
304c94c89359 simple logo remover
henry
parents:
diff changeset
220 &vf->priv->band);
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
221 if (args && (res != 5)) {
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
222 uninit(vf);
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
223 return 0; // bad syntax
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
224 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
225
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
226 mp_msg(MSGT_VFILTER, MSGL_V, "delogo: %d x %d, %d x %d, band = %d\n",
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
227 vf->priv->xoff, vf->priv->yoff,
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
228 vf->priv->lw, vf->priv->lh,
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
229 vf->priv->band);
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
230
304c94c89359 simple logo remover
henry
parents:
diff changeset
231 vf->priv->show = 0;
304c94c89359 simple logo remover
henry
parents:
diff changeset
232
304c94c89359 simple logo remover
henry
parents:
diff changeset
233 if (vf->priv->band < 0) {
10811
a69221e84948 DR, 10l fixes
henry
parents: 10809
diff changeset
234 vf->priv->band = 4;
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
235 vf->priv->show = 1;
304c94c89359 simple logo remover
henry
parents:
diff changeset
236 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
237
304c94c89359 simple logo remover
henry
parents:
diff changeset
238
304c94c89359 simple logo remover
henry
parents:
diff changeset
239 vf->priv->lw += vf->priv->band*2;
304c94c89359 simple logo remover
henry
parents:
diff changeset
240 vf->priv->lh += vf->priv->band*2;
304c94c89359 simple logo remover
henry
parents:
diff changeset
241 vf->priv->xoff -= vf->priv->band;
304c94c89359 simple logo remover
henry
parents:
diff changeset
242 vf->priv->yoff -= vf->priv->band;
304c94c89359 simple logo remover
henry
parents:
diff changeset
243
304c94c89359 simple logo remover
henry
parents:
diff changeset
244 // check csp:
304c94c89359 simple logo remover
henry
parents:
diff changeset
245 vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_YV12);
304c94c89359 simple logo remover
henry
parents:
diff changeset
246 if(!vf->priv->outfmt)
304c94c89359 simple logo remover
henry
parents:
diff changeset
247 {
304c94c89359 simple logo remover
henry
parents:
diff changeset
248 uninit(vf);
304c94c89359 simple logo remover
henry
parents:
diff changeset
249 return 0; // no csp match :(
304c94c89359 simple logo remover
henry
parents:
diff changeset
250 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
251
304c94c89359 simple logo remover
henry
parents:
diff changeset
252 return 1;
304c94c89359 simple logo remover
henry
parents:
diff changeset
253 }
304c94c89359 simple logo remover
henry
parents:
diff changeset
254
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
255 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
256 static m_option_t vf_opts_fields[] = {
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
257 { "x", ST_OFF(xoff), CONF_TYPE_INT, 0, 0, 0, NULL },
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
258 { "y", ST_OFF(yoff), CONF_TYPE_INT, 0, 0, 0, NULL },
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
259 { "w", ST_OFF(lw), CONF_TYPE_INT, 0, 0, 0, NULL },
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
260 { "h", ST_OFF(lh), CONF_TYPE_INT, 0, 0, 0, NULL },
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
261 { "t", ST_OFF(band), CONF_TYPE_INT, 0, 0, 0, NULL },
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
262 { "band", ST_OFF(band), CONF_TYPE_INT, 0, 0, 0, NULL }, // alias
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
263 { NULL, NULL, 0, 0, 0, 0, NULL }
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
264 };
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
265
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
266 static m_struct_t vf_opts = {
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
267 "delogo",
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
268 sizeof(struct vf_priv_s),
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
269 &vf_priv_dflt,
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
270 vf_opts_fields
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
271 };
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
272
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 22027
diff changeset
273 const vf_info_t vf_info_delogo = {
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
274 "simple logo remover",
304c94c89359 simple logo remover
henry
parents:
diff changeset
275 "delogo",
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
276 "Jindrich Makovicka, Alex Beregszaszi",
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
277 "",
304c94c89359 simple logo remover
henry
parents:
diff changeset
278 open,
10816
e9dc9b0b16fa added new config system support and fixed some bugs (altought sanity checks are needed in delogo as it segfaults easily with w/h out of range)
alex
parents: 10811
diff changeset
279 &vf_opts
10809
304c94c89359 simple logo remover
henry
parents:
diff changeset
280 };
304c94c89359 simple logo remover
henry
parents:
diff changeset
281
304c94c89359 simple logo remover
henry
parents:
diff changeset
282 //===========================================================================//