From 5185b0138aaeffeecc93b958cb9cd9821f260faf Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 9 Sep 2010 12:01:11 -0700 Subject: LVM release 1.09 delivery - Reverb: - 1 channel mixed has gain zero - core componenet now only outputs STEREO samples - wrapper now handles only STEREO from the Reverb Core - Bass Boost: - increase scratch memory Change-Id: I00ae31051cc40a7006fc993420facfeb4d30dc52 --- media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h | 2 +- .../lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c | 7 +- .../libeffects/lvm/lib/Reverb/src/LVREV_Process.c | 166 +++++++-------------- .../libeffects/lvm/wrapper/Reverb/EffectReverb.cpp | 29 ++-- 4 files changed, 69 insertions(+), 135 deletions(-) (limited to 'media/libeffects/lvm') diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h index 495b38f..8339d3c 100644 --- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h +++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h @@ -64,7 +64,7 @@ extern "C" { #define LVDBE_PERSISTENT_COEF_ALIGN 4 /* 32-bit alignment for coef */ #define LVDBE_SCRATCH_ALIGN 4 /* 32-bit alignment for long data */ -#define LVDBE_SCRATCHBUFFERS_INPLACE 4 /* Number of buffers required for inplace processing */ +#define LVDBE_SCRATCHBUFFERS_INPLACE 6 /* Number of buffers required for inplace processing */ #define LVDBE_MIXER_TC 5 /* Mixer time */ #define LVDBE_BYPASS_MIXER_TC 100 /* Bypass mixer time */ diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c index 9a40f68..ac2ef9d 100644 --- a/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c +++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c @@ -496,7 +496,6 @@ LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st *pPrivate) * Update the bypass mixer time constant */ if((pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) || - (pPrivate->NewParams.SourceFormat != pPrivate->CurrentParams.SourceFormat) || (pPrivate->bFirstControl == LVM_TRUE)) { LVM_UINT16 NumChannels = 1; /* Assume MONO format */ @@ -508,11 +507,7 @@ LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st *pPrivate) pPrivate->FeedbackMixer[2].Alpha=Alpha; pPrivate->FeedbackMixer[3].Alpha=Alpha; - if (pPrivate->NewParams.SourceFormat != LVM_MONO) - { - /* Stereo or Mono-in-Stereo format data */ - NumChannels = 2; - } + NumChannels = 2; /* Always stereo output */ pPrivate->BypassMixer.Alpha1 = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_BYPASSMIXER_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), NumChannels); pPrivate->BypassMixer.Alpha2 = pPrivate->BypassMixer.Alpha1; pPrivate->GainMixer.Alpha = pPrivate->BypassMixer.Alpha1; diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c index 81521ba..5c7a8a0 100644 --- a/media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c +++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c @@ -54,7 +54,8 @@ LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance, LVREV_Instance_st *pLVREV_Private = (LVREV_Instance_st *)hInstance; LVM_INT32 *pInput = (LVM_INT32 *)pInData; LVM_INT32 *pOutput = pOutData; - LVM_INT32 SamplesToProcess, RemainingSamples, format; + LVM_INT32 SamplesToProcess, RemainingSamples; + LVM_INT32 format = 1; /* * Check for error conditions @@ -66,7 +67,6 @@ LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance, return LVREV_NULLADDRESS; } - /* * Apply the new controls settings if required */ @@ -95,9 +95,31 @@ LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance, return LVREV_SUCCESS; } + /* + * If OFF copy and reformat the data as necessary + */ + if (pLVREV_Private->CurrentParams.OperatingMode == LVM_MODE_OFF) + { + if(pInput != pOutput) + { + /* + * Copy the data to the output buffer, convert to stereo is required + */ + + if(pLVREV_Private->CurrentParams.SourceFormat == LVM_MONO){ + MonoTo2I_32(pInput, pOutput, NumSamples); + } else { + Copy_16((LVM_INT16 *)pInput, + (LVM_INT16 *)pOutput, + (LVM_INT16)(NumSamples << 2)); // 32 bit data, stereo + } + } + + return LVREV_SUCCESS; + } + RemainingSamples = (LVM_INT32)NumSamples; - format = 1; if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO) { format = 2; @@ -106,51 +128,24 @@ LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t hInstance, while (RemainingSamples!=0) { /* - * If OFF copy and reformat the data as necessary + * Process the data */ - if (pLVREV_Private->CurrentParams.OperatingMode == LVM_MODE_OFF) - { - if((pInput != pOutput) || (pLVREV_Private->CurrentParams.SourceFormat == LVM_MONO)) - { - /* - * Copy the data to the output buffer - */ - if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO) - { - RemainingSamples = (RemainingSamples << 1); /* Stereo data */ - } - - Copy_16((LVM_INT16 *)pInput, - (LVM_INT16 *)pOutput, - (LVM_INT16)(RemainingSamples << 1)); - } - - RemainingSamples = 0; + if(RemainingSamples > pLVREV_Private->MaxBlkLen) + { + SamplesToProcess = pLVREV_Private->MaxBlkLen; + RemainingSamples = (LVM_INT16)(RemainingSamples - SamplesToProcess); } - - /* - * Process the data - */ else { + SamplesToProcess = RemainingSamples; + RemainingSamples = 0; + } - if(RemainingSamples > pLVREV_Private->MaxBlkLen) - { - SamplesToProcess = pLVREV_Private->MaxBlkLen; - RemainingSamples = (LVM_INT16)(RemainingSamples - SamplesToProcess); - } - else - { - SamplesToProcess = RemainingSamples; - RemainingSamples = 0; - } - - ReverbBlock(pInput, pOutput, pLVREV_Private, (LVM_UINT16)SamplesToProcess); + ReverbBlock(pInput, pOutput, pLVREV_Private, (LVM_UINT16)SamplesToProcess); - pInput = (LVM_INT32 *)(pInput +(SamplesToProcess*format)); - pOutput = (LVM_INT32 *)(pOutput+(SamplesToProcess*format)); - } + pInput = (LVM_INT32 *)(pInput +(SamplesToProcess*format)); + pOutput = (LVM_INT32 *)(pOutput+(SamplesToProcess*2)); // Always stereo output } return LVREV_SUCCESS; @@ -420,26 +415,13 @@ void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPriv pPrivate->pScratchDelayLine[1], (LVM_INT16)NumSamples); - if(pPrivate->CurrentParams.SourceFormat != LVM_MONO) - { - JoinTo2i_32x32(pPrivate->pScratchDelayLine[0], - pPrivate->pScratchDelayLine[1], - pTemp, - (LVM_INT16)NumSamples); - } - else - { - Add2_Sat_32x32(pPrivate->pScratchDelayLine[1], - pPrivate->pScratchDelayLine[0], - (LVM_INT16)NumSamples); + JoinTo2i_32x32(pPrivate->pScratchDelayLine[0], + pPrivate->pScratchDelayLine[1], + pTemp, + (LVM_INT16)NumSamples); + - /*Apply 3-dB gain in-order to compensate for the gain change in stereo mode*/ - Mult3s_32x16(pPrivate->pScratchDelayLine[0], - LVREV_MIN3DB, - pTemp, - (LVM_INT16)NumSamples); - } break; case LVREV_DELAYLINES_2: @@ -447,49 +429,25 @@ void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPriv (LVM_INT16*)pScratch, (LVM_INT16)(NumSamples << 1)); - - - if(pPrivate->CurrentParams.SourceFormat != LVM_MONO) - { - - Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0], - -0x8000, - pScratch, - (LVM_INT16)NumSamples); - } + Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0], + -0x8000, + pScratch, + (LVM_INT16)NumSamples); Add2_Sat_32x32(pPrivate->pScratchDelayLine[1], pPrivate->pScratchDelayLine[0], (LVM_INT16)NumSamples); - if(pPrivate->CurrentParams.SourceFormat != LVM_MONO) - { - JoinTo2i_32x32(pPrivate->pScratchDelayLine[0], - pScratch, - pTemp, - (LVM_INT16)NumSamples); - } - else - { - Copy_16( (LVM_INT16*)pPrivate->pScratchDelayLine[0], - (LVM_INT16*)pTemp, - (LVM_INT16)(NumSamples << 1)); - - } - break; - case LVREV_DELAYLINES_1: - if(pPrivate->CurrentParams.SourceFormat != LVM_MONO) - { - - MonoTo2I_32(pPrivate->pScratchDelayLine[0], + JoinTo2i_32x32(pPrivate->pScratchDelayLine[0], + pScratch, pTemp, (LVM_INT16)NumSamples); - } - else - { - pTemp = pPrivate->pScratchDelayLine[0]; - } + break; + case LVREV_DELAYLINES_1: + MonoTo2I_32(pPrivate->pScratchDelayLine[0], + pTemp, + (LVM_INT16)NumSamples); break; default: break; @@ -499,30 +457,15 @@ void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPriv /* * Dry/wet mixer */ - if(pPrivate->CurrentParams.SourceFormat != LVM_MONO) - { - size = (LVM_INT16)(NumSamples << 1); - } - else - { - size = (LVM_INT16)NumSamples; - } + size = (LVM_INT16)(NumSamples << 1); MixSoft_2St_D32C31_SAT(&pPrivate->BypassMixer, - pInput, + pTemp, pTemp, pOutput, size); /* Apply Gain*/ - if(pPrivate->CurrentParams.SourceFormat != LVM_MONO) - { - size = (LVM_INT16)(NumSamples << 1); - } - else - { - size = (LVM_INT16)NumSamples; - } Shift_Sat_v32xv32 (LVREV_OUTPUTGAIN_SHIFT, pOutput, @@ -533,6 +476,7 @@ void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPriv pOutput, pOutput, size); + return; } diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp index b3e1531..60f4288 100755 --- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp +++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp @@ -431,26 +431,15 @@ int process( LVM_INT16 *pIn, pContext->InFrames32[i] = (LVM_INT32)pIn[i]<<8; } - // If the input was MONO, convert to STEREO - if(pContext->config.inputCfg.channels == CHANNEL_MONO){ - //LOGV("\tConverting Output from MONO to STEREO"); - MonoTo2I_32(pContext->InFrames32, pContext->InFrames32, frameCount); - } - - //LOGV("\tProcess, frames: %d, InFormat: %d(MONO=%d), OutFormat: %d(STEREO=%d)", - //frameCount, pContext->config.inputCfg.channels, CHANNEL_MONO, - //pContext->config.outputCfg.channels, CHANNEL_STEREO); - if (pContext->preset && pContext->curPreset == REVERB_PRESET_NONE) { memset(pContext->OutFrames32, 0, frameCount * sizeof(LVM_INT32) * 2); //always stereo here } else { if(pContext->bEnabled == LVM_FALSE && pContext->SamplesToExitCount > 0) { - memset(pContext->InFrames32, - 0, - frameCount * sizeof(LVM_INT32) * 2); //always stereo here + memset(pContext->InFrames32,0,frameCount * sizeof(LVM_INT32) * samplesPerFrame); + LOGV("\tZeroing %d samples per frame at the end of call", samplesPerFrame); } - /* Process the samples */ + /* Process the samples, producing a stereo output */ LvmStatus = LVREV_Process(pContext->hInstance, /* Instance handle */ pContext->InFrames32, /* Input buffer */ pContext->OutFrames32, /* Output buffer */ @@ -677,7 +666,7 @@ int Reverb_init(ReverbContext *pContext){ /* Set the capabilities */ InstParams.MaxBlockSize = MAX_CALL_SIZE; - InstParams.SourceFormat = LVM_STEREO; + InstParams.SourceFormat = LVM_STEREO; // Max format, could be mono during process InstParams.NumDelays = LVREV_DELAYLINES_4; /* Allocate memory, forcing alignment */ @@ -742,7 +731,12 @@ int Reverb_init(ReverbContext *pContext){ /* General parameters */ params.OperatingMode = LVM_MODE_ON; params.SampleRate = LVM_FS_44100; - params.SourceFormat = LVM_STEREO; + + if(pContext->config.inputCfg.channels == CHANNEL_MONO){ + params.SourceFormat = LVM_MONO; + } else { + params.SourceFormat = LVM_STEREO; + } /* Reverb parameters */ params.Level = 0; @@ -1790,8 +1784,9 @@ extern "C" int Reverb_process(effect_interface_t self, if (pContext->bEnabled == LVM_FALSE){ if( pContext->SamplesToExitCount > 0){ pContext->SamplesToExitCount -= outBuffer->frameCount; + LOGV("\tReverb_process() Effect is being stopped %d", pContext->SamplesToExitCount); }else{ - LOGV("\tReverb_process() ERROR Effect is not enabled %d", pContext->SamplesToExitCount); + LOGV("\tReverb_process() Effect is being stopped"); return -ENODATA; } } -- cgit v1.1