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

Simple post processing filter. More...

#include "libavcodec/dsputil.h"
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "internal.h"
#include "vf_spp.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 STORE(pos)
 

Enumerations

enum  mode {
  MODE_NONE, MODE_RO, MODE_RW, MODE_TOGGLE,
  MODE_RANDOM, NB_MODES, PROGRESSIVE, TOP_FIRST,
  BOTTOM_FIRST, TOP_FIRST_ANALYZE, BOTTOM_FIRST_ANALYZE, ANALYZE,
  FULL_ANALYZE, AUTO, AUTO_ANALYZE, MODE_HARD,
  MODE_SOFT, NB_MODES
}
 

Functions

 AVFILTER_DEFINE_CLASS (spp)
 
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 add_block (int16_t *dst, int linesize, const int16_t block[64])
 
static int norm_qscale (int qscale, int type)
 
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)
 
static int query_formats (AVFilterContext *ctx)
 
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 init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption spp_options []
 
static const uint8_t ldither [8][8]
 
static const uint8_t offset [127][2]
 
static const AVFilterPad spp_inputs []
 
static const AVFilterPad spp_outputs []
 
AVFilter avfilter_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

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

Definition at line 48 of file vf_spp.c.

Definition at line 49 of file vf_spp.c.

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

Enumeration Type Documentation

enum mode
Enumerator:
MODE_NONE 
MODE_RO 
MODE_RW 
MODE_TOGGLE 
MODE_RANDOM 
NB_MODES 
PROGRESSIVE 
TOP_FIRST 
BOTTOM_FIRST 
TOP_FIRST_ANALYZE 
BOTTOM_FIRST_ANALYZE 
ANALYZE 
FULL_ANALYZE 
AUTO 
AUTO_ANALYZE 
MODE_HARD 
MODE_SOFT 
NB_MODES 

Definition at line 42 of file vf_spp.c.

Function Documentation

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

Definition at line 98 of file vf_spp.c.

Referenced by init().

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

Definition at line 119 of file vf_spp.c.

Referenced by init().

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 141 of file vf_spp.c.

Referenced by init().

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

Definition at line 171 of file vf_spp.c.

Referenced by filter().

static int norm_qscale ( int  qscale,
int  type 
)
inlinestatic

Definition at line 184 of file vf_spp.c.

Referenced by 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 
)
static

Definition at line 195 of file vf_spp.c.

Referenced by filter_frame().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 250 of file vf_spp.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 264 of file vf_spp.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 287 of file vf_spp.c.

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

Definition at line 361 of file vf_spp.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 376 of file vf_spp.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 394 of file vf_spp.c.

Variable Documentation

const AVOption spp_options[]
static
Initial value:
= {
{ "quality", "set quality", OFFSET(log2_count), AV_OPT_TYPE_INT, {.i64 = 3}, 0, MAX_LEVEL, FLAGS },
{ "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, "mode" },
{ "hard", "hard thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_HARD}, INT_MIN, INT_MAX, FLAGS, "mode" },
{ "soft", "soft thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_SOFT}, INT_MIN, INT_MAX, FLAGS, "mode" },
{ "use_bframe_qp", "use B-frames' QP", OFFSET(use_bframe_qp), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 50 of file vf_spp.c.

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 63 of file vf_spp.c.

Referenced by filter().

const uint8_t offset[127][2]
static
Initial value:
= {
{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 74 of file vf_spp.c.

Referenced by filter().

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

Definition at line 407 of file vf_spp.c.

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

Definition at line 417 of file vf_spp.c.

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

Definition at line 425 of file vf_spp.c.