From 2c6179aa829e6f50eea6faf47b2b6efd7650a41d Mon Sep 17 00:00:00 2001 From: Martin Vignali Date: Fri, 5 May 2017 22:20:58 +0200 Subject: [PATCH] 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 --- libavcodec/exr.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 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 #include +#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; + const uint8_t *t1 = src; + int half_size = size / 2; + const uint8_t *t2 = src + half_size; + uint8_t *s = dst; + int i; - while (1) { - if (s < stop) - *(s++) = *(t1++); - else - break; + av_assert1(size % 2 == 0); - if (s < stop) - *(s++) = *(t2++); - else - break; + for (i = 0; i < half_size; i++) { + *(s++) = *(t1++); + *(s++) = *(t2++); } }