FFmpeg  4.3
Data Structures | Macros | Typedefs | Functions | Variables
vf_hqx.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  HQXContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define OFFSET(x)   offsetof(HQXContext, 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 P(m, r)   ((k_shuffled & (m)) == (r))
 
#define DROP4(z)   ((z) > 4 ? (z)-1 : (z))
 
#define SHF(x, rot, n)   (((x) >> ((rot) ? 7-DROP4(n) : DROP4(n)) & 1) << DROP4(p##n))
 
#define WDIFF(c1, c2)   yuv_diff(rgb2yuv(r2y, c1), rgb2yuv(r2y, c2))
 
#define INTERP_BOOTSTRAP(rot)
 
#define HQX_FUNC(size)
 

Typedefs

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

Functions

 AVFILTER_DEFINE_CLASS (hqx)
 
static av_always_inline uint32_t rgb2yuv (const uint32_t *r2y, uint32_t c)
 
static av_always_inline int yuv_diff (uint32_t yuv1, uint32_t yuv2)
 
static av_always_inline uint32_t interp_2px (uint32_t c1, int w1, uint32_t c2, int w2, int s)
 
static av_always_inline uint32_t interp_3px (uint32_t c1, int w1, uint32_t c2, int w2, uint32_t c3, int w3, int s)
 
static av_always_inline uint32_t hq2x_interp_1x1 (const uint32_t *r2y, int k, const uint32_t *w, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8)
 
static av_always_inline void hq3x_interp_2x1 (uint32_t *dst, int dst_linesize, const uint32_t *r2y, int k, const uint32_t *w, int pos00, int pos01, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int rotate)
 
static av_always_inline void hq4x_interp_2x2 (uint32_t *dst, int dst_linesize, const uint32_t *r2y, int k, const uint32_t *w, int pos00, int pos01, int pos10, int pos11, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8)
 
static av_always_inline void hqx_filter (const ThreadData *td, int jobnr, int nb_jobs, int n)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold int init (AVFilterContext *ctx)
 

Variables

static const AVOption hqx_options []
 
static const AVFilterPad hqx_inputs []
 
static const AVFilterPad hqx_outputs []
 
AVFilter ff_vf_hqx
 

Detailed Description

hqx magnification filters (hq2x, hq3x, hq4x)

Originally designed by Maxim Stephin.

See also
http://en.wikipedia.org/wiki/Hqx
http://web.archive.org/web/20131114143602/http://www.hiend3d.com/hq3x.html
http://blog.pkh.me/p/19-butchering-hqx-scaling-filters.html

Definition in file vf_hqx.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 49 of file vf_hqx.c.

◆ FLAGS

Definition at line 50 of file vf_hqx.c.

◆ YMASK

#define YMASK   0xff0000

◆ UMASK

#define UMASK   0x00ff00

◆ VMASK

#define VMASK   0x0000ff

◆ ABSDIFF

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

◆ P

#define P (   m,
  r 
)    ((k_shuffled & (m)) == (r))

Definition at line 92 of file vf_hqx.c.

◆ DROP4

#define DROP4 (   z)    ((z) > 4 ? (z)-1 : (z))

Definition at line 96 of file vf_hqx.c.

◆ SHF

#define SHF (   x,
  rot,
 
)    (((x) >> ((rot) ? 7-DROP4(n) : DROP4(n)) & 1) << DROP4(p##n))

Definition at line 99 of file vf_hqx.c.

◆ WDIFF

#define WDIFF (   c1,
  c2 
)    yuv_diff(rgb2yuv(r2y, c1), rgb2yuv(r2y, c2))

Definition at line 102 of file vf_hqx.c.

◆ INTERP_BOOTSTRAP

#define INTERP_BOOTSTRAP (   rot)
Value:
const int k_shuffled = SHF(k,rot,0) | SHF(k,rot,1) | SHF(k,rot,2) \
| SHF(k,rot,3) | 0 | SHF(k,rot,5) \
| SHF(k,rot,6) | SHF(k,rot,7) | SHF(k,rot,8); \
\
const uint32_t w0 = w[p0], w1 = w[p1], \
w3 = w[p3], w4 = w[p4], w5 = w[p5], \
w7 = w[p7]

Definition at line 107 of file vf_hqx.c.

◆ HQX_FUNC

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

Definition at line 453 of file vf_hqx.c.

Typedef Documentation

◆ hqxfunc_t

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

Definition at line 35 of file vf_hqx.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( hqx  )

◆ rgb2yuv()

static av_always_inline uint32_t rgb2yuv ( const uint32_t *  r2y,
uint32_t  c 
)
static

Definition at line 58 of file vf_hqx.c.

Referenced by hqx_filter().

◆ yuv_diff()

static av_always_inline int yuv_diff ( uint32_t  yuv1,
uint32_t  yuv2 
)
static

Definition at line 63 of file vf_hqx.c.

Referenced by hqx_filter().

◆ interp_2px()

static av_always_inline uint32_t interp_2px ( uint32_t  c1,
int  w1,
uint32_t  c2,
int  w2,
int  s 
)
static

Definition at line 76 of file vf_hqx.c.

Referenced by hq2x_interp_1x1(), hq3x_interp_2x1(), and hq4x_interp_2x2().

◆ interp_3px()

static av_always_inline uint32_t interp_3px ( uint32_t  c1,
int  w1,
uint32_t  c2,
int  w2,
uint32_t  c3,
int  w3,
int  s 
)
static

Definition at line 83 of file vf_hqx.c.

Referenced by hq2x_interp_1x1(), hq3x_interp_2x1(), and hq4x_interp_2x2().

◆ hq2x_interp_1x1()

static av_always_inline uint32_t hq2x_interp_1x1 ( const uint32_t *  r2y,
int  k,
const uint32_t *  w,
int  p0,
int  p1,
int  p2,
int  p3,
int  p4,
int  p5,
int  p6,
int  p7,
int  p8 
)
static

Definition at line 119 of file vf_hqx.c.

Referenced by hqx_filter().

◆ hq3x_interp_2x1()

static av_always_inline void hq3x_interp_2x1 ( uint32_t *  dst,
int  dst_linesize,
const uint32_t *  r2y,
int  k,
const uint32_t *  w,
int  pos00,
int  pos01,
int  p0,
int  p1,
int  p2,
int  p3,
int  p4,
int  p5,
int  p6,
int  p7,
int  p8,
int  rotate 
)
static

Definition at line 169 of file vf_hqx.c.

Referenced by hqx_filter().

◆ hq4x_interp_2x2()

static av_always_inline void hq4x_interp_2x2 ( uint32_t *  dst,
int  dst_linesize,
const uint32_t *  r2y,
int  k,
const uint32_t *  w,
int  pos00,
int  pos01,
int  pos10,
int  pos11,
int  p0,
int  p1,
int  p2,
int  p3,
int  p4,
int  p5,
int  p6,
int  p7,
int  p8 
)
static

Definition at line 235 of file vf_hqx.c.

Referenced by hqx_filter().

◆ hqx_filter()

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

Definition at line 383 of file vf_hqx.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 464 of file vf_hqx.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 473 of file vf_hqx.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 487 of file vf_hqx.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 511 of file vf_hqx.c.

Variable Documentation

◆ hqx_options

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

Definition at line 51 of file vf_hqx.c.

◆ hqx_inputs

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

Definition at line 538 of file vf_hqx.c.

◆ hqx_outputs

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

Definition at line 547 of file vf_hqx.c.

◆ ff_vf_hqx

AVFilter ff_vf_hqx
Initial value:
= {
.name = "hqx",
.description = NULL_IF_CONFIG_SMALL("Scale the input by 2, 3 or 4 using the hq*x magnification algorithm."),
.priv_size = sizeof(HQXContext),
.init = init,
.priv_class = &hqx_class,
}

Definition at line 556 of file vf_hqx.c.

SHF
#define SHF(x, rot, n)
Definition: vf_hqx.c:99
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_hqx.c:487
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_hqx.c:511
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
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_hqx.c:464
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ctx
AVFormatContext * ctx
Definition: movenc.c:48
arg
const char * arg
Definition: jacosubdec.c:66
OFFSET
#define OFFSET(x)
Definition: vf_hqx.c:49
NULL
#define NULL
Definition: coverity.c:32
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
hqx_inputs
static const AVFilterPad hqx_inputs[]
Definition: vf_hqx.c:538
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
size
int size
Definition: twinvq_data.h:11134
HQXContext
Definition: hqx.h:62
hqx_outputs
static const AVFilterPad hqx_outputs[]
Definition: vf_hqx.c:547
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_hqx.c:473
w
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 ug o o w
Definition: fate.txt:150
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
FLAGS
#define FLAGS
Definition: vf_hqx.c:50
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
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:564