[FFmpeg-devel] [PATCH] Electronic Arts TGV decoder

Reimar Döffinger Reimar.Doeffinger
Sun Jul 20 10:04:44 CEST 2008


Hello,
On Sun, Jul 20, 2008 at 12:28:06PM +1000, pross at xvid.org wrote:
> On Sat, Jul 19, 2008 at 11:30:38AM +0200, Reimar D?ffinger wrote:
> > The diff should be smaller if you change the order of these two
> > functions.
> 
> Okay, but s/smaller/simpler/.

Why did you put the new function below lzo1x_decode? And no, I did mean
smaller, the diff should basically consist of an additional { and a new
function header + doxy and maybe a few more lines.
Anything above that IMO needs an explanation why that would be needed.
Oh well, I just did change it myself, see attached patch.
-------------- next part --------------
Index: libavutil/lzo.c
===================================================================
--- libavutil/lzo.c	(revision 14263)
+++ libavutil/lzo.c	(working copy)
@@ -125,9 +125,23 @@
         cnt = FFMAX(c->out_end - dst, 0);
         c->error |= LZO_OUTPUT_FULL;
     }
+    av_memcpy_backptr(dst, back, cnt);
+    c->out = dst + cnt;
+}
+
+/**
+ * \brief deliberately overlapping memcpy implementation
+ * \param dst destination buffer; must be padded with 12 additional bytes
+ * \param back how many bytes back we start (the initial size of the overlapping window)
+ * \param cnt number of bytes to copy, must be >= 0
+ *
+ * cnt > back is valid, this will copy the bytes we just copied,
+ * thus creating a repeating pattern with a period length of back.
+ */
+void av_memcpy_backptr(uint8_t *dst, int back, int cnt) {
+    const uint8_t *src = &dst[-back];
     if (back == 1) {
         memset(dst, *src, cnt);
-        dst += cnt;
     } else {
 #ifdef OUTBUF_PADDED
         COPY2(dst, src);
@@ -155,9 +169,7 @@
             }
             memcpy(dst, src, cnt);
         }
-        dst += cnt;
     }
-    c->out = dst;
 }
 
 /**



More information about the ffmpeg-devel mailing list