FFmpeg  4.3
Data Structures | Macros | Typedefs | Functions | Variables
vf_xbr.c File Reference
#include "libavutil/opt.h"
#include "libavutil/avassert.h"
#include "libavutil/pixdesc.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  XBRContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define LB_MASK   0x00FEFEFE
 
#define RED_BLUE_MASK   0x00FF00FF
 
#define GREEN_MASK   0x0000FF00
 
#define OFFSET(x)   offsetof(XBRContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define YMASK   0xff0000
 
#define UMASK   0x00ff00
 
#define VMASK   0x0000ff
 
#define ABSDIFF(a, b)   (abs((int)(a)-(int)(b)))
 
#define ALPHA_BLEND_128_W(a, b)   ((((a) & LB_MASK) >> 1) + (((b) & LB_MASK) >> 1))
 
#define ALPHA_BLEND_BASE(a, b, m, s)
 
#define ALPHA_BLEND_32_W(a, b)   ALPHA_BLEND_BASE(a, b, 1, 3)
 
#define ALPHA_BLEND_64_W(a, b)   ALPHA_BLEND_BASE(a, b, 1, 2)
 
#define ALPHA_BLEND_192_W(a, b)   ALPHA_BLEND_BASE(a, b, 3, 2)
 
#define ALPHA_BLEND_224_W(a, b)   ALPHA_BLEND_BASE(a, b, 7, 3)
 
#define df(A, B)   pixel_diff(A, B, r2y)
 
#define eq(A, B)   (df(A, B) < 155)
 
#define FILT2(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3)
 
#define FILT3(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3, N4, N5, N6, N7, N8)
 
#define FILT4(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N15, N14, N11, N3, N7, N10, N13, N12, N9, N6, N2, N1, N5, N8, N4, N0)
 
#define XBR_FUNC(size)
 

Typedefs

typedef int(* xbrfunc_t) (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 

Functions

 AVFILTER_DEFINE_CLASS (xbr)
 
static uint32_t pixel_diff (uint32_t x, uint32_t y, const uint32_t *r2y)
 
static av_always_inline void xbr_filter (const ThreadData *td, int jobnr, int nb_jobs, int n)
 
static int config_output (AVFilterLink *outlink)
 
static int query_formats (AVFilterContext *ctx)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold int init (AVFilterContext *ctx)
 

Variables

static const AVOption xbr_options []
 
static const AVFilterPad xbr_inputs []
 
static const AVFilterPad xbr_outputs []
 
AVFilter ff_vf_xbr
 

Detailed Description

XBR Filter is used for depixelization of image. This is based on Hyllian's xBR shader.

See also
https://forums.libretro.com/t/xbr-algorithm-tutorial/123
https://github.com/yoyofr/iFBA/blob/master/fba_src/src/intf/video/scalers/xbr.cpp

Definition in file vf_xbr.c.

Macro Definition Documentation

◆ LB_MASK

#define LB_MASK   0x00FEFEFE

Definition at line 36 of file vf_xbr.c.

◆ RED_BLUE_MASK

#define RED_BLUE_MASK   0x00FF00FF

Definition at line 37 of file vf_xbr.c.

◆ GREEN_MASK

#define GREEN_MASK   0x0000FF00

Definition at line 38 of file vf_xbr.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(XBRContext, x)

Definition at line 58 of file vf_xbr.c.

◆ FLAGS

Definition at line 59 of file vf_xbr.c.

◆ YMASK

#define YMASK   0xff0000

◆ UMASK

#define UMASK   0x00ff00

◆ VMASK

#define VMASK   0x0000ff

◆ ABSDIFF

#define ABSDIFF (   a,
  b 
)    (abs((int)(a)-(int)(b)))

◆ ALPHA_BLEND_128_W

#define ALPHA_BLEND_128_W (   a,
  b 
)    ((((a) & LB_MASK) >> 1) + (((b) & LB_MASK) >> 1))

Definition at line 82 of file vf_xbr.c.

◆ ALPHA_BLEND_BASE

#define ALPHA_BLEND_BASE (   a,
  b,
  m,
  s 
)
Value:
( (RED_BLUE_MASK & (((a) & RED_BLUE_MASK) + (((((b) & RED_BLUE_MASK) - ((a) & RED_BLUE_MASK)) * (m)) >> (s)))) \
| (GREEN_MASK & (((a) & GREEN_MASK) + (((((b) & GREEN_MASK) - ((a) & GREEN_MASK)) * (m)) >> (s)))))

Definition at line 83 of file vf_xbr.c.

◆ ALPHA_BLEND_32_W

#define ALPHA_BLEND_32_W (   a,
  b 
)    ALPHA_BLEND_BASE(a, b, 1, 3)

Definition at line 85 of file vf_xbr.c.

◆ ALPHA_BLEND_64_W

#define ALPHA_BLEND_64_W (   a,
  b 
)    ALPHA_BLEND_BASE(a, b, 1, 2)

Definition at line 86 of file vf_xbr.c.

◆ ALPHA_BLEND_192_W

#define ALPHA_BLEND_192_W (   a,
  b 
)    ALPHA_BLEND_BASE(a, b, 3, 2)

Definition at line 87 of file vf_xbr.c.

◆ ALPHA_BLEND_224_W

#define ALPHA_BLEND_224_W (   a,
  b 
)    ALPHA_BLEND_BASE(a, b, 7, 3)

Definition at line 88 of file vf_xbr.c.

◆ df

#define df (   A,
  B 
)    pixel_diff(A, B, r2y)

Definition at line 90 of file vf_xbr.c.

◆ eq

#define eq (   A,
  B 
)    (df(A, B) < 155)

Definition at line 91 of file vf_xbr.c.

◆ FILT2

#define FILT2 (   PE,
  PI,
  PH,
  PF,
  PG,
  PC,
  PD,
  PB,
  PA,
  G5,
  C4,
  G0,
  D0,
  C1,
  B1,
  F4,
  I4,
  H5,
  I5,
  A0,
  A1,
  N0,
  N1,
  N2,
  N3 
)

Definition at line 93 of file vf_xbr.c.

◆ FILT3

#define FILT3 (   PE,
  PI,
  PH,
  PF,
  PG,
  PC,
  PD,
  PB,
  PA,
  G5,
  C4,
  G0,
  D0,
  C1,
  B1,
  F4,
  I4,
  H5,
  I5,
  A0,
  A1,
  N0,
  N1,
  N2,
  N3,
  N4,
  N5,
  N6,
  N7,
  N8 
)

Definition at line 127 of file vf_xbr.c.

◆ FILT4

#define FILT4 (   PE,
  PI,
  PH,
  PF,
  PG,
  PC,
  PD,
  PB,
  PA,
  G5,
  C4,
  G0,
  D0,
  C1,
  B1,
  F4,
  I4,
  H5,
  I5,
  A0,
  A1,
  N15,
  N14,
  N11,
  N3,
  N7,
  N10,
  N13,
  N12,
  N9,
  N6,
  N2,
  N1,
  N5,
  N8,
  N4,
  N0 
)

Definition at line 169 of file vf_xbr.c.

◆ XBR_FUNC

#define XBR_FUNC (   size)
Value:
static int xbr##size##x(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
{ \
xbr_filter(arg, jobnr, nb_jobs, size); \
return 0; \
}

Definition at line 321 of file vf_xbr.c.

Typedef Documentation

◆ xbrfunc_t

typedef int(* xbrfunc_t) (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)

Definition at line 44 of file vf_xbr.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( xbr  )

◆ pixel_diff()

static uint32_t pixel_diff ( uint32_t  x,
uint32_t  y,
const uint32_t *  r2y 
)
static

Definition at line 67 of file vf_xbr.c.

◆ xbr_filter()

static av_always_inline void xbr_filter ( const ThreadData td,
int  jobnr,
int  nb_jobs,
int  n 
)
static

Definition at line 215 of file vf_xbr.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 333 of file vf_xbr.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 344 of file vf_xbr.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 356 of file vf_xbr.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 383 of file vf_xbr.c.

Variable Documentation

◆ xbr_options

const AVOption xbr_options[]
static
Initial value:
= {
{ "n", "set scale factor", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 3}, 2, 4, .flags = FLAGS },
{ NULL }
}

Definition at line 60 of file vf_xbr.c.

◆ xbr_inputs

const AVFilterPad xbr_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}

Definition at line 410 of file vf_xbr.c.

◆ xbr_outputs

const AVFilterPad xbr_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
{ NULL }
}

Definition at line 419 of file vf_xbr.c.

◆ ff_vf_xbr

AVFilter ff_vf_xbr
Initial value:
= {
.name = "xbr",
.description = NULL_IF_CONFIG_SMALL("Scale the input using xBR algorithm."),
.inputs = xbr_inputs,
.outputs = xbr_outputs,
.query_formats = query_formats,
.priv_size = sizeof(XBRContext),
.priv_class = &xbr_class,
.init = init,
}

Definition at line 428 of file vf_xbr.c.

xbr_outputs
static const AVFilterPad xbr_outputs[]
Definition: vf_xbr.c:419
b
#define b
Definition: input.c:41
xbr_inputs
static const AVFilterPad xbr_inputs[]
Definition: vf_xbr.c:410
x
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
Definition: fate.txt:150
s
#define s(width, name)
Definition: cbs_vp9.c:257
FLAGS
#define FLAGS
Definition: vf_xbr.c:59
ctx
AVFormatContext * ctx
Definition: movenc.c:48
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_xbr.c:344
arg
const char * arg
Definition: jacosubdec.c:66
NULL
#define NULL
Definition: coverity.c:32
XBRContext
Definition: vf_xbr.c:46
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:186
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_xbr.c:333
size
int size
Definition: twinvq_data.h:11134
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
RED_BLUE_MASK
#define RED_BLUE_MASK
Definition: vf_xbr.c:37
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_xbr.c:356
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_xbr.c:383
GREEN_MASK
#define GREEN_MASK
Definition: vf_xbr.c:38
OFFSET
#define OFFSET(x)
Definition: vf_xbr.c:58
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:564