Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-04-10 20:38:39 +0400
committerMichael Niedermayer <michaelni@gmx.at>2014-04-10 21:58:14 +0400
commitc486cfab792e53de3f5fc9f5082909ce687a3fe8 (patch)
tree42cdb9104ace2c3acdb0cfda3ad07e5ae37fe03a /libavcodec/imgconvert.c
parentcdd21f1f03c5d59aad8f0244b1be0f864d8416a7 (diff)
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>
Diffstat (limited to 'libavcodec/imgconvert.c')
-rw-r--r--libavcodec/imgconvert.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index b830961fda..cabd3fd26b 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -130,13 +130,18 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt,
src_color = get_color_type(src_desc);
dst_color = get_color_type(dst_desc);
- nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components);
-
- for (i = 0; i < nb_components; i++)
- if (src_desc->comp[i].depth_minus1 > dst_desc->comp[i].depth_minus1 && (consider & FF_LOSS_DEPTH)) {
+ 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);
+
+ for (i = 0; i < nb_components; i++) {
+ 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;
- score -= 65536 >> dst_desc->comp[i].depth_minus1;
+ score -= 65536 >> depth_minus1;
}
+ }
if (consider & FF_LOSS_RESOLUTION) {
if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) {