Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c84e930a authored by Andy Hung's avatar Andy Hung Committed by Gerrit Code Review
Browse files

Merge "LVM True mono support : Initial version"

parents 91b07bce 59c2d1c3
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -53,8 +53,6 @@ constexpr audio_channel_mask_t kChMasks[] = {

constexpr size_t kNumChMasks = std::size(kChMasks);
constexpr int kSampleRate = 44100;
// TODO(b/131240940) Remove once effects are updated to produce mono output
constexpr size_t kMinOutputChannelCount = 2;

/*******************************************************************
 * A test result running on Pixel 3 for comparison.
@@ -64,6 +62,10 @@ constexpr size_t kMinOutputChannelCount = 2;
 * -----------------------------------------------------
 * Benchmark           Time             CPU   Iterations
 * -----------------------------------------------------
 * BM_LVM/1/0       52123 ns        51971 ns        13437
 * BM_LVM/1/1       75397 ns        75175 ns         9382
 * BM_LVM/1/2       40253 ns        40140 ns        17418
 * BM_LVM/1/3       19918 ns        19860 ns        35230
 * BM_LVM/2/0       62455 ns        62283 ns        11214
 * BM_LVM/2/1      110086 ns       109751 ns         6350
 * BM_LVM/2/2       44017 ns        43890 ns        15982
@@ -203,7 +205,7 @@ static void BM_LVM(benchmark::State& state) {

    // Run the test
    for (auto _ : state) {
        std::vector<float> output(kFrameCount * std::max(channelCount, kMinOutputChannelCount));
        std::vector<float> output(kFrameCount * channelCount);

        benchmark::DoNotOptimize(input.data());
        benchmark::DoNotOptimize(output.data());
@@ -224,8 +226,7 @@ static void BM_LVM(benchmark::State& state) {
}

static void LVMArgs(benchmark::internal::Benchmark* b) {
    // TODO(b/131240940) Test single channel once effects are updated to process mono data
    for (int i = 2; i <= kNumChMasks; i++) {
    for (int i = FCC_1; i <= kNumChMasks; i++) {
        for (int j = 0; j < kNumEffectUuids; ++j) {
            b->Args({i, j});
        }
+2 −2
Original line number Diff line number Diff line
@@ -277,8 +277,8 @@ LVDBE_ReturnStatus_en LVDBE_Control(LVDBE_Handle_t hInstance, LVDBE_Params_t* pP
    /*
     * Create biquad instance
     */
    pInstance->pHPFBiquad.reset(new android::audio_utils::BiquadFilter<LVM_FLOAT>(
            (FCC_1 == pParams->NrChannels) ? FCC_2 : pParams->NrChannels));
    pInstance->pHPFBiquad.reset(
            new android::audio_utils::BiquadFilter<LVM_FLOAT>(pParams->NrChannels));

    /*
     * Update the filters
+1 −5
Original line number Diff line number Diff line
@@ -79,11 +79,7 @@ LVDBE_ReturnStatus_en LVDBE_Process(
        const LVM_UINT16 NrFrames)  // updated to use samples = frames * channels.
{
    LVDBE_Instance_t* pInstance = (LVDBE_Instance_t*)hInstance;

    /*Extract number of Channels info*/
    // Mono passed in as stereo
    const LVM_INT32 NrChannels =
            pInstance->Params.NrChannels == 1 ? 2 : pInstance->Params.NrChannels;
    const LVM_INT32 NrChannels = pInstance->Params.NrChannels;
    const LVM_INT32 NrSamples = NrChannels * NrFrames;

    /* Space to store DBE path computation */
+0 −4
Original line number Diff line number Diff line
@@ -487,10 +487,6 @@ void LVM_BufferManagedOut(LVM_Handle_t hInstance, LVM_FLOAT* pOutData, LVM_UINT1
void LVM_BufferUnmanagedOut(LVM_Handle_t hInstance, LVM_UINT16* pNumSamples) {
    LVM_Instance_t* pInstance = (LVM_Instance_t*)hInstance;
    LVM_INT16 NumChannels = pInstance->NrChannels;
    if (NumChannels == 1) {
        /* Mono input is processed as stereo by LVM module */
        NumChannels = 2;
    }
#undef NrFrames
#define NrFrames (*pNumSamples)  // alias for clarity

+0 −13
Original line number Diff line number Diff line
@@ -110,19 +110,6 @@ LVM_ReturnStatus_en LVM_Process(LVM_Handle_t hInstance, const LVM_FLOAT* pInData
        }
    }

    /*
     * Convert from Mono if necessary
     */
    if (pInstance->Params.SourceFormat == LVM_MONO) {
        MonoTo2I_Float(pInData,                /* Source */
                       pOutData,               /* Destination */
                       (LVM_INT16)NumSamples); /* Number of input samples */
        pInput = pOutData;
        pToProcess = pOutData;
        NrChannels = 2;
        ChMask = AUDIO_CHANNEL_OUT_STEREO;
    }

    /*
     * Process the data with managed buffers
     */
Loading