diff options
author | Paul B Mahol <onemda@gmail.com> | 2015-10-05 12:28:41 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2015-10-09 21:38:15 +0200 |
commit | 35af7add6fac7f926d0cbb5724f36f0fe5022488 (patch) | |
tree | 038c8d9a54b192093ed2c05b679a80ee6e0fa673 /libavcodec/takdec.c | |
parent | 2f4374fae135afeee84f987c8fab8cbad1c7fcc7 (diff) | |
download | ffmpeg-35af7add6fac7f926d0cbb5724f36f0fe5022488.tar.gz |
avcodec/takdec: add x86 SIMD for rest of decorrelation modes
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/takdec.c')
-rw-r--r-- | libavcodec/takdec.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c index 5395596cfc..e5c0723940 100644 --- a/libavcodec/takdec.c +++ b/libavcodec/takdec.c @@ -28,6 +28,7 @@ #include "libavutil/internal.h" #include "libavutil/samplefmt.h" #include "tak.h" +#include "takdsp.h" #include "audiodsp.h" #include "thread.h" #include "avcodec.h" @@ -47,6 +48,7 @@ typedef struct MCDParam { typedef struct TAKDecContext { AVCodecContext *avctx; ///< parent AVCodecContext AudioDSPContext adsp; + TAKDSPContext tdsp; TAKStreamInfo ti; GetBitContext gb; ///< bitstream reader initialized to start at the current frame @@ -172,6 +174,7 @@ static av_cold int tak_decode_init(AVCodecContext *avctx) TAKDecContext *s = avctx->priv_data; ff_audiodsp_init(&s->adsp); + ff_takdsp_init(&s->tdsp); s->avctx = avctx; avctx->bits_per_raw_sample = avctx->bits_per_coded_sample; @@ -541,46 +544,32 @@ static int decode_channel(TAKDecContext *s, int chan) static int decorrelate(TAKDecContext *s, int c1, int c2, int length) { GetBitContext *gb = &s->gb; - int32_t *p1 = s->decoded[c1] + 1; - int32_t *p2 = s->decoded[c2] + 1; + int32_t *p1 = s->decoded[c1] + (s->dmode > 5); + int32_t *p2 = s->decoded[c2] + (s->dmode > 5); + int32_t bp1 = p1[0]; + int32_t bp2 = p2[0]; int i; int dshift, dfactor; + length += s->dmode < 6; + switch (s->dmode) { case 1: /* left/side */ - for (i = 0; i < length; i++) { - int32_t a = p1[i]; - int32_t b = p2[i]; - p2[i] = a + b; - } + s->tdsp.decorrelate_ls(p1, p2, length); break; case 2: /* side/right */ - for (i = 0; i < length; i++) { - int32_t a = p1[i]; - int32_t b = p2[i]; - p1[i] = b - a; - } + s->tdsp.decorrelate_sr(p1, p2, length); break; case 3: /* side/mid */ - for (i = 0; i < length; i++) { - int32_t a = p1[i]; - int32_t b = p2[i]; - a -= b >> 1; - p1[i] = a; - p2[i] = a + b; - } + s->tdsp.decorrelate_sm(p1, p2, length); break; case 4: /* side/left with scale factor */ FFSWAP(int32_t*, p1, p2); + FFSWAP(int32_t, bp1, bp2); case 5: /* side/right with scale factor */ dshift = get_bits_esc4(gb); dfactor = get_sbits(gb, 10); - for (i = 0; i < length; i++) { - int32_t a = p1[i]; - int32_t b = p2[i]; - b = dfactor * (b >> dshift) + 128 >> 8 << dshift; - p1[i] = b - a; - } + s->tdsp.decorrelate_sf(p1, p2, length, dshift, dfactor); break; case 6: FFSWAP(int32_t*, p1, p2); @@ -664,6 +653,11 @@ static int decorrelate(TAKDecContext *s, int c1, int c2, int length) } } + if (s->dmode > 0 && s->dmode < 6) { + p1[0] = bp1; + p2[0] = bp2; + } + return 0; } |