History

avfilter/palette{gen,use}: simplify a few alpha masks

Clément Bœsch committed 4 years ago

Commit 7bc054e1 parent 320fbf51 file · +7 −7Browse files

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

Unified · Split

libavfilter/vf_paletteuse.c+7−7
@@ -156,7 +156,7 @@ static int query_formats(AVFilterContext *ctx) · 155 unmodified lines
156156 static av_always_inline uint32_t dither_color(uint32_t px, int er, int eg,
157157 int eb, int scale, int shift)
158158 {
159− return px >> 24 << 24
159+ return (px & 0xff000000)
160160 | av_clip_uint8((px >> 16 & 0xff) + ((er * scale) / (1<<shift))) << 16
161161 | av_clip_uint8((px >> 8 & 0xff) + ((eg * scale) / (1<<shift))) << 8
162162 | av_clip_uint8((px & 0xff) + ((eb * scale) / (1<<shift)));
@@ -187,7 +187,7 @@ static av_always_inline uint8_t colormap_nearest_bruteforce(const uint32_t *pale · 24 unmodified lines
187187
188188 if (c >> 24 >= trans_thresh) { // ignore transparent entry
189189 const uint8_t palargb[] = {
190− palette[i]>>24 & 0xff,
190+ palette[i]>>24,
191191 palette[i]>>16 & 0xff,
192192 palette[i]>> 8 & 0xff,
193193 palette[i] & 0xff,
@@ -372,7 +372,7 @@ static av_always_inline int get_dst_color_err(PaletteUseContext *s, · 178 unmodified lines
372372 uint32_t c, int *er, int *eg, int *eb,
373373 const enum color_search_method search_method)
374374 {
375− const uint8_t a = c >> 24 & 0xff;
375+ const uint8_t a = c >> 24;
376376 const uint8_t r = c >> 16 & 0xff;
377377 const uint8_t g = c >> 8 & 0xff;
378378 const uint8_t b = c & 0xff;
@@ -411,7 +411,7 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram · 32 unmodified lines
411411
412412 if (dither == DITHERING_BAYER) {
413413 const int d = s->ordered_dither[(y & 7)<<3 | (x & 7)];
414− const uint8_t a8 = src[x] >> 24 & 0xff;
414+ const uint8_t a8 = src[x] >> 24;
415415 const uint8_t r8 = src[x] >> 16 & 0xff;
416416 const uint8_t g8 = src[x] >> 8 & 0xff;
417417 const uint8_t b8 = src[x] & 0xff;
@@ -483,7 +483,7 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram · 65 unmodified lines
483483 if ( down) src[src_linesize + x ] = dither_color(src[src_linesize + x ], er, eg, eb, 1, 2);
484484
485485 } else {
486− const uint8_t a = src[x] >> 24 & 0xff;
486+ const uint8_t a = src[x] >> 24;
487487 const uint8_t r = src[x] >> 16 & 0xff;
488488 const uint8_t g = src[x] >> 8 & 0xff;
489489 const uint8_t b = src[x] & 0xff;
@@ -630,7 +630,7 @@ static int get_next_color(const uint8_t *color_used, const uint32_t *palette, · 140 unmodified lines
630630
631631 for (i = 0; i < AVPALETTE_COUNT; i++) {
632632 const uint32_t c = palette[i];
633− const uint8_t a = c >> 24 & 0xff;
633+ const uint8_t a = c >> 24;
634634 const uint8_t r = c >> 16 & 0xff;
635635 const uint8_t g = c >> 8 & 0xff;
636636 const uint8_t b = c & 0xff;
@@ -700,7 +700,7 @@ static int colormap_insert(struct color_node *map, · 63 unmodified lines
700700 node = &map[cur_id];
701701 node->split = component;
702702 node->palette_id = pal_id;
703− node->val[0] = c>>24 & 0xff;
703+ node->val[0] = c>>24;
704704 node->val[1] = c>>16 & 0xff;
705705 node->val[2] = c>> 8 & 0xff;
706706 node->val[3] = c & 0xff;

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