Mercurial > libavcodec.hg
changeset 1206:fd676abc754c libavcodec
loss fixes (thanks to Daniel Serpell) - shrink22 fix
author | bellard |
---|---|
date | Mon, 21 Apr 2003 15:01:37 +0000 |
parents | c2672cdf2d2a |
children | 162be12df86a |
files | imgconvert.c |
diffstat | 1 files changed, 11 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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++;