History

avfilter/palettegen: rename variance to cut_score

"Variance" wasn't exactly the correct word; "cut score" is more agnostic, which will be useful when changing the algorithm in the next commit.

Clément Bœsch committed 3 years ago

Commit 187f5e71 parent e49fc1a1 file · +6 −6Browse files

Unified · Split

libavfilter/vf_palettegen.c+6−6
@@ -42,7 +42,7 @@ struct range_box { · 41 unmodified lines
4242 uint32_t color; // average color
4343 int major_axis; // best axis candidate for cutting the box
4444 uint64_t weight; // sum of all the weights of the colors
45− int64_t variance; // overall variance of the box (how much the colors are spread)
45+ 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
4848 int sorted_by; // whether range of colors is sorted by red (0), green (1) or blue (2)
@@ -171,25 +171,25 @@ static void compute_box_stats(PaletteGenContext *s, struct range_box *box) · 122 unmodified lines
171171 if (er2[0] >= er2[1] && er2[0] >= er2[2]) box->major_axis = 0;
172172 if (er2[1] >= er2[0] && er2[1] >= er2[2]) box->major_axis = 1; // prefer green again
173173
174− box->variance = er2[0] + er2[1] + er2[2];
174+ box->cut_score = er2[0] + er2[1] + er2[2];
175175 }
176176
177177 /**
178− * Find the next box to split: pick the one with the highest variance
178+ * Find the next box to split: pick the one with the highest cut score
179179 */
180180 static int get_next_box_id_to_split(PaletteGenContext *s)
181181 {
182182 int box_id, best_box_id = -1;
183− int64_t max_variance = -1;
183+ int64_t max_score = -1;
184184
185185 if (s->nb_boxes == s->max_colors - s->reserve_transparent)
186186 return -1;
187187
188188 for (box_id = 0; box_id < s->nb_boxes; box_id++) {
189189 struct range_box *box = &s->boxes[box_id];
190− if (s->boxes[box_id].len >= 2 && box->variance > max_variance) {
190+ if (s->boxes[box_id].len >= 2 && box->cut_score > max_score) {
191191 best_box_id = box_id;
192− max_variance = box->variance;
192+ max_score = box->cut_score;
193193 }
194194 }
195195 return best_box_id;

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