FFmpeg
|
#include "libavutil/avassert.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.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 (AVFilterContext *ctx) |
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 68 of file vf_palettegen.c.
#define OFFSET | ( | x | ) | offsetof(PaletteGenContext, x) |
Definition at line 87 of file vf_palettegen.c.
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
Definition at line 88 of file vf_palettegen.c.
#define DECLARE_CMP_FUNC | ( | k0, | |
k1, | |||
k2 | |||
) |
Definition at line 117 of file vf_palettegen.c.
typedef int(* cmp_func) (const void *, const void *) |
Definition at line 115 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 61 of file vf_palettegen.c.
anonymous enum |
Enumerator | |
---|---|
ID_XYZ | |
ID_XZY | |
ID_ZXY | |
ID_YXZ | |
ID_ZYX | |
ID_YZX |
Definition at line 135 of file vf_palettegen.c.
AVFILTER_DEFINE_CLASS | ( | palettegen | ) |
|
static |
Definition at line 102 of file vf_palettegen.c.
|
static |
Definition at line 151 of file vf_palettegen.c.
Referenced by compute_box_stats().
|
static |
Simple color comparison for sorting the final palette.
Definition at line 166 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Definition at line 173 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 212 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 234 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Write the palette into the output frame.
Definition at line 252 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 285 of file vf_palettegen.c.
Referenced by get_palette_frame().
Definition at line 303 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 316 of file vf_palettegen.c.
Referenced by filter_frame(), and request_frame().
Locate the color in the hash table and increment its counter.
Definition at line 394 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 421 of file vf_palettegen.c.
Referenced by filter_frame().
Simple histogram of the frame.
Definition at line 445 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 465 of file vf_palettegen.c.
|
static |
Returns only one frame at the end containing the full palette.
Definition at line 507 of file vf_palettegen.c.
|
static |
The output is one simple 16x16 squared-pixels palette.
Definition at line 526 of file vf_palettegen.c.
|
static |
Definition at line 533 of file vf_palettegen.c.
|
static |
Definition at line 545 of file vf_palettegen.c.
|
static |
Definition at line 89 of file vf_palettegen.c.
|
static |
Definition at line 136 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Definition at line 138 of file vf_palettegen.c.
Referenced by get_palette_frame().
|
static |
Definition at line 556 of file vf_palettegen.c.
|
static |
Definition at line 564 of file vf_palettegen.c.
const AVFilter ff_vf_palettegen |
Definition at line 573 of file vf_palettegen.c.