# HG changeset patch # User bellard # Date 1050937297 0 # Node ID fd676abc754c77279c3ad1c3f79a7f3fd1fe37a9 # Parent c2672cdf2d2a5fdabec2e6df1911a5b8c2b1d06e loss fixes (thanks to Daniel Serpell) - shrink22 fix diff -r c2672cdf2d2a -r fd676abc754c imgconvert.c --- a/imgconvert.c Mon Apr 21 14:38:52 2003 +0000 +++ b/imgconvert.c Mon Apr 21 15:01:37 2003 +0000 @@ -324,10 +324,11 @@ /* compute loss */ loss = 0; pf = &pix_fmt_info[dst_pix_fmt]; - if (pf->depth < ps->depth) + if (pf->depth < ps->depth || + (dst_pix_fmt == PIX_FMT_RGB555 && src_pix_fmt == PIX_FMT_RGB565)) loss |= FF_LOSS_DEPTH; - if (pf->x_chroma_shift >= ps->x_chroma_shift || - pf->y_chroma_shift >= ps->y_chroma_shift) + if (pf->x_chroma_shift > ps->x_chroma_shift || + pf->y_chroma_shift > ps->y_chroma_shift) loss |= FF_LOSS_RESOLUTION; switch(pf->color_type) { case FF_COLOR_RGB: @@ -345,7 +346,8 @@ break; case FF_COLOR_YUV_JPEG: if (ps->color_type != FF_COLOR_YUV_JPEG && - ps->color_type != FF_COLOR_YUV) + ps->color_type != FF_COLOR_YUV && + ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_COLORSPACE; break; default: @@ -867,16 +869,16 @@ s2 = s1 + src_wrap; d = dst; for(w = width;w >= 4; w-=4) { - d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 1; - d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 1; - d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 1; - d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 1; + d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2; + d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2; + d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2; + d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2; s1 += 8; s2 += 8; d += 4; } for(;w > 0; w--) { - d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 1; + d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2; s1 += 2; s2 += 2; d++;