Unverified Commit 73adbdef authored by janssontoftg's avatar janssontoftg
Browse files

Change ISM_GAIN PI data to cover -Inf, -24 to +12 dB. Include -128...

Change ISM_GAIN PI data to cover -Inf, -24 to +12 dB. Include -128 (correcponsing to -Inf) in pytest for gain and directivity
parent 5d71279b
Loading
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -969,13 +969,13 @@ static ivas_error packISMGain( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffe
    for ( n = 0; n < ism_gain->numObjects; n++ )
    {
        gain = (int16_t) ism_gain->dB[n];
        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;
@@ -999,21 +999,21 @@ static ivas_error unpackISMGain( const uint8_t *buffer, uint32_t numDataBytes, I
    /* Unpack ID for each object (1 byte each) */
    for ( n = 0; n < ism_gain->numObjects; n++ )
    {
        idx = ( buffer[n] ) >> 1;
        idx = ( buffer[n] ) >> 2;
        /* negative gains*/
        if ( idx < 97 )
        if ( idx < 25 )
        {
            ism_gain->dB[n] = -(int8_t) ( idx );
        }
        /* Set to min for muting, to be interpreted as -Inf */
        else if ( idx == 97 )
        else if ( idx == 25 )
        {
            ism_gain->dB[n] = -128;
        }
        /* postive gains */
        else if ( idx < 101 )
        else if ( idx < 38 )
        {
            ism_gain->dB[n] = (int8_t) idx - 97;
            ism_gain->dB[n] = (int8_t) idx - 25;
        }
        else
        {
@@ -1181,7 +1181,7 @@ static ivas_error unpackISMDirectivity( const uint8_t *buffer, uint32_t numDataB

        if ( idx == 0 )
        {
            ism_directivity->directivity[n].outerAttenuationdB = -32768.0f; /* corresponds to muting */
            ism_directivity->directivity[n].outerAttenuationdB = -128.0f; /* corresponds to muting */
        }
        else
        {
+5 −5
Original line number Diff line number Diff line
@@ -634,12 +634,12 @@ roomDimensionValue = [
    90.51,
]
absorptionCoeffValues = [0.0800, 0.1656, 0.3430, 0.7101]
ismGains = list(range(0, -97, -1)) + [-float("inf")] + list(range(1, 4))
ismGains = list(range(0, -25, -1)) + [-128] + list(range(1, 13)) # -128 corresponds to -Inf
refDistances = [round(x * 0.1, 1) for x in range(1, 65)]
maxDistances = list(range(1,65))
rolloffFactors = [round(x * 0.1, 1) for x in range(0, 41)]
innerOuterAngles = list(range(0,361,15))
outerAttenuations = [-float("inf")] + list(range(-90,1,3))
outerAttenuations = [-128] + list(range(-90,1,3)) # -128 corresponds to -Inf
codedFormats = list(FORMATS)
codedSubFormats = list(SUBFORMATS)
PiTypeNames = list(PIDATAS)
@@ -1029,7 +1029,7 @@ def unpackISMGain(bitstrm: ConstBitStream, piSize: int) -> ISM_GAIN:
    assert piSize == 1 or piSize == 2 or piSize == 3 or piSize == 4, "Incorrect PI Data Size for ISM_GAIN"
    IsmGain = list()
    for _ in range(piSize):
        IsmGain.append(bitstrm.read(7).uint)
        IsmGain.append(bitstrm.read(6).uint)
        bitstrm.bytealign()
    return ISM_GAIN(gains=IsmGain)

@@ -1039,8 +1039,8 @@ def packISMGain(bitstrm: BitStream, data: any):
    assert len(ism_gain.gains) <= 4, "Maximum 4 objects"
    for gain in ism_gain.gains:
        gain_idx = getListIndex(ismGains, 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 unpackISMDistanceAttenuation(bitstrm: ConstBitStream, piSize: int) -> ISM_DISTANCE_ATTENUATION:
    ref_dist = None
+2 −2
Original line number Diff line number Diff line
@@ -263,11 +263,11 @@ def generatePiData(startTs: int, endTs: int) -> dict:

    someNumISM = lambda : ISM_NUM(num=random.randint(1, 4))
    someISMIds = lambda num_ism : ISM_ID(ids=[int(random.getrandbits(8)) for _ in range(num_ism)])
    someISMGains = lambda num_ism : ISM_GAIN(gains=[int(random.randint(-96,3)) for _ in range(num_ism)])
    someISMGains = lambda num_ism : ISM_GAIN(gains=[random.choice([int(random.randint(-24,12)), -128]) for _ in range(num_ism)]) # -128 corresponds to -Inf
    someISMOrientations = lambda num_ism : [ORIENTATION(w=2*random.random()-1.0, x=2*random.random()-1.0, y=2*random.random()-1.0, z=2*random.random()-1.0) for _ in range(num_ism)]
    someISMPositions = lambda num_ism : [POSITION( x=random.randint(-32788, 32767)/100.0, y=random.randint(-32788, 32767)/100.0, z=random.randint(-32788, 32767)/100.0) for _ in range(num_ism)]
    someISMDistanceAttenuations = lambda num_ism : [DISTANCE_ATTENUATION(ref_dist=random.randint(1,64)/10.0, max_dist=random.randint(1,64), roll_off=random.randint(0,40)/10.0) for _ in range(num_ism)]
    someISMDirectivities = lambda num_ism : [DIRECTIVITY(inner_ang=random.randint(0,24)*15, outer_ang=random.randint(0,24)*15, outer_att=random.randint(-30,0)*3) for _ in range(num_ism)]
    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)))