FFmpeg
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
vf_paletteuse.c File Reference

Use a palette to downsample an input video stream. More...

#include "libavutil/bprint.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/qsort.h"
#include "avfilter.h"
#include "filters.h"
#include "framesync.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  color_node
 
struct  cached_color
 
struct  cache_node
 
struct  PaletteUseContext
 
struct  nearest_color
 
struct  stack_node
 
struct  color
 
struct  color_rect
 

Macros

#define NBITS   5
 
#define CACHE_SIZE   (1<<(3*NBITS))
 
#define OFFSET(x)   offsetof(PaletteUseContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define COLORMAP_NEAREST(search, palette, root, target, trans_thresh)
 
#define INDENT   4
 
#define DECLARE_CMP_FUNC(name, pos)
 
#define DEFINE_SET_FRAME(color_search, name, value)
 
#define DEFINE_SET_FRAME_COLOR_SEARCH(color_search, color_search_macro)
 
#define DITHERING_ENTRIES(color_search)
 

Typedefs

typedef int(* set_frame_func) (struct PaletteUseContext *s, AVFrame *out, AVFrame *in, int x_start, int y_start, int width, int height)
 
typedef int(* cmp_func) (const void *, const void *)
 

Enumerations

enum  dithering_mode {
  DITHERING_NONE, DITHERING_BAYER, DITHERING_HECKBERT, DITHERING_FLOYD_STEINBERG,
  DITHERING_SIERRA2, DITHERING_SIERRA2_4A, NB_DITHERING
}
 
enum  color_search_method { COLOR_SEARCH_NNS_ITERATIVE, COLOR_SEARCH_NNS_RECURSIVE, COLOR_SEARCH_BRUTEFORCE, NB_COLOR_SEARCHES }
 
enum  diff_mode { DIFF_MODE_NONE, DIFF_MODE_RECTANGLE, NB_DIFF_MODE }
 

Functions

 AVFILTER_DEFINE_CLASS (paletteuse)
 
static int load_apply_palette (FFFrameSync *fs)
 
static int query_formats (AVFilterContext *ctx)
 
static av_always_inline int dither_color (uint32_t px, int er, int eg, int eb, int scale, int shift)
 
static av_always_inline int diff (const uint8_t *c1, const uint8_t *c2, const int trans_thresh)
 
static av_always_inline uint8_t colormap_nearest_bruteforce (const uint32_t *palette, const uint8_t *argb, const int trans_thresh)
 
static void colormap_nearest_node (const struct color_node *map, const int node_pos, const uint8_t *target, const int trans_thresh, struct nearest_color *nearest)
 
static av_always_inline uint8_t colormap_nearest_recursive (const struct color_node *node, const uint8_t *rgb, const int trans_thresh)
 
static av_always_inline uint8_t colormap_nearest_iterative (const struct color_node *root, const uint8_t *target, const int trans_thresh)
 
static av_always_inline int color_get (PaletteUseContext *s, uint32_t color, uint8_t a, uint8_t r, uint8_t g, uint8_t b, const enum color_search_method search_method)
 Check if the requested color is in the cache already. More...
 
static av_always_inline int get_dst_color_err (PaletteUseContext *s, uint32_t c, int *er, int *eg, int *eb, const enum color_search_method search_method)
 
static av_always_inline int set_frame (PaletteUseContext *s, AVFrame *out, AVFrame *in, int x_start, int y_start, int w, int h, enum dithering_mode dither, const enum color_search_method search_method)
 
static void disp_node (AVBPrint *buf, const struct color_node *map, int parent_id, int node_id, int depth)
 
static int disp_tree (const struct color_node *node, const char *fname)
 
static int debug_accuracy (const struct color_node *node, const uint32_t *palette, const int trans_thresh, const enum color_search_method search_method)
 
static int get_next_color (const uint8_t *color_used, const uint32_t *palette, const int trans_thresh, int *component, const struct color_rect *box)
 
static int colormap_insert (struct color_node *map, uint8_t *color_used, int *nb_used, const uint32_t *palette, const int trans_thresh, const struct color_rect *box)
 
static int cmp_pal_entry (const void *a, const void *b)
 
static void load_colormap (PaletteUseContext *s)
 
static void debug_mean_error (PaletteUseContext *s, const AVFrame *in1, const AVFrame *in2, int frame_count)
 
static void set_processing_window (enum diff_mode diff_mode, const AVFrame *prv_src, const AVFrame *cur_src, const AVFrame *prv_dst, AVFrame *cur_dst, int *xp, int *yp, int *wp, int *hp)
 
static int apply_palette (AVFilterLink *inlink, AVFrame *in, AVFrame **outf)
 
static int config_output (AVFilterLink *outlink)
 
static int config_input_palette (AVFilterLink *inlink)
 
static void load_palette (PaletteUseContext *s, const AVFrame *palette_frame)
 
static int dither_value (int p)
 
static av_cold int init (AVFilterContext *ctx)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption paletteuse_options []
 
static const cmp_func cmp_funcs [] = {cmp_a, cmp_r, cmp_g, cmp_b}
 
static const set_frame_func set_frame_lut [NB_COLOR_SEARCHES][NB_DITHERING]
 
static const AVFilterPad paletteuse_inputs []
 
static const AVFilterPad paletteuse_outputs []
 
AVFilter ff_vf_paletteuse
 

Detailed Description

Use a palette to downsample an input video stream.

Definition in file vf_paletteuse.c.

Macro Definition Documentation

#define NBITS   5

Definition at line 65 of file vf_paletteuse.c.

Referenced by color_get().

#define CACHE_SIZE   (1<<(3*NBITS))

Definition at line 66 of file vf_paletteuse.c.

Referenced by load_palette(), and uninit().

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

Definition at line 109 of file vf_paletteuse.c.

Definition at line 110 of file vf_paletteuse.c.

#define COLORMAP_NEAREST (   search,
  palette,
  root,
  target,
  trans_thresh 
)
Value:
search == COLOR_SEARCH_NNS_ITERATIVE ? colormap_nearest_iterative(root, target, trans_thresh) : \
search == COLOR_SEARCH_NNS_RECURSIVE ? colormap_nearest_recursive(root, target, trans_thresh) : \
colormap_nearest_bruteforce(palette, target, trans_thresh)
static av_always_inline uint8_t colormap_nearest_iterative(const struct color_node *root, const uint8_t *target, const int trans_thresh)
static av_always_inline uint8_t colormap_nearest_recursive(const struct color_node *node, const uint8_t *rgb, const int trans_thresh)
static float search(FOCContext *foc, int pass, int maxpass, int xmin, int xmax, int ymin, int ymax, int *best_x, int *best_y, float best_score)
Definition: vf_find_rect.c:156
static av_always_inline uint8_t colormap_nearest_bruteforce(const uint32_t *palette, const uint8_t *argb, const int trans_thresh)

Definition at line 330 of file vf_paletteuse.c.

Referenced by color_get(), and debug_accuracy().

#define INDENT   4

Definition at line 502 of file vf_paletteuse.c.

Referenced by disp_node().

#define DECLARE_CMP_FUNC (   name,
  pos 
)
Value:
static int cmp_##name(const void *pa, const void *pb) \
{ \
const struct color *a = pa; \
const struct color *b = pb; \
return (a->value >> (8 * (3 - (pos))) & 0xff) \
- (b->value >> (8 * (3 - (pos))) & 0xff); \
}
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
#define b
Definition: input.c:41
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
uint32_t value
const char * name
Definition: opengl_enc.c:102

Definition at line 600 of file vf_paletteuse.c.

#define DEFINE_SET_FRAME (   color_search,
  name,
  value 
)
Value:
static int set_frame_##name(PaletteUseContext *s, AVFrame *out, AVFrame *in, \
int x_start, int y_start, int w, int h) \
{ \
return set_frame(s, out, in, x_start, y_start, w, h, value, color_search); \
}
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
GLsizei GLboolean const GLfloat * value
Definition: opengl_enc.c:108
uint8_t w
Definition: llviddspenc.c:38
#define s(width, name)
Definition: cbs_vp9.c:257
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFrame *in, int x_start, int y_start, int w, int h, enum dithering_mode dither, const enum color_search_method search_method)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
FILE * out
Definition: movenc.c:54
const char * name
Definition: opengl_enc.c:102

Definition at line 1042 of file vf_paletteuse.c.

#define DEFINE_SET_FRAME_COLOR_SEARCH (   color_search,
  color_search_macro 
)
Value:
DEFINE_SET_FRAME(color_search_macro, color_search##_##none, DITHERING_NONE) \
DEFINE_SET_FRAME(color_search_macro, color_search##_##bayer, DITHERING_BAYER) \
DEFINE_SET_FRAME(color_search_macro, color_search##_##heckbert, DITHERING_HECKBERT) \
DEFINE_SET_FRAME(color_search_macro, color_search##_##floyd_steinberg, DITHERING_FLOYD_STEINBERG) \
DEFINE_SET_FRAME(color_search_macro, color_search##_##sierra2, DITHERING_SIERRA2) \
DEFINE_SET_FRAME(color_search_macro, color_search##_##sierra2_4a, DITHERING_SIERRA2_4A) \
#define DEFINE_SET_FRAME(color_search, name, value)
#define _

Definition at line 1049 of file vf_paletteuse.c.

#define DITHERING_ENTRIES (   color_search)
Value:
{ \
set_frame_##color_search##_none, \
set_frame_##color_search##_bayer, \
set_frame_##color_search##_heckbert, \
set_frame_##color_search##_floyd_steinberg, \
set_frame_##color_search##_sierra2, \
set_frame_##color_search##_sierra2_4a, \
}

Definition at line 1061 of file vf_paletteuse.c.

Typedef Documentation

typedef int(* set_frame_func) (struct PaletteUseContext *s, AVFrame *out, AVFrame *in, int x_start, int y_start, int width, int height)

Definition at line 80 of file vf_paletteuse.c.

typedef int(* cmp_func) (const void *, const void *)

Definition at line 598 of file vf_paletteuse.c.

Enumeration Type Documentation

Enumerator
DITHERING_NONE 
DITHERING_BAYER 
DITHERING_HECKBERT 
DITHERING_FLOYD_STEINBERG 
DITHERING_SIERRA2 
DITHERING_SIERRA2_4A 
NB_DITHERING 

Definition at line 35 of file vf_paletteuse.c.

Enumerator
COLOR_SEARCH_NNS_ITERATIVE 
COLOR_SEARCH_NNS_RECURSIVE 
COLOR_SEARCH_BRUTEFORCE 
NB_COLOR_SEARCHES 

Definition at line 45 of file vf_paletteuse.c.

enum diff_mode
Enumerator
DIFF_MODE_NONE 
DIFF_MODE_RECTANGLE 
NB_DIFF_MODE 

Definition at line 52 of file vf_paletteuse.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( paletteuse  )
static int load_apply_palette ( FFFrameSync fs)
static

Definition at line 1013 of file vf_paletteuse.c.

Referenced by config_output().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 139 of file vf_paletteuse.c.

static av_always_inline int dither_color ( uint32_t  px,
int  er,
int  eg,
int  eb,
int  scale,
int  shift 
)
static

Definition at line 161 of file vf_paletteuse.c.

Referenced by set_frame().

static av_always_inline int diff ( const uint8_t c1,
const uint8_t c2,
const int  trans_thresh 
)
static
static av_always_inline uint8_t colormap_nearest_bruteforce ( const uint32_t *  palette,
const uint8_t argb,
const int  trans_thresh 
)
static

Definition at line 185 of file vf_paletteuse.c.

Referenced by debug_accuracy().

static void colormap_nearest_node ( const struct color_node map,
const int  node_pos,
const uint8_t target,
const int  trans_thresh,
struct nearest_color nearest 
)
static

Definition at line 215 of file vf_paletteuse.c.

Referenced by colormap_nearest_recursive().

static av_always_inline uint8_t colormap_nearest_recursive ( const struct color_node node,
const uint8_t rgb,
const int  trans_thresh 
)
static

Definition at line 246 of file vf_paletteuse.c.

static av_always_inline uint8_t colormap_nearest_iterative ( const struct color_node root,
const uint8_t target,
const int  trans_thresh 
)
static

Definition at line 258 of file vf_paletteuse.c.

static av_always_inline int color_get ( PaletteUseContext s,
uint32_t  color,
uint8_t  a,
uint8_t  r,
uint8_t  g,
uint8_t  b,
const enum color_search_method  search_method 
)
static

Check if the requested color is in the cache already.

If not, find it in the color tree and cache it. Note: a, r, g, and b are the components of color, but are passed as well to avoid recomputing them (they are generally computed by the caller for other uses).

Definition at line 341 of file vf_paletteuse.c.

Referenced by get_dst_color_err(), and set_frame().

static av_always_inline int get_dst_color_err ( PaletteUseContext s,
uint32_t  c,
int er,
int eg,
int eb,
const enum color_search_method  search_method 
)
static

Definition at line 375 of file vf_paletteuse.c.

Referenced by set_frame().

static av_always_inline int set_frame ( PaletteUseContext s,
AVFrame out,
AVFrame in,
int  x_start,
int  y_start,
int  w,
int  h,
enum dithering_mode  dither,
const enum color_search_method  search_method 
)
static

Definition at line 394 of file vf_paletteuse.c.

static void disp_node ( AVBPrint *  buf,
const struct color_node map,
int  parent_id,
int  node_id,
int  depth 
)
static

Definition at line 503 of file vf_paletteuse.c.

Referenced by disp_tree().

static int disp_tree ( const struct color_node node,
const char *  fname 
)
static

Definition at line 532 of file vf_paletteuse.c.

Referenced by load_colormap().

static int debug_accuracy ( const struct color_node node,
const uint32_t *  palette,
const int  trans_thresh,
const enum color_search_method  search_method 
)
static

Definition at line 557 of file vf_paletteuse.c.

Referenced by load_colormap().

static int get_next_color ( const uint8_t color_used,
const uint32_t *  palette,
const int  trans_thresh,
int component,
const struct color_rect box 
)
static

Definition at line 616 of file vf_paletteuse.c.

Referenced by colormap_insert().

static int colormap_insert ( struct color_node map,
uint8_t color_used,
int nb_used,
const uint32_t *  palette,
const int  trans_thresh,
const struct color_rect box 
)
static

Definition at line 679 of file vf_paletteuse.c.

Referenced by load_colormap().

static int cmp_pal_entry ( const void a,
const void b 
)
static

Definition at line 725 of file vf_paletteuse.c.

Referenced by load_colormap().

static void load_colormap ( PaletteUseContext s)
static

Definition at line 732 of file vf_paletteuse.c.

Referenced by load_palette().

static void debug_mean_error ( PaletteUseContext s,
const AVFrame in1,
const AVFrame in2,
int  frame_count 
)
static

Definition at line 778 of file vf_paletteuse.c.

Referenced by apply_palette().

static void set_processing_window ( enum diff_mode  diff_mode,
const AVFrame prv_src,
const AVFrame cur_src,
const AVFrame prv_dst,
AVFrame cur_dst,
int xp,
int yp,
int wp,
int hp 
)
static

Definition at line 808 of file vf_paletteuse.c.

Referenced by apply_palette().

static int apply_palette ( AVFilterLink inlink,
AVFrame in,
AVFrame **  outf 
)
static

Definition at line 897 of file vf_paletteuse.c.

Referenced by load_apply_palette().

static int config_output ( AVFilterLink outlink)
static

Definition at line 942 of file vf_paletteuse.c.

static int config_input_palette ( AVFilterLink inlink)
static

Definition at line 964 of file vf_paletteuse.c.

static void load_palette ( PaletteUseContext s,
const AVFrame palette_frame 
)
static

Definition at line 979 of file vf_paletteuse.c.

Referenced by load_apply_palette().

static int dither_value ( int  p)
static

Definition at line 1076 of file vf_paletteuse.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 1084 of file vf_paletteuse.c.

static int activate ( AVFilterContext ctx)
static

Definition at line 1109 of file vf_paletteuse.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1115 of file vf_paletteuse.c.

Variable Documentation

const AVOption paletteuse_options[]
static
Initial value:
= {
{ "dither", "select dithering mode", OFFSET(dither), AV_OPT_TYPE_INT, {.i64=DITHERING_SIERRA2_4A}, 0, NB_DITHERING-1, FLAGS, "dithering_mode" },
{ "bayer", "ordered 8x8 bayer dithering (deterministic)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_BAYER}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" },
{ "heckbert", "dithering as defined by Paul Heckbert in 1982 (simple error diffusion)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_HECKBERT}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" },
{ "floyd_steinberg", "Floyd and Steingberg dithering (error diffusion)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_FLOYD_STEINBERG}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" },
{ "sierra2", "Frankie Sierra dithering v2 (error diffusion)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_SIERRA2}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" },
{ "sierra2_4a", "Frankie Sierra dithering v2 \"Lite\" (error diffusion)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_SIERRA2_4A}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" },
{ "bayer_scale", "set scale for bayer dithering", OFFSET(bayer_scale), AV_OPT_TYPE_INT, {.i64=2}, 0, 5, FLAGS },
{ "diff_mode", "set frame difference mode", OFFSET(diff_mode), AV_OPT_TYPE_INT, {.i64=DIFF_MODE_NONE}, 0, NB_DIFF_MODE-1, FLAGS, "diff_mode" },
{ "rectangle", "process smallest different rectangle", 0, AV_OPT_TYPE_CONST, {.i64=DIFF_MODE_RECTANGLE}, INT_MIN, INT_MAX, FLAGS, "diff_mode" },
{ "new", "take new palette for each output frame", OFFSET(new), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ "alpha_threshold", "set the alpha threshold for transparency", OFFSET(trans_thresh), AV_OPT_TYPE_INT, {.i64=128}, 0, 255, FLAGS },
{ "debug_kdtree", "save Graphviz graph of the kdtree in specified file", OFFSET(dot_filename), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "color_search", "set reverse colormap color search method", OFFSET(color_search_method), AV_OPT_TYPE_INT, {.i64=COLOR_SEARCH_NNS_ITERATIVE}, 0, NB_COLOR_SEARCHES-1, FLAGS, "search" },
{ "nns_iterative", "iterative search", 0, AV_OPT_TYPE_CONST, {.i64=COLOR_SEARCH_NNS_ITERATIVE}, INT_MIN, INT_MAX, FLAGS, "search" },
{ "nns_recursive", "recursive search", 0, AV_OPT_TYPE_CONST, {.i64=COLOR_SEARCH_NNS_RECURSIVE}, INT_MIN, INT_MAX, FLAGS, "search" },
{ "bruteforce", "brute-force into the palette", 0, AV_OPT_TYPE_CONST, {.i64=COLOR_SEARCH_BRUTEFORCE}, INT_MIN, INT_MAX, FLAGS, "search" },
{ "mean_err", "compute and print mean error", OFFSET(calc_mean_err), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ "debug_accuracy", "test color search accuracy", OFFSET(debug_accuracy), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ NULL }
}
diff_mode
Definition: vf_paletteuse.c:52
#define NULL
Definition: coverity.c:32
color_search_method
Definition: vf_paletteuse.c:45
static const uint8_t dither[8][8]
Definition: vf_fspp.c:57
static int debug_accuracy(const struct color_node *node, const uint32_t *palette, const int trans_thresh, const enum color_search_method search_method)
#define OFFSET(x)
#define FLAGS

Definition at line 111 of file vf_paletteuse.c.

const cmp_func cmp_funcs[] = {cmp_a, cmp_r, cmp_g, cmp_b}
static

Definition at line 614 of file vf_paletteuse.c.

Referenced by get_next_color().

const set_frame_func set_frame_lut[NB_COLOR_SEARCHES][NB_DITHERING]
static
Initial value:
= {
DITHERING_ENTRIES(nns_iterative),
DITHERING_ENTRIES(nns_recursive),
DITHERING_ENTRIES(bruteforce),
}
#define DITHERING_ENTRIES(color_search)

Definition at line 1070 of file vf_paletteuse.c.

const AVFilterPad paletteuse_inputs[]
static
Initial value:
= {
{
.name = "default",
},{
.name = "palette",
.config_props = config_input_palette,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input_palette(AVFilterLink *inlink)

Definition at line 1127 of file vf_paletteuse.c.

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

Definition at line 1139 of file vf_paletteuse.c.

AVFilter ff_vf_paletteuse
Initial value:
= {
.name = "paletteuse",
.description = NULL_IF_CONFIG_SMALL("Use a palette to downsample an input video stream."),
.priv_size = sizeof(PaletteUseContext),
.init = init,
.priv_class = &paletteuse_class,
}
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad paletteuse_outputs[]
static av_cold int init(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static int activate(AVFilterContext *ctx)
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad paletteuse_inputs[]

Definition at line 1148 of file vf_paletteuse.c.