FFmpeg
4.0
|
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 *) |
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 |
Use a palette to downsample an input video stream.
Definition in file vf_paletteuse.c.
#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.
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
Definition at line 110 of file vf_paletteuse.c.
#define COLORMAP_NEAREST | ( | search, | |
palette, | |||
root, | |||
target, | |||
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 | |||
) |
Definition at line 600 of file vf_paletteuse.c.
Definition at line 1043 of file vf_paletteuse.c.
#define DEFINE_SET_FRAME_COLOR_SEARCH | ( | color_search, | |
color_search_macro | |||
) |
Definition at line 1050 of file vf_paletteuse.c.
#define DITHERING_ENTRIES | ( | color_search | ) |
Definition at line 1062 of file vf_paletteuse.c.
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.
Definition at line 598 of file vf_paletteuse.c.
enum dithering_mode |
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.
enum color_search_method |
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.
AVFILTER_DEFINE_CLASS | ( | paletteuse | ) |
|
static |
Definition at line 1014 of file vf_paletteuse.c.
Referenced by config_output().
|
static |
Definition at line 139 of file vf_paletteuse.c.
|
static |
Definition at line 161 of file vf_paletteuse.c.
Referenced by set_frame().
|
static |
Definition at line 169 of file vf_paletteuse.c.
Referenced by colormap_nearest_bruteforce(), colormap_nearest_iterative(), colormap_nearest_node(), debug_accuracy(), and debug_mean_error().
|
static |
Definition at line 185 of file vf_paletteuse.c.
Referenced by debug_accuracy().
|
static |
Definition at line 215 of file vf_paletteuse.c.
Referenced by colormap_nearest_recursive().
|
static |
Definition at line 246 of file vf_paletteuse.c.
|
static |
Definition at line 258 of file vf_paletteuse.c.
|
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 |
Definition at line 375 of file vf_paletteuse.c.
Referenced by set_frame().
|
static |
Definition at line 394 of file vf_paletteuse.c.
|
static |
Definition at line 503 of file vf_paletteuse.c.
Referenced by disp_tree().
|
static |
Definition at line 532 of file vf_paletteuse.c.
Referenced by load_colormap().
|
static |
Definition at line 557 of file vf_paletteuse.c.
Referenced by load_colormap().
|
static |
Definition at line 616 of file vf_paletteuse.c.
Referenced by colormap_insert().
|
static |
Definition at line 679 of file vf_paletteuse.c.
Referenced by load_colormap().
Definition at line 725 of file vf_paletteuse.c.
Referenced by load_colormap().
|
static |
Definition at line 732 of file vf_paletteuse.c.
Referenced by load_palette().
|
static |
Definition at line 778 of file vf_paletteuse.c.
Referenced by apply_palette().
|
static |
Definition at line 808 of file vf_paletteuse.c.
Referenced by apply_palette().
|
static |
Definition at line 897 of file vf_paletteuse.c.
Referenced by load_apply_palette().
|
static |
Definition at line 943 of file vf_paletteuse.c.
|
static |
Definition at line 965 of file vf_paletteuse.c.
|
static |
Definition at line 980 of file vf_paletteuse.c.
Referenced by load_apply_palette().
Definition at line 1077 of file vf_paletteuse.c.
Referenced by init().
|
static |
Definition at line 1085 of file vf_paletteuse.c.
|
static |
Definition at line 1102 of file vf_paletteuse.c.
|
static |
Definition at line 1108 of file vf_paletteuse.c.
|
static |
Definition at line 111 of file vf_paletteuse.c.
|
static |
Definition at line 614 of file vf_paletteuse.c.
Referenced by get_next_color().
|
static |
Definition at line 1071 of file vf_paletteuse.c.
|
static |
Definition at line 1120 of file vf_paletteuse.c.
|
static |
Definition at line 1132 of file vf_paletteuse.c.
AVFilter ff_vf_paletteuse |
Definition at line 1141 of file vf_paletteuse.c.