FFmpeg
Macros | Functions | Variables
vf_fspp.c File Reference
#include "libavutil/emms.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "internal.h"
#include "qp_table.h"
#include "vf_fspp.h"
#include "video.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(FSPPContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define STORE(pos)
 
#define STORE2(pos)
 

Functions

 AVFILTER_DEFINE_CLASS (fspp)
 
static void store_slice_c (uint8_t *dst, int16_t *src, ptrdiff_t dst_stride, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, ptrdiff_t log2_scale)
 
static void store_slice2_c (uint8_t *dst, int16_t *src, ptrdiff_t dst_stride, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, ptrdiff_t log2_scale)
 
static void mul_thrmat_c (int16_t *thr_adr_noq, int16_t *thr_adr, int q)
 
static void filter (FSPPContext *p, uint8_t *dst, uint8_t *src, int dst_stride, int src_stride, int width, int height, uint8_t *qp_store, int qp_stride, int is_luma)
 
static void column_fidct_c (int16_t *thr_adr, int16_t *data, int16_t *output, int cnt)
 
static void row_idct_c (int16_t *workspace, int16_t *output_adr, ptrdiff_t output_stride, int cnt)
 
static void row_fdct_c (int16_t *data, const uint8_t *pixels, ptrdiff_t line_size, int cnt)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption fspp_options []
 
static const uint8_t dither [8][8]
 
static const short custom_threshold [64]
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad fspp_inputs []
 
const AVFilter ff_vf_fspp
 

Detailed Description

Fast Simple Post-processing filter This implementation is based on an algorithm described in "Aria Nosratinia Embedded Post-Processing for Enhancement of Compressed Images (1999)" (http://www.utdallas.edu/~aria/papers/vlsisp99.pdf) Further, with splitting (I)DCT into horizontal/vertical passes, one of them can be performed once per block, not per pixel. This allows for much higher speed.

Originally written by Michael Niedermayer and Nikolaj for the MPlayer project, and ported by Arwa Arif for FFmpeg.

Definition in file vf_fspp.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 48 of file vf_fspp.c.

◆ FLAGS

Definition at line 49 of file vf_fspp.c.

◆ STORE

#define STORE (   pos)
Value:
temp = (src[x + pos] + (d[pos] >> log2_scale)) >> (6 - log2_scale); \
src[x + pos] = src[x + pos - 8 * src_stride] = 0; \
if (temp & 0x100) temp = ~(temp >> 31); \
dst[x + pos] = temp;

◆ STORE2

#define STORE2 (   pos)
Value:
temp = (src[x + pos] + src[x + pos + 16 * src_stride] + (d[pos] >> log2_scale)) >> (6 - log2_scale); \
src[x + pos + 16 * src_stride] = 0; \
if (temp & 0x100) temp = ~(temp >> 31); \
dst[x + pos] = temp;

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( fspp  )

◆ store_slice_c()

static void store_slice_c ( uint8_t *  dst,
int16_t *  src,
ptrdiff_t  dst_stride,
ptrdiff_t  src_stride,
ptrdiff_t  width,
ptrdiff_t  height,
ptrdiff_t  log2_scale 
)
static

Definition at line 86 of file vf_fspp.c.

Referenced by config_input().

◆ store_slice2_c()

static void store_slice2_c ( uint8_t *  dst,
int16_t *  src,
ptrdiff_t  dst_stride,
ptrdiff_t  src_stride,
ptrdiff_t  width,
ptrdiff_t  height,
ptrdiff_t  log2_scale 
)
static

Definition at line 116 of file vf_fspp.c.

Referenced by config_input().

◆ mul_thrmat_c()

static void mul_thrmat_c ( int16_t *  thr_adr_noq,
int16_t *  thr_adr,
int  q 
)
static

Definition at line 145 of file vf_fspp.c.

Referenced by config_input().

◆ filter()

static void filter ( FSPPContext p,
uint8_t *  dst,
uint8_t *  src,
int  dst_stride,
int  src_stride,
int  width,
int  height,
uint8_t *  qp_store,
int  qp_stride,
int  is_luma 
)
static

Definition at line 152 of file vf_fspp.c.

Referenced by filter_frame().

◆ column_fidct_c()

static void column_fidct_c ( int16_t *  thr_adr,
int16_t *  data,
int16_t *  output,
int  cnt 
)
static

Definition at line 250 of file vf_fspp.c.

Referenced by config_input().

◆ row_idct_c()

static void row_idct_c ( int16_t *  workspace,
int16_t *  output_adr,
ptrdiff_t  output_stride,
int  cnt 
)
static

Definition at line 373 of file vf_fspp.c.

Referenced by config_input().

◆ row_fdct_c()

static void row_fdct_c ( int16_t *  data,
const uint8_t *  pixels,
ptrdiff_t  line_size,
int  cnt 
)
static

Definition at line 435 of file vf_fspp.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 506 of file vf_fspp.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 537 of file vf_fspp.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 639 of file vf_fspp.c.

Variable Documentation

◆ fspp_options

const AVOption fspp_options[]
static
Initial value:
= {
{ "quality", "set quality", OFFSET(log2_count), AV_OPT_TYPE_INT, {.i64 = 4}, 4, MAX_LEVEL, FLAGS },
{ "qp", "force a constant quantizer parameter", OFFSET(qp), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 64, FLAGS },
{ "strength", "set filter strength", OFFSET(strength), AV_OPT_TYPE_INT, {.i64 = 0}, -15, 32, FLAGS },
{ "use_bframe_qp", "use B-frames' QP", OFFSET(use_bframe_qp), AV_OPT_TYPE_BOOL,{.i64 = 0}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 50 of file vf_fspp.c.

◆ dither

const uint8_t dither[8][8]
static
Initial value:
= {
{ 0, 48, 12, 60, 3, 51, 15, 63, },
{ 32, 16, 44, 28, 35, 19, 47, 31, },
{ 8, 56, 4, 52, 11, 59, 7, 55, },
{ 40, 24, 36, 20, 43, 27, 39, 23, },
{ 2, 50, 14, 62, 1, 49, 13, 61, },
{ 34, 18, 46, 30, 33, 17, 45, 29, },
{ 10, 58, 6, 54, 9, 57, 5, 53, },
{ 42, 26, 38, 22, 41, 25, 37, 21, },
}

Definition at line 60 of file vf_fspp.c.

Referenced by ac3_decode_transform_coeffs_ch(), aptx_invert_quantization(), aptx_process_subband(), aptx_quantize_difference(), check_yuv2yuv1(), check_yuv2yuvX(), encode_frame(), ff_yuv2planeX_8_lasx(), render_charset(), rv40_loop_filter(), set_frame(), store_slice16_c(), store_slice2_c(), store_slice_c(), yuv2plane1_8_c(), yuv2planeX(), yuv2planeX_8_16(), yuv2planeX_8_c(), yuv2planeX_8_ref(), and yuv2planeX_u().

◆ custom_threshold

const short custom_threshold[64]
static
Initial value:
= {
71, 296, 295, 237, 71, 40, 38, 19,
245, 193, 185, 121, 102, 73, 53, 27,
158, 129, 141, 107, 97, 73, 50, 26,
102, 116, 109, 98, 82, 66, 45, 23,
71, 94, 95, 81, 70, 56, 38, 20,
56, 77, 74, 66, 56, 44, 30, 15,
38, 53, 50, 45, 38, 30, 21, 11,
20, 27, 26, 23, 20, 15, 11, 5
}

Definition at line 71 of file vf_fspp.c.

Referenced by filter_frame().

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ fspp_inputs

const AVFilterPad fspp_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
}

Definition at line 647 of file vf_fspp.c.

◆ ff_vf_fspp

const AVFilter ff_vf_fspp
Initial value:
= {
.name = "fspp",
.description = NULL_IF_CONFIG_SMALL("Apply Fast Simple Post-processing filter."),
.priv_size = sizeof(FSPPContext),
.priv_class = &fspp_class,
}

Definition at line 656 of file vf_fspp.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:172
FLAGS
#define FLAGS
Definition: vf_fspp.c:49
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
fspp_inputs
static const AVFilterPad fspp_inputs[]
Definition: vf_fspp.c:647
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:36
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_fspp.c:506
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:192
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_fspp.c:496
MAX_LEVEL
#define MAX_LEVEL
Definition: rl.h:36
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:106
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_fspp.c:639
OFFSET
#define OFFSET(x)
Definition: vf_fspp.c:48
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
pos
unsigned int pos
Definition: spdifenc.c:413
FSPPContext
Definition: vf_fspp.h:54
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
temp
else temp
Definition: vf_mcdeint.c:263
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_fspp.c:537
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:193
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
d
d
Definition: ffmpeg_filter.c:368
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:155
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72