You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/webp: add optimization: use local palette with extra padding
for big enough pictures. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
committed by
Michael Niedermayer
parent
e81eca0ce5
commit
19fb476841
@@ -1061,6 +1061,21 @@ static int apply_color_indexing_transform(WebPContext *s)
|
|||||||
av_free(line);
|
av_free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// switch to local palette if it's worth initializing it
|
||||||
|
if (img->frame->height * img->frame->width > 300) {
|
||||||
|
uint8_t palette[256 * 4];
|
||||||
|
const int size = pal->frame->width * 4;
|
||||||
|
memcpy(palette, GET_PIXEL(pal->frame, 0, 0), size); // copy palette
|
||||||
|
// set extra entries to transparent black
|
||||||
|
memset(palette + size, 0, 256 * 4 - size);
|
||||||
|
for (y = 0; y < img->frame->height; y++) {
|
||||||
|
for (x = 0; x < img->frame->width; x++) {
|
||||||
|
p = GET_PIXEL(img->frame, x, y);
|
||||||
|
i = p[2];
|
||||||
|
AV_COPY32(p, &palette[i * 4]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (y = 0; y < img->frame->height; y++) {
|
for (y = 0; y < img->frame->height; y++) {
|
||||||
for (x = 0; x < img->frame->width; x++) {
|
for (x = 0; x < img->frame->width; x++) {
|
||||||
p = GET_PIXEL(img->frame, x, y);
|
p = GET_PIXEL(img->frame, x, y);
|
||||||
@@ -1073,6 +1088,7 @@ static int apply_color_indexing_transform(WebPContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user