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