[FFmpeg-devel] [PATCH] pcx: use memset()

Paul B Mahol onemda at gmail.com
Mon Aug 26 17:28:50 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/pcx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
index 67bc839..e66c80b 100644
--- a/libavcodec/pcx.c
+++ b/libavcodec/pcx.c
@@ -30,10 +30,10 @@
 
 static void pcx_rle_decode(GetByteContext *gb,
                            uint8_t *dst,
-                           unsigned int bytes_per_scanline,
+                           int bytes_per_scanline,
                            int compressed)
 {
-    unsigned int i = 0;
+    int i = 0;
     unsigned char run, value;
 
     if (compressed) {
@@ -44,8 +44,8 @@ static void pcx_rle_decode(GetByteContext *gb,
                 run   = value & 0x3f;
                 value = bytestream2_get_byte(gb);
             }
-            while (i < bytes_per_scanline && run--)
-                dst[i++] = value;
+            memset(&dst[i], value, FFMIN(FFMAX(bytes_per_scanline - i, 0), run));
+            i += FFMIN(FFMAX(bytes_per_scanline - i, 0), run);
         }
     } else {
         bytestream2_get_buffer(gb, dst, bytes_per_scanline);
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list