From 92bec05d2d2d342580176e493ee67a6b3cfd7ba8 Mon Sep 17 00:00:00 2001 From: Sushanth Patil Date: Tue, 29 Oct 2019 10:41:29 +0530 Subject: [PATCH] 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 --- decoder/ixheaacd_constants.h | 3 +++ 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 #include #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;