Unverified Commit fbcbfa48 authored by janssontoftg's avatar janssontoftg
Browse files

Update ISM gain range also in reverse direction.

parent 8ab0daf2
Loading
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -1271,13 +1271,13 @@ static ivas_error packReverseISMGain( const IVAS_PIDATA_GENERIC *piData, uint8_t

    buffer[nBytes++] = ( r_ism_gain->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */
    gain = (int16_t) r_ism_gain->dB;
    idx = min( -gain, 97 );
    idx = min( -gain, 25 );
    if ( gain > 0 )
    {
        idx += 97;
        idx += 25;
    }

    buffer[nBytes++] = ( idx & MASK_7BIT ) << 1;
    buffer[nBytes++] = ( idx & MASK_6BIT ) << 2;
    *nBytesWritten = nBytes;
    return IVAS_ERR_OK;
}
@@ -1297,21 +1297,21 @@ static ivas_error unpackReverseISMGain( const uint8_t *buffer, uint32_t numDataB
    r_ism_gain->piDataType = IVAS_PI_R_ISM_GAIN;

    /* Unpack gain */
    idx = ( *buffer ) >> 1;
    idx = ( *buffer ) >> 2;
    /* negative gains*/
    if ( idx < 97 )
    if ( idx < 25 )
    {
        r_ism_gain->dB = -(int8_t) ( idx );
    }
    /* Set to min for muting, to be interpreted as -Inf */
    else if ( idx == 97 )
    else if ( idx == 25 )
    {
        r_ism_gain->dB = -128;
    }
    /* postive gains */
    else if ( idx < 101 )
    else if ( idx < 38 )
    {
        r_ism_gain->dB = (int8_t) idx - 97;
        r_ism_gain->dB = (int8_t) idx - 25;
    }
    else
    {
+3 −3
Original line number Diff line number Diff line
@@ -1108,15 +1108,15 @@ def packReverseISMID(bitstrm: BitStream, data: any):

def unpackReverseISMGain(bitstrm: ConstBitStream, piSize: int) -> R_ISM_GAIN:
    assert piSize == 1, "Incorrect PI Data Size for R_ISM_GAIN"
    gain = bitstrm.read(7).uint
    gain = bitstrm.read(6).uint
    return R_ISM_GAIN(gain=gain)

def packReverseISMGain(bitstrm: BitStream, data: any):
    assert type(data) == R_ISM_GAIN, "Data of type R_ISM_GAIN is expected"
    r_ism_gain = cast(R_ISM_GAIN, data)
    gain_idx = getListIndex(ismGains, r_ism_gain.gain)
    bitstrm.append(f'uint:7={gain_idx}')
    bitstrm.append(f'uint:1=0')
    bitstrm.append(f'uint:6={gain_idx}')
    bitstrm.append(f'uint:2=0')

def unpackReverseISMDirection(bitstrm: ConstBitStream, piSize: int) -> R_ISM_DIRECTION:
    assert piSize == 2, "Incorrect PI Data Size for R_ISM_DIRECTION"
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ def generatePiData(startTs: int, endTs: int) -> dict:
    someISMDirectivities = lambda num_ism : [DIRECTIVITY(inner_ang=random.randint(0,24)*15, outer_ang=random.randint(0,24)*15, outer_att=random.choice([random.randint(-30,0)*3, -128])) for _ in range(num_ism)] # -128 corresponds to -Inf

    someReverseISMId = lambda : R_ISM_ID(id=(random.getrandbits(8)))
    someReverseISMGain = lambda : R_ISM_GAIN(gain=int(random.randint(-96,3)))
    someReverseISMGain = lambda : R_ISM_GAIN(gain=random.choice([int(random.randint(-24,12)), -128]))
    someReverseISMDirection = lambda : R_ISM_DIRECTION( azi=random.randint(1,512) * azimuthStepSize - 180.0, elev=random.randint(0,127) * elevationStepSize - 90.0 )

    for ts in range(startTs, endTs, 320):