FFmpeg
Macros | Enumerations | Functions | Variables
vf_spp.c File Reference
#include "libavutil/emms.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "filters.h"
#include "qp_table.h"
#include "vf_spp.h"
#include "video.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(SPPContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define TFLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define STORE(pos)
 
#define STORE16(pos)
 

Enumerations

enum  mode {
  FF_EBUR128_MODE_M = (1 << 0), FF_EBUR128_MODE_S = (1 << 1) | FF_EBUR128_MODE_M, FF_EBUR128_MODE_I = (1 << 2) | FF_EBUR128_MODE_M, FF_EBUR128_MODE_LRA = (1 << 3) | FF_EBUR128_MODE_S,
  FF_EBUR128_MODE_SAMPLE_PEAK = (1 << 4) | FF_EBUR128_MODE_M, MODE_NONE, MODE_RO, MODE_RW,
  MODE_TOGGLE, MODE_RANDOM, NB_MODES, MODE_COVER,
  MODE_BLUR, NB_MODES, MODE_HARD, MODE_SOFT,
  MODE_MEDIUM, MODE_HARD, MODE_SOFT, NB_MODES
}
 

Functions

static const AVClasschild_class_iterate (void **iter)
 
static void * child_next (void *obj, void *prev)
 
static void hardthresh_c (int16_t dst[64], const int16_t src[64], int qp, const uint8_t *permutation)
 
static void softthresh_c (int16_t dst[64], const int16_t src[64], int qp, const uint8_t *permutation)
 
static void store_slice_c (uint8_t *dst, const int16_t *src, int dst_linesize, int src_linesize, int width, int height, int log2_scale, const uint8_t dither[8][8])
 
static void store_slice16_c (uint16_t *dst, const int16_t *src, int dst_linesize, int src_linesize, int width, int height, int log2_scale, const uint8_t dither[8][8], int depth)
 
static void add_block (uint16_t *dst, int linesize, const int16_t block[64])
 
static void filter (SPPContext *p, uint8_t *dst, uint8_t *src, int dst_linesize, int src_linesize, int width, int height, const uint8_t *qp_table, int qp_stride, int is_luma, int depth)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
static av_cold int preinit (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption spp_options []
 
static const AVClass spp_class
 
static const uint8_t ldither [8][8]
 
static const uint8_t offset [128][2]
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad spp_inputs []
 
const AVFilter ff_vf_spp
 

Detailed Description

Simple post processing filter

This implementation is based on an algorithm described in "Aria Nosratinia Embedded Post-Processing for Enhancement of Compressed Images (1999)"

Originally written by Michael Niedermayer for the MPlayer project, and ported by Clément Bœsch for FFmpeg.

Definition in file vf_spp.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 65 of file vf_spp.c.

◆ FLAGS

Definition at line 66 of file vf_spp.c.

◆ TFLAGS

Definition at line 67 of file vf_spp.c.

◆ STORE

#define STORE (   pos)
Value:
do { \
temp = (src[x + y*src_linesize + pos] * (1 << log2_scale) + d[pos]) >> 6;\
if (temp & 0x100) \
temp = ~(temp >> 31); \
dst[x + y*dst_linesize + pos] = temp; \
} while (0)

◆ STORE16

#define STORE16 (   pos)
Value:
do { \
temp = (src[x + y*src_linesize + pos] * (1 << log2_scale) + (d[pos]>>1)) >> 5; \
if (temp & mask ) \
temp = ~(temp >> 31); \
dst[x + y*dst_linesize + pos] = temp; \
} while (0)

Enumeration Type Documentation

◆ mode

enum mode
Enumerator
FF_EBUR128_MODE_M 

can resurrrect and call ff_ebur128_loudness_momentary

FF_EBUR128_MODE_S 

can call ff_ebur128_loudness_shortterm

FF_EBUR128_MODE_I 

can call ff_ebur128_loudness_global_* and ff_ebur128_relative_threshold

FF_EBUR128_MODE_LRA 

can call ff_ebur128_loudness_range

FF_EBUR128_MODE_SAMPLE_PEAK 

can call ff_ebur128_sample_peak

MODE_NONE 
MODE_RO 
MODE_RW 
MODE_TOGGLE 
MODE_RANDOM 
NB_MODES 
MODE_COVER 
MODE_BLUR 
NB_MODES 
MODE_HARD 
MODE_SOFT 
MODE_MEDIUM 
MODE_HARD 
MODE_SOFT 
NB_MODES 

Definition at line 46 of file vf_spp.c.

Function Documentation

◆ child_class_iterate()

static const AVClass* child_class_iterate ( void **  iter)
static

Definition at line 52 of file vf_spp.c.

◆ child_next()

static void* child_next ( void *  obj,
void *  prev 
)
static

Definition at line 59 of file vf_spp.c.

◆ hardthresh_c()

static void hardthresh_c ( int16_t  dst[64],
const int16_t  src[64],
int  qp,
const uint8_t *  permutation 
)
static

Definition at line 125 of file vf_spp.c.

Referenced by config_input().

◆ softthresh_c()

static void softthresh_c ( int16_t  dst[64],
const int16_t  src[64],
int  qp,
const uint8_t *  permutation 
)
static

Definition at line 146 of file vf_spp.c.

Referenced by config_input().

◆ store_slice_c()

static void store_slice_c ( uint8_t *  dst,
const int16_t *  src,
int  dst_linesize,
int  src_linesize,
int  width,
int  height,
int  log2_scale,
const uint8_t  dither[8][8] 
)
static

Definition at line 168 of file vf_spp.c.

Referenced by config_input().

◆ store_slice16_c()

static void store_slice16_c ( uint16_t *  dst,
const int16_t *  src,
int  dst_linesize,
int  src_linesize,
int  width,
int  height,
int  log2_scale,
const uint8_t  dither[8][8],
int  depth 
)
static

Definition at line 198 of file vf_spp.c.

Referenced by filter().

◆ add_block()

static void add_block ( uint16_t *  dst,
int  linesize,
const int16_t  block[64] 
)
inlinestatic

Definition at line 229 of file vf_spp.c.

Referenced by filter().

◆ filter()

static void filter ( SPPContext p,
uint8_t *  dst,
uint8_t *  src,
int  dst_linesize,
int  src_linesize,
int  width,
int  height,
const uint8_t *  qp_table,
int  qp_stride,
int  is_luma,
int  depth 
)
static

Definition at line 245 of file vf_spp.c.

Referenced by filter_frame().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 334 of file vf_spp.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 365 of file vf_spp.c.

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 446 of file vf_spp.c.

◆ preinit()

static av_cold int preinit ( AVFilterContext ctx)
static

Definition at line 461 of file vf_spp.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 472 of file vf_spp.c.

Variable Documentation

◆ spp_options

const AVOption spp_options[]
static
Initial value:
= {
{ "quality", "set quality", OFFSET(log2_count), AV_OPT_TYPE_INT, {.i64 = 3}, 0, MAX_LEVEL, TFLAGS },
{ "qp", "force a constant quantizer parameter", OFFSET(qp), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 63, FLAGS },
{ "mode", "set thresholding mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MODE_HARD}, 0, NB_MODES - 1, FLAGS, .unit = "mode" },
{ "hard", "hard thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_HARD}, INT_MIN, INT_MAX, FLAGS, .unit = "mode" },
{ "soft", "soft thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_SOFT}, INT_MIN, INT_MAX, FLAGS, .unit = "mode" },
{ "use_bframe_qp", "use B-frames' QP", OFFSET(use_bframe_qp), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 68 of file vf_spp.c.

◆ spp_class

const AVClass spp_class
static
Initial value:
= {
.class_name = "spp",
.item_name = av_default_item_name,
.option = spp_options,
.child_class_iterate = child_class_iterate,
}

Definition at line 78 of file vf_spp.c.

◆ ldither

const uint8_t ldither[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 89 of file vf_spp.c.

Referenced by filter().

◆ offset

const uint8_t offset[128][2]
static
Initial value:
= {
{0,0},
{0,0},
{0,0}, {4,4},
{0,0}, {2,2}, {6,4}, {4,6},
{0,0}, {5,1}, {2,2}, {7,3}, {4,4}, {1,5}, {6,6}, {3,7},
{0,0}, {4,0}, {1,1}, {5,1}, {3,2}, {7,2}, {2,3}, {6,3},
{0,4}, {4,4}, {1,5}, {5,5}, {3,6}, {7,6}, {2,7}, {6,7},
{0,0}, {0,2}, {0,4}, {0,6}, {1,1}, {1,3}, {1,5}, {1,7},
{2,0}, {2,2}, {2,4}, {2,6}, {3,1}, {3,3}, {3,5}, {3,7},
{4,0}, {4,2}, {4,4}, {4,6}, {5,1}, {5,3}, {5,5}, {5,7},
{6,0}, {6,2}, {6,4}, {6,6}, {7,1}, {7,3}, {7,5}, {7,7},
{0,0}, {4,4}, {0,4}, {4,0}, {2,2}, {6,6}, {2,6}, {6,2},
{0,2}, {4,6}, {0,6}, {4,2}, {2,0}, {6,4}, {2,4}, {6,0},
{1,1}, {5,5}, {1,5}, {5,1}, {3,3}, {7,7}, {3,7}, {7,3},
{1,3}, {5,7}, {1,7}, {5,3}, {3,1}, {7,5}, {3,5}, {7,1},
{0,1}, {4,5}, {0,5}, {4,1}, {2,3}, {6,7}, {2,7}, {6,3},
{0,3}, {4,7}, {0,7}, {4,3}, {2,1}, {6,5}, {2,5}, {6,1},
{1,0}, {5,4}, {1,4}, {5,0}, {3,2}, {7,6}, {3,6}, {7,2},
{1,2}, {5,6}, {1,6}, {5,2}, {3,0}, {7,4}, {3,4}, {7,0},
}

Definition at line 100 of file vf_spp.c.

Referenced by filter().

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ spp_inputs

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

Definition at line 482 of file vf_spp.c.

◆ ff_vf_spp

const AVFilter ff_vf_spp
Initial value:
= {
.name = "spp",
.description = NULL_IF_CONFIG_SMALL("Apply a simple post processing filter."),
.priv_size = sizeof(SPPContext),
.process_command = process_command,
.priv_class = &spp_class,
}

Definition at line 491 of file vf_spp.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_spp.c:365
spp_options
static const AVOption spp_options[]
Definition: vf_spp.c:68
mask
int mask
Definition: mediacodecdec_common.c:154
MODE_SOFT
@ MODE_SOFT
Definition: vf_spp.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
mode
Definition: swscale.c:52
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:502
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
preinit
static av_cold int preinit(AVFilterContext *ctx)
Definition: vf_spp.c:461
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_spp.c:446
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:518
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:500
child_class_iterate
static const AVClass * child_class_iterate(void **iter)
Definition: vf_spp.c:52
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_spp.c:317
spp_class
static const AVClass spp_class
Definition: vf_spp.c:78
OFFSET
#define OFFSET(x)
Definition: vf_spp.c:65
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:37
NB_MODES
@ NB_MODES
Definition: vf_spp.c:49
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:86
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_spp.c:472
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:499
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:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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:87
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
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:85
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:503
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:517
AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_FILTER
Definition: log.h:36
SPPContext
Definition: vf_spp.h:31
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:94
AVClass::child_next
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
Definition: log.h:149
TFLAGS
#define TFLAGS
Definition: vf_spp.c:67
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_spp.c:334
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:107
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:501
FLAGS
#define FLAGS
Definition: vf_spp.c:66
spp_inputs
static const AVFilterPad spp_inputs[]
Definition: vf_spp.c:482
pos
unsigned int pos
Definition: spdifenc.c:414
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
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:78
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
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:77
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
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:80
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:190
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:79
child_next
static void * child_next(void *obj, void *prev)
Definition: vf_spp.c:59
MODE_HARD
@ MODE_HARD
Definition: vf_spp.c:47
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
src
#define src
Definition: vp8dsp.c:248