diff options
author | Sushanth Patil <sushanth.patil@ittiam.com> | 2019-10-29 10:41:29 +0530 |
---|---|---|
committer | Ray Essick <essick@google.com> | 2020-04-18 08:15:56 -0700 |
commit | 92bec05d2d2d342580176e493ee67a6b3cfd7ba8 (patch) | |
tree | 8238f7b6f052679457d8edd72eb175c94e35d2ac | |
parent | 05c7402a06c8f5053e0daeaa5faad9e03ad6c2be (diff) | |
download | libxaac-92bec05d2d2d342580176e493ee67a6b3cfd7ba8.tar.gz |
Optimisation changes in ixheaacd_samples_sat
Changed 64-bit operations used for saturating the
output pcm to 32 bit operations targeted towards
32-bit/armv7 architecture.
Bug: 154143053
Test: xaacdec
Change-Id: I3914f5a92feee592626fb53ca7e24b60dda59db4
-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; |