diff options
author | Diego Biurrun <diego@biurrun.de> | 2014-01-23 17:25:16 +0100 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2014-06-26 16:15:07 -0700 |
commit | d2869aea0494d3a20d53d5034cd41dbb488eb133 (patch) | |
tree | 5ac56a53fdba6b7edebc34130bae0415165c09db | |
parent | 24f45c16224d4c5d482e928676714766ffdda4fc (diff) | |
download | ffmpeg-d2869aea0494d3a20d53d5034cd41dbb488eb133.tar.gz |
dsputil: Move MMX/SSE2-optimized IDCT bits to the x86 subdirectory
-rw-r--r-- | libavcodec/dsputil.c | 27 | ||||
-rw-r--r-- | libavcodec/dsputil.h | 2 | ||||
-rw-r--r-- | libavcodec/x86/dsputil_init.c | 33 |
3 files changed, 40 insertions, 22 deletions
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 5d706bd6e7..ca0c8ef622 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -48,20 +48,6 @@ uint32_t ff_square_tab[512] = { 0, }; #define BIT_DEPTH 8 #include "dsputilenc_template.c" -/* Input permutation for the simple_idct_mmx */ -static const uint8_t simple_mmx_permutation[64] = { - 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, - 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D, - 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D, - 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F, - 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F, - 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D, - 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, - 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, -}; - -static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 }; - av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable) { @@ -88,6 +74,11 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, { int i; + if (ARCH_X86) + if (ff_init_scantable_permutation_x86(idct_permutation, + idct_permutation_type)) + return; + switch (idct_permutation_type) { case FF_NO_IDCT_PERM: for (i = 0; i < 64; i++) @@ -97,10 +88,6 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, for (i = 0; i < 64; i++) idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); break; - case FF_SIMPLE_IDCT_PERM: - for (i = 0; i < 64; i++) - idct_permutation[i] = simple_mmx_permutation[i]; - break; case FF_TRANSPOSE_IDCT_PERM: for (i = 0; i < 64; i++) idct_permutation[i] = ((i & 7) << 3) | (i >> 3); @@ -109,10 +96,6 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, for (i = 0; i < 64; i++) idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3); break; - case FF_SSE2_IDCT_PERM: - for (i = 0; i < 64; i++) - idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7]; - break; default: av_log(NULL, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n"); diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 1dbc784fbb..b271dccf82 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -57,6 +57,8 @@ void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable); void ff_init_scantable_permutation(uint8_t *idct_permutation, int idct_permutation_type); +int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, + int idct_permutation_type); /** * DSPContext. diff --git a/libavcodec/x86/dsputil_init.c b/libavcodec/x86/dsputil_init.c index 90e62715db..74dab48e72 100644 --- a/libavcodec/x86/dsputil_init.c +++ b/libavcodec/x86/dsputil_init.c @@ -26,6 +26,39 @@ #include "dsputil_x86.h" #include "idct_xvid.h" +/* Input permutation for the simple_idct_mmx */ +static const uint8_t simple_mmx_permutation[64] = { + 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, + 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D, + 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D, + 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F, + 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F, + 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D, + 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, + 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, +}; + +static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 }; + +av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, + int idct_permutation_type) +{ + int i; + + switch (idct_permutation_type) { + case FF_SIMPLE_IDCT_PERM: + for (i = 0; i < 64; i++) + idct_permutation[i] = simple_mmx_permutation[i]; + return 1; + case FF_SSE2_IDCT_PERM: + for (i = 0; i < 64; i++) + idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7]; + return 1; + } + + return 0; +} + static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx, int cpu_flags, unsigned high_bit_depth) { |