Go to the source code of this file.
|
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
} |
|
|
| 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) |
|
Use a palette to downsample an input video stream.
Definition in file vf_paletteuse.c.
◆ NBITS
◆ CACHE_SIZE
#define CACHE_SIZE (1<<(3*NBITS)) |
◆ OFFSET
◆ FLAGS
◆ COLORMAP_NEAREST
#define COLORMAP_NEAREST |
( |
|
search, |
|
|
|
palette, |
|
|
|
root, |
|
|
|
target, |
|
|
|
trans_thresh |
|
) |
| |
◆ INDENT
◆ DECLARE_CMP_FUNC
#define DECLARE_CMP_FUNC |
( |
|
name, |
|
|
|
pos |
|
) |
| |
Value:static int cmp_##
name(
const void *pa,
const void *pb) \
{ \
return (
a->value >> (8 * (3 - (pos))) & 0xff) \
- (
b->value >> (8 * (3 - (pos))) & 0xff); \
}
Definition at line 600 of file vf_paletteuse.c.
◆ DEFINE_SET_FRAME
#define DEFINE_SET_FRAME |
( |
|
color_search, |
|
|
|
name, |
|
|
|
value |
|
) |
| |
◆ DEFINE_SET_FRAME_COLOR_SEARCH
#define DEFINE_SET_FRAME_COLOR_SEARCH |
( |
|
color_search, |
|
|
|
color_search_macro |
|
) |
| |
◆ DITHERING_ENTRIES
#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 1055 of file vf_paletteuse.c.
◆ set_frame_func
◆ cmp_func
typedef int(* cmp_func) (const void *, const void *) |
◆ 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.
◆ 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.
◆ diff_mode
Enumerator |
---|
DIFF_MODE_NONE | |
DIFF_MODE_RECTANGLE | |
NB_DIFF_MODE | |
Definition at line 52 of file vf_paletteuse.c.
◆ AVFILTER_DEFINE_CLASS()
AVFILTER_DEFINE_CLASS |
( |
paletteuse |
| ) |
|
◆ load_apply_palette()
◆ query_formats()
◆ dither_color()
◆ diff()
◆ colormap_nearest_bruteforce()
◆ colormap_nearest_node()
◆ colormap_nearest_recursive()
◆ colormap_nearest_iterative()
◆ color_get()
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().
◆ get_dst_color_err()
◆ set_frame()
◆ disp_node()
static void disp_node |
( |
AVBPrint * |
buf, |
|
|
const struct color_node * |
map, |
|
|
int |
parent_id, |
|
|
int |
node_id, |
|
|
int |
depth |
|
) |
| |
|
static |
◆ disp_tree()
static int disp_tree |
( |
const struct color_node * |
node, |
|
|
const char * |
fname |
|
) |
| |
|
static |
◆ debug_accuracy()
◆ get_next_color()
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 |
◆ colormap_insert()
◆ cmp_pal_entry()
static int cmp_pal_entry |
( |
const void * |
a, |
|
|
const void * |
b |
|
) |
| |
|
static |
◆ load_colormap()
◆ debug_mean_error()
◆ set_processing_window()
◆ apply_palette()
◆ config_output()
◆ config_input_palette()
◆ load_palette()
◆ dither_value()
static int dither_value |
( |
int |
p | ) |
|
|
static |
◆ init()
◆ activate()
◆ uninit()
◆ paletteuse_options
◆ cmp_funcs
const cmp_func cmp_funcs[] = {cmp_a, cmp_r, cmp_g, cmp_b} |
|
static |
◆ set_frame_lut
◆ paletteuse_inputs
Initial value:= {
{
.name = "default",
},{
.name = "palette",
},
}
Definition at line 1121 of file vf_paletteuse.c.
◆ paletteuse_outputs
◆ ff_vf_paletteuse
Initial value:= {
.name = "paletteuse",
.priv_class = &paletteuse_class,
}
Definition at line 1142 of file vf_paletteuse.c.
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