#include "avcodec.h"
#include "bytestream.h"
+
+#if HAVE_BIGENDIAN
+#include "bswapdsp.h"
+#endif
+
#include "get_bits.h"
#include "internal.h"
#include "mathops.h"
AVFrame *picture;
AVCodecContext *avctx;
+#if HAVE_BIGENDIAN
+ BswapDSPContext bbdsp;
+#endif
+
enum ExrCompr compression;
enum ExrPixelType pixel_type;
int channel_offsets[4]; // 0 = red, 1 = green, 2 = blue and 3 = alpha
*
* @return normalized 16-bit unsigned int
*/
-static inline uint16_t exr_flt2uint(uint32_t v)
+static inline uint16_t exr_flt2uint(int32_t v)
{
- unsigned int exp = v >> 23;
+ int32_t exp = v >> 23;
// "HACK": negative values result in exp< 0, so clipping them to 0
// is also handled by this condition, avoids explicit check for sign bit.
if (exp <= 127 + 7 - 24) // we would shift out all bits anyway
uint16_t maxval, min_non_zero, max_non_zero;
uint16_t *ptr;
uint16_t *tmp = (uint16_t *)td->tmp;
- uint8_t *out;
+ uint16_t *out;
+ uint16_t *in;
int ret, i, j;
int pixel_half_size;/* 1 for half, 2 for float and uint32 */
EXRChannel *channel;
apply_lut(td->lut, tmp, dsize / sizeof(uint16_t));
- out = td->uncompressed_data;
+ out = (uint16_t *)td->uncompressed_data;
for (i = 0; i < td->ysize; i++) {
tmp_offset = 0;
for (j = 0; j < s->nb_channels; j++) {
- uint16_t *in;
- EXRChannel *channel = &s->channels[j];
+ channel = &s->channels[j];
if (channel->pixel_type == EXR_HALF)
pixel_half_size = 1;
else
in = tmp + tmp_offset * td->xsize * td->ysize + i * td->xsize * pixel_half_size;
tmp_offset += pixel_half_size;
+
+#if HAVE_BIGENDIAN
+ s->bbdsp.bswap16_buf(out, in, td->xsize * pixel_half_size);
+#else
memcpy(out, in, td->xsize * 2 * pixel_half_size);
- out += td->xsize * 2 * pixel_half_size;
+#endif
+ out += td->xsize * pixel_half_size;
}
}
s->avctx = avctx;
+#if HAVE_BIGENDIAN
+ ff_bswapdsp_init(&s->bbdsp);
+#endif
+
trc_func = avpriv_get_trc_function_from_trc(s->apply_trc_type);
if (trc_func) {
for (i = 0; i < 65536; ++i) {