Mercurial > mplayer.hg
changeset 21920:65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
and non-transparent copy.
author | reimar |
---|---|
date | Tue, 16 Jan 2007 07:01:53 +0000 |
parents | 05223564b604 |
children | e4265d11dc37 |
files | libmpdemux/demux_gif.c |
diffstat | 1 files changed, 21 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_gif.c Mon Jan 15 23:03:45 2007 +0000 +++ b/libmpdemux/demux_gif.c Tue Jan 16 07:01:53 2007 +0000 @@ -43,6 +43,25 @@ return 0; } +static void memcpy_transp_pic(uint8_t *dst, uint8_t *src, int w, int h, + int dstride, int sstride, int transp, uint8_t trans_col) { + if (transp) { + dstride -= w; + sstride -= w; + while (h-- > 0) { + int wleft = w; + while (wleft-- > 0) { + if (*src != trans_col) + *dst = *src; + dst++; src++; + } + dst += dstride; + src += sstride; + } + } else + memcpy_pic(dst, src, w, h, dstride, sstride); +} + static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds) { gif_priv_t *priv = demuxer->priv; @@ -148,21 +167,8 @@ priv->palette[(y * 4) + 3] = 0; } - if (transparency) { - uint8_t *dpos = dest, *spos = buf; - int hleft = h; - while (hleft-- > 0) { - int wleft = w; - while (wleft-- > 0) { - if (*spos != transparent_col) - *dpos = *spos; - dpos++; spos++; - } - dpos += priv->w - w; - spos += gif->Image.Width - w; - } - } else - memcpy_pic(dest, buf, w, h, priv->w, gif->Image.Width); + memcpy_transp_pic(dest, buf, w, h, priv->w, gif->Image.Width, + transparency, transparent_col); if (refmode == 1) memcpy(priv->refimg, dp->buffer, priv->w * priv->h); if (refmode == 2 && priv->useref) {