diff options
author | Clément Bœsch <u@pkh.me> | 2022-12-27 15:05:01 +0100 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2023-01-03 17:18:55 +0100 |
commit | 724f52b906a8d375de8a9b80b8a2b353e2a092d8 (patch) | |
tree | fd2a3fd4c178cff1602adb2c8116b4272084f697 /libavfilter/vf_palettegen.c | |
parent | 67ce6ad9a2580f5bb84f7e389b0303adcf1a0f3a (diff) | |
download | ffmpeg-724f52b906a8d375de8a9b80b8a2b353e2a092d8.tar.gz |
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.
Diffstat (limited to 'libavfilter/vf_palettegen.c')
-rw-r--r-- | libavfilter/vf_palettegen.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index b8db234fef..99e4512e52 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -34,14 +34,14 @@ /* Reference a color and how much it's used */ struct color_ref { uint32_t color; - uint64_t count; + int64_t count; }; /* Store a range of colors */ struct range_box { uint32_t color; // average color int major_axis; // best axis candidate for cutting the box - uint64_t weight; // sum of all the weights of the colors + int64_t weight; // sum of all the weights of the colors int64_t cut_score; // how likely the box is to be cut down (higher implying more likely) int start; // index in PaletteGenContext->refs int len; // number of referenced colors @@ -141,7 +141,7 @@ static void compute_box_stats(PaletteGenContext *s, struct range_box *box) int64_t er2[3] = {0}; /* Compute average color */ - uint64_t sr = 0, sg = 0, sb = 0; + int64_t sr = 0, sg = 0, sb = 0; box->weight = 0; for (int i = box->start; i < box->start + box->len; i++) { const struct color_ref *ref = s->refs[i]; @@ -314,7 +314,7 @@ static AVFrame *get_palette_frame(AVFilterContext *ctx) while (box && box->len > 1) { int i; - uint64_t median, weight; + int64_t median, weight; ff_dlog(ctx, "box #%02X [%6d..%-6d] (%6d) w:%-6"PRIu64" sort by %c (already sorted:%c) ", box_id, box->start, box->start + box->len - 1, box->len, box->weight, |