diff --git a/system/embdrv/encoder_for_aptx/src/CodewordPacker.h b/system/embdrv/encoder_for_aptx/src/CodewordPacker.h index 68b7a1dea6bcfccb5de62b52558da5a883ddfc7c..a4b96ebf95c6a206b7b0714d1c4e923ddf30ebe1 100644 --- a/system/embdrv/encoder_for_aptx/src/CodewordPacker.h +++ b/system/embdrv/encoder_for_aptx/src/CodewordPacker.h @@ -27,7 +27,7 @@ #include "AptxParameters.h" -XBT_INLINE_ int32_t packCodeword(Encoder_data* EncoderDataPt, +XBT_INLINE_ int16_t packCodeword(Encoder_data* EncoderDataPt, uint32_t aligned) { int32_t syncContribution; int32_t hhCode; @@ -58,7 +58,7 @@ XBT_INLINE_ int32_t packCodeword(Encoder_data* EncoderDataPt, ((EncoderDataPt->m_qdata[HL].qCode & 0x3L) << 11) | ((EncoderDataPt->m_qdata[HH].qCode & 0x7L) << 13); } - return codeword; + return (int16_t)codeword; } #endif // CODEWORDPACKER_H diff --git a/system/embdrv/encoder_for_aptx/src/QmfConv.c b/system/embdrv/encoder_for_aptx/src/QmfConv.c index e584129820b20f799eb07ab84119656a74190497..de3057f4e23fe47fc08819d45f67a8dd52515c83 100644 --- a/system/embdrv/encoder_for_aptx/src/QmfConv.c +++ b/system/embdrv/encoder_for_aptx/src/QmfConv.c @@ -19,7 +19,7 @@ * *----------------------------------------------------------------------------*/ -#include "AptxParameters.h" +#include "Qmf.h" void AsmQmfConvO(const int16_t* p1dl_buffPtr, const int16_t* p2dl_buffPtr, const int32_t* coeffPtr, int32_t* convSumDiff) { diff --git a/system/embdrv/encoder_for_aptx/src/QuantiseDifference.c b/system/embdrv/encoder_for_aptx/src/QuantiseDifference.c index 697ed3e19893a6c59563813c95dfe99f8771b178..9d87a122c90367aa1dc46d4e4380de3e75dfe25d 100644 --- a/system/embdrv/encoder_for_aptx/src/QuantiseDifference.c +++ b/system/embdrv/encoder_for_aptx/src/QuantiseDifference.c @@ -228,7 +228,7 @@ void quantiseDifferenceHL(const int32_t diffSignal, const int32_t ditherVal, if (tmp_round0 == 0x40000000L) acc--; _delta = -delta << 8; - acc = acc << 4; + acc = (int32_t)((uint32_t)acc << 4); /* Form (absDiffSignal * 0.125) - (acc * delta), which is the final distance * signal used to determine if dithering alters the quantised code value or @@ -373,7 +373,7 @@ void quantiseDifferenceHH(const int32_t diffSignal, const int32_t ditherVal, if (tmp_round0 == 0x40000000L) acc--; _delta = -delta << 8; - acc = acc << 4; + acc = (int32_t)((uint32_t)acc << 4); /* Form (absDiffSignal * 0.125) - (acc * delta), which is the final distance * signal used to determine if dithering alters the quantised code value or @@ -518,7 +518,8 @@ void quantiseDifferenceLL(const int32_t diffSignal, const int32_t ditherVal, if (tmp_round0 == 0x40000000L) acc--; _delta = -delta << 8; - acc = acc << 4; + acc = (int32_t)((uint32_t)acc << 4); + /* Form (absDiffSignal * 0.125) - (acc * delta), which is the final distance * signal used to determine if dithering alters the quantised code value or * not. */ @@ -661,7 +662,7 @@ void quantiseDifferenceLH(const int32_t diffSignal, const int32_t ditherVal, if (tmp_round0 == 0x40000000L) acc--; _delta = -delta << 8; - acc = acc << 4; + acc = (int32_t)((uint32_t)acc << 4); /* Form (absDiffSignal * 0.125) - (acc * delta), which is the final distance * signal used to determine if dithering alters the quantised code value or diff --git a/system/embdrv/encoder_for_aptx/src/SubbandFunctions.h b/system/embdrv/encoder_for_aptx/src/SubbandFunctions.h index 949846f39383a8f5de0b9a23098609fff8ff0c1e..16c1b9fb2d2471020b654d19faf000c0f2454452 100644 --- a/system/embdrv/encoder_for_aptx/src/SubbandFunctions.h +++ b/system/embdrv/encoder_for_aptx/src/SubbandFunctions.h @@ -71,16 +71,14 @@ XBT_INLINE_ void updatePredictorPoleCoefficients( PoleCoeffDataPt->m_poleAdaptDelayLine.s16.h = PoleCoeffDataPt->m_poleAdaptDelayLine.s16.l; PoleCoeffDataPt->m_poleAdaptDelayLine.s16.l = -1; - } - if (adaptSum == 0L) { + } else if (adaptSum == 0L) { sgnP[k] = 0L; sgnP[k_1] = 0L; sgnP[k_2] = 0L; PoleCoeffDataPt->m_poleAdaptDelayLine.s16.h = PoleCoeffDataPt->m_poleAdaptDelayLine.s16.l; PoleCoeffDataPt->m_poleAdaptDelayLine.s16.l = 1; - } - if (adaptSum > 0L) { + } else { // adaptSum > 0L sgnP[k] = oneQ22; sgnP[k_1] = ((int32_t)PoleCoeffDataPt->m_poleAdaptDelayLine.s16.l) << 22; sgnP[k_2] = ((int32_t)PoleCoeffDataPt->m_poleAdaptDelayLine.s16.h) << 22; @@ -129,7 +127,7 @@ XBT_INLINE_ void updatePredictorPoleCoefficients( * back out. */ acc2 = PoleCoeffDataPt->m_poleCoeff[a2] << 8; acc2 -= PoleCoeffDataPt->m_poleCoeff[a2] << 1; - Bacc <<= 8; + Bacc = (int32_t)((uint32_t)Bacc << 8); Bacc += acc2; tmp2_round0 = (int16_t)Bacc & 0x01FFL; diff --git a/system/embdrv/encoder_for_aptx/src/aptXbtenc.c b/system/embdrv/encoder_for_aptx/src/aptXbtenc.c index cd819ce20a5f79fafee3e4a18fd99c0a808bcdb8..9a69bf6677041b894f6f2c157374fbbc08950d9b 100644 --- a/system/embdrv/encoder_for_aptx/src/aptXbtenc.c +++ b/system/embdrv/encoder_for_aptx/src/aptXbtenc.c @@ -56,7 +56,7 @@ static const int32_t IQuant_tableLogT[32] = { 28160 * 256, 28776 * 256, 29408 * 256, 30048 * 256, 30704 * 256, 31376 * 256, 32064 * 256}; -void clearmem(void* mem, int32_t sz) { +static void clearmem(void* mem, int32_t sz) { int8_t* m = (int8_t*)mem; int32_t i = 0; for (; i < sz; i++) { @@ -183,7 +183,7 @@ APTXBTENCEXPORT int aptxbtenc_encodestereo(void* _state, void* _pcmL, int32_t* pcmL = (int32_t*)_pcmL; int32_t* pcmR = (int32_t*)_pcmR; int16_t* buffer = (int16_t*)_buffer; - int32_t tmp_reg; + int16_t tmp_reg; int16_t tmp_out; // Feed the PCM to the dual aptX encoders aptxEncode(pcmL, &state->m_qmf_l, &state->m_encoderData[0]); diff --git a/system/embdrv/encoder_for_aptxhd/src/QmfConv.c b/system/embdrv/encoder_for_aptxhd/src/QmfConv.c index bae3c48fdab14b356c506a07c9f2d5fbde281bed..e32b3ee1d9f87654ee0d67240e8ee172bebe2353 100644 --- a/system/embdrv/encoder_for_aptxhd/src/QmfConv.c +++ b/system/embdrv/encoder_for_aptxhd/src/QmfConv.c @@ -19,7 +19,7 @@ * *----------------------------------------------------------------------------*/ -#include "AptxParameters.h" +#include "Qmf.h" void AsmQmfConvO_HD(const int32_t* p1dl_buffPtr, const int32_t* p2dl_buffPtr, const int32_t* coeffPtr, int32_t* convSumDiff) { diff --git a/system/embdrv/encoder_for_aptxhd/src/QuantiseDifference.c b/system/embdrv/encoder_for_aptxhd/src/QuantiseDifference.c index 899ab3f815cd93439a1a8ac99d70c8986fc51f18..f7e4b3a63dbf889188d37eae79401aaea07526f4 100644 --- a/system/embdrv/encoder_for_aptxhd/src/QuantiseDifference.c +++ b/system/embdrv/encoder_for_aptxhd/src/QuantiseDifference.c @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "AptxParameters.h" + +#include "Quantiser.h" XBT_INLINE_ int32_t BsearchLL(const int32_t absDiffSignalShifted, const int32_t delta, @@ -232,7 +233,7 @@ void quantiseDifference_HDHL(const int32_t diffSignal, const int32_t ditherVal, if (tmp_round0 == 0x40000000L) acc--; _delta = -delta << 8; - acc = acc << 4; + acc = (int32_t)((uint32_t)acc << 4); /* Form (absDiffSignal * 0.125) - (acc * delta), which is the final distance * signal used to determine if dithering alters the quantised code value or @@ -375,7 +376,7 @@ void quantiseDifference_HDHH(const int32_t diffSignal, const int32_t ditherVal, if (tmp_round0 == 0x40000000L) acc--; _delta = -delta << 8; - acc = acc << 4; + acc = (int32_t)((uint32_t)acc << 4); /* Form (absDiffSignal * 0.125) - (acc * delta), which is the final distance * signal used to determine if dithering alters the quantised code value or @@ -443,8 +444,6 @@ void quantiseDifference_HDLL(const int32_t diffSignal, const int32_t ditherVal, * table index of the LARGEST threshold table value for which * absDiffSignalShifted >= (delta * threshold) */ - index = 0; - index = BsearchLL(absDiffSignalShifted, delta, qdata_pt->thresholdTablePtr_sl1); @@ -522,7 +521,7 @@ void quantiseDifference_HDLL(const int32_t diffSignal, const int32_t ditherVal, if (tmp_round0 == 0x40000000L) acc--; _delta = -delta << 8; - acc = acc << 4; + acc = (int32_t)((uint32_t)acc << 4); /* Form (absDiffSignal * 0.125) - (acc * delta), which is the final distance * signal used to determine if dithering alters the quantised code value or @@ -564,8 +563,8 @@ void quantiseDifference_HDLL(const int32_t diffSignal, const int32_t ditherVal, qdata_pt->qCode = tmp_qCode; } -int32_t BsearchLH(const int32_t absDiffSignalShifted, const int32_t delta, - const int32_t* dqbitTablePrt) { +static int32_t BsearchLH(const int32_t absDiffSignalShifted, + const int32_t delta, const int32_t* dqbitTablePrt) { int32_t qCode; reg64_t tmp_acc; int32_t tmp; @@ -711,7 +710,7 @@ void quantiseDifference_HDLH(const int32_t diffSignal, const int32_t ditherVal, if (tmp_round0 == 0x40000000L) acc--; _delta = -delta << 8; - acc = acc << 4; + acc = (int32_t)((uint32_t)acc << 4); /* Form (absDiffSignal * 0.125) - (acc * delta), which is the final distance * signal used to determine if dithering alters the quantised code value or diff --git a/system/embdrv/encoder_for_aptxhd/src/SubbandFunctions.h b/system/embdrv/encoder_for_aptxhd/src/SubbandFunctions.h index b2ef3c28f8f1cbfb193ab3e80f82df5e0208c06a..ebf8f4853417d88cb8467d3a3e8eb5db1e23dd09 100644 --- a/system/embdrv/encoder_for_aptxhd/src/SubbandFunctions.h +++ b/system/embdrv/encoder_for_aptxhd/src/SubbandFunctions.h @@ -127,7 +127,7 @@ XBT_INLINE_ void updatePredictorPoleCoefficients( * back out. */ acc2 = PoleCoeffDataPt->m_poleCoeff[a2] << 8; acc2 -= PoleCoeffDataPt->m_poleCoeff[a2] << 1; - Bacc <<= 8; + Bacc = (int32_t)((uint32_t)Bacc << 8); Bacc += acc2; tmp2_round0 = (int16_t)Bacc & 0x01FFL; diff --git a/system/embdrv/encoder_for_aptxhd/src/aptXHDbtenc.c b/system/embdrv/encoder_for_aptxhd/src/aptXHDbtenc.c index fa5128b67b605da3b29e928d9eb03af6e1e42501..2d4a08309534fb1d5ceb3a2948d4922b6190cee9 100644 --- a/system/embdrv/encoder_for_aptxhd/src/aptXHDbtenc.c +++ b/system/embdrv/encoder_for_aptxhd/src/aptXHDbtenc.c @@ -50,7 +50,7 @@ static const int32_t IQuant_tableLogT[32] = { 28160 * 256, 28776 * 256, 29408 * 256, 30048 * 256, 30704 * 256, 31376 * 256, 32064 * 256}; -void clearmem_HD(void* mem, int32_t sz) { +static void clearmem_HD(void* mem, int32_t sz) { int8_t* m = (int8_t*)mem; int32_t i = 0; for (; i < sz; i++) {