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@niedermayer.cc>
This commit is contained in:
Martin Vignali 2017-05-05 22:20:58 +02:00 committed by Michael Niedermayer
parent a453f5549a
commit 2c6179aa82
1 changed files with 10 additions and 13 deletions

View File

@ -37,6 +37,7 @@
#include <float.h> #include <float.h>
#include <zlib.h> #include <zlib.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h" #include "libavutil/common.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "libavutil/intfloat.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) static void reorder_pixels(uint8_t *src, uint8_t *dst, int size)
{ {
const int8_t *t1 = src; const uint8_t *t1 = src;
const int8_t *t2 = src + (size + 1) / 2; int half_size = size / 2;
int8_t *s = dst; const uint8_t *t2 = src + half_size;
int8_t *stop = s + size; uint8_t *s = dst;
int i;
while (1) { av_assert1(size % 2 == 0);
if (s < stop)
for (i = 0; i < half_size; i++) {
*(s++) = *(t1++); *(s++) = *(t1++);
else
break;
if (s < stop)
*(s++) = *(t2++); *(s++) = *(t2++);
else
break;
} }
} }