e30c1da7335b13b60b8e1986f67eea313f318004
[ffmpeg.git] / libavfilter / vf_xbr.c
1 /*
2  * This file is part of FFmpeg.
3  *
4  * Copyright (C) 2011, 2012 Hyllian/Jararaca - sergiogdb@gmail.com
5  *
6  * Copyright (c) 2014 Arwa Arif <arwaarif1994@gmail.com>
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22
23 /**
24  * @file
25  * XBR Filter is used for depixelization of image.
26  * This is based on Hyllian's xBR shader.
27  *
28  * @see http://www.libretro.com/forums/viewtopic.php?f=6&t=134
29  * @see https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xbr.cpp
30  *
31  * @todo add threading and FATE test
32  */
33
34 #include "libavutil/opt.h"
35 #include "libavutil/avassert.h"
36 #include "libavutil/pixdesc.h"
37 #include "internal.h"
38
39 #define RGB_MASK      0x00FFFFFF
40 #define LB_MASK       0x00FEFEFE
41 #define RED_BLUE_MASK 0x00FF00FF
42 #define GREEN_MASK    0x0000FF00
43
44 typedef struct {
45     const AVClass *class;
46     int n;
47     uint32_t rgbtoyuv[1<<24];
48 } XBRContext;
49
50 #define OFFSET(x) offsetof(XBRContext, x)
51 static const AVOption xbr_options[] = {
52     { "n", "set scale factor", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 3}, 2, 4, },
53     { NULL }
54 };
55
56 AVFILTER_DEFINE_CLASS(xbr);
57
58 static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
59 {
60 #define YMASK 0xff0000
61 #define UMASK 0x00ff00
62 #define VMASK 0x0000ff
63
64     uint32_t yuv1 = r2y[x & 0xffffff];
65     uint32_t yuv2 = r2y[y & 0xffffff];
66
67     return (abs((yuv1 & YMASK) - (yuv2 & YMASK)) >> 16) +
68            (abs((yuv1 & UMASK) - (yuv2 & UMASK)) >>  8) +
69            abs((yuv1 & VMASK) - (yuv2 & VMASK));
70 }
71
72 #define ALPHA_BLEND_128_W(dst, src) dst = ((src & LB_MASK) >> 1) + ((dst & LB_MASK) >> 1)
73
74 #define ALPHA_BLEND_32_W(dst, src) \
75     dst = ((RED_BLUE_MASK & ((dst & RED_BLUE_MASK) + ((((src & RED_BLUE_MASK) - \
76           (dst & RED_BLUE_MASK))) >> 3))) | (GREEN_MASK & ((dst & GREEN_MASK) + \
77           ((((src & GREEN_MASK) - (dst & GREEN_MASK))) >> 3))))
78
79 #define ALPHA_BLEND_64_W(dst, src) \
80     dst = ((RED_BLUE_MASK & ((dst & RED_BLUE_MASK) + ((((src & RED_BLUE_MASK) - \
81           (dst & RED_BLUE_MASK))) >> 2))) | (GREEN_MASK & ((dst & GREEN_MASK) + \
82           ((((src & GREEN_MASK) - (dst & GREEN_MASK))) >> 2))))
83
84 #define ALPHA_BLEND_192_W(dst, src) \
85     dst = ((RED_BLUE_MASK & ((dst & RED_BLUE_MASK) + ((((src & RED_BLUE_MASK) - \
86           (dst & RED_BLUE_MASK)) * 3) >> 2))) | (GREEN_MASK & ((dst & GREEN_MASK) + \
87           ((((src & GREEN_MASK) - (dst & GREEN_MASK)) * 3) >> 2))))
88
89 #define ALPHA_BLEND_224_W(dst, src) \
90     dst = ((RED_BLUE_MASK & ((dst & RED_BLUE_MASK) + ((((src & RED_BLUE_MASK) - \
91           (dst & RED_BLUE_MASK)) * 7) >> 3))) | (GREEN_MASK & ((dst & GREEN_MASK) + \
92           ((((src & GREEN_MASK) - (dst & GREEN_MASK)) * 7) >> 3))))
93
94 #define df(A, B) pixel_diff(A, B, r2y)
95 #define eq(A, B) (df(A, B) < 155)
96
97 #define INIT_SRC_DST_POINTERS(level)                                                                    \
98     uint32_t *E = (uint32_t *)(output->data[0] + y * output->linesize[0] * (level));                    \
99     const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8); /* center */       \
100     const uint32_t *sa1 = sa2 - (input->linesize[0]>>2); /* up x1 */                                    \
101     const uint32_t *sa0 = sa1 - (input->linesize[0]>>2); /* up x2 */                                    \
102     const uint32_t *sa3 = sa2 + (input->linesize[0]>>2); /* down x1 */                                  \
103     const uint32_t *sa4 = sa3 + (input->linesize[0]>>2); /* down x2 */                                  \
104                                                                                                         \
105     if (y <= 1) {                                                                                       \
106         sa0 = sa1;                                                                                      \
107         if (y == 0) {                                                                                   \
108             sa0 = sa1 = sa2;                                                                            \
109         }                                                                                               \
110     }                                                                                                   \
111                                                                                                         \
112     if (y >= input->height - 2) {                                                                       \
113         sa4 = sa3;                                                                                      \
114         if (y == input->height - 1) {                                                                   \
115             sa4 = sa3 = sa2;                                                                            \
116         }                                                                                               \
117     }
118
119 #define INIT_21_PIXELS                                      \
120     const uint32_t B1 = sa0[2];                             \
121     const uint32_t PB = sa1[2];                             \
122     const uint32_t PE = sa2[2];                             \
123     const uint32_t PH = sa3[2];                             \
124     const uint32_t H5 = sa4[2];                             \
125                                                             \
126     const int pprev = 2 - (x > 0);                          \
127     const uint32_t A1 = sa0[pprev];                         \
128     const uint32_t PA = sa1[pprev];                         \
129     const uint32_t PD = sa2[pprev];                         \
130     const uint32_t PG = sa3[pprev];                         \
131     const uint32_t G5 = sa4[pprev];                         \
132                                                             \
133     const int pprev2 = pprev - (x > 1);                     \
134     const uint32_t A0 = sa1[pprev2];                        \
135     const uint32_t D0 = sa2[pprev2];                        \
136     const uint32_t G0 = sa3[pprev2];                        \
137                                                             \
138     const int pnext = 3 - (x == input->width - 1);          \
139     const uint32_t C1 = sa0[pnext];                         \
140     const uint32_t PC = sa1[pnext];                         \
141     const uint32_t PF = sa2[pnext];                         \
142     const uint32_t PI = sa3[pnext];                         \
143     const uint32_t I5 = sa4[pnext];                         \
144                                                             \
145     const int pnext2 = pnext + 1 - (x >= input->width - 2); \
146     const uint32_t C4 = sa1[pnext2];                        \
147     const uint32_t F4 = sa2[pnext2];                        \
148     const uint32_t I4 = sa3[pnext2];
149
150 #define FILT2(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1,   \
151               N0, N1, N2, N3) do {                                                                  \
152     if (PE != PH && PE != PF) {                                                                     \
153         const unsigned e = df(PE,PC) + df(PE,PG) + df(PI,H5) + df(PI,F4) + (df(PH,PF)<<2);          \
154         const unsigned i = df(PH,PD) + df(PH,I5) + df(PF,I4) + df(PF,PB) + (df(PE,PI)<<2);          \
155         if (e < i && (!eq(PF,PB) && !eq(PH,PD) || eq(PE,PI)                                         \
156                       && (!eq(PF,I4) && !eq(PH,I5))                                                 \
157                       || eq(PE,PG) || eq(PE,PC))) {                                                 \
158             const unsigned ke = df(PF,PG);                                                          \
159             const unsigned ki = df(PH,PC);                                                          \
160             const int left    = ke<<1 <= ki && PE != PG && PD != PG;                                \
161             const int up      = ke >= ki<<1 && PE != PC && PB != PC;                                \
162             const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
163             if (left && up) {                                                                       \
164                 ALPHA_BLEND_224_W(E[N3], px);                                                       \
165                 ALPHA_BLEND_64_W( E[N2], px);                                                       \
166                 E[N1] = E[N2];                                                                      \
167             } else if (left) {                                                                      \
168                 ALPHA_BLEND_192_W(E[N3], px);                                                       \
169                 ALPHA_BLEND_64_W( E[N2], px);                                                       \
170             } else if (up) {                                                                        \
171                 ALPHA_BLEND_192_W(E[N3], px);                                                       \
172                 ALPHA_BLEND_64_W( E[N1], px);                                                       \
173             } else { /* diagonal */                                                                 \
174                 ALPHA_BLEND_128_W(E[N3], px);                                                       \
175             }                                                                                       \
176         } else if (e <= i) {                                                                        \
177             ALPHA_BLEND_128_W( E[N3], ((df(PE,PF) <= df(PE,PH)) ? PF : PH));                        \
178         }                                                                                           \
179     }                                                                                               \
180 } while (0)
181
182 static void xbr2x(AVFrame * input, AVFrame * output, const uint32_t * r2y)
183 {
184     int x, y;
185     const int nl = output->linesize[0] >> 2;
186
187     for (y = 0; y < input->height; y++) {
188         INIT_SRC_DST_POINTERS(2)
189
190         for (x = 0; x < input->width; x++) {
191             INIT_21_PIXELS
192
193             E[0] = E[1] = E[nl] = E[nl + 1] = PE; // 0, 1, 2, 3
194
195             FILT2(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, nl, nl+1);
196             FILT2(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, nl, 0, nl+1, 1);
197             FILT2(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, nl+1, nl, 1, 0);
198             FILT2(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 1, nl+1, 0, nl);
199
200             sa0 += 1;
201             sa1 += 1;
202             sa2 += 1;
203             sa3 += 1;
204             sa4 += 1;
205
206             E += 2;
207         }
208     }
209 }
210
211 #define FILT3(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1,   \
212               N0, N1, N2, N3, N4, N5, N6, N7, N8) do {                                              \
213     if (PE != PH && PE != PF) {                                                                     \
214         const unsigned e = df(PE,PC) + df(PE,PG) + df(PI,H5) + df(PI,F4) + (df(PH,PF)<<2);          \
215         const unsigned i = df(PH,PD) + df(PH,I5) + df(PF,I4) + df(PF,PB) + (df(PE,PI)<<2);          \
216         if (e < i && (!eq(PF,PB) && !eq(PF,PC) || !eq(PH,PD) && !eq(PH,PG) || eq(PE,PI)             \
217                       && (!eq(PF,F4) && !eq(PF,I4) || !eq(PH,H5) && !eq(PH,I5))                     \
218                       || eq(PE,PG) || eq(PE,PC))) {                                                 \
219             const unsigned ke = df(PF,PG);                                                          \
220             const unsigned ki = df(PH,PC);                                                          \
221             const int left    = ke<<1 <= ki && PE != PG && PD != PG;                                \
222             const int up      = ke >= ki<<1 && PE != PC && PB != PC;                                \
223             const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
224             if (left && up) {                                                                       \
225                 ALPHA_BLEND_192_W(E[N7], px);                                                       \
226                 ALPHA_BLEND_64_W( E[N6], px);                                                       \
227                 E[N5] = E[N7];                                                                      \
228                 E[N2] = E[N6];                                                                      \
229                 E[N8] = px;                                                                         \
230             } else if (left) {                                                                      \
231                 ALPHA_BLEND_192_W(E[N7], px);                                                       \
232                 ALPHA_BLEND_64_W( E[N5], px);                                                       \
233                 ALPHA_BLEND_64_W( E[N6], px);                                                       \
234                 E[N8] = px;                                                                         \
235             } else if (up) {                                                                        \
236                 ALPHA_BLEND_192_W(E[N5], px);                                                       \
237                 ALPHA_BLEND_64_W( E[N7], px);                                                       \
238                 ALPHA_BLEND_64_W( E[N2], px);                                                       \
239                 E[N8] = px;                                                                         \
240             } else { /* diagonal */                                                                 \
241                 ALPHA_BLEND_224_W(E[N8], px);                                                       \
242                 ALPHA_BLEND_32_W( E[N5], px);                                                       \
243                 ALPHA_BLEND_32_W( E[N7], px);                                                       \
244             }                                                                                       \
245         } else if (e <= i) {                                                                        \
246             ALPHA_BLEND_128_W(E[N8], ((df(PE,PF) <= df(PE,PH)) ? PF : PH));                         \
247         }                                                                                           \
248     }                                                                                               \
249 } while (0)
250
251 static void xbr3x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
252 {
253     int x, y;
254     const int nl = output->linesize[0] >> 2;
255     const int nl1 = nl + nl;
256
257     for (y = 0; y < input->height; y++) {
258         INIT_SRC_DST_POINTERS(3)
259
260         for (x = 0; x < input->width; x++) {
261             INIT_21_PIXELS
262
263             E[0]   = E[1]     = E[2]     = PE;
264             E[nl]  = E[nl+1]  = E[nl+2]  = PE; // 3, 4, 5
265             E[nl1] = E[nl1+1] = E[nl1+2] = PE; // 6, 7, 8
266
267             FILT3(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, 2, nl, nl+1, nl+2, nl1, nl1+1, nl1+2);
268             FILT3(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, nl1, nl, 0, nl1+1, nl+1, 1, nl1+2, nl+2, 2);
269             FILT3(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, nl1+2, nl1+1, nl1, nl+2, nl+1, nl, 2, 1, 0);
270             FILT3(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 2, nl+2, nl1+2, 1, nl+1, nl1+1, 0, nl, nl1);
271
272             sa0 += 1;
273             sa1 += 1;
274             sa2 += 1;
275             sa3 += 1;
276             sa4 += 1;
277
278             E += 3;
279         }
280     }
281 }
282
283 #define FILT4(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1,   \
284               N15, N14, N11, N3, N7, N10, N13, N12, N9, N6, N2, N1, N5, N8, N4, N0) do {            \
285     if (PE != PH && PE != PF) {                                                                     \
286         const unsigned e = df(PE,PC) + df(PE,PG) + df(PI,H5) + df(PI,F4) + (df(PH,PF)<<2);          \
287         const unsigned i = df(PH,PD) + df(PH,I5) + df(PF,I4) + df(PF,PB) + (df(PE,PI)<<2);          \
288         if (e < i && (!eq(PF,PB) && !eq(PH,PD) || eq(PE,PI)                                         \
289                       && (!eq(PF,I4) && !eq(PH,I5))                                                 \
290                       || eq(PE,PG) || eq(PE,PC))) {                                                 \
291             const unsigned ke = df(PF,PG);                                                          \
292             const unsigned ki = df(PH,PC);                                                          \
293             const int left    = ke<<1 <= ki && PE != PG && PD != PG;                                \
294             const int up      = ke >= ki<<1 && PE != PC && PB != PC;                                \
295             const unsigned px = df(PE,PF) <= df(PE,PH) ? PF : PH;                                   \
296             if (left && up) {                                                                       \
297                 ALPHA_BLEND_192_W(E[N13], px);                                                      \
298                 ALPHA_BLEND_64_W( E[N12], px);                                                      \
299                 E[N15] = E[N14] = E[N11] = px;                                                      \
300                 E[N10] = E[N3]  = E[N12];                                                           \
301                 E[N7]  = E[N13];                                                                    \
302             } else if (left) {                                                                      \
303                 ALPHA_BLEND_192_W(E[N11], px);                                                      \
304                 ALPHA_BLEND_192_W(E[N13], px);                                                      \
305                 ALPHA_BLEND_64_W( E[N10], px);                                                      \
306                 ALPHA_BLEND_64_W( E[N12], px);                                                      \
307                 E[N14] = px;                                                                        \
308                 E[N15] = px;                                                                        \
309             } else if (up) {                                                                        \
310                 ALPHA_BLEND_192_W(E[N14], px);                                                      \
311                 ALPHA_BLEND_192_W(E[N7 ], px);                                                      \
312                 ALPHA_BLEND_64_W( E[N10], px);                                                      \
313                 ALPHA_BLEND_64_W( E[N3 ], px);                                                      \
314                 E[N11] = px;                                                                        \
315                 E[N15] = px;                                                                        \
316             } else { /* diagonal */                                                                 \
317                 ALPHA_BLEND_128_W(E[N11], px);                                                      \
318                 ALPHA_BLEND_128_W(E[N14], px);                                                      \
319                 E[N15] = px;                                                                        \
320             }                                                                                       \
321         } else if (e <= i) {                                                                        \
322             ALPHA_BLEND_128_W( E[N15], ((df(PE,PF) <= df(PE,PH)) ? PF : PH));                       \
323         }                                                                                           \
324     }                                                                                               \
325 } while (0)
326
327 static void xbr4x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
328 {
329     int x, y;
330     const int nl = output->linesize[0] >> 2;
331     const int nl1 = nl + nl;
332     const int nl2 = nl1 + nl;
333
334     for (y = 0; y < input->height; y++) {
335         INIT_SRC_DST_POINTERS(4)
336
337         for (x = 0; x < input->width; x++) {
338             INIT_21_PIXELS
339
340             E[0]   = E[1]     = E[2]     = E[3]     = PE;
341             E[nl]  = E[nl+1]  = E[nl+2]  = E[nl+3]  = PE; //  4,  5,  6,  7
342             E[nl1] = E[nl1+1] = E[nl1+2] = E[nl1+3] = PE; //  8,  9, 10, 11
343             E[nl2] = E[nl2+1] = E[nl2+2] = E[nl2+3] = PE; // 12, 13, 14, 15
344
345             FILT4(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, nl2+3, nl2+2, nl1+3,  3,  nl+3, nl1+2, nl2+1, nl2,  nl1+1,  nl+2, 2,  1, nl+1, nl1, nl, 0);
346             FILT4(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0,  3,  nl+3,  2,  0,  1,  nl+2, nl1+3, nl2+3, nl1+2,  nl+1, nl,  nl1, nl1+1,nl2+2,nl2+1,nl2);
347             FILT4(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5,  0,  1,  nl, nl2,  nl1,  nl+1,  2,  3,  nl+2,  nl1+1, nl2+1,nl2+2,nl1+2, nl+3,nl1+3,nl2+3);
348             FILT4(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, nl2,  nl1, nl2+1, nl2+3, nl2+2,  nl1+1,  nl,  0,  nl+1, nl1+2, nl1+3, nl+3, nl+2, 1, 2, 3);
349
350             sa0 += 1;
351             sa1 += 1;
352             sa2 += 1;
353             sa3 += 1;
354             sa4 += 1;
355
356             E += 4;
357         }
358     }
359 }
360
361 static int config_output(AVFilterLink *outlink)
362 {
363     AVFilterContext *ctx = outlink->src;
364     XBRContext *xbr = ctx->priv;
365     AVFilterLink *inlink = ctx->inputs[0];
366
367     outlink->w = inlink->w * xbr->n;
368     outlink->h = inlink->h * xbr->n;
369     return 0;
370 }
371
372 static int query_formats(AVFilterContext *ctx)
373 {
374     static const enum AVPixelFormat pix_fmts[] = {
375         AV_PIX_FMT_0RGB32, AV_PIX_FMT_NONE,
376     };
377
378     ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
379     return 0;
380 }
381
382 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
383 {
384     AVFilterContext *ctx = inlink->dst;
385     AVFilterLink *outlink = ctx->outputs[0];
386     XBRContext *xbr = ctx->priv;
387     const uint32_t *r2y = xbr->rgbtoyuv;
388
389     AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
390     if (!out) {
391         av_frame_free(&in);
392         return AVERROR(ENOMEM);
393     }
394
395     av_frame_copy_props(out, in);
396     if (xbr->n == 4)
397         xbr4x(in, out, r2y);
398     else if (xbr->n == 3)
399         xbr3x(in, out, r2y);
400     else
401         xbr2x(in, out, r2y);
402
403     out->width  = outlink->w;
404     out->height = outlink->h;
405
406     av_frame_free(&in);
407     return ff_filter_frame(outlink, out);
408 }
409
410 static int init(AVFilterContext *ctx)
411 {
412     XBRContext *xbr = ctx->priv;
413     uint32_t c;
414     int bg, rg, g;
415
416     for (bg = -255; bg < 256; bg++) {
417         for (rg = -255; rg < 256; rg++) {
418             const uint32_t u = (uint32_t)((-169*rg + 500*bg)/1000) + 128;
419             const uint32_t v = (uint32_t)(( 500*rg -  81*bg)/1000) + 128;
420             int startg = FFMAX3(-bg, -rg, 0);
421             int endg = FFMIN3(255-bg, 255-rg, 255);
422             uint32_t y = (uint32_t)(( 299*rg + 1000*startg + 114*bg)/1000);
423             c = bg + (rg<<16) + 0x010101 * startg;
424             for (g = startg; g <= endg; g++) {
425                 xbr->rgbtoyuv[c] = ((y++) << 16) + (u << 8) + v;
426                 c+= 0x010101;
427             }
428         }
429     }
430
431     return 0;
432 }
433
434 static const AVFilterPad xbr_inputs[] = {
435     {
436         .name         = "default",
437         .type         = AVMEDIA_TYPE_VIDEO,
438         .filter_frame = filter_frame,
439     },
440     { NULL }
441 };
442
443 static const AVFilterPad xbr_outputs[] = {
444     {
445         .name         = "default",
446         .type         = AVMEDIA_TYPE_VIDEO,
447         .config_props = config_output,
448     },
449     { NULL }
450 };
451
452 AVFilter ff_vf_xbr = {
453     .name          = "xbr",
454     .description   = NULL_IF_CONFIG_SMALL("Scale the input using xBR algorithm."),
455     .inputs        = xbr_inputs,
456     .outputs       = xbr_outputs,
457     .query_formats = query_formats,
458     .priv_size     = sizeof(XBRContext),
459     .priv_class    = &xbr_class,
460     .init          = init,
461 };