From efc60ce3b9a56c7135bfaca063ddba280ab52e58 Mon Sep 17 00:00:00 2001 From: William Escande <wescande@google.com> Date: Fri, 4 Nov 2022 21:26:23 -0700 Subject: [PATCH] Enable tidy for aptx and aptxHD Test: ALLOW_LOCAL_TIDY_TRUE=true m libaptxhd_enc Test: ALLOW_LOCAL_TIDY_TRUE=true m libaptx_enc Bug: 226572369 Change-Id: I8785e725dad51e263483efd8b91cd4ad4cbfb06b --- system/embdrv/encoder_for_aptx/Android.bp | 16 ++ system/embdrv/encoder_for_aptx/src/QmfConv.c | 80 ++++-- .../encoder_for_aptx/src/QuantiseDifference.c | 161 +++++++---- .../embdrv/encoder_for_aptx/src/aptXbtenc.c | 4 +- system/embdrv/encoder_for_aptxhd/Android.bp | 16 ++ .../embdrv/encoder_for_aptxhd/src/QmfConv.c | 72 +++-- .../src/QuantiseDifference.c | 261 ++++++++++++------ .../encoder_for_aptxhd/src/aptXHDbtenc.c | 21 +- 8 files changed, 437 insertions(+), 194 deletions(-) diff --git a/system/embdrv/encoder_for_aptx/Android.bp b/system/embdrv/encoder_for_aptx/Android.bp index 8c1df8488ec..502759e9250 100644 --- a/system/embdrv/encoder_for_aptx/Android.bp +++ b/system/embdrv/encoder_for_aptx/Android.bp @@ -1,3 +1,16 @@ +tidy_errors = [ + "*", + "-altera-struct-pack-align", + "-altera-unroll-loops", + "-bugprone-narrowing-conversions", + "-cppcoreguidelines-avoid-magic-numbers", + "-cppcoreguidelines-init-variables", + "-cppcoreguidelines-narrowing-conversions", + "-hicpp-signed-bitwise", + "-readability-identifier-length", + "-readability-magic-numbers", +] + cc_library_static { name: "libaptx_enc", host_supported: true, @@ -9,6 +22,9 @@ cc_library_static { "src/QuantiseDifference.c", ], cflags: ["-O2", "-Werror", "-Wall", "-Wextra"], + tidy: true, + tidy_checks: tidy_errors, + tidy_checks_as_errors: tidy_errors, min_sdk_version: "Tiramisu", apex_available: [ "com.android.btservices", diff --git a/system/embdrv/encoder_for_aptx/src/QmfConv.c b/system/embdrv/encoder_for_aptx/src/QmfConv.c index de3057f4e23..4f24d1e894f 100644 --- a/system/embdrv/encoder_for_aptx/src/QmfConv.c +++ b/system/embdrv/encoder_for_aptx/src/QmfConv.c @@ -143,29 +143,49 @@ void AsmQmfConvO(const int16_t* p1dl_buffPtr, const int16_t* p2dl_buffPtr, local_acc0 += 0x004000L; acc = (int32_t)(local_acc0 >> 15); - if (tmp_round0 == 0x004000L) acc--; - if (acc > 8388607) acc = 8388607; - if (acc < -8388608) acc = -8388608; + if (tmp_round0 == 0x004000L) { + acc--; + } + if (acc > 8388607) { + acc = 8388607; + } + if (acc < -8388608) { + acc = -8388608; + } - phaseConv[0] = (int32_t)acc; + phaseConv[0] = acc; tmp_round0 = (int32_t)local_acc1 & 0x00FFFFL; local_acc1 += 0x004000L; acc = (int32_t)(local_acc1 >> 15); - if (tmp_round0 == 0x004000L) acc--; - if (acc > 8388607) acc = 8388607; - if (acc < -8388608) acc = -8388608; + if (tmp_round0 == 0x004000L) { + acc--; + } + if (acc > 8388607) { + acc = 8388607; + } + if (acc < -8388608) { + acc = -8388608; + } - phaseConv[1] = (int32_t)acc; + phaseConv[1] = acc; convSum = phaseConv[1] + phaseConv[0]; - if (convSum > 8388607) convSum = 8388607; - if (convSum < -8388608) convSum = -8388608; + if (convSum > 8388607) { + convSum = 8388607; + } + if (convSum < -8388608) { + convSum = -8388608; + } convDiff = phaseConv[1] - phaseConv[0]; - if (convDiff > 8388607) convDiff = 8388607; - if (convDiff < -8388608) convDiff = -8388608; + if (convDiff > 8388607) { + convDiff = 8388607; + } + if (convDiff < -8388608) { + convDiff = -8388608; + } *(convSumDiff) = convSum; *(convSumDiff + 2) = convDiff; @@ -293,10 +313,14 @@ void AsmQmfConvI(const int32_t* p1dl_buffPtr, const int32_t* p2dl_buffPtr, acc--; } - if (acc > 8388607) acc = 8388607; - if (acc < -8388608) acc = -8388608; + if (acc > 8388607) { + acc = 8388607; + } + if (acc < -8388608) { + acc = -8388608; + } - phaseConv[0] = (int32_t)acc; + phaseConv[0] = acc; tmp_round0 = (int32_t)local_acc1; local_acc1 += 0x00400000L; @@ -305,20 +329,32 @@ void AsmQmfConvI(const int32_t* p1dl_buffPtr, const int32_t* p2dl_buffPtr, acc--; } - if (acc > 8388607) acc = 8388607; - if (acc < -8388608) acc = -8388608; + if (acc > 8388607) { + acc = 8388607; + } + if (acc < -8388608) { + acc = -8388608; + } - phaseConv[1] = (int32_t)acc; + phaseConv[1] = acc; convSum = phaseConv[1] + phaseConv[0]; - if (convSum > 8388607) convSum = 8388607; - if (convSum < -8388608) convSum = -8388608; + if (convSum > 8388607) { + convSum = 8388607; + } + if (convSum < -8388608) { + convSum = -8388608; + } *(filterOutputs) = convSum; convDiff = phaseConv[1] - phaseConv[0]; - if (convDiff > 8388607) convDiff = 8388607; - if (convDiff < -8388608) convDiff = -8388608; + if (convDiff > 8388607) { + convDiff = 8388607; + } + if (convDiff < -8388608) { + convDiff = -8388608; + } *(filterOutputs + 1) = convDiff; } diff --git a/system/embdrv/encoder_for_aptx/src/QuantiseDifference.c b/system/embdrv/encoder_for_aptx/src/QuantiseDifference.c index 9d87a122c90..5f6c865859b 100644 --- a/system/embdrv/encoder_for_aptx/src/QuantiseDifference.c +++ b/system/embdrv/encoder_for_aptx/src/QuantiseDifference.c @@ -30,31 +30,43 @@ XBT_INLINE_ int32_t BsearchLL(const int32_t absDiffSignalShifted, tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[32]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode = 32; + if (tmp <= 0) { + qCode = 32; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 16]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 16; + if (tmp <= 0) { + qCode += 16; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 8]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 8; + if (tmp <= 0) { + qCode += 8; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 4]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 4; + if (tmp <= 0) { + qCode += 4; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 2]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 2; + if (tmp <= 0) { + qCode += 2; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 1]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode++; + if (tmp <= 0) { + qCode++; + } return (qCode); } @@ -67,10 +79,7 @@ XBT_INLINE_ int32_t BsearchHL(const int32_t absDiffSignalShifted, /* first iteration */ tmp_acc.s64 = (int64_t)lc_delta * (int64_t)(97040 << 1); tmp_acc.s32.h -= absDiffSignalShifted; - if (tmp_acc.s64 <= 0) - return (1); - else - return (0); + return (tmp_acc.s64 <= 0); } XBT_INLINE_ int32_t BsearchHH(const int32_t absDiffSignalShifted, @@ -86,11 +95,15 @@ XBT_INLINE_ int32_t BsearchHH(const int32_t absDiffSignalShifted, tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[2]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 2; + if (tmp <= 0) { + qCode += 2; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 1]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode++; + if (tmp <= 0) { + qCode++; + } return (qCode); } @@ -109,16 +122,22 @@ XBT_INLINE_ int32_t BsearchLH(const int32_t absDiffSignalShifted, tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[4]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode = 4; + if (tmp <= 0) { + qCode = 4; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 2]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 2; + if (tmp <= 0) { + qCode += 2; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 1]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode++; + if (tmp <= 0) { + qCode++; + } return (qCode); } @@ -143,7 +162,9 @@ void quantiseDifferenceHL(const int32_t diffSignal, const int32_t ditherVal, /* Form the absolute value of the difference signal and maintain a version * that is right-shifted 4 places for delta scaling. */ absDiffSignal = -diffSignal; - if (diffSignal >= 0) absDiffSignal = diffSignal; + if (diffSignal >= 0) { + absDiffSignal = diffSignal; + } absDiffSignal = ssat24(absDiffSignal); absDiffSignalShifted = absDiffSignal >> deltaScale; absDiffSignalShifted = ssat24(absDiffSignalShifted); @@ -175,7 +196,9 @@ void quantiseDifferenceHL(const int32_t diffSignal, const int32_t ditherVal, acc = (acc >> 6) + 1; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } acc = ssat24(acc); @@ -186,15 +209,17 @@ void quantiseDifferenceHL(const int32_t diffSignal, const int32_t ditherVal, * applied to the difference calculation. */ minusLambdaD = qdata_pt->minusLambdaDTable[index]; - tmp_accL = (1 << 23) - (int32_t)dithSquared; + tmp_accL = (1 << 23) - dithSquared; tmp_acc.s64 = (int64_t)tmp_accL * minusLambdaD; - tmp_round0 = (int32_t)tmp_acc.s32.l << 8; + tmp_round0 = tmp_acc.s32.l << 8; acc = (tmp_acc.u32.l >> 22) | (tmp_acc.s32.h << 10); acc++; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } // worst case value for acc = 0x000d3e08 // no saturation required @@ -214,18 +239,24 @@ void quantiseDifferenceHL(const int32_t diffSignal, const int32_t ditherVal, /* Based on the sign of the difference signal, either add or subtract the * threshold table difference from the accumulated value. Recover the final * accumulated value (saturated/rounded) */ - if (diffSignal < 0) threshDiff = -threshDiff; + if (diffSignal < 0) { + threshDiff = -threshDiff; + } tmp_reg64.s64 = ((int64_t)ditherVal * (int64_t)threshDiff); tmp_reg64.s32.h += acc; acc = tmp_reg64.s32.h; - if (tmp_reg64.u32.l >= 0x80000000) acc++; + if (tmp_reg64.u32.l >= 0x80000000) { + acc++; + } tmp_round0 = (tmp_reg64.u32.l >> 1) | (tmp_reg64.s32.h << 31); acc = ssat24(acc); - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } _delta = -delta << 8; acc = (int32_t)((uint32_t)acc << 4); @@ -288,7 +319,9 @@ void quantiseDifferenceHH(const int32_t diffSignal, const int32_t ditherVal, /* Form the absolute value of the difference signal and maintain a version * that is right-shifted 4 places for delta scaling. */ absDiffSignal = -diffSignal; - if (diffSignal >= 0) absDiffSignal = diffSignal; + if (diffSignal >= 0) { + absDiffSignal = diffSignal; + } absDiffSignal = ssat24(absDiffSignal); absDiffSignalShifted = absDiffSignal >> deltaScale; absDiffSignalShifted = ssat24(absDiffSignalShifted); @@ -321,7 +354,9 @@ void quantiseDifferenceHH(const int32_t diffSignal, const int32_t ditherVal, acc = (acc >> 6) + 1; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } acc = ssat24(acc); @@ -332,15 +367,17 @@ void quantiseDifferenceHH(const int32_t diffSignal, const int32_t ditherVal, * applied to the difference calculation. */ minusLambdaD = qdata_pt->minusLambdaDTable[index]; - tmp_accL = (1 << 23) - (int32_t)dithSquared; + tmp_accL = (1 << 23) - dithSquared; tmp_acc.s64 = (int64_t)tmp_accL * minusLambdaD; - tmp_round0 = (int32_t)tmp_acc.s32.l << 8; + tmp_round0 = tmp_acc.s32.l << 8; acc = (tmp_acc.u32.l >> 22) | (tmp_acc.s32.h << 10); acc++; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } // worst case value for acc = 0x000d3e08 // no saturation required @@ -360,17 +397,23 @@ void quantiseDifferenceHH(const int32_t diffSignal, const int32_t ditherVal, /* Based on the sign of the difference signal, either add or subtract the * threshold table difference from the accumulated value. Recover the final * accumulated value (saturated/rounded) */ - if (diffSignal < 0) threshDiff = -threshDiff; + if (diffSignal < 0) { + threshDiff = -threshDiff; + } tmp_reg64.s64 = ((int64_t)ditherVal * (int64_t)threshDiff); tmp_reg64.s32.h += acc; acc = tmp_reg64.s32.h; - if (tmp_reg64.u32.l >= 0x80000000) acc++; + if (tmp_reg64.u32.l >= 0x80000000) { + acc++; + } tmp_round0 = (tmp_reg64.u32.l >> 1) | (tmp_reg64.s32.h << 31); acc = ssat24(acc); - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } _delta = -delta << 8; acc = (int32_t)((uint32_t)acc << 4); @@ -433,7 +476,9 @@ void quantiseDifferenceLL(const int32_t diffSignal, const int32_t ditherVal, /* Form the absolute value of the difference signal and maintain a version * that is right-shifted 4 places for delta scaling. */ absDiffSignal = -diffSignal; - if (diffSignal >= 0) absDiffSignal = diffSignal; + if (diffSignal >= 0) { + absDiffSignal = diffSignal; + } absDiffSignal = ssat24(absDiffSignal); absDiffSignalShifted = absDiffSignal >> deltaScale; @@ -465,7 +510,9 @@ void quantiseDifferenceLL(const int32_t diffSignal, const int32_t ditherVal, acc = (acc >> 6) + 1; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } acc = ssat24(acc); @@ -476,16 +523,18 @@ void quantiseDifferenceLL(const int32_t diffSignal, const int32_t ditherVal, * applied to the difference calculation. */ minusLambdaD = qdata_pt->minusLambdaDTable[index]; - tmp_accL = (1 << 23) - (int32_t)dithSquared; + tmp_accL = (1 << 23) - dithSquared; tmp_acc.s64 = (int64_t)tmp_accL * minusLambdaD; - tmp_round0 = (int32_t)tmp_acc.s32.l << 8; + tmp_round0 = tmp_acc.s32.l << 8; tmp_acc.s64 >>= 22; acc = tmp_acc.s32.l; acc++; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } // worst case value for acc = 0x000d3e08 // no saturation required @@ -505,17 +554,23 @@ void quantiseDifferenceLL(const int32_t diffSignal, const int32_t ditherVal, /* Based on the sign of the difference signal, either add or subtract the * threshold table difference from the accumulated value. Recover the final * accumulated value (saturated/rounded) */ - if (diffSignal < 0) threshDiff = -threshDiff; + if (diffSignal < 0) { + threshDiff = -threshDiff; + } tmp_reg64.s64 = ((int64_t)ditherVal * (int64_t)threshDiff); tmp_reg64.s32.h += acc; acc = tmp_reg64.s32.h; - if (tmp_reg64.u32.l >= 0x80000000) acc++; + if (tmp_reg64.u32.l >= 0x80000000) { + acc++; + } tmp_round0 = (tmp_reg64.u32.l >> 1) | (tmp_reg64.s32.h << 31); acc = ssat24(acc); - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } _delta = -delta << 8; acc = (int32_t)((uint32_t)acc << 4); @@ -579,7 +634,9 @@ void quantiseDifferenceLH(const int32_t diffSignal, const int32_t ditherVal, /* Form the absolute value of the difference signal and maintain a version * that is right-shifted 4 places for delta scaling. */ absDiffSignal = -diffSignal; - if (diffSignal >= 0) absDiffSignal = diffSignal; + if (diffSignal >= 0) { + absDiffSignal = diffSignal; + } absDiffSignal = ssat24(absDiffSignal); absDiffSignalShifted = absDiffSignal >> deltaScale; @@ -611,7 +668,9 @@ void quantiseDifferenceLH(const int32_t diffSignal, const int32_t ditherVal, acc = (acc >> 6) + 1; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } acc = ssat24(acc); @@ -622,13 +681,15 @@ void quantiseDifferenceLH(const int32_t diffSignal, const int32_t ditherVal, * applied to the difference calculation. */ minusLambdaD = qdata_pt->minusLambdaDTable[index]; - tmp_accL = (1 << 23) - (int32_t)dithSquared; + tmp_accL = (1 << 23) - dithSquared; tmp_acc.s64 = (int64_t)tmp_accL * minusLambdaD; - tmp_round0 = (int32_t)tmp_acc.s32.l << 8; + tmp_round0 = tmp_acc.s32.l << 8; acc = (tmp_acc.u32.l >> 22) | (tmp_acc.s32.h << 10); - if (tmp_round0 == 0x40000000L) acc -= 2; + if (tmp_round0 == 0x40000000L) { + acc -= 2; + } acc++; // worst case value for acc = 0x000d3e08 @@ -648,18 +709,24 @@ void quantiseDifferenceLH(const int32_t diffSignal, const int32_t ditherVal, /* Based on the sign of the difference signal, either add or subtract the * threshold table difference from the accumulated value. Recover the final * accumulated value (saturated/rounded) */ - if (diffSignal < 0) threshDiff = -threshDiff; + if (diffSignal < 0) { + threshDiff = -threshDiff; + } tmp_reg64.s64 = ((int64_t)ditherVal * (int64_t)threshDiff); tmp_reg64.s32.h += acc; acc = tmp_reg64.s32.h; - if (tmp_reg64.u32.l >= 0x80000000) acc++; + if (tmp_reg64.u32.l >= 0x80000000) { + acc++; + } tmp_round0 = (tmp_reg64.u32.l >> 1) | (tmp_reg64.s32.h << 31); acc = ssat24(acc); - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } _delta = -delta << 8; acc = (int32_t)((uint32_t)acc << 4); diff --git a/system/embdrv/encoder_for_aptx/src/aptXbtenc.c b/system/embdrv/encoder_for_aptx/src/aptXbtenc.c index 9a69bf66770..6286ca942d9 100644 --- a/system/embdrv/encoder_for_aptx/src/aptXbtenc.c +++ b/system/embdrv/encoder_for_aptx/src/aptXbtenc.c @@ -215,13 +215,13 @@ APTXBTENCEXPORT int aptxbtenc_encodestereo(void* _state, void* _pcmL, tmp_out = tmp_reg >> state->m_endian; tmp_out |= tmp_reg << state->m_endian; - buffer[0] = (int16_t)tmp_out; + buffer[0] = tmp_out; tmp_reg = packCodeword(&state->m_encoderData[1], state->m_sync_mode); // Swap bytes to output data in big-endian as expected by bc5 code... tmp_out = tmp_reg >> state->m_endian; tmp_out |= tmp_reg << state->m_endian; - buffer[1] = (int16_t)tmp_out; + buffer[1] = tmp_out; return 0; } diff --git a/system/embdrv/encoder_for_aptxhd/Android.bp b/system/embdrv/encoder_for_aptxhd/Android.bp index ec40b630b50..801563e4ef6 100644 --- a/system/embdrv/encoder_for_aptxhd/Android.bp +++ b/system/embdrv/encoder_for_aptxhd/Android.bp @@ -1,3 +1,16 @@ +tidy_errors = [ + "*", + "-altera-struct-pack-align", + "-altera-unroll-loops", + "-bugprone-narrowing-conversions", + "-cppcoreguidelines-avoid-magic-numbers", + "-cppcoreguidelines-init-variables", + "-cppcoreguidelines-narrowing-conversions", + "-hicpp-signed-bitwise", + "-readability-identifier-length", + "-readability-magic-numbers", +] + cc_library_static { name: "libaptxhd_enc", host_supported: true, @@ -9,6 +22,9 @@ cc_library_static { "src/QuantiseDifference.c", ], cflags: ["-O2", "-Werror", "-Wall", "-Wextra"], + tidy: true, + tidy_checks: tidy_errors, + tidy_checks_as_errors: tidy_errors, min_sdk_version: "Tiramisu", apex_available: [ "com.android.btservices", diff --git a/system/embdrv/encoder_for_aptxhd/src/QmfConv.c b/system/embdrv/encoder_for_aptxhd/src/QmfConv.c index e32b3ee1d9f..5312f65e50f 100644 --- a/system/embdrv/encoder_for_aptxhd/src/QmfConv.c +++ b/system/embdrv/encoder_for_aptxhd/src/QmfConv.c @@ -150,10 +150,14 @@ void AsmQmfConvO_HD(const int32_t* p1dl_buffPtr, const int32_t* p2dl_buffPtr, acc--; } - if (acc > 8388607) acc = 8388607; - if (acc < -8388608) acc = -8388608; + if (acc > 8388607) { + acc = 8388607; + } + if (acc < -8388608) { + acc = -8388608; + } - phaseConv[0] = (int32_t)acc; + phaseConv[0] = acc; tmp_round0 = (int32_t)local_acc1; @@ -163,18 +167,30 @@ void AsmQmfConvO_HD(const int32_t* p1dl_buffPtr, const int32_t* p2dl_buffPtr, acc--; } - if (acc > 8388607) acc = 8388607; - if (acc < -8388608) acc = -8388608; + if (acc > 8388607) { + acc = 8388607; + } + if (acc < -8388608) { + acc = -8388608; + } - phaseConv[1] = (int32_t)acc; + phaseConv[1] = acc; convSum = phaseConv[1] + phaseConv[0]; - if (convSum > 8388607) convSum = 8388607; - if (convSum < -8388608) convSum = -8388608; + if (convSum > 8388607) { + convSum = 8388607; + } + if (convSum < -8388608) { + convSum = -8388608; + } convDiff = phaseConv[1] - phaseConv[0]; - if (convDiff > 8388607) convDiff = 8388607; - if (convDiff < -8388608) convDiff = -8388608; + if (convDiff > 8388607) { + convDiff = 8388607; + } + if (convDiff < -8388608) { + convDiff = -8388608; + } *(convSumDiff) = convSum; *(convSumDiff + 2) = convDiff; @@ -303,10 +319,14 @@ void AsmQmfConvI_HD(const int32_t* p1dl_buffPtr, const int32_t* p2dl_buffPtr, acc--; } - if (acc > 8388607) acc = 8388607; - if (acc < -8388608) acc = -8388608; + if (acc > 8388607) { + acc = 8388607; + } + if (acc < -8388608) { + acc = -8388608; + } - phaseConv[0] = (int32_t)acc; + phaseConv[0] = acc; tmp_round0 = (int32_t)local_acc1; @@ -316,20 +336,32 @@ void AsmQmfConvI_HD(const int32_t* p1dl_buffPtr, const int32_t* p2dl_buffPtr, acc--; } - if (acc > 8388607) acc = 8388607; - if (acc < -8388608) acc = -8388608; + if (acc > 8388607) { + acc = 8388607; + } + if (acc < -8388608) { + acc = -8388608; + } - phaseConv[1] = (int32_t)acc; + phaseConv[1] = acc; convSum = phaseConv[1] + phaseConv[0]; - if (convSum > 8388607) convSum = 8388607; - if (convSum < -8388608) convSum = -8388608; + if (convSum > 8388607) { + convSum = 8388607; + } + if (convSum < -8388608) { + convSum = -8388608; + } *(filterOutputs) = convSum; convDiff = phaseConv[1] - phaseConv[0]; - if (convDiff > 8388607) convDiff = 8388607; - if (convDiff < -8388608) convDiff = -8388608; + if (convDiff > 8388607) { + convDiff = 8388607; + } + if (convDiff < -8388608) { + convDiff = -8388608; + } *(filterOutputs + 1) = convDiff; } diff --git a/system/embdrv/encoder_for_aptxhd/src/QuantiseDifference.c b/system/embdrv/encoder_for_aptxhd/src/QuantiseDifference.c index f7e4b3a63db..cac8bf3aeb2 100644 --- a/system/embdrv/encoder_for_aptxhd/src/QuantiseDifference.c +++ b/system/embdrv/encoder_for_aptxhd/src/QuantiseDifference.c @@ -19,51 +19,65 @@ XBT_INLINE_ int32_t BsearchLL(const int32_t absDiffSignalShifted, const int32_t delta, const int32_t* dqbitTablePrt) { - int32_t qCode; + int32_t qCode = 0; reg64_t tmp_acc; - int32_t tmp; + int32_t tmp = 0; int32_t lc_delta = delta << 8; - qCode = 0; - tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[128]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode = 128; + if (tmp <= 0) { + qCode = 128; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 64]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 64; + if (tmp <= 0) { + qCode += 64; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 32]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 32; + if (tmp <= 0) { + qCode += 32; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 16]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 16; + if (tmp <= 0) { + qCode += 16; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 8]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 8; + if (tmp <= 0) { + qCode += 8; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 4]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 4; + if (tmp <= 0) { + qCode += 4; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 2]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 2; + if (tmp <= 0) { + qCode += 2; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 1]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode++; + if (tmp <= 0) { + qCode++; + } return (qCode); } @@ -71,28 +85,31 @@ XBT_INLINE_ int32_t BsearchLL(const int32_t absDiffSignalShifted, XBT_INLINE_ int32_t BsearchHL(const int32_t absDiffSignalShifted, const int32_t delta, const int32_t* dqbitTablePrt) { - int32_t qCode; + int32_t qCode = 0; reg64_t tmp_acc; - int32_t tmp; + int32_t tmp = 0; int32_t lc_delta = delta << 8; - /* first iteration */ - qCode = 0; - tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[4]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode = 4; + if (tmp <= 0) { + qCode = 4; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 2]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 2; + if (tmp <= 0) { + qCode += 2; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 1]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode++; + if (tmp <= 0) { + qCode++; + } return (qCode); } @@ -100,57 +117,65 @@ XBT_INLINE_ int32_t BsearchHL(const int32_t absDiffSignalShifted, XBT_INLINE_ int32_t BsearchHH(const int32_t absDiffSignalShifted, const int32_t delta, const int32_t* dqbitTablePrt) { - int32_t qCode; + int32_t qCode = 0; reg64_t tmp_acc; - int32_t tmp; + int32_t tmp = 0; int32_t lc_delta = delta << 8; - qCode = 0; - tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[8]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode = 8; + if (tmp <= 0) { + qCode = 8; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 4]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 4; + if (tmp <= 0) { + qCode += 4; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 2]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 2; + if (tmp <= 0) { + qCode += 2; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 1]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode++; + if (tmp <= 0) { + qCode++; + } return (qCode); } void quantiseDifference_HDHL(const int32_t diffSignal, const int32_t ditherVal, const int32_t delta, Quantiser_data* qdata_pt) { - int32_t absDiffSignal; - int32_t absDiffSignalShifted; - int32_t index; - int32_t dithSquared; - int32_t minusLambdaD; - int32_t acc; - int32_t threshDiff; + int32_t absDiffSignal = 0; + int32_t absDiffSignalShifted = 0; + int32_t index = 0; + int32_t dithSquared = 0; + int32_t minusLambdaD = 0; + int32_t acc = 0; + int32_t threshDiff = 0; reg64_t tmp_acc; reg64_t tmp_reg64; - int32_t tmp_accL; - int32_t tmp_qCode; - int32_t tmp_altQcode; - uint32_t tmp_round0; - int32_t _delta; + int32_t tmp_accL = 0; + int32_t tmp_qCode = 0; + int32_t tmp_altQcode = 0; + uint32_t tmp_round0 = 0; + int32_t _delta = 0; /* Form the absolute value of the difference signal and maintain a version * that is right-shifted 4 places for delta scaling. */ absDiffSignal = -diffSignal; - if (diffSignal >= 0) absDiffSignal = diffSignal; + if (diffSignal >= 0) { + absDiffSignal = diffSignal; + } absDiffSignal = ssat24(absDiffSignal); absDiffSignalShifted = absDiffSignal >> deltaScale; @@ -181,7 +206,9 @@ void quantiseDifference_HDHL(const int32_t diffSignal, const int32_t ditherVal, acc = (acc >> 6) + 1; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } acc = ssat24(acc); dithSquared = acc; @@ -191,15 +218,17 @@ void quantiseDifference_HDHL(const int32_t diffSignal, const int32_t ditherVal, * applied to the difference calculation. */ minusLambdaD = qdata_pt->minusLambdaDTable[index]; - tmp_accL = (1 << 23) - (int32_t)dithSquared; + tmp_accL = (1 << 23) - dithSquared; tmp_acc.s64 = (int64_t)tmp_accL * minusLambdaD; - tmp_round0 = (int32_t)tmp_acc.s32.l << 8; + tmp_round0 = tmp_acc.s32.l << 8; acc = (tmp_acc.u32.l >> 22) | (tmp_acc.s32.h << 10); acc++; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } /* Add the threshold table values at index and index-1 to the accumulated * value. */ @@ -219,18 +248,24 @@ void quantiseDifference_HDHL(const int32_t diffSignal, const int32_t ditherVal, /* Based on the sign of the difference signal, either add or subtract the * threshold table difference from the accumulated value. Recover the final * accumulated value (saturated/rounded) */ - if (diffSignal < 0) threshDiff = -threshDiff; + if (diffSignal < 0) { + threshDiff = -threshDiff; + } tmp_reg64.s64 = ((int64_t)ditherVal * (int64_t)threshDiff); tmp_reg64.s32.h += acc; acc = tmp_reg64.s32.h; - if (tmp_reg64.u32.l >= 0x80000000) acc++; + if (tmp_reg64.u32.l >= 0x80000000) { + acc++; + } tmp_round0 = (tmp_reg64.u32.l >> 1) | (tmp_reg64.s32.h << 31); acc = ssat24(acc); - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } _delta = -delta << 8; acc = (int32_t)((uint32_t)acc << 4); @@ -293,7 +328,9 @@ void quantiseDifference_HDHH(const int32_t diffSignal, const int32_t ditherVal, /* Form the absolute value of the difference signal and maintain a version * that is right-shifted 4 places for delta scaling. */ absDiffSignal = -diffSignal; - if (diffSignal >= 0) absDiffSignal = diffSignal; + if (diffSignal >= 0) { + absDiffSignal = diffSignal; + } absDiffSignal = ssat24(absDiffSignal); absDiffSignalShifted = absDiffSignal >> deltaScale; @@ -324,7 +361,9 @@ void quantiseDifference_HDHH(const int32_t diffSignal, const int32_t ditherVal, acc = (acc >> 6) + 1; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } acc = ssat24(acc); @@ -335,15 +374,17 @@ void quantiseDifference_HDHH(const int32_t diffSignal, const int32_t ditherVal, * applied to the difference calculation. */ minusLambdaD = qdata_pt->minusLambdaDTable[index]; - tmp_accL = (1 << 23) - (int32_t)dithSquared; + tmp_accL = (1 << 23) - dithSquared; tmp_acc.s64 = (int64_t)tmp_accL * minusLambdaD; - tmp_round0 = (int32_t)tmp_acc.s32.l << 8; + tmp_round0 = tmp_acc.s32.l << 8; acc = (tmp_acc.u32.l >> 22) | (tmp_acc.s32.h << 10); acc++; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } /* Add the threshold table values at index and index-1 to the accumulated * value. */ @@ -363,17 +404,23 @@ void quantiseDifference_HDHH(const int32_t diffSignal, const int32_t ditherVal, /* Based on the sign of the difference signal, either add or subtract the * threshold table difference from the accumulated value. Recover the final * accumulated value (saturated/rounded) */ - if (diffSignal < 0) threshDiff = -threshDiff; + if (diffSignal < 0) { + threshDiff = -threshDiff; + } tmp_reg64.s64 = ((int64_t)ditherVal * (int64_t)threshDiff); tmp_reg64.s32.h += acc; acc = tmp_reg64.s32.h; - if (tmp_reg64.u32.l >= 0x80000000) acc++; + if (tmp_reg64.u32.l >= 0x80000000) { + acc++; + } tmp_round0 = (tmp_reg64.u32.l >> 1) | (tmp_reg64.s32.h << 31); acc = ssat24(acc); - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } _delta = -delta << 8; acc = (int32_t)((uint32_t)acc << 4); @@ -436,7 +483,9 @@ void quantiseDifference_HDLL(const int32_t diffSignal, const int32_t ditherVal, /* Form the absolute value of the difference signal and maintain a version * that is right-shifted 4 places for delta scaling. */ absDiffSignal = -diffSignal; - if (diffSignal >= 0) absDiffSignal = diffSignal; + if (diffSignal >= 0) { + absDiffSignal = diffSignal; + } absDiffSignal = ssat24(absDiffSignal); absDiffSignalShifted = absDiffSignal >> deltaScale; @@ -468,7 +517,9 @@ void quantiseDifference_HDLL(const int32_t diffSignal, const int32_t ditherVal, acc = (acc >> 6) + 1; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } acc = ssat24(acc); @@ -479,15 +530,17 @@ void quantiseDifference_HDLL(const int32_t diffSignal, const int32_t ditherVal, * applied to the difference calculation. */ minusLambdaD = qdata_pt->minusLambdaDTable[index]; - tmp_accL = (1 << 23) - (int32_t)dithSquared; + tmp_accL = (1 << 23) - dithSquared; tmp_acc.s64 = (int64_t)tmp_accL * minusLambdaD; - tmp_round0 = (int32_t)tmp_acc.s32.l << 8; + tmp_round0 = tmp_acc.s32.l << 8; acc = (tmp_acc.u32.l >> 22) | (tmp_acc.s32.h << 10); acc++; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } /* Add the threshold table values at index and index-1 to the accumulated * value. */ @@ -508,17 +561,23 @@ void quantiseDifference_HDLL(const int32_t diffSignal, const int32_t ditherVal, * threshold table difference from the accumulated value. Recover the final * accumulated value (saturated/rounded) */ - if (diffSignal < 0) threshDiff = -threshDiff; + if (diffSignal < 0) { + threshDiff = -threshDiff; + } tmp_reg64.s64 = ((int64_t)ditherVal * (int64_t)threshDiff); tmp_reg64.s32.h += acc; acc = tmp_reg64.s32.h; - if (tmp_reg64.u32.l >= 0x80000000) acc++; + if (tmp_reg64.u32.l >= 0x80000000) { + acc++; + } tmp_round0 = (tmp_reg64.u32.l >> 1) | (tmp_reg64.s32.h << 31); acc = ssat24(acc); - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } _delta = -delta << 8; acc = (int32_t)((uint32_t)acc << 4); @@ -575,53 +634,65 @@ static int32_t BsearchLH(const int32_t absDiffSignalShifted, tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[16]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode = 16; + if (tmp <= 0) { + qCode = 16; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 8]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 8; + if (tmp <= 0) { + qCode += 8; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 4]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 4; + if (tmp <= 0) { + qCode += 4; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 2]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode += 2; + if (tmp <= 0) { + qCode += 2; + } tmp_acc.s64 = (int64_t)lc_delta * (int64_t)dqbitTablePrt[qCode + 1]; tmp_acc.s32.h -= absDiffSignalShifted; tmp = tmp_acc.s32.h | (tmp_acc.u32.l >> 1); - if (tmp <= 0) qCode++; + if (tmp <= 0) { + qCode++; + } return (qCode); } void quantiseDifference_HDLH(const int32_t diffSignal, const int32_t ditherVal, const int32_t delta, Quantiser_data* qdata_pt) { - int32_t absDiffSignal; - int32_t absDiffSignalShifted; - int32_t index; - int32_t dithSquared; - int32_t minusLambdaD; - int32_t acc; - int32_t threshDiff; + int32_t absDiffSignal = 0; + int32_t absDiffSignalShifted = 0; + int32_t index = 0; + int32_t dithSquared = 0; + int32_t minusLambdaD = 0; + int32_t acc = 0; + int32_t threshDiff = 0; reg64_t tmp_acc; reg64_t tmp_reg64; - int32_t tmp_accL; - int32_t tmp_qCode; - int32_t tmp_altQcode; + int32_t tmp_accL = 0; + int32_t tmp_qCode = 0; + int32_t tmp_altQcode = 0; - uint32_t tmp_round0; - int32_t _delta; + uint32_t tmp_round0 = 0; + int32_t _delta = 0; /* Form the absolute value of the difference signal and maintain a version * that is right-shifted 4 places for delta scaling. */ absDiffSignal = -diffSignal; - if (diffSignal >= 0) absDiffSignal = diffSignal; + if (diffSignal >= 0) { + absDiffSignal = diffSignal; + } absDiffSignal = ssat24(absDiffSignal); absDiffSignalShifted = absDiffSignal >> deltaScale; @@ -656,7 +727,9 @@ void quantiseDifference_HDLH(const int32_t diffSignal, const int32_t ditherVal, acc = (acc >> 6) + 1; acc >>= 1; - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } acc = ssat24(acc); dithSquared = acc; @@ -667,13 +740,15 @@ void quantiseDifference_HDLH(const int32_t diffSignal, const int32_t ditherVal, minusLambdaD = qdata_pt->minusLambdaDTable[index]; - tmp_accL = (1 << 23) - (int32_t)dithSquared; + tmp_accL = (1 << 23) - dithSquared; tmp_acc.s64 = (int64_t)tmp_accL * minusLambdaD; - tmp_round0 = (int32_t)tmp_acc.s32.l << 8; + tmp_round0 = tmp_acc.s32.l << 8; - acc = (tmp_acc.u32.l >> 22) | (tmp_acc.s32.h << 10); - if (tmp_round0 == 0x40000000L) acc -= 2; + acc = (int32_t)(tmp_acc.u32.l >> 22) | (tmp_acc.s32.h << 10); + if (tmp_round0 == 0x40000000L) { + acc -= 2; + } acc++; /* Add the threshold table values at index and index-1 to the accumulated @@ -696,18 +771,24 @@ void quantiseDifference_HDLH(const int32_t diffSignal, const int32_t ditherVal, * threshold table difference from the accumulated value. Recover the final * accumulated value (saturated/rounded) */ - if (diffSignal < 0) threshDiff = -threshDiff; + if (diffSignal < 0) { + threshDiff = -threshDiff; + } tmp_reg64.s64 = ((int64_t)ditherVal * (int64_t)threshDiff); tmp_reg64.s32.h += acc; acc = tmp_reg64.s32.h; - if (tmp_reg64.u32.l >= 0x80000000) acc++; + if (tmp_reg64.u32.l >= 0x80000000) { + acc++; + } tmp_round0 = (tmp_reg64.u32.l >> 1) | (tmp_reg64.s32.h << 31); acc = ssat24(acc); - if (tmp_round0 == 0x40000000L) acc--; + if (tmp_round0 == 0x40000000L) { + acc--; + } _delta = -delta << 8; acc = (int32_t)((uint32_t)acc << 4); diff --git a/system/embdrv/encoder_for_aptxhd/src/aptXHDbtenc.c b/system/embdrv/encoder_for_aptxhd/src/aptXHDbtenc.c index 2d4a0830953..8d93d9d37c7 100644 --- a/system/embdrv/encoder_for_aptxhd/src/aptXHDbtenc.c +++ b/system/embdrv/encoder_for_aptxhd/src/aptXHDbtenc.c @@ -65,13 +65,12 @@ APTXHDBTENCEXPORT const char* aptxhdbtenc_version() { return (swversion); } APTXHDBTENCEXPORT int aptxhdbtenc_init(void* _state, short endian) { aptxhdbtenc* state = (aptxhdbtenc*)_state; - int32_t j = 0; - int32_t k; - int32_t t; clearmem_HD(_state, sizeof(aptxhdbtenc)); - if (state == 0) return 1; + if (state == 0) { + return 1; + } state->m_syncWordPhase = 7L; if (endian == 0) { @@ -80,7 +79,7 @@ APTXHDBTENCEXPORT int aptxhdbtenc_init(void* _state, short endian) { state->m_endian = 8; } - for (j = 0; j < 2; j++) { + for (int j = 0; j < 2; j++) { Encoder_data* encode_dat = &state->m_encoderData[j]; uint32_t i; @@ -123,7 +122,7 @@ APTXHDBTENCEXPORT int aptxhdbtenc_init(void* _state, short endian) { encode_dat->m_SubbandData[i].m_predData.m_zeroDelayLine.modulo = subbandParameters[i].numZeros; - for (t = 0; t < 48; t++) { + for (int t = 0; t < 48; t++) { encode_dat->m_SubbandData[i].m_predData.m_zeroDelayLine.buffer[t] = 0; } @@ -138,7 +137,7 @@ APTXHDBTENCEXPORT int aptxhdbtenc_init(void* _state, short endian) { encode_dat->m_SubbandData[i].m_predData.m_poleDelayLine[0] = 0L; encode_dat->m_SubbandData[i].m_predData.m_poleDelayLine[1] = 0L; - for (k = 0; k < 24; k++) { + for (int k = 0; k < 24; k++) { encode_dat->m_SubbandData[i].m_ZeroCoeffData.m_zeroCoeff[k] = 0; } @@ -165,7 +164,6 @@ APTXHDBTENCEXPORT int aptxhdbtenc_encodestereo(void* _state, void* _pcmL, int32_t* pcmL = (int32_t*)_pcmL; int32_t* pcmR = (int32_t*)_pcmR; int32_t* buffer = (int32_t*)_buffer; - int32_t tmp_reg; // Feed the PCM to the dual aptX HD encoders aptxhdEncode(pcmL, &state->m_qmf_l, &state->m_encoderData[0]); @@ -179,11 +177,8 @@ APTXHDBTENCEXPORT int aptxhdbtenc_encodestereo(void* _state, void* _pcmL, aptxhdPostEncode(&state->m_encoderData[1]); // Pack the (possibly adjusted) codes into a 24-bit codeword per channel - tmp_reg = packCodeword(&state->m_encoderData[0]); - buffer[0] = (int32_t)tmp_reg; - - tmp_reg = packCodeword(&state->m_encoderData[1]); - buffer[1] = (int32_t)tmp_reg; + buffer[0] = packCodeword(&state->m_encoderData[0]); + buffer[1] = packCodeword(&state->m_encoderData[1]); return 0; } -- GitLab