[FFmpeg-cvslog] libavcodec/exr : simplify reorder_pixels

Martin Vignali git at videolan.org
Sun May 14 22:19:05 EEST 2017


ffmpeg | branch: master | Martin Vignali <martin.vignali at gmail.com> | Fri May  5 22:20:58 2017 +0200| [2c6179aa829e6f50eea6faf47b2b6efd7650a41d] | committer: Michael Niedermayer

libavcodec/exr : simplify reorder_pixels

reorder_pixels is call by rle_uncompress and zip_uncompress
with size == uncompress_size

uncompress_size is a multiple of 2 (because exr store data
in half, float, or uint32)

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2c6179aa829e6f50eea6faf47b2b6efd7650a41d
---

 libavcodec/exr.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index bf18ad0c79..759880756d 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -37,6 +37,7 @@
 #include <float.h>
 #include <zlib.h>
 
+#include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intfloat.h"
@@ -276,21 +277,17 @@ static void predictor(uint8_t *src, int size)
 
 static void reorder_pixels(uint8_t *src, uint8_t *dst, int size)
 {
-    const int8_t *t1 = src;
-    const int8_t *t2 = src + (size + 1) / 2;
-    int8_t *s        = dst;
-    int8_t *stop     = s + size;
-
-    while (1) {
-        if (s < stop)
-            *(s++) = *(t1++);
-        else
-            break;
+    const uint8_t *t1 = src;
+    int half_size     = size / 2;
+    const uint8_t *t2 = src + half_size;
+    uint8_t *s        = dst;
+    int i;
 
-        if (s < stop)
-            *(s++) = *(t2++);
-        else
-            break;
+    av_assert1(size % 2 == 0);
+
+    for (i = 0; i < half_size; i++) {
+        *(s++) = *(t1++);
+        *(s++) = *(t2++);
     }
 }
 



More information about the ffmpeg-cvslog mailing list