diff mbox series

[FFmpeg-devel,v2,18/32] avfilter/palettegen: rename local variable box_weight to weight

Message ID 20221227231814.2520181-19-u@pkh.me
State Accepted
Commit 67ce6ad9a2580f5bb84f7e389b0303adcf1a0f3a
Headers show
Series [FFmpeg-devel,v2,01/32] avfilter/palettegen: allow a minimum of 2 colors | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Clément Bœsch Dec. 27, 2022, 11:18 p.m. UTC
This variable is used only for the running weight (used to reach the
target median). The places where we actually need the box weight are
changed to use box->weight.
---
 libavfilter/vf_palettegen.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c
index ad21882df3..b8db234fef 100644
--- a/libavfilter/vf_palettegen.c
+++ b/libavfilter/vf_palettegen.c
@@ -314,12 +314,10 @@  static AVFrame *get_palette_frame(AVFilterContext *ctx)
 
     while (box && box->len > 1) {
         int i;
-        uint64_t median, box_weight;
-
-        box_weight = box->weight;
+        uint64_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,
+                box_id, box->start, box->start + box->len - 1, box->len, box->weight,
                 "rgb"[box->major_axis], box->sorted_by == box->major_axis ? 'y':'n');
 
         /* sort the range by its major axis if it's not already sorted */
@@ -330,16 +328,16 @@  static AVFrame *get_palette_frame(AVFilterContext *ctx)
         }
 
         /* locate the median where to split */
-        median = (box_weight + 1) >> 1;
-        box_weight = 0;
+        median = (box->weight + 1) >> 1;
+        weight = 0;
         /* if you have 2 boxes, the maximum is actually #0: you must have at
          * least 1 color on each side of the split, hence the -2 */
         for (i = box->start; i < box->start + box->len - 2; i++) {
-            box_weight += s->refs[i]->count;
-            if (box_weight > median)
+            weight += s->refs[i]->count;
+            if (weight > median)
                 break;
         }
-        ff_dlog(ctx, "split @ i=%-6d with w=%-6"PRIu64" (target=%6"PRIu64")\n", i, box_weight, median);
+        ff_dlog(ctx, "split @ i=%-6d with w=%-6"PRIu64" (target=%6"PRIu64")\n", i, weight, median);
         split_box(s, box, i);
 
         box_id = get_next_box_id_to_split(s);