annotate libmpcodecs/vf_delogo.c @ 28588:7f03a6d3c941

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