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 "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)
 
#define STORE16(pos)
 

Enumerations

enum  mode {
  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_next (const AVClass *prev)
 
static voidchild_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 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_dict (AVFilterContext *ctx, AVDictionary **opts)
 
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 [127][2]
 
static const AVFilterPad spp_inputs []
 
static const AVFilterPad spp_outputs []
 
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

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

Definition at line 58 of file vf_spp.c.

Definition at line 59 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)
else temp
Definition: vf_mcdeint.c:257
if()
Definition: avfilter.c:975
float y
AVS_Value src
Definition: avisynth_c.h:482

Referenced by store_slice_c().

#define STORE16 (   pos)
Value:
do { \
temp = ((src[x + y*src_linesize + pos] << log2_scale) + (d[pos]>>1)) >> 5; \
if (temp & mask ) \
temp = ~(temp >> 31); \
dst[x + y*dst_linesize + pos] = temp; \
} while (0)
else temp
Definition: vf_mcdeint.c:257
if()
Definition: avfilter.c:975
static const uint16_t mask[17]
Definition: lzw.c:38
float y
AVS_Value src
Definition: avisynth_c.h:482

Referenced by store_slice16_c().

Enumeration Type Documentation

enum mode
Enumerator
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 41 of file vf_spp.c.

Function Documentation

static const AVClass* child_class_next ( const AVClass prev)
static

Definition at line 47 of file vf_spp.c.

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

Definition at line 52 of file vf_spp.c.

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

Definition at line 116 of file vf_spp.c.

Referenced by init_dict().

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

Definition at line 137 of file vf_spp.c.

Referenced by init_dict().

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

Referenced by init_dict().

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

Referenced by filter().

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

Definition at line 220 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,
int  depth 
)
static

Definition at line 232 of file vf_spp.c.

Referenced by filter_frame().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 304 of file vf_spp.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 329 of file vf_spp.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 353 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 442 of file vf_spp.c.

static av_cold int init_dict ( AVFilterContext ctx,
AVDictionary **  opts 
)
static

Definition at line 457 of file vf_spp.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 485 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 }
}
#define NULL
Definition: coverity.c:32
mode
Definition: f_perms.c:27
#define OFFSET(x)
Definition: vf_spp.c:58
#define MAX_LEVEL
Definition: rl.h:35
#define FLAGS
Definition: vf_spp.c:59

Definition at line 60 of file vf_spp.c.

const AVClass spp_class
static
Initial value:
= {
.class_name = "spp",
.item_name = av_default_item_name,
.option = spp_options,
.child_class_next = child_class_next,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
static const AVClass * child_class_next(const AVClass *prev)
Definition: vf_spp.c:47
av_default_item_name
static void * child_next(void *obj, void *prev)
Definition: vf_spp.c:52
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
Definition: log.h:113
static const AVOption spp_options[]
Definition: vf_spp.c:60

Definition at line 70 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 81 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 92 of file vf_spp.c.

Referenced by adx_decode(), aiff_read_header(), alloc_and_copy(), alloc_frame_buffer(), ape_decode_frame(), apng_read_header(), apply_window_and_mdct(), asf_parse_packet(), asf_write_markers(), asf_write_packet(), assign_pair(), av_probe_input_buffer2(), avc_biwgt_16width_msa(), avc_biwgt_4x2_msa(), avc_biwgt_4x4multiple_msa(), avc_biwgt_8width_msa(), avc_wgt_16width_msa(), avc_wgt_4x2_msa(), avc_wgt_4x4multiple_msa(), avc_wgt_8width_msa(), avi_extract_stream_metadata(), avio_seek(), avpriv_copy_pce_data(), aw_parse_coords(), bfi_decode_frame(), bidir_sal(), bitplane_decoding(), bl_intrp(), buffer_offset(), bytestream2_seek(), bytestream2_seek_p(), celt_decode_allocation(), celt_decode_band(), celt_decode_final_energy(), celt_decode_fine_energy(), chroma_4mv_motion(), chroma_4mv_motion_lowres(), chroma_tc(), cin_decode_lzss(), comp_block(), comp_interp_index(), comp_ppf_coeff(), compute_pkt_fields(), cook_decode_frame(), copy_cell(), count_ts(), decode_0(), decode_8_pulses_35bits(), decode_blockcode(), decode_blocks(), decode_bytes_and_gain(), decode_cell(), decode_dds1(), decode_decorrelation_matrix(), decode_dsw1(), decode_entropy_coded_image(), decode_fixed_sparse(), decode_frame(), decode_init(), decode_init_static(), decode_interframe_v4(), decode_interframe_v4a(), decode_log_area(), decode_rgb_frame(), decode_rle(), decode_scalefactors(), decode_subframe(), decode_tilehdr(), decode_tsw1(), dnxhd_encode_picture(), dnxhd_init_vlc(), dnxhd_setup_threads_slices(), draw_slice(), dss_723_1_read_packet(), dss_read_seek(), dss_sp_read_packet(), dss_sp_update_state(), dv_frame_offset(), dv_read_seek(), dyn_buf_seek(), encode_422_bitstream(), encode_block(), encode_callback(), encode_frame(), encode_init(), encode_plane(), encode_rgb_frame(), estimate_timings_from_pts(), ff_adx_decode_header(), ff_copy_and_dup(), ff_cos(), ff_draw_horiz_band(), ff_h264_biweight_pixels16_8_mmi(), ff_h264_biweight_pixels4_8_mmi(), ff_h264_biweight_pixels8_8_mmi(), ff_h264_chroma422_dc_dequant_idct(), ff_h264_decode_init_vlc(), ff_h264_draw_horiz_band(), ff_h264_filter_mb(), ff_h264_luma_dc_dequant_idct(), ff_hevc_hls_residual_coding(), ff_huff_gen_len_table(), ff_mpa_synth_filter_TMPL(), ff_mpeg4_encode_mb(), ff_mpv_export_qp_table(), ff_mspel_motion(), ff_rtmpe_gen_pub_key(), ff_rtp_send_latm(), ff_rv34_decode_frame(), ff_snow_get_buffer(), ff_spdif_probe(), ff_spdif_read_packet(), ff_svq3_luma_dc_dequant_idct_c(), filter(), filter_frame(), find_header(), find_headers_search_validate(), fixup_vorbis_headers(), flac_fifo_read(), flac_fifo_read_wrap(), flac_read_header(), flv_read_header(), gen_fcb_excitation(), get_buffer_with_edge(), get_intra_count(), get_p_cbp(), get_residual(), gmc1_motion(), gsm_decode_block(), h263_mv4_search(), h_block_filter(), hashNext(), hevc_biwgt_copy_12w_msa(), hevc_biwgt_copy_16multx4mult_msa(), hevc_biwgt_copy_4w_msa(), hevc_biwgt_copy_6w_msa(), hevc_biwgt_copy_8w_msa(), hevc_hv_biwgt_4t_4multx8mult_msa(), hevc_hv_biwgt_4t_4x2_msa(), hevc_hv_biwgt_4t_4x4_msa(), hevc_hv_biwgt_4t_6w_msa(), hevc_hv_biwgt_4t_8multx4mult_msa(), hevc_hv_biwgt_4t_8x2_msa(), hevc_hv_biwgt_4t_8x6_msa(), hevc_hv_biwgt_8t_4w_msa(), hevc_hv_biwgt_8t_8multx2mult_msa(), hevc_hz_biwgt_4t_12w_msa(), hevc_hz_biwgt_4t_16w_msa(), hevc_hz_biwgt_4t_24w_msa(), hevc_hz_biwgt_4t_32w_msa(), hevc_hz_biwgt_4t_4x2_msa(), hevc_hz_biwgt_4t_4x4_msa(), hevc_hz_biwgt_4t_4x8multiple_msa(), hevc_hz_biwgt_4t_6w_msa(), hevc_hz_biwgt_4t_8x2_msa(), hevc_hz_biwgt_4t_8x4multiple_msa(), hevc_hz_biwgt_4t_8x6_msa(), hevc_hz_biwgt_8t_16w_msa(), hevc_hz_biwgt_8t_24w_msa(), hevc_hz_biwgt_8t_32w_msa(), hevc_hz_biwgt_8t_48w_msa(), hevc_hz_biwgt_8t_4w_msa(), hevc_hz_biwgt_8t_64w_msa(), hevc_hz_biwgt_8t_8w_msa(), hevc_vt_biwgt_4t_12w_msa(), hevc_vt_biwgt_4t_16w_msa(), hevc_vt_biwgt_4t_24w_msa(), hevc_vt_biwgt_4t_32w_msa(), hevc_vt_biwgt_4t_4x2_msa(), hevc_vt_biwgt_4t_4x4_msa(), hevc_vt_biwgt_4t_4x8multiple_msa(), hevc_vt_biwgt_4t_6w_msa(), hevc_vt_biwgt_4t_8x2_msa(), hevc_vt_biwgt_4t_8x4multiple_msa(), hevc_vt_biwgt_4t_8x6_msa(), hevc_vt_biwgt_8t_12w_msa(), hevc_vt_biwgt_8t_16multx2mult_msa(), hevc_vt_biwgt_8t_4w_msa(), hevc_vt_biwgt_8t_8w_msa(), hls_slice_data_wpp(), horizontal_fill(), imdct_output(), init_ref(), ism_seek(), lag_decode_arith_plane(), libvorbis_encode_init(), lrc_probe(), lsp2lpc(), luma_mc_bi(), luma_mc_uni(), matroska_parse_frame(), matroska_parse_seekhead_entry(), matroska_parse_wavpack(), mc_dir_part(), md5_finish(), mkv_strip_wavpack(), mkv_write_block(), motion_search(), mov_flush_fragment_interleaving(), mov_probe(), mov_read_trun(), mov_write_sidx_tag(), mp_read_changes_map(), mxf_absolute_bodysid_offset(), mxf_compute_ptses_fake_index(), nsv_probe(), ogg_write_vorbiscomment(), oggvorbis_decode_init(), pop_integer(), postProcess_TMPL(), probe(), process_options(), ptx_decode_frame(), put_hevc_epel_bi_h(), put_hevc_epel_bi_hv(), put_hevc_epel_bi_v(), put_hevc_epel_uni_h(), put_hevc_epel_uni_hv(), put_hevc_epel_uni_v(), put_hevc_epel_uni_w_h(), put_hevc_epel_uni_w_hv(), put_hevc_epel_uni_w_v(), put_hevc_pel_bi_pixels(), put_hevc_pel_uni_w_pixels(), put_hevc_qpel_bi_h(), put_hevc_qpel_bi_hv(), put_hevc_qpel_bi_v(), put_hevc_qpel_uni_h(), put_hevc_qpel_uni_hv(), put_hevc_qpel_uni_v(), put_hevc_qpel_uni_w_h(), put_hevc_qpel_uni_w_hv(), put_hevc_qpel_uni_w_v(), qdm2_fft_decode_tones(), qdm2_fft_init_coefficient(), qdm2_fft_tone_synthesizer(), quantize_value(), radix_count(), read_braindead_odml_indx(), read_frame_data(), read_header(), read_packet(), read_tfra(), read_ts(), read_uncompressed_sgi(), read_var_block_data(), revert_channel_correlation(), rpl_read_header(), rv10_decode_frame(), sao_edge_restore_0(), sao_edge_restore_1(), seg_write_packet(), seq_decode_op3(), set_sar(), silk_decode_lpc(), silk_lsf2lpc(), svq1_decode_init(), svq1_encode_plane(), svq3_decode_init(), tgv_decode_inter(), transform_skip(), unpack(), unpack_intraframe(), unpack_parse_unit(), v_block_filter(), vb_decode_framedata(), vble_decode_frame(), vble_restore_plane(), vcr1_decode_frame(), vertical_frame_pack(), vorbis_floor1_decode(), vp3_draw_horiz_band(), vp56_get_vectors_predictors(), write_mb_info(), write_packet(), writer_print_data(), writer_print_integers(), wtvfile_seek(), x11grab_read_header(), x8_vlc_init(), xan_decode_chroma(), yae_flush(), yuv2NBPS(), yuv2plane1_8_c(), and yuv2yuvX_TMPL().

const AVFilterPad spp_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_spp.c:353
static int config_input(AVFilterLink *inlink)
Definition: vf_spp.c:329

Definition at line 499 of file vf_spp.c.

const AVFilterPad spp_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 509 of file vf_spp.c.

AVFilter ff_vf_spp
Initial value:
= {
.name = "spp",
.description = NULL_IF_CONFIG_SMALL("Apply a simple post processing filter."),
.priv_size = sizeof(SPPContext),
.priv_class = &spp_class,
}
static int query_formats(AVFilterContext *ctx)
Definition: vf_spp.c:304
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_spp.c:442
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_spp.c:485
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
static const AVClass spp_class
Definition: vf_spp.c:70
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
Definition: vf_spp.c:457
static const AVFilterPad spp_outputs[]
Definition: vf_spp.c:509
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
#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:459
static const AVFilterPad spp_inputs[]
Definition: vf_spp.c:499
static int flags
Definition: cpu.c:47

Definition at line 517 of file vf_spp.c.