[MPlayer-cvslog] r21938 - trunk/libmpdemux/demux_gif.c

reimar subversion at mplayerhq.hu
Tue Jan 16 08:01:53 CET 2007


Author: reimar
Date: Tue Jan 16 08:01:53 2007
New Revision: 21938

Modified:
   trunk/libmpdemux/demux_gif.c

Log:
"Cosmetics" Introduce a memcpy function doing bot transparent
and non-transparent copy.


Modified: trunk/libmpdemux/demux_gif.c
==============================================================================
--- trunk/libmpdemux/demux_gif.c	(original)
+++ trunk/libmpdemux/demux_gif.c	Tue Jan 16 08:01:53 2007
@@ -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) {



More information about the MPlayer-cvslog mailing list