You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/imgconvert: fix nb_components and depth for PAL8 in get_pix_fmt_score()
This causes us to favor RGB8 over PAL8 when FF_LOSS_COLORQUANT is used It probably makes sense to reinvestigate the exact scoring of pal8 when our pal8 support improves to be supperior to rgb8 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -130,12 +130,17 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
|
|||||||
|
|
||||||
src_color = get_color_type(src_desc);
|
src_color = get_color_type(src_desc);
|
||||||
dst_color = get_color_type(dst_desc);
|
dst_color = get_color_type(dst_desc);
|
||||||
|
if (dst_pix_fmt == AV_PIX_FMT_PAL8)
|
||||||
|
nb_components = FFMIN(src_desc->nb_components, 4);
|
||||||
|
else
|
||||||
nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components);
|
nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components);
|
||||||
|
|
||||||
for (i = 0; i < nb_components; i++)
|
for (i = 0; i < nb_components; i++) {
|
||||||
if (src_desc->comp[i].depth_minus1 > dst_desc->comp[i].depth_minus1 && (consider & FF_LOSS_DEPTH)) {
|
int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components : dst_desc->comp[i].depth_minus1;
|
||||||
|
if (src_desc->comp[i].depth_minus1 > depth_minus1 && (consider & FF_LOSS_DEPTH)) {
|
||||||
loss |= FF_LOSS_DEPTH;
|
loss |= FF_LOSS_DEPTH;
|
||||||
score -= 65536 >> dst_desc->comp[i].depth_minus1;
|
score -= 65536 >> depth_minus1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (consider & FF_LOSS_RESOLUTION) {
|
if (consider & FF_LOSS_RESOLUTION) {
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
8aef8081e8afa445f63f320f4a1c5edb *./tests/data/lavf/lavf.gif
|
e35f5ea283bbcb249818e0078ec72664 *./tests/data/lavf/lavf.gif
|
||||||
2030198 ./tests/data/lavf/lavf.gif
|
2011766 ./tests/data/lavf/lavf.gif
|
||||||
./tests/data/lavf/lavf.gif CRC=0x0dc5477c
|
./tests/data/lavf/lavf.gif CRC=0x0dc5477c
|
||||||
|
Reference in New Issue
Block a user