FFmpeg
|
#include "libavutil/avassert.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "palette.h"
#include "video.h"
Go to the source code of this file.
Data Structures | |
struct | color_ref |
struct | range_box |
struct | hist_node |
struct | PaletteGenContext |
Macros | |
#define | HIST_SIZE (1<<15) |
#define | OFFSET(x) offsetof(PaletteGenContext, x) |
#define | FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
#define | DECLARE_CMP_FUNC(k0, k1, k2) |
Typedefs | |
typedef int(* | cmp_func) (const void *, const void *) |
Enumerations | |
enum | { STATS_MODE_ALL_FRAMES, STATS_MODE_DIFF_FRAMES, STATS_MODE_SINGLE_FRAMES, NB_STATS_MODE } |
enum | { ID_XYZ, ID_XZY, ID_ZXY, ID_YXZ, ID_ZYX, ID_YZX } |
Functions | |
AVFILTER_DEFINE_CLASS (palettegen) | |
static int | query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out) |
static int | sort3id (int64_t x, int64_t y, int64_t z) |
static int | cmp_color (const void *a, const void *b) |
Simple color comparison for sorting the final palette. More... | |
static void | compute_box_stats (PaletteGenContext *s, struct range_box *box) |
static int | get_next_box_id_to_split (PaletteGenContext *s) |
Find the next box to split: pick the one with the highest cut score. More... | |
static void | split_box (PaletteGenContext *s, struct range_box *box, int n) |
Split given box in two at position n. More... | |
static void | write_palette (AVFilterContext *ctx, AVFrame *out) |
Write the palette into the output frame. More... | |
static struct color_ref ** | load_color_refs (const struct hist_node *hist, int nb_refs) |
Crawl the histogram to get all the defined colors, and create a linear list of them (each color reference entry is a pointer to the value in the histogram/hash table). More... | |
static double | set_colorquant_ratio_meta (AVFrame *out, int nb_out, int nb_in) |
static AVFrame * | get_palette_frame (AVFilterContext *ctx) |
Main function implementing the Median Cut Algorithm defined by Paul Heckbert in Color Image Quantization for Frame Buffer Display (1982) More... | |
static int | color_inc (struct hist_node *hist, uint32_t color) |
Locate the color in the hash table and increment its counter. More... | |
static int | update_histogram_diff (struct hist_node *hist, const AVFrame *f1, const AVFrame *f2) |
Update histogram when pixels differ from previous frame. More... | |
static int | update_histogram_frame (struct hist_node *hist, const AVFrame *f) |
Simple histogram of the frame. More... | |
static int | filter_frame (AVFilterLink *inlink, AVFrame *in) |
Update the histogram for each passing frame. More... | |
static int | request_frame (AVFilterLink *outlink) |
Returns only one frame at the end containing the full palette. More... | |
static int | config_output (AVFilterLink *outlink) |
The output is one simple 16x16 squared-pixels palette. More... | |
static int | init (AVFilterContext *ctx) |
static av_cold void | uninit (AVFilterContext *ctx) |
Variables | |
static const AVOption | palettegen_options [] |
static const char *const | sortstr [] = { "Lab", "Lba", "bLa", "aLb", "baL", "abL" } |
static const cmp_func | cmp_funcs [] |
static const AVFilterPad | palettegen_inputs [] |
static const AVFilterPad | palettegen_outputs [] |
const AVFilter | ff_vf_palettegen |
Generate one palette for a whole video stream.
Definition in file vf_palettegen.c.
#define HIST_SIZE (1<<15) |
Definition at line 69 of file vf_palettegen.c.
#define OFFSET | ( | x | ) | offsetof(PaletteGenContext, x) |
Definition at line 88 of file vf_palettegen.c.
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
Definition at line 89 of file vf_palettegen.c.
#define DECLARE_CMP_FUNC | ( | k0, | |
k1, | |||
k2 | |||
) |
Definition at line 120 of file vf_palettegen.c.
typedef int(* cmp_func) (const void *, const void *) |
Definition at line 118 of file vf_palettegen.c.
anonymous enum |
Enumerator | |
---|---|
STATS_MODE_ALL_FRAMES | |
STATS_MODE_DIFF_FRAMES | |
STATS_MODE_SINGLE_FRAMES | |
NB_STATS_MODE |
Definition at line 62 of file vf_palettegen.c.
anonymous enum |
Enumerator | |
---|---|
ID_XYZ | |
ID_XZY | |
ID_ZXY | |
ID_YXZ | |
ID_ZYX | |
ID_YZX |
Definition at line 138 of file vf_palettegen.c.
AVFILTER_DEFINE_CLASS | ( | palettegen | ) |
|
static |
Definition at line 103 of file vf_palettegen.c.
Definition at line 154 of file vf_palettegen.c.
Referenced by compute_box_stats().
|
static |
Simple color comparison for sorting the final palette.
Definition at line 169 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Definition at line 176 of file vf_palettegen.c.
Referenced by get_palette_frame(), and split_box().
|
static |
Find the next box to split: pick the one with the highest cut score.
Definition at line 215 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Split given box in two at position n.
The original box becomes the left part of the split, and the new index box is the right part.
Definition at line 237 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Write the palette into the output frame.
Definition at line 255 of file vf_palettegen.c.
Referenced by get_palette_frame().
Crawl the histogram to get all the defined colors, and create a linear list of them (each color reference entry is a pointer to the value in the histogram/hash table).
Definition at line 288 of file vf_palettegen.c.
Referenced by get_palette_frame().
Definition at line 306 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Main function implementing the Median Cut Algorithm defined by Paul Heckbert in Color Image Quantization for Frame Buffer Display (1982)
Definition at line 319 of file vf_palettegen.c.
Referenced by filter_frame(), and request_frame().
|
static |
Locate the color in the hash table and increment its counter.
Definition at line 397 of file vf_palettegen.c.
Referenced by update_histogram_diff(), and update_histogram_frame().
|
static |
Update histogram when pixels differ from previous frame.
Definition at line 424 of file vf_palettegen.c.
Referenced by filter_frame().
Simple histogram of the frame.
Definition at line 448 of file vf_palettegen.c.
Referenced by filter_frame().
|
static |
Update the histogram for each passing frame.
No frame will be pushed here.
Definition at line 468 of file vf_palettegen.c.
|
static |
Returns only one frame at the end containing the full palette.
Definition at line 510 of file vf_palettegen.c.
|
static |
The output is one simple 16x16 squared-pixels palette.
Definition at line 529 of file vf_palettegen.c.
|
static |
Definition at line 536 of file vf_palettegen.c.
|
static |
Definition at line 548 of file vf_palettegen.c.
|
static |
Definition at line 90 of file vf_palettegen.c.
|
static |
Definition at line 139 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Definition at line 141 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Definition at line 559 of file vf_palettegen.c.
|
static |
Definition at line 567 of file vf_palettegen.c.
const AVFilter ff_vf_palettegen |
Definition at line 576 of file vf_palettegen.c.