diff options
author | Martin Vignali <martin.vignali@gmail.com> | 2017-09-17 22:59:41 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-09-17 23:53:57 +0300 |
commit | 9b8c1224d7e1804b0b750de11e6a8c4648f1e115 (patch) | |
tree | badd352b0822660a1172da30088ad545a530c0c5 /libavcodec/exr.c | |
parent | 08ec828de9663e46fbfe8feef5c15253f841c687 (diff) |
libavcodec/exr : add X86 SIMD for reorder_pixels
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/exr.c')
-rw-r--r-- | libavcodec/exr.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 759880756d..de2f05d3a9 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -51,6 +51,7 @@ #include "bswapdsp.h" #endif +#include "exrdsp.h" #include "get_bits.h" #include "internal.h" #include "mathops.h" @@ -121,6 +122,7 @@ typedef struct EXRContext { AVClass *class; AVFrame *picture; AVCodecContext *avctx; + ExrDSPContext dsp; #if HAVE_BIGENDIAN BswapDSPContext bbdsp; @@ -275,23 +277,7 @@ static void predictor(uint8_t *src, int size) } } -static void reorder_pixels(uint8_t *src, uint8_t *dst, int size) -{ - const uint8_t *t1 = src; - int half_size = size / 2; - const uint8_t *t2 = src + half_size; - uint8_t *s = dst; - int i; - - av_assert1(size % 2 == 0); - - for (i = 0; i < half_size; i++) { - *(s++) = *(t1++); - *(s++) = *(t2++); - } -} - -static int zip_uncompress(const uint8_t *src, int compressed_size, +static int zip_uncompress(EXRContext *s, const uint8_t *src, int compressed_size, int uncompressed_size, EXRThreadData *td) { unsigned long dest_len = uncompressed_size; @@ -300,13 +286,15 @@ static int zip_uncompress(const uint8_t *src, int compressed_size, dest_len != uncompressed_size) return AVERROR_INVALIDDATA; + av_assert1(uncompressed_size % 2 == 0); + predictor(td->tmp, uncompressed_size); - reorder_pixels(td->tmp, td->uncompressed_data, uncompressed_size); + s->dsp.reorder_pixels(td->tmp, td->uncompressed_data, uncompressed_size); return 0; } -static int rle_uncompress(const uint8_t *src, int compressed_size, +static int rle_uncompress(EXRContext *ctx, const uint8_t *src, int compressed_size, int uncompressed_size, EXRThreadData *td) { uint8_t *d = td->tmp; @@ -345,8 +333,10 @@ static int rle_uncompress(const uint8_t *src, int compressed_size, if (dend != d) return AVERROR_INVALIDDATA; + av_assert1(uncompressed_size % 2 == 0); + predictor(td->tmp, uncompressed_size); - reorder_pixels(td->tmp, td->uncompressed_data, uncompressed_size); + ctx->dsp.reorder_pixels(td->tmp, td->uncompressed_data, uncompressed_size); return 0; } @@ -1152,7 +1142,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata, if (data_size < uncompressed_size) { av_fast_padded_malloc(&td->uncompressed_data, - &td->uncompressed_size, uncompressed_size); + &td->uncompressed_size, uncompressed_size + 64);/* Force 64 padding for AVX2 reorder_pixels dst */ if (!td->uncompressed_data) return AVERROR(ENOMEM); @@ -1161,7 +1151,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata, switch (s->compression) { case EXR_ZIP1: case EXR_ZIP16: - ret = zip_uncompress(src, data_size, uncompressed_size, td); + ret = zip_uncompress(s, src, data_size, uncompressed_size, td); break; case EXR_PIZ: ret = piz_uncompress(s, src, data_size, uncompressed_size, td); @@ -1170,7 +1160,7 @@ static int decode_block(AVCodecContext *avctx, void *tdata, ret = pxr24_uncompress(s, src, data_size, uncompressed_size, td); break; case EXR_RLE: - ret = rle_uncompress(src, data_size, uncompressed_size, td); + ret = rle_uncompress(s, src, data_size, uncompressed_size, td); break; case EXR_B44: case EXR_B44A: @@ -1804,6 +1794,8 @@ static av_cold int decode_init(AVCodecContext *avctx) s->avctx = avctx; + ff_exrdsp_init(&s->dsp); + #if HAVE_BIGENDIAN ff_bswapdsp_init(&s->bbdsp); #endif |