History

avfilter/palettegen: switch to signed arithmetic

This prevents mixed sign arithmetic (typically because we have signed color channel differences), which has nasty side effects in C.

Clément Bœsch committed 3 years ago

Commit 724f52b1 parent 67ce6ad1 file · +4 −4Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_palettegen.c+4−4
@@ -34,14 +34,14 @@ · 33 unmodified lines
3434 /* Reference a color and how much it's used */
3535 struct color_ref {
3636 uint32_t color;
37− uint64_t count;
37+ int64_t count;
3838 };
3939
4040 /* Store a range of colors */
4141 struct range_box {
4242 uint32_t color; // average color
4343 int major_axis; // best axis candidate for cutting the box
44− uint64_t weight; // sum of all the weights of the colors
44+ int64_t weight; // sum of all the weights of the colors
4545 int64_t cut_score; // how likely the box is to be cut down (higher implying more likely)
4646 int start; // index in PaletteGenContext->refs
4747 int len; // number of referenced colors
@@ -141,7 +141,7 @@ static void compute_box_stats(PaletteGenContext *s, struct range_box *box) · 93 unmodified lines
141141 int64_t er2[3] = {0};
142142
143143 /* Compute average color */
144− uint64_t sr = 0, sg = 0, sb = 0;
144+ int64_t sr = 0, sg = 0, sb = 0;
145145 box->weight = 0;
146146 for (int i = box->start; i < box->start + box->len; i++) {
147147 const struct color_ref *ref = s->refs[i];
@@ -314,7 +314,7 @@ static AVFrame *get_palette_frame(AVFilterContext *ctx) · 166 unmodified lines
314314
315315 while (box && box->len > 1) {
316316 int i;
317− uint64_t median, weight;
317+ int64_t median, weight;
318318
319319 ff_dlog(ctx, "box #%02X [%6d..%-6d] (%6d) w:%-6"PRIu64" sort by %c (already sorted:%c) ",
320320 box_id, box->start, box->start + box->len - 1, box->len, box->weight,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t