FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
vf_hqx.c File Reference

hqx magnification filters (hq2x, hq3x, hq4x) More...

#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
 

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 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

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

Definition at line 49 of file vf_hqx.c.

Definition at line 50 of file vf_hqx.c.

#define YMASK   0xff0000

Referenced by yuv_diff().

#define UMASK   0x00ff00

Referenced by yuv_diff().

#define VMASK   0x0000ff

Referenced by yuv_diff().

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

Definition at line 90 of file vf_hqx.c.

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

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

Definition at line 94 of file vf_hqx.c.

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

Definition at line 97 of file vf_hqx.c.

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

Definition at line 100 of file vf_hqx.c.

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

#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]
#define SHF(x, rot, n)
Definition: vf_hqx.c:97

Definition at line 105 of file vf_hqx.c.

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

#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; \
}
ptrdiff_t size
Definition: opengl_enc.c:101
const char * arg
Definition: jacosubdec.c:66
static av_always_inline void hqx_filter(const ThreadData *td, int jobnr, int nb_jobs, int n)
Definition: vf_hqx.c:381
return
An instance of a filter.
Definition: avfilter.h:633

Definition at line 451 of file vf_hqx.c.

Typedef Documentation

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 ( hqx  )
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 bayer_to_yv12_wrapper(), hqx_filter(), yv12_copy(), and yv12_interpolate().

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().

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

Definition at line 74 of file vf_hqx.c.

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

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 81 of file vf_hqx.c.

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

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 117 of file vf_hqx.c.

Referenced by hqx_filter().

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 167 of file vf_hqx.c.

Referenced by hqx_filter().

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 233 of file vf_hqx.c.

Referenced by hqx_filter().

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

Definition at line 381 of file vf_hqx.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 462 of file vf_hqx.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 471 of file vf_hqx.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 485 of file vf_hqx.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 509 of file vf_hqx.c.

Variable Documentation

const AVOption hqx_options[]
static
Initial value:
= {
{ "n", "set scale factor", OFFSET(n), AV_OPT_TYPE_INT, {.i64 = 3}, 2, 4, .flags = FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
int n
Definition: avisynth_c.h:547
#define OFFSET(x)
Definition: vf_hqx.c:49
#define FLAGS
Definition: vf_hqx.c:50

Definition at line 51 of file vf_hqx.c.

const AVFilterPad hqx_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_hqx.c:485
#define NULL
Definition: coverity.c:32

Definition at line 536 of file vf_hqx.c.

const AVFilterPad hqx_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_output(AVFilterLink *outlink)
Definition: vf_hqx.c:471

Definition at line 545 of file vf_hqx.c.

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,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
static av_cold int init(AVFilterContext *ctx)
Definition: vf_hqx.c:509
static int query_formats(AVFilterContext *ctx)
Definition: vf_hqx.c:462
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:442
Definition: hqx.h:62
static const AVFilterPad hqx_outputs[]
Definition: vf_hqx.c:545
static const AVFilterPad hqx_inputs[]
Definition: vf_hqx.c:536
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
static int flags
Definition: cpu.c:47

Definition at line 554 of file vf_hqx.c.