diff options
author | Sushanth Patil <sushanth.patil@ittiam.com> | 2020-04-23 21:56:44 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-04-23 21:56:44 +0000 |
commit | cc445e47c81e48380a652108be2b2c49e8004177 (patch) | |
tree | 8238f7b6f052679457d8edd72eb175c94e35d2ac | |
parent | fa556454ffd4cc13c6a3ce06e940c0ddfacf3c29 (diff) | |
parent | fae1d2a232d5eb860ce4dd70b4588e0760700aa4 (diff) | |
download | libxaac-cc445e47c81e48380a652108be2b2c49e8004177.tar.gz |
Optimisation changes in ixheaacd_samples_sat am: 92bec05d2d am: fae1d2a232
Change-Id: I58bbe1c3e0876fdc6f7081a52fd9b73aabfd1f01
-rw-r--r-- | decoder/ixheaacd_constants.h | 3 | ||||
-rw-r--r-- | decoder/ixheaacd_decode_main.c | 32 |
2 files changed, 19 insertions, 16 deletions
diff --git a/decoder/ixheaacd_constants.h b/decoder/ixheaacd_constants.h index a3c2675..3ac0065 100644 --- a/decoder/ixheaacd_constants.h +++ b/decoder/ixheaacd_constants.h @@ -63,6 +63,9 @@ #define MAX_16 (WORD16)0x7fff #define MIN_16 (WORD16)0x8000 +#define MAX_24 (WORD32)0x007fffff +#define MIN_24 (WORD32)0xff800000 + #define NULLPTR ((VOID *)0) #define IT_NULL ((VOID *)0) diff --git a/decoder/ixheaacd_decode_main.c b/decoder/ixheaacd_decode_main.c index 234178b..7ee1bcd 100644 --- a/decoder/ixheaacd_decode_main.c +++ b/decoder/ixheaacd_decode_main.c @@ -20,6 +20,7 @@ #include <stdlib.h> #include <string.h> #include "ixheaacd_type_def.h" +#include "ixheaacd_constants.h" #include "ixheaacd_error_standards.h" #include "ixheaacd_memory_standards.h" #include "ixheaacd_sbrdecsettings.h" @@ -69,7 +70,7 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, WORD32 *out_bytes, WORD32 num_channel_out) { WORD32 num; WORD32 i; - WORD64 write_local; + FLOAT32 sample; WORD16 *out_buf = (WORD16 *)outbuffer; @@ -77,31 +78,30 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, if (pcmsize == 16) { for (i = 0; i < num; i++) { - write_local = - ((WORD64)(out_samples[i % num_channel_out][i / num_channel_out])); + sample = (out_samples[i % num_channel_out][i / num_channel_out]); - if (write_local > 32767) { - write_local = 32767; + if (sample > MAX_16) { + sample = MAX_16; + } else if (sample < MIN_16) { + sample = MIN_16; } - if (write_local < -32768) { - write_local = -32768; - } - out_buf[i] = (WORD16)write_local; + out_buf[i] = (WORD16)sample; } *out_bytes = num * sizeof(WORD16); } else { WORD8 *out_24bit = (WORD8 *)out_buf; for (i = 0; i < num; i++) { - write_local = ((WORD64)( - out_samples[i % num_channel_out][i / num_channel_out] * 256)); + WORD32 write_local; + sample = (out_samples[i % num_channel_out][i / num_channel_out] * 256); - if (write_local > 8388607) { - write_local = 8388607; - } - if (write_local < -8388608) { - write_local = -8388608; + if (sample > MAX_24) { + sample = MAX_24; + } else if (sample < MIN_24) { + sample = MIN_24; } + write_local = (WORD32)sample; + *out_24bit++ = (WORD32)write_local & 0xff; *out_24bit++ = ((WORD32)write_local >> 8) & 0xff; *out_24bit++ = ((WORD32)write_local >> 16) & 0xff; |