diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e16553e85a3a061c6ab250a31b781092bd4d923a..3e8521f47d8f5fc485771b6c1ce76bfaffcf783d 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1226,6 +1226,9 @@ enum #define OMASA_GAIN_EDIT_THR 0.06f /* OMASA gain change threshold */ #define OMASA_AZI_EDIT_THR 1.0f /* OMASA-DISC azimuth change threshold */ #define OMASA_ELE_EDIT_THR 2.0f /* OMASA-DISC elevation change threshold */ +#ifdef NONBE_1380_OMASA_BUILD_DIFF +#define OMASA_PAN_TBL_LEN 601 +#endif #define MASA_JBM_RINGBUFFER_FRAMES 3 diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c index 4042dd959b6e5a5e0ce4c18ca96f9685c118933e..a66e0e5c6b90130930482c74ef2b0d8da3359b88 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -61,7 +61,11 @@ #define GAMMA_ISM_MEDIUM_IMP4 1.0f #define GAMMA_ISM_HIGH_IMP4 1.2f - +#ifdef NONBE_1380_OMASA_BUILD_DIFF +#define PAN_MAX_DEG 30.0f +#define ONE_OVER_PAN_STEP_DEG 10.0f +#define SIN_LS_ANGLE 0.5f /* sinf( 30.0f * PI_OVER_180 ) */ +#endif /*--------------------------------------------------------------- * ivas_omasa_ism_mode_select() * @@ -496,6 +500,64 @@ void ivas_get_stereo_panning_gains( const float eleDeg, float panningGains[2] ) { +#ifdef NONBE_1380_OMASA_BUILD_DIFF + float aziPlusEle, aziMinusEle, y; + + /* use identity sin(A+B) + sin(A−B) = 2 sinA cosB */ + aziPlusEle = aziDeg + eleDeg; + aziMinusEle = aziDeg - eleDeg; + + /* wrap into -180..+180 */ + while ( aziPlusEle > 180.0f ) + { + aziPlusEle -= 360.0f; + } + while ( aziPlusEle < -180.0f ) + { + aziPlusEle += 360.0f; + } + while ( aziMinusEle > 180.0f ) + { + aziMinusEle -= 360.0f; + } + while ( aziMinusEle < -180.0f ) + { + aziMinusEle += 360.0f; + } + + /* compute Y-coordinate corresponding to the azimuth and elevation: y = sin(azi) * cos(ele) = (sin(azi+ele) + sin(azi-ele)) / 2 */ + y = ( sinf( aziPlusEle * PI_OVER_180 ) + sinf( aziMinusEle * PI_OVER_180 ) ) * 0.5f; + + if ( y >= SIN_LS_ANGLE ) + { /* Left side */ + panningGains[0] = 1.0f; + panningGains[1] = 0.0f; + } + else if ( y <= -SIN_LS_ANGLE ) + { /* Right side */ + panningGains[0] = 0.0f; + panningGains[1] = 1.0f; + } + else /* Tangent panning law */ + { + /* from sin(angle) to index assuming range -30..+30 degrees with 0.1-degree spacing */ + float angleDeg, pos; + int16_t idx; + + /* Convert azi and ele to an azi value of the cone of confusion */ + angleDeg = asinf( y ) * _180_OVER_PI; + angleDeg = fmaxf( fminf( angleDeg, PAN_MAX_DEG ), -PAN_MAX_DEG ); + + /* compute the panning gains from the mapped azimuth using a look-up table */ + pos = ( angleDeg + PAN_MAX_DEG ) * ONE_OVER_PAN_STEP_DEG; /* ideal floating index */ + idx = (int16_t) roundf( pos ); + + idx = max( 0, min( idx, OMASA_PAN_TBL_LEN - 1 ) ); + + panningGains[0] = ivas_tan_panning_gain_tbl[idx]; + panningGains[1] = ivas_tan_panning_gain_tbl[OMASA_PAN_TBL_LEN - 1 - idx]; + } +#else float aziRad, eleRad; float y, mappedX, aziRadMapped, A, A2, A3; const float LsAngleRad = 30.0f * PI_OVER_180; @@ -524,6 +586,7 @@ void ivas_get_stereo_panning_gains( panningGains[0] = sqrtf( A3 ); panningGains[1] = sqrtf( 1.0f - A3 ); } +#endif return; } diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 75098e78f52e70284888b203e1a3aafe80a1a070..039dee13c5bb829a839ba2e29eef384e4a318204 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2869,6 +2869,133 @@ const float dct12[12*12]= 0.2887f, -0.4048f, 0.3943f, -0.3772f, 0.3536f, -0.3239f, 0.2887f, -0.2485f, 0.2041f, -0.1562f, 0.1057f, -0.0533f }; +#ifdef NONBE_1380_OMASA_BUILD_DIFF +const float ivas_tan_panning_gain_tbl[OMASA_PAN_TBL_LEN] = +{ + 0.0000000f, 0.0020142f, 0.0040283f, 0.0060425f, 0.0080872f, + 0.0101013f, 0.0121460f, 0.0141907f, 0.0162354f, 0.0182800f, + 0.0203552f, 0.0223999f, 0.0244751f, 0.0265198f, 0.0285950f, + 0.0306702f, 0.0327454f, 0.0348206f, 0.0369263f, 0.0390015f, + 0.0411072f, 0.0432129f, 0.0453186f, 0.0474243f, 0.0495300f, + 0.0516357f, 0.0537415f, 0.0558777f, 0.0580139f, 0.0601196f, + 0.0622559f, 0.0643921f, 0.0665588f, 0.0686951f, 0.0708313f, + 0.0729980f, 0.0751648f, 0.0773315f, 0.0794983f, 0.0816650f, + 0.0838318f, 0.0859985f, 0.0881958f, 0.0903625f, 0.0925598f, + 0.0947571f, 0.0969543f, 0.0991516f, 0.1013489f, 0.1035767f, + 0.1057739f, 0.1080017f, 0.1102295f, 0.1124573f, 0.1146851f, + 0.1169128f, 0.1191406f, 0.1213684f, 0.1236267f, 0.1258850f, + 0.1281128f, 0.1303711f, 0.1326294f, 0.1348877f, 0.1371765f, + 0.1394348f, 0.1416931f, 0.1439819f, 0.1462708f, 0.1485596f, + 0.1508484f, 0.1531372f, 0.1554260f, 0.1577148f, 0.1600342f, + 0.1623230f, 0.1646423f, 0.1669617f, 0.1692505f, 0.1715698f, + 0.1739197f, 0.1762390f, 0.1785583f, 0.1809082f, 0.1832275f, + 0.1855774f, 0.1879272f, 0.1902466f, 0.1925964f, 0.1949768f, + 0.1973267f, 0.1996765f, 0.2020569f, 0.2044067f, 0.2067871f, + 0.2091370f, 0.2115173f, 0.2138977f, 0.2162781f, 0.2186584f, + 0.2210693f, 0.2234497f, 0.2258301f, 0.2282410f, 0.2306519f, + 0.2330322f, 0.2354431f, 0.2378540f, 0.2402649f, 0.2426758f, + 0.2450867f, 0.2475281f, 0.2499390f, 0.2523499f, 0.2547913f, + 0.2572327f, 0.2596436f, 0.2620850f, 0.2645264f, 0.2669678f, + 0.2694092f, 0.2718506f, 0.2742920f, 0.2767639f, 0.2792053f, + 0.2816772f, 0.2841187f, 0.2865906f, 0.2890320f, 0.2915039f, + 0.2939758f, 0.2964478f, 0.2989197f, 0.3013916f, 0.3038635f, + 0.3063354f, 0.3088074f, 0.3113098f, 0.3137817f, 0.3162537f, + 0.3187561f, 0.3212280f, 0.3237305f, 0.3262329f, 0.3287048f, + 0.3312073f, 0.3337097f, 0.3362122f, 0.3387146f, 0.3412170f, + 0.3437195f, 0.3462219f, 0.3487244f, 0.3512268f, 0.3537292f, + 0.3562317f, 0.3587646f, 0.3612671f, 0.3637695f, 0.3663025f, + 0.3688049f, 0.3713074f, 0.3738403f, 0.3763428f, 0.3788757f, + 0.3814087f, 0.3839111f, 0.3864441f, 0.3889465f, 0.3914795f, + 0.3940125f, 0.3965149f, 0.3990479f, 0.4015808f, 0.4041138f, + 0.4066162f, 0.4091492f, 0.4116821f, 0.4142151f, 0.4167175f, + 0.4192505f, 0.4217834f, 0.4243164f, 0.4268188f, 0.4293518f, + 0.4318848f, 0.4344177f, 0.4369202f, 0.4394531f, 0.4419861f, + 0.4445190f, 0.4470215f, 0.4495544f, 0.4520874f, 0.4545898f, + 0.4571228f, 0.4596558f, 0.4621582f, 0.4646912f, 0.4671936f, + 0.4697266f, 0.4722290f, 0.4747620f, 0.4772644f, 0.4797668f, + 0.4822998f, 0.4848022f, 0.4873047f, 0.4898071f, 0.4923096f, + 0.4948425f, 0.4973450f, 0.4998474f, 0.5023193f, 0.5048218f, + 0.5073242f, 0.5098267f, 0.5123291f, 0.5148010f, 0.5173035f, + 0.5197754f, 0.5222778f, 0.5247498f, 0.5272217f, 0.5297241f, + 0.5321960f, 0.5346680f, 0.5371399f, 0.5396118f, 0.5420837f, + 0.5445251f, 0.5469971f, 0.5494385f, 0.5519104f, 0.5543518f, + 0.5568237f, 0.5592651f, 0.5617065f, 0.5641479f, 0.5665894f, + 0.5690002f, 0.5714417f, 0.5738831f, 0.5762939f, 0.5787048f, + 0.5811462f, 0.5835571f, 0.5859680f, 0.5883789f, 0.5907593f, + 0.5931702f, 0.5955505f, 0.5979614f, 0.6003418f, 0.6027222f, + 0.6051025f, 0.6074829f, 0.6098633f, 0.6122131f, 0.6145935f, + 0.6169434f, 0.6192932f, 0.6216431f, 0.6239929f, 0.6263428f, + 0.6286621f, 0.6309814f, 0.6333313f, 0.6356506f, 0.6379700f, + 0.6402588f, 0.6425781f, 0.6448669f, 0.6471863f, 0.6494751f, + 0.6517639f, 0.6540527f, 0.6563110f, 0.6585999f, 0.6608582f, + 0.6631165f, 0.6653748f, 0.6676025f, 0.6698608f, 0.6720886f, + 0.6743164f, 0.6765442f, 0.6787720f, 0.6809998f, 0.6831970f, + 0.6853943f, 0.6875916f, 0.6897888f, 0.6919861f, 0.6941528f, + 0.6963196f, 0.6984863f, 0.7006531f, 0.7027893f, 0.7049561f, + 0.7070923f, 0.7092285f, 0.7113647f, 0.7134705f, 0.7155762f, + 0.7177124f, 0.7197876f, 0.7218933f, 0.7239685f, 0.7260742f, + 0.7281494f, 0.7301941f, 0.7322693f, 0.7343140f, 0.7363586f, + 0.7384033f, 0.7404480f, 0.7424622f, 0.7444763f, 0.7464905f, + 0.7485046f, 0.7504883f, 0.7524719f, 0.7544556f, 0.7564392f, + 0.7583923f, 0.7603455f, 0.7622986f, 0.7642517f, 0.7662048f, + 0.7681274f, 0.7700500f, 0.7719421f, 0.7738647f, 0.7757568f, + 0.7776489f, 0.7795410f, 0.7814026f, 0.7832642f, 0.7851257f, + 0.7869873f, 0.7888184f, 0.7906494f, 0.7924805f, 0.7943115f, + 0.7961121f, 0.7979126f, 0.7997131f, 0.8015137f, 0.8032837f, + 0.8050537f, 0.8068237f, 0.8085632f, 0.8103027f, 0.8120422f, + 0.8137817f, 0.8154907f, 0.8171997f, 0.8189087f, 0.8206177f, + 0.8222961f, 0.8239746f, 0.8256531f, 0.8273010f, 0.8289795f, + 0.8306274f, 0.8322449f, 0.8338928f, 0.8355103f, 0.8370972f, + 0.8387146f, 0.8403015f, 0.8418884f, 0.8434753f, 0.8450317f, + 0.8465881f, 0.8481445f, 0.8497009f, 0.8512268f, 0.8527527f, + 0.8542786f, 0.8557739f, 0.8572693f, 0.8587646f, 0.8602600f, + 0.8617249f, 0.8631897f, 0.8646545f, 0.8660889f, 0.8675232f, + 0.8689575f, 0.8703918f, 0.8717957f, 0.8731995f, 0.8746033f, + 0.8759766f, 0.8773804f, 0.8787231f, 0.8800964f, 0.8814392f, + 0.8827820f, 0.8841248f, 0.8854675f, 0.8867798f, 0.8880920f, + 0.8893738f, 0.8906860f, 0.8919678f, 0.8932190f, 0.8945007f, + 0.8957520f, 0.8970032f, 0.8982544f, 0.8994751f, 0.9006958f, + 0.9019165f, 0.9031067f, 0.9042969f, 0.9054871f, 0.9066772f, + 0.9078369f, 0.9089966f, 0.9101562f, 0.9113159f, 0.9124451f, + 0.9135742f, 0.9147034f, 0.9158020f, 0.9169006f, 0.9179993f, + 0.9190979f, 0.9201660f, 0.9212341f, 0.9223022f, 0.9233398f, + 0.9243774f, 0.9254150f, 0.9264526f, 0.9274597f, 0.9284973f, + 0.9294739f, 0.9304810f, 0.9314575f, 0.9324341f, 0.9334106f, + 0.9343872f, 0.9353333f, 0.9362793f, 0.9371948f, 0.9381409f, + 0.9390564f, 0.9399719f, 0.9408569f, 0.9417725f, 0.9426575f, + 0.9435425f, 0.9443970f, 0.9452820f, 0.9461365f, 0.9469910f, + 0.9478149f, 0.9486389f, 0.9494629f, 0.9502869f, 0.9511108f, + 0.9519043f, 0.9526978f, 0.9534912f, 0.9542542f, 0.9550171f, + 0.9557800f, 0.9565430f, 0.9573059f, 0.9580383f, 0.9587708f, + 0.9595032f, 0.9602051f, 0.9609070f, 0.9616089f, 0.9623108f, + 0.9630127f, 0.9636841f, 0.9643555f, 0.9650269f, 0.9656677f, + 0.9663391f, 0.9669800f, 0.9676208f, 0.9682312f, 0.9688721f, + 0.9694824f, 0.9700928f, 0.9707031f, 0.9712830f, 0.9718628f, + 0.9724426f, 0.9730225f, 0.9735718f, 0.9741516f, 0.9747009f, + 0.9752502f, 0.9757690f, 0.9763184f, 0.9768372f, 0.9773560f, + 0.9778748f, 0.9783630f, 0.9788818f, 0.9793701f, 0.9798279f, + 0.9803162f, 0.9808044f, 0.9812622f, 0.9817200f, 0.9821777f, + 0.9826050f, 0.9830627f, 0.9834900f, 0.9839172f, 0.9843445f, + 0.9847412f, 0.9851379f, 0.9855652f, 0.9859619f, 0.9863281f, + 0.9867249f, 0.9870911f, 0.9874573f, 0.9878235f, 0.9881897f, + 0.9885559f, 0.9888916f, 0.9892273f, 0.9895630f, 0.9898987f, + 0.9902039f, 0.9905396f, 0.9908447f, 0.9911499f, 0.9914551f, + 0.9917297f, 0.9920349f, 0.9923096f, 0.9925842f, 0.9928589f, + 0.9931335f, 0.9933777f, 0.9936523f, 0.9938965f, 0.9941406f, + 0.9943848f, 0.9945984f, 0.9948425f, 0.9950562f, 0.9952698f, + 0.9954834f, 0.9956970f, 0.9958801f, 0.9960938f, 0.9962769f, + 0.9964600f, 0.9966431f, 0.9968262f, 0.9969788f, 0.9971619f, + 0.9973145f, 0.9974670f, 0.9976196f, 0.9977722f, 0.9978943f, + 0.9980469f, 0.9981689f, 0.9982910f, 0.9984131f, 0.9985352f, + 0.9986572f, 0.9987488f, 0.9988708f, 0.9989624f, 0.9990540f, + 0.9991455f, 0.9992371f, 0.9992981f, 0.9993896f, 0.9994507f, + 0.9995117f, 0.9995728f, 0.9996338f, 0.9996948f, 0.9997253f, + 0.9997864f, 0.9998169f, 0.9998474f, 0.9998779f, 0.9999084f, + 0.9999390f, 0.9999390f, 0.9999695f, 0.9999695f, 0.9999695f, + 0.9999695f +}; +#endif + /*----------------------------------------------------------------------------------* * ISM ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index b90a30699feff1e4734ef1c896701477a2f4fe7e..9ef4737c59c6cdfeaf73782c43095ac7fecfb317 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -336,6 +336,9 @@ extern const float dct4[]; extern const float dct5[]; extern const float dct8[]; extern const float dct12[]; +#ifdef NONBE_1380_OMASA_BUILD_DIFF +extern const float ivas_tan_panning_gain_tbl[]; +#endif /*----------------------------------------------------------------------------------* * ISM ROM tables diff --git a/lib_com/options.h b/lib_com/options.h index e455aa059df3ccdb294f55d956cd13727bf4306d..b72be74b4f342769a8b21a0bde86c3029b833403 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -191,6 +191,8 @@ /*#define NONBE_1324_TC_BUFFER_MEMOERY_KEEP*/ /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */ +#define NONBE_1380_OMASA_BUILD_DIFF /* Nokia: Fix for issue #1380: Large differences in OMASA output between Debug and Release builds */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */