Commit 16a50ea9 authored by sagnowski's avatar sagnowski
Browse files

JBM: Limit max scaling to the duration of one frame

This fixes integer overflows in max scaling calculation
parent 05b43c35
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@
#define NONBE_1246_INF_COHERENCE_IN_HIGH_LEVEL_DTX      /* Ericsson: Issue 1246: High level input which triggers DTX can lead to numerical overflow in coherence calculation */
#define NONBE_1211_DTX_BR_SWITCHING                     /* VA: issue 1211: fix crash in MASA DTX bitrate switching */
#define NONBE_1217_INIT_OBJ_EDIT                        /* VA: issue 1217: do object editing only when objects metadata is available */
#define NONBE_1215_FIX_JBM_MAX_SCALING                  /* FhG: issue 1215: Fix assert hit in a specific VoIP decoder config. Caused by integer overflow in max scaling calculation. */

/* ##################### End NON-BE switches ########################### */

+16 −0
Original line number Diff line number Diff line
@@ -811,7 +811,15 @@ static void JB4_adaptActivePlayout(
                           ( dropRateMax - dropRateMin ) / dropGapMax +
                       dropRateMin;
                *scale = ( 1000 - rate ) / 10;
#ifdef NONBE_1215_FIX_JBM_MAX_SCALING
                /* Limit max scaling to the duration of one frame. APA will not exceed this limit
                 * anyway due to the 50% limitation of APA_MIN_SCALE and APA_MAX_SCALE. Limiting
                 * the value to a sensible range here avoids integer overflows at later stages when
                 * converting maxScaling from milliseconds to samples. */
                *maxScaling = JB4_MIN( currPlayoutDelay - targetMax, 1000 / IVAS_NUM_FRAMES_PER_SEC );
#else
                *maxScaling = currPlayoutDelay - targetMax;
#endif
            }
        }
    }
@@ -827,7 +835,15 @@ static void JB4_adaptActivePlayout(
             currPlayoutDelay < targetMaxStretch && currPlayoutDelay < (uint32_t) ( 110 + h->rfDelay / 4 ) )
        {
            *scale = 120;
#ifdef NONBE_1215_FIX_JBM_MAX_SCALING
            /* Limit max scaling to the duration of one frame. APA will not exceed this limit
             * anyway due to the 50% limitation of APA_MIN_SCALE and APA_MAX_SCALE. Limiting
             * the value to a sensible range here avoids integer overflows at later stages when
             * converting maxScaling from milliseconds to samples. */
            *maxScaling = JB4_MIN( targetMaxStretch - currPlayoutDelay, 1000 / IVAS_NUM_FRAMES_PER_SEC );
#else
            *maxScaling = targetMaxStretch - currPlayoutDelay;
#endif
        }
    }