Browse code

lavfi: remove delogo mp wrapper

The delogo filter has been natively integrated into libavfilter,
simplify.

Stefano Sabatini authored on 2011/08/14 19:04:23
Showing 5 changed files
... ...
@@ -993,7 +993,6 @@ The list of the currently supported filters follows:
993 993
 @table @var
994 994
 @item 2xsai
995 995
 @item decimate
996
-@item delogo
997 996
 @item denoise3d
998 997
 @item detc
999 998
 @item dint
... ...
@@ -84,7 +84,6 @@ OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/mp_image.o
84 84
 OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/img_format.o
85 85
 OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_2xsai.o
86 86
 OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_decimate.o
87
-OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_delogo.o
88 87
 OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_denoise3d.o
89 88
 OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_detc.o
90 89
 OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/vf_dint.o
... ...
@@ -30,7 +30,7 @@
30 30
 
31 31
 #define LIBAVFILTER_VERSION_MAJOR  2
32 32
 #define LIBAVFILTER_VERSION_MINOR 31
33
-#define LIBAVFILTER_VERSION_MICRO  0
33
+#define LIBAVFILTER_VERSION_MICRO  1
34 34
 
35 35
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
36 36
                                                LIBAVFILTER_VERSION_MINOR, \
37 37
deleted file mode 100644
... ...
@@ -1,252 +0,0 @@
1
-/*
2
- * Copyright (C) 2002 Jindrich Makovicka <makovick@gmail.com>
3
- *
4
- * This file is part of MPlayer.
5
- *
6
- * MPlayer is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * MPlayer is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License along
17
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
- */
20
-
21
-/* A very simple tv station logo remover */
22
-
23
-#include <stdio.h>
24
-#include <stdlib.h>
25
-#include <string.h>
26
-#include <inttypes.h>
27
-#include <math.h>
28
-
29
-#include "mp_msg.h"
30
-#include "cpudetect.h"
31
-#include "img_format.h"
32
-#include "mp_image.h"
33
-#include "vf.h"
34
-#include "libvo/fastmemcpy.h"
35
-
36
-//===========================================================================//
37
-
38
-struct vf_priv_s {
39
-    unsigned int outfmt;
40
-    int xoff, yoff, lw, lh, band, show;
41
-};
42
-
43
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
44
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
45
-
46
-static void delogo(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height,
47
-                   int logo_x, int logo_y, int logo_w, int logo_h, int band, int show, int direct) {
48
-    int y, x;
49
-    int interp, dist;
50
-    uint8_t *xdst, *xsrc;
51
-
52
-    uint8_t *topleft, *botleft, *topright;
53
-    int xclipl, xclipr, yclipt, yclipb;
54
-    int logo_x1, logo_x2, logo_y1, logo_y2;
55
-
56
-    xclipl = MAX(-logo_x, 0);
57
-    xclipr = MAX(logo_x+logo_w-width, 0);
58
-    yclipt = MAX(-logo_y, 0);
59
-    yclipb = MAX(logo_y+logo_h-height, 0);
60
-
61
-    logo_x1 = logo_x + xclipl;
62
-    logo_x2 = logo_x + logo_w - xclipr;
63
-    logo_y1 = logo_y + yclipt;
64
-    logo_y2 = logo_y + logo_h - yclipb;
65
-
66
-    topleft = src+logo_y1*srcStride+logo_x1;
67
-    topright = src+logo_y1*srcStride+logo_x2-1;
68
-    botleft = src+(logo_y2-1)*srcStride+logo_x1;
69
-
70
-    if (!direct) memcpy_pic(dst, src, width, height, dstStride, srcStride);
71
-
72
-    dst += (logo_y1+1)*dstStride;
73
-    src += (logo_y1+1)*srcStride;
74
-
75
-    for(y = logo_y1+1; y < logo_y2-1; y++)
76
-    {
77
-        for (x = logo_x1+1, xdst = dst+logo_x1+1, xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
78
-            interp = ((topleft[srcStride*(y-logo_y-yclipt)]
79
-                       + topleft[srcStride*(y-logo_y-1-yclipt)]
80
-                       + topleft[srcStride*(y-logo_y+1-yclipt)])*(logo_w-(x-logo_x))/logo_w
81
-                      + (topright[srcStride*(y-logo_y-yclipt)]
82
-                         + topright[srcStride*(y-logo_y-1-yclipt)]
83
-                         + topright[srcStride*(y-logo_y+1-yclipt)])*(x-logo_x)/logo_w
84
-                      + (topleft[x-logo_x-xclipl]
85
-                         + topleft[x-logo_x-1-xclipl]
86
-                         + topleft[x-logo_x+1-xclipl])*(logo_h-(y-logo_y))/logo_h
87
-                      + (botleft[x-logo_x-xclipl]
88
-                         + botleft[x-logo_x-1-xclipl]
89
-                         + botleft[x-logo_x+1-xclipl])*(y-logo_y)/logo_h
90
-                )/6;
91
-/*                interp = (topleft[srcStride*(y-logo_y)]*(logo_w-(x-logo_x))/logo_w
92
-                          + topright[srcStride*(y-logo_y)]*(x-logo_x)/logo_w
93
-                          + topleft[x-logo_x]*(logo_h-(y-logo_y))/logo_h
94
-                          + botleft[x-logo_x]*(y-logo_y)/logo_h
95
-                          )/2;*/
96
-            if (y >= logo_y+band && y < logo_y+logo_h-band && x >= logo_x+band && x < logo_x+logo_w-band) {
97
-                    *xdst = interp;
98
-            } else {
99
-                dist = 0;
100
-                if (x < logo_x+band) dist = MAX(dist, logo_x-x+band);
101
-                else if (x >= logo_x+logo_w-band) dist = MAX(dist, x-(logo_x+logo_w-1-band));
102
-                if (y < logo_y+band) dist = MAX(dist, logo_y-y+band);
103
-                else if (y >= logo_y+logo_h-band) dist = MAX(dist, y-(logo_y+logo_h-1-band));
104
-                *xdst = (*xsrc*dist + interp*(band-dist))/band;
105
-                if (show && (dist == band-1)) *xdst = 0;
106
-            }
107
-        }
108
-
109
-        dst+= dstStride;
110
-        src+= srcStride;
111
-    }
112
-}
113
-
114
-static int config(struct vf_instance *vf,
115
-                  int width, int height, int d_width, int d_height,
116
-                  unsigned int flags, unsigned int outfmt){
117
-
118
-    return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
119
-}
120
-
121
-
122
-static void get_image(struct vf_instance *vf, mp_image_t *mpi){
123
-    if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
124
-    if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ
125
-    // ok, we can do pp in-place (or pp disabled):
126
-    vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
127
-                          mpi->type, mpi->flags, mpi->w, mpi->h);
128
-    mpi->planes[0]=vf->dmpi->planes[0];
129
-    mpi->stride[0]=vf->dmpi->stride[0];
130
-    mpi->width=vf->dmpi->width;
131
-    if(mpi->flags&MP_IMGFLAG_PLANAR){
132
-        mpi->planes[1]=vf->dmpi->planes[1];
133
-        mpi->planes[2]=vf->dmpi->planes[2];
134
-        mpi->stride[1]=vf->dmpi->stride[1];
135
-        mpi->stride[2]=vf->dmpi->stride[2];
136
-    }
137
-    mpi->flags|=MP_IMGFLAG_DIRECT;
138
-}
139
-
140
-static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
141
-    mp_image_t *dmpi;
142
-
143
-    if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
144
-        // no DR, so get a new image! hope we'll get DR buffer:
145
-        vf->dmpi=vf_get_image(vf->next,vf->priv->outfmt,
146
-                              MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
147
-                              mpi->w,mpi->h);
148
-    }
149
-    dmpi= vf->dmpi;
150
-
151
-    delogo(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h,
152
-           vf->priv->xoff, vf->priv->yoff, vf->priv->lw, vf->priv->lh, vf->priv->band, vf->priv->show,
153
-           mpi->flags&MP_IMGFLAG_DIRECT);
154
-    delogo(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2,
155
-           vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show,
156
-           mpi->flags&MP_IMGFLAG_DIRECT);
157
-    delogo(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2,
158
-           vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show,
159
-           mpi->flags&MP_IMGFLAG_DIRECT);
160
-
161
-    vf_clone_mpi_attributes(dmpi, mpi);
162
-
163
-    return vf_next_put_image(vf,dmpi, pts);
164
-}
165
-
166
-static void uninit(struct vf_instance *vf){
167
-    if(!vf->priv) return;
168
-
169
-    free(vf->priv);
170
-    vf->priv=NULL;
171
-}
172
-
173
-//===========================================================================//
174
-
175
-static int query_format(struct vf_instance *vf, unsigned int fmt){
176
-    switch(fmt)
177
-    {
178
-    case IMGFMT_YV12:
179
-    case IMGFMT_I420:
180
-    case IMGFMT_IYUV:
181
-        return vf_next_query_format(vf,vf->priv->outfmt);
182
-    }
183
-    return 0;
184
-}
185
-
186
-static const unsigned int fmt_list[]={
187
-    IMGFMT_YV12,
188
-    IMGFMT_I420,
189
-    IMGFMT_IYUV,
190
-    0
191
-};
192
-
193
-static int vf_open(vf_instance_t *vf, char *args){
194
-    int res=0;
195
-    vf->config=config;
196
-    vf->put_image=put_image;
197
-    vf->get_image=get_image;
198
-    vf->query_format=query_format;
199
-    vf->uninit=uninit;
200
-
201
-    vf->priv=malloc(sizeof(struct vf_priv_s));
202
-    memset(vf->priv, 0, sizeof(struct vf_priv_s));
203
-
204
-    if (args) res = sscanf(args, "%d:%d:%d:%d:%d",
205
-                          &vf->priv->xoff, &vf->priv->yoff,
206
-                          &vf->priv->lw, &vf->priv->lh,
207
-                          &vf->priv->band);
208
-
209
-    if (res != 5) {
210
-       mp_msg(MSGT_VFILTER, MSGL_ERR, "deLogo: syntax is \"delogo=xoff:yoff:width:height:band\"\n");
211
-       uninit(vf);
212
-       return 0;
213
-    }
214
-
215
-    mp_msg(MSGT_VFILTER, MSGL_V, "delogo: %d x %d, %d x %d, band = %d\n",
216
-           vf->priv->xoff, vf->priv->yoff,
217
-           vf->priv->lw, vf->priv->lh,
218
-           vf->priv->band);
219
-
220
-    vf->priv->show = 0;
221
-
222
-    if (vf->priv->band < 0) {
223
-        vf->priv->band = 4;
224
-        vf->priv->show = 1;
225
-    }
226
-
227
-
228
-    vf->priv->lw += vf->priv->band*2;
229
-    vf->priv->lh += vf->priv->band*2;
230
-    vf->priv->xoff -= vf->priv->band;
231
-    vf->priv->yoff -= vf->priv->band;
232
-
233
-    // check csp:
234
-    vf->priv->outfmt=vf_match_csp(&vf->next,fmt_list,IMGFMT_YV12);
235
-    if(!vf->priv->outfmt)
236
-    {
237
-        uninit(vf);
238
-        return 0; // no csp match :(
239
-    }
240
-
241
-    return 1;
242
-}
243
-
244
-const vf_info_t vf_info_delogo = {
245
-    "simple logo remover",
246
-    "delogo",
247
-    "Jindrich Makovicka, Alex Beregszaszi",
248
-    "",
249
-    vf_open,
250
-};
251
-
252
-//===========================================================================//
... ...
@@ -126,7 +126,6 @@ extern const vf_info_t vf_info_ass;
126 126
 extern const vf_info_t vf_info_bmovl;
127 127
 extern const vf_info_t vf_info_crop;
128 128
 extern const vf_info_t vf_info_decimate;
129
-extern const vf_info_t vf_info_delogo;
130 129
 extern const vf_info_t vf_info_denoise3d;
131 130
 extern const vf_info_t vf_info_detc;
132 131
 extern const vf_info_t vf_info_dint;
... ...
@@ -197,7 +196,6 @@ extern const vf_info_t vf_info_zrmjpeg;
197 197
 static const vf_info_t* const filters[]={
198 198
     &vf_info_2xsai,
199 199
     &vf_info_decimate,
200
-    &vf_info_delogo,
201 200
     &vf_info_denoise3d,
202 201
     &vf_info_detc,
203 202
     &vf_info_dint,