Commit b7224412 authored by Lauros Pajunen's avatar Lauros Pajunen
Browse files

Fix usan, orientation progreses

parent 7a3ebeb6
Loading
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -111,12 +111,12 @@ static int16_t ivasPayload_convertToQ9( float value )
 *
 * Convert a float value into a Q7 encoded value.
 *-----------------------------------------------------------------------*/
static int8_t ivasPayload_convertToQ7( float value )
static int16_t ivasPayload_convertToQ7( float value )
{
    value = ( value * 128.0f );
    value = value > +128.0f ? +128.0f : value;
    value = value < -128.0f ? -128.0f : value;
    return (int8_t) ( value );
    return (int16_t) ( value );
}
#endif

@@ -775,6 +775,14 @@ static ivas_error unpackPositionCompact( const uint8_t *buffer, uint32_t numData
        return IVAS_ERROR( IVAS_ERR_RTP_UNPACK_PI_DATA, "Incorrect size to unpack compact position PI data" );
    }

    int16_t value1 = -100;
    int16_t value2 = 100;
    uint16_t value1_uint16 = (uint16_t) value1;
    uint16_t value2_uint16 = (uint16_t) value2;




    position->size = sizeof( IVAS_PIDATA_POSITION );

    compactRead = ( (int32_t) buffer[0] << 24 ) | ( (int32_t) buffer[1] << 16 ) | ( (int32_t) buffer[2] << 8 ) | ( (int32_t) buffer[3] );
+18 −3
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ import base64
import argparse
from pathlib import Path
from typing import cast, Optional
import numpy as np
import ctypes

NO_REQ = "NO_REQ"

@@ -657,6 +659,8 @@ elevationStepSize = 1.417322835
azimuthDirections = [round(x * azimuthStepSize - 180, 3) for x in range(1, 512)]
elevationDirections = [round(x * elevationStepSize - 90, 3) for x in range(0, 127)]

MASK_3BIT = 0x7
MASK_6BIT = 0x3F

def mapNearestIndex(table: list, val: float) -> int:
    for idx, entry in enumerate(table):
@@ -822,9 +826,20 @@ def packPositionsCompact(bitstrm: BitStream, data: any):
        assert (
                type(position) == POSITION
        ), "Compact position PI Data expects a data of type list[POSITIONS]"
        bitstrm.append(f"int:11={q10(position.x / 10.24)}")
        bitstrm.append(f"int:11={q10(position.y / 10.24)}")
        bitstrm.append(f"int:10={q9(position.z / 5.12)}")
        #posX = np.uint16(q10(position.x / 10.24))
        #posY = np.uint16(q10(position.y / 10.24))
        #posZ = np.uint16(q9(position.z / 5.12))
        posX = ctypes.c_int16( q10(position.x / 10.24) ).value
        posY = ctypes.c_int16( q10(position.y / 10.24) ).value
        posZ = ctypes.c_int16( q9(position.z / 5.12) ).value
        bitstrm.append(f"uintbe:8={ctypes.c_uint8(posX >> 3).value}")
        bitstrm.append(f"uintbe:8={ctypes.c_uint8(( (posX & MASK_3BIT) << 5 ) | (posY >> 6)).value}")
        bitstrm.append(f"uintbe:8={ctypes.c_uint8(( (posY & MASK_6BIT) << 2 ) | (posZ >> 8)).value}")
        bitstrm.append(f"uintbe:8={(posZ >> 2)}")

        #bitstrm.append(f"int:11={q10(position.x / 10.24)}")
        #bitstrm.append(f"int:11={q10(position.y / 10.24)}")
        #bitstrm.append(f"int:10={q9(position.z / 5.12)}")


def unpackOrientation(bitstrm: ConstBitStream, piSize: int) -> ORIENTATION:
+15 −4
Original line number Diff line number Diff line
@@ -193,10 +193,15 @@ def generatePiData(startTs: int, endTs: int) -> dict:
        y=random.randint(-32788, 32767) / 100.0,
        z=random.randint(-32788, 32767) / 100.0,
    )
    #somePositionCompact = lambda: POSITION(
    #    x=random.randint(-1024, 1023) / 100.0,
    #    y=random.randint(-1024, 1023) / 100.0,
    #    z=random.randint(-512, 511) / 100.0,
    #)
    somePositionCompact = lambda: POSITION(
        x=random.randint(-1024, 1023) / 100.0,
        y=random.randint(-1024, 1023) / 100.0,
        z=random.randint(-512, 511) / 100.0,
        x=1.0,
        y=1.0,
        z=-1.0,
    )
    someDesc = lambda: AUDIO_DESCRIPTION(
        isSpeech=bool(random.getrandbits(1)),
@@ -290,6 +295,11 @@ def generatePiData(startTs: int, endTs: int) -> dict:

    for ts in range(startTs, endTs, 320):
        pidata = dict()

        pidata["ISM_NUM"] = someNumISM()
        pidata["ISM_POSITION_COMPACT"] = someISMPositionsCompact(pidata["ISM_NUM"].num)
        #pidata["R_ISM_POSITION_COMPACT"] = somePositionCompact()
        '''
        pidata["SCENE_ORIENTATION"] = someOrientation()
        pidata["DEVICE_ORIENTATION_COMPENSATED"] = someOrientation()
        pidata["DEVICE_ORIENTATION_UNCOMPENSATED"] = someOrientation()
@@ -317,6 +327,7 @@ def generatePiData(startTs: int, endTs: int) -> dict:
        pidata["R_ISM_POSITION"] = somePosition()
        pidata["R_ISM_POSITION_COMPACT"] = somePositionCompact()
        pidata["R_ISM_DIRECTION"] = someReverseISMDirection()
        '''
        data[str(ts)] = pidata
    return data

@@ -758,7 +769,7 @@ def run_rtp_bitstream_tests(
                        elif pitype == "ISM_ORIENTATION":
                            for r, d in zip(generatedPIData[ts][pitype], decodedPiData[ts][pitype]):
                                isEqualOrientation(ORIENTATION(**d), r)
                        elif pitype == "ISM_POSITION":
                        elif pitype == "ISM_POSITION" or pitype == "ISM_POSITION_COMPACT":
                            for r, d in zip(generatedPIData[ts][pitype], decodedPiData[ts][pitype]):
                                isEqualPosition(POSITION(**d), r)     
                        elif pitype == "ISM_DISTANCE_ATTENUATION":