Loading lib_com/options.h 100755 → 100644 +1 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT /* RTPDUMP acoustic environment */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ #define ISM_PI_DATA /* Add reading and packing/unpacking of ISM PI data */ /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ Loading lib_util/ivas_rtp_file.c +103 −1 Original line number Diff line number Diff line Loading @@ -152,13 +152,16 @@ void IVAS_RTP_LogPiData( uint32_t nPiDataPresent /* i : Number of valid elements in the piData array */ ) { #ifdef ISM_PI_DATA uint16_t n; #endif uint32_t timestamp = ~0u; if ( f_piDataOut == NULL || piData == NULL || nPiDataPresent == 0 ) { return; } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT #if defined IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT || defined ISM_PI_DATA #ifdef _WIN32 if ( ftell( f_piDataOut ) > 3 ) #else Loading Loading @@ -332,6 +335,104 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, "{}" ); } break; #ifdef ISM_PI_DATA case IVAS_PI_ISM_ORIENTATION: { fprintf( f_piDataOut, "[\n" ); for ( n = 0; n < cur->data.ismOrientation.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"w\": %f,\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", cur->data.ismOrientation.orientation[n].w, cur->data.ismOrientation.orientation[n].x, cur->data.ismOrientation.orientation[n].y, cur->data.ismOrientation.orientation[n].z ); } fprintf( f_piDataOut, "\n\t\t]" ); } break; case IVAS_PI_ISM_NUM: { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"num\": %d", cur->data.ismNum.numObjects ); fprintf( f_piDataOut, "\n\t\t}" ); } break; case IVAS_PI_ISM_ID: { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"ids\": [\n" ); for ( n = 0; n < cur->data.ismId.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismId.id[n] ); } fprintf( f_piDataOut, "\n\t\t\t]" ); fprintf( f_piDataOut, "\n\t\t}" ); } break; case IVAS_PI_ISM_GAIN: { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"gains\": [\n" ); for ( n = 0; n < cur->data.ismGain.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismGain.dB[n] ); } fprintf( f_piDataOut, "\n\t\t\t]" ); fprintf( f_piDataOut, "\n\t\t}" ); } break; case IVAS_PI_ISM_POSITION: { fprintf( f_piDataOut, "[\n" ); for ( n = 0; n < cur->data.ismPosition.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", cur->data.ismPosition.position[n].x, cur->data.ismPosition.position[n].y, cur->data.ismPosition.position[n].z ); } fprintf( f_piDataOut, "\n\t\t]" ); } break; case IVAS_PI_ISM_DISTANCE_ATTENUATION: { fprintf( f_piDataOut, "[\n" ); for ( n = 0; n < cur->data.ismAttenuation.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"ref_dist\": %f,\n\t\t\t\t\"max_dist\": %f,\n\t\t\t\t\"roll_off\": %f \n\t\t\t}", cur->data.ismAttenuation.distAtten[n].ref_dist, cur->data.ismAttenuation.distAtten[n].max_dist, cur->data.ismAttenuation.distAtten[n].roll ); } fprintf( f_piDataOut, "\n\t\t]" ); } break; case IVAS_PI_ISM_DIRECTIVITY: { fprintf( f_piDataOut, "[\n" ); for ( n = 0; n < cur->data.ismDirectivity.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"inner_ang\": %d,\n\t\t\t\t\"outer_ang\": %d,\n\t\t\t\t\"outer_att\": %f \n\t\t\t}", cur->data.ismDirectivity.directivity[n].innerConeAngle, cur->data.ismDirectivity.directivity[n].outerConeAngle, cur->data.ismDirectivity.directivity[n].outerAttenuationdB ); } fprintf( f_piDataOut, "\n\t\t]" ); } break; #else case IVAS_PI_ISM_NUM: case IVAS_PI_ISM_ID: case IVAS_PI_ISM_GAIN: Loading @@ -339,6 +440,7 @@ void IVAS_RTP_LogPiData( case IVAS_PI_ISM_POSITION: case IVAS_PI_ISM_DISTANCE_ATTENUATION: case IVAS_PI_ISM_DIRECTIVITY: #endif case IVAS_PI_PI_LATENCY: case IVAS_PI_R_ISM_ID: case IVAS_PI_R_ISM_GAIN: Loading lib_util/ivas_rtp_pi_data.c +542 −9 File changed.Preview size limit exceeded, changes collapsed. Show changes lib_util/ivas_rtp_pi_data.h +30 −13 Original line number Diff line number Diff line Loading @@ -216,6 +216,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ uint32_t piDataType; /* IVAS_PI_ISM_ID */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif uint8_t id[IVAS_MAX_NUM_OBJECTS]; /* 8-bit ISM id of object */ } IVAS_PIDATA_ISM_ID; Loading @@ -224,6 +227,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif int8_t dB[IVAS_MAX_NUM_OBJECTS]; /* ISM gain in dB per object [-96, +3] */ } IVAS_PIDATA_ISM_GAIN; Loading @@ -232,6 +238,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif IVAS_QUATERNION orientation[IVAS_MAX_NUM_OBJECTS]; /* Orientation of audio objects in ISM(s) */ } IVAS_PIDATA_ISM_ORIENTATION; Loading @@ -240,6 +249,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif IVAS_COORDINATE position[IVAS_MAX_NUM_OBJECTS]; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_ISM_POSITION; Loading @@ -259,6 +271,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif IVAS_DIST_ATTEN distAtten[IVAS_MAX_NUM_OBJECTS]; /* Distance attenuation of audio objects */ } IVAS_PIDATA_ISM_ATTENUATION; Loading @@ -278,6 +293,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif IVAS_ISM_DIRECTIVITY directivity[IVAS_MAX_NUM_OBJECTS]; /* Directivity of audio objects */ } IVAS_PIDATA_ISM_DIRECTIVITY; Loading Loading @@ -337,7 +355,6 @@ typedef struct IVAS_COORDINATE position; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_LISTENER_POSITION; /* Dynamic Audio Suppression describes receiver’s preference with respect to the * type of audio content that should be enhanced and the amount of suppression to * be applied to the background noise Loading tests/rtp/ivasrtp.py +154 −11 Original line number Diff line number Diff line Loading @@ -389,6 +389,46 @@ class ACOUSTIC_ENVIRONMENT: abscoeff: tuple[float, float, float, float, float, float] = () @dataclass class ISM_NUM: num: int = 1 @dataclass class ISM_ID: ids: list[int] @dataclass class ISM_GAIN: gains: list[int] @dataclass class ISM_ORIENTATION: orientations: list[ORIENTATION] @dataclass class ISM_POSITION: positions: list[POSITION] @dataclass class DISTANCE_ATTENUATION: ref_dist: float = 1.0 max_dist: int = 10 roll_off: float = 1.0 @dataclass class ISM_DISTANCE_ATTENUATION: distance_attenuations: list[DISTANCE_ATTENUATION] @dataclass class DIRECTIVITY: inner_ang: int = 360 outer_ang: int = 0 outer_att: int = 0 @dataclass class ISM_DIRECTIVITY: directivities: list[DIRECTIVITY] @dataclass class AUDIO_FOCUS: direction: Optional[ORIENTATION] = None Loading @@ -402,7 +442,7 @@ class PIDATA: data: any = None MAX_PACKED_PI_SIZE = 32 MAX_PACKED_PI_SIZE = 48 ivasBitrates = [ 13200, 16400, Loading Loading @@ -581,6 +621,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)) 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)) codedFormats = list(FORMATS) codedSubFormats = list(SUBFORMATS) PiTypeNames = list(PIDATAS) Loading Loading @@ -923,6 +969,103 @@ def packAudioFocus(bitstrm: BitStream, data: any): bitstrm.append(f"uint:4={level}") bitstrm.append(f"uint:4=0") def unpackISMNum(bitstrm: ConstBitStream, piSize: int) -> ISM_NUM: assert piSize == 1, "Incorrect PI Data Size for ISM_NUM" numISM = bitstrm.read(2).uint + 1 bitstrm.bytealign() return ISM_NUM(num=numISM) def packISMNum(bitstrm: BitStream, data: any): assert type(data) == ISM_NUM, "Data of type ISM_NUM is expected" ism_num = cast(ISM_NUM, data) assert ism_num.num <= 4, "Maximum 4 objects" bitstrm.append(f'uint:2={ism_num.num-1}') bitstrm.append(f'uint:6=0') def unpackISMID(bitstrm: ConstBitStream, piSize: int) -> ISM_ID: assert piSize == 1 or piSize == 2 or piSize == 3 or piSize == 4, "Incorrect PI Data Size for ISM_ID" IsmID = list() for _ in range(piSize): IsmID.append(bitstrm.read(8).uint+1) return ISM_ID(ids=IsmID) def packISMID(bitstrm: BitStream, data: any): assert type(data) == ISM_ID, "Data of type ISM_ID is expected" ism_id = cast(ISM_ID, data) assert len(ism_id.ids) <= 4, "Maximum 4 objects" for id in ism_id.ids: bitstrm.append(f'uint:8={id}') 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) bitstrm.bytealign() return ISM_GAIN(gains=IsmGain) def packISMGain(bitstrm: BitStream, data: any): assert type(data) == ISM_GAIN, "Data of type ISM_GAIN is expected" ism_gain = cast(ISM_GAIN, data) 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') def unpackISMDistanceAttenuation(bitstrm: ConstBitStream, piSize: int) -> ISM_DISTANCE_ATTENUATION: ref_dist = None max_dist = None roll_off = None assert piSize == 1*3 or piSize == 2*3 or piSize == 3*3 or piSize == 4*3, "Incorrect PI Data Size for ISM_DISTANCE_ATTENUATION" ism_distance_attenutation = list() for _ in range(piSize): ref_dist = bitstrm.read(6).uint max_dist = bitstrm.read(6).uint roll_off = bitstrm.read(6).uint ism_distance_attenutation.append(DISTANCE_ATTENUATION(ref_dist=ref_dist, max_dist=max_dist, roll_off=roll_off)) bitstrm.bytealign() return ISM_DISTANCE_ATTENUATION(distance_attenuations=ism_distance_attenutation) def packISMDistanceAttenuation(bitstrm: BitStream, data: any): assert type(data) == list, "Data of type list is expected" for att in cast(list, data): assert type(att) == DISTANCE_ATTENUATION, "Data of type list[DISTANCE_ATTENUATION] is expected" ref_dist_idx = getListIndex(refDistances, att.ref_dist) max_dist_idx = getListIndex(maxDistances, att.max_dist) roll_off_idx = getListIndex(rolloffFactors, att.roll_off) bitstrm.append(f'uint:6={ref_dist_idx}') bitstrm.append(f'uint:6={max_dist_idx}') bitstrm.append(f'uint:6={roll_off_idx}') bitstrm.append(f'uint:6=0') def unpackISMDirectivity(bitstrm: ConstBitStream, piSize: int) -> list[DISTANCE_ATTENUATION]: inner_ang = None outer_ang = None outer_att = None assert piSize == 1*2 or piSize == 2*2 or piSize == 3*2 or piSize == 4*2, "Incorrect PI Data Size for ISM_DISTANCE_ATTENUATION" directivities = list() for _ in range(piSize): inner_ang = bitstrm.read(5).uint outer_ang = bitstrm.read(5).uint outer_att = bitstrm.read(5).uint directivities.append(DIRECTIVITY(inner_ang=inner_ang, outer_ang=outer_ang, outer_att=outer_att)) bitstrm.bytealign() return directivities def packISMDirectivity(bitstrm: BitStream, data: any): assert type(data) == list, "Data of type ISM_DIRECTIVITY is expected" for dir in cast(list, data): assert type(dir) == DIRECTIVITY, "Orientation PI Data expects a data of type list[DIRECTIVITY]" inner_ang_idx = getListIndex(innerOuterAngles, dir.inner_ang) outer_ang_idx = getListIndex(innerOuterAngles, dir.outer_ang) outer_att_idx = getListIndex(outerAttenuations, dir.outer_att) bitstrm.append(f'uint:5={inner_ang_idx}') bitstrm.append(f'uint:5={outer_ang_idx}') bitstrm.append(f'uint:5={outer_att_idx}') bitstrm.append(f'uint:1=0') PIDataUnpacker = [ unpackOrientation, # SCENE_ORIENTATION, Loading @@ -930,13 +1073,13 @@ PIDataUnpacker = [ unpackOrientation, # DEVICE_ORIENTATION_UNCOMPENSATED unpackAcousticEnv, # ACOUSTIC_ENVIRONMENT unpackAudioDescription, # AUDIO_DESCRIPTION unpackUnsupported, # ISM_NUM unpackUnsupported, # ISM_ID unpackUnsupported, # ISM_GAIN unpackISMNum, # ISM_NUM unpackISMID, # ISM_ID unpackISMGain, # ISM_GAIN unpackOrientations, # ISM_ORIENTATION unpackPositions, # ISM_POSITION unpackUnsupported, # ISM_DISTANCE_ATTENUATION unpackUnsupported, # ISM_DIRECTIVITY unpackISMDistanceAttenuation, # ISM_DISTANCE_ATTENUATION unpackISMDirectivity, # ISM_DIRECTIVITY unpackDiegetic, # DIEGETIC_TYPE unpackDAS, # DYNAMIC_AUDIO_SUPPRESSION_INDICATION unpackAudioFocus, # AUDIO_FOCUS_INDICATION Loading Loading @@ -965,13 +1108,13 @@ PIDataPacker = [ packOrientation, # DEVICE_ORIENTATION_UNCOMPENSATED packAcousticEnv, # ACOUSTIC_ENVIRONMENT packAudioDescription, # AUDIO_DESCRIPTION packUnsupported, # ISM_NUM packUnsupported, # ISM_ID packUnsupported, # ISM_GAIN packISMNum, # ISM_NUM packISMID, # ISM_ID packISMGain, # ISM_GAIN packOrientations, # ISM_ORIENTATION packPositions, # ISM_POSITION packUnsupported, # ISM_DISTANCE_ATTENUATION packUnsupported, # ISM_DIRECTIVITY packISMDistanceAttenuation, # ISM_DISTANCE_ATTENUATION packISMDirectivity, # ISM_DIRECTIVITY packDiegetic, # DIEGETIC_TYPE packDAS, # DYNAMIC_AUDIO_SUPPRESSION_INDICATION packAudioFocus, # AUDIO_FOCUS_INDICATION Loading Loading
lib_com/options.h 100755 → 100644 +1 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ #define IVAS_RTPDUMP /* RTPDUMP writing and reading for IVAS payloads */ #define IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT /* RTPDUMP acoustic environment */ #define FIXED_RTP_SEQUENCE_NUM /* Remove random sequence number initialization */ #define ISM_PI_DATA /* Add reading and packing/unpacking of ISM PI data */ /* ################### Start BE switches ################################# */ /* only BE switches wrt selection floating point code */ Loading
lib_util/ivas_rtp_file.c +103 −1 Original line number Diff line number Diff line Loading @@ -152,13 +152,16 @@ void IVAS_RTP_LogPiData( uint32_t nPiDataPresent /* i : Number of valid elements in the piData array */ ) { #ifdef ISM_PI_DATA uint16_t n; #endif uint32_t timestamp = ~0u; if ( f_piDataOut == NULL || piData == NULL || nPiDataPresent == 0 ) { return; } #ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT #if defined IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT || defined ISM_PI_DATA #ifdef _WIN32 if ( ftell( f_piDataOut ) > 3 ) #else Loading Loading @@ -332,6 +335,104 @@ void IVAS_RTP_LogPiData( fprintf( f_piDataOut, "{}" ); } break; #ifdef ISM_PI_DATA case IVAS_PI_ISM_ORIENTATION: { fprintf( f_piDataOut, "[\n" ); for ( n = 0; n < cur->data.ismOrientation.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"w\": %f,\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", cur->data.ismOrientation.orientation[n].w, cur->data.ismOrientation.orientation[n].x, cur->data.ismOrientation.orientation[n].y, cur->data.ismOrientation.orientation[n].z ); } fprintf( f_piDataOut, "\n\t\t]" ); } break; case IVAS_PI_ISM_NUM: { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"num\": %d", cur->data.ismNum.numObjects ); fprintf( f_piDataOut, "\n\t\t}" ); } break; case IVAS_PI_ISM_ID: { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"ids\": [\n" ); for ( n = 0; n < cur->data.ismId.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismId.id[n] ); } fprintf( f_piDataOut, "\n\t\t\t]" ); fprintf( f_piDataOut, "\n\t\t}" ); } break; case IVAS_PI_ISM_GAIN: { fprintf( f_piDataOut, "{\n" ); fprintf( f_piDataOut, "\t\t\t\"gains\": [\n" ); for ( n = 0; n < cur->data.ismGain.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t\t%d", cur->data.ismGain.dB[n] ); } fprintf( f_piDataOut, "\n\t\t\t]" ); fprintf( f_piDataOut, "\n\t\t}" ); } break; case IVAS_PI_ISM_POSITION: { fprintf( f_piDataOut, "[\n" ); for ( n = 0; n < cur->data.ismPosition.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"x\": %f,\n\t\t\t\t\"y\": %f,\n\t\t\t\t\"z\": %f \n\t\t\t}", cur->data.ismPosition.position[n].x, cur->data.ismPosition.position[n].y, cur->data.ismPosition.position[n].z ); } fprintf( f_piDataOut, "\n\t\t]" ); } break; case IVAS_PI_ISM_DISTANCE_ATTENUATION: { fprintf( f_piDataOut, "[\n" ); for ( n = 0; n < cur->data.ismAttenuation.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"ref_dist\": %f,\n\t\t\t\t\"max_dist\": %f,\n\t\t\t\t\"roll_off\": %f \n\t\t\t}", cur->data.ismAttenuation.distAtten[n].ref_dist, cur->data.ismAttenuation.distAtten[n].max_dist, cur->data.ismAttenuation.distAtten[n].roll ); } fprintf( f_piDataOut, "\n\t\t]" ); } break; case IVAS_PI_ISM_DIRECTIVITY: { fprintf( f_piDataOut, "[\n" ); for ( n = 0; n < cur->data.ismDirectivity.numObjects; n++ ) { if ( n != 0 ) { fprintf( f_piDataOut, ",\n" ); } fprintf( f_piDataOut, "\t\t\t{\n\t\t\t\t\"inner_ang\": %d,\n\t\t\t\t\"outer_ang\": %d,\n\t\t\t\t\"outer_att\": %f \n\t\t\t}", cur->data.ismDirectivity.directivity[n].innerConeAngle, cur->data.ismDirectivity.directivity[n].outerConeAngle, cur->data.ismDirectivity.directivity[n].outerAttenuationdB ); } fprintf( f_piDataOut, "\n\t\t]" ); } break; #else case IVAS_PI_ISM_NUM: case IVAS_PI_ISM_ID: case IVAS_PI_ISM_GAIN: Loading @@ -339,6 +440,7 @@ void IVAS_RTP_LogPiData( case IVAS_PI_ISM_POSITION: case IVAS_PI_ISM_DISTANCE_ATTENUATION: case IVAS_PI_ISM_DIRECTIVITY: #endif case IVAS_PI_PI_LATENCY: case IVAS_PI_R_ISM_ID: case IVAS_PI_R_ISM_GAIN: Loading
lib_util/ivas_rtp_pi_data.c +542 −9 File changed.Preview size limit exceeded, changes collapsed. Show changes
lib_util/ivas_rtp_pi_data.h +30 −13 Original line number Diff line number Diff line Loading @@ -216,6 +216,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ID) */ uint32_t piDataType; /* IVAS_PI_ISM_ID */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif uint8_t id[IVAS_MAX_NUM_OBJECTS]; /* 8-bit ISM id of object */ } IVAS_PIDATA_ISM_ID; Loading @@ -224,6 +227,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_GAIN) */ uint32_t piDataType; /* IVAS_PI_ISM_GAIN */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif int8_t dB[IVAS_MAX_NUM_OBJECTS]; /* ISM gain in dB per object [-96, +3] */ } IVAS_PIDATA_ISM_GAIN; Loading @@ -232,6 +238,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ORIENTATION) */ uint32_t piDataType; /* IVAS_PI_ISM_ORIENTATION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif IVAS_QUATERNION orientation[IVAS_MAX_NUM_OBJECTS]; /* Orientation of audio objects in ISM(s) */ } IVAS_PIDATA_ISM_ORIENTATION; Loading @@ -240,6 +249,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_POSITION) */ uint32_t piDataType; /* IVAS_PI_ISM_POSITION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif IVAS_COORDINATE position[IVAS_MAX_NUM_OBJECTS]; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_ISM_POSITION; Loading @@ -259,6 +271,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_ATTENUATION) */ uint32_t piDataType; /* IVAS_PI_ISM_DISTANCE_ATTENUATION */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif IVAS_DIST_ATTEN distAtten[IVAS_MAX_NUM_OBJECTS]; /* Distance attenuation of audio objects */ } IVAS_PIDATA_ISM_ATTENUATION; Loading @@ -278,6 +293,9 @@ typedef struct { size_t size; /* sizeof(IVAS_PIDATA_ISM_DIRECTIVITY) */ uint32_t piDataType; /* IVAS_PI_ISM_DIRECTIVITY */ #ifdef ISM_PI_DATA uint16_t numObjects; /* number of objects */ #endif IVAS_ISM_DIRECTIVITY directivity[IVAS_MAX_NUM_OBJECTS]; /* Directivity of audio objects */ } IVAS_PIDATA_ISM_DIRECTIVITY; Loading Loading @@ -337,7 +355,6 @@ typedef struct IVAS_COORDINATE position; /* Position of audio objects in ISM(s) */ } IVAS_PIDATA_LISTENER_POSITION; /* Dynamic Audio Suppression describes receiver’s preference with respect to the * type of audio content that should be enhanced and the amount of suppression to * be applied to the background noise Loading
tests/rtp/ivasrtp.py +154 −11 Original line number Diff line number Diff line Loading @@ -389,6 +389,46 @@ class ACOUSTIC_ENVIRONMENT: abscoeff: tuple[float, float, float, float, float, float] = () @dataclass class ISM_NUM: num: int = 1 @dataclass class ISM_ID: ids: list[int] @dataclass class ISM_GAIN: gains: list[int] @dataclass class ISM_ORIENTATION: orientations: list[ORIENTATION] @dataclass class ISM_POSITION: positions: list[POSITION] @dataclass class DISTANCE_ATTENUATION: ref_dist: float = 1.0 max_dist: int = 10 roll_off: float = 1.0 @dataclass class ISM_DISTANCE_ATTENUATION: distance_attenuations: list[DISTANCE_ATTENUATION] @dataclass class DIRECTIVITY: inner_ang: int = 360 outer_ang: int = 0 outer_att: int = 0 @dataclass class ISM_DIRECTIVITY: directivities: list[DIRECTIVITY] @dataclass class AUDIO_FOCUS: direction: Optional[ORIENTATION] = None Loading @@ -402,7 +442,7 @@ class PIDATA: data: any = None MAX_PACKED_PI_SIZE = 32 MAX_PACKED_PI_SIZE = 48 ivasBitrates = [ 13200, 16400, Loading Loading @@ -581,6 +621,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)) 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)) codedFormats = list(FORMATS) codedSubFormats = list(SUBFORMATS) PiTypeNames = list(PIDATAS) Loading Loading @@ -923,6 +969,103 @@ def packAudioFocus(bitstrm: BitStream, data: any): bitstrm.append(f"uint:4={level}") bitstrm.append(f"uint:4=0") def unpackISMNum(bitstrm: ConstBitStream, piSize: int) -> ISM_NUM: assert piSize == 1, "Incorrect PI Data Size for ISM_NUM" numISM = bitstrm.read(2).uint + 1 bitstrm.bytealign() return ISM_NUM(num=numISM) def packISMNum(bitstrm: BitStream, data: any): assert type(data) == ISM_NUM, "Data of type ISM_NUM is expected" ism_num = cast(ISM_NUM, data) assert ism_num.num <= 4, "Maximum 4 objects" bitstrm.append(f'uint:2={ism_num.num-1}') bitstrm.append(f'uint:6=0') def unpackISMID(bitstrm: ConstBitStream, piSize: int) -> ISM_ID: assert piSize == 1 or piSize == 2 or piSize == 3 or piSize == 4, "Incorrect PI Data Size for ISM_ID" IsmID = list() for _ in range(piSize): IsmID.append(bitstrm.read(8).uint+1) return ISM_ID(ids=IsmID) def packISMID(bitstrm: BitStream, data: any): assert type(data) == ISM_ID, "Data of type ISM_ID is expected" ism_id = cast(ISM_ID, data) assert len(ism_id.ids) <= 4, "Maximum 4 objects" for id in ism_id.ids: bitstrm.append(f'uint:8={id}') 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) bitstrm.bytealign() return ISM_GAIN(gains=IsmGain) def packISMGain(bitstrm: BitStream, data: any): assert type(data) == ISM_GAIN, "Data of type ISM_GAIN is expected" ism_gain = cast(ISM_GAIN, data) 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') def unpackISMDistanceAttenuation(bitstrm: ConstBitStream, piSize: int) -> ISM_DISTANCE_ATTENUATION: ref_dist = None max_dist = None roll_off = None assert piSize == 1*3 or piSize == 2*3 or piSize == 3*3 or piSize == 4*3, "Incorrect PI Data Size for ISM_DISTANCE_ATTENUATION" ism_distance_attenutation = list() for _ in range(piSize): ref_dist = bitstrm.read(6).uint max_dist = bitstrm.read(6).uint roll_off = bitstrm.read(6).uint ism_distance_attenutation.append(DISTANCE_ATTENUATION(ref_dist=ref_dist, max_dist=max_dist, roll_off=roll_off)) bitstrm.bytealign() return ISM_DISTANCE_ATTENUATION(distance_attenuations=ism_distance_attenutation) def packISMDistanceAttenuation(bitstrm: BitStream, data: any): assert type(data) == list, "Data of type list is expected" for att in cast(list, data): assert type(att) == DISTANCE_ATTENUATION, "Data of type list[DISTANCE_ATTENUATION] is expected" ref_dist_idx = getListIndex(refDistances, att.ref_dist) max_dist_idx = getListIndex(maxDistances, att.max_dist) roll_off_idx = getListIndex(rolloffFactors, att.roll_off) bitstrm.append(f'uint:6={ref_dist_idx}') bitstrm.append(f'uint:6={max_dist_idx}') bitstrm.append(f'uint:6={roll_off_idx}') bitstrm.append(f'uint:6=0') def unpackISMDirectivity(bitstrm: ConstBitStream, piSize: int) -> list[DISTANCE_ATTENUATION]: inner_ang = None outer_ang = None outer_att = None assert piSize == 1*2 or piSize == 2*2 or piSize == 3*2 or piSize == 4*2, "Incorrect PI Data Size for ISM_DISTANCE_ATTENUATION" directivities = list() for _ in range(piSize): inner_ang = bitstrm.read(5).uint outer_ang = bitstrm.read(5).uint outer_att = bitstrm.read(5).uint directivities.append(DIRECTIVITY(inner_ang=inner_ang, outer_ang=outer_ang, outer_att=outer_att)) bitstrm.bytealign() return directivities def packISMDirectivity(bitstrm: BitStream, data: any): assert type(data) == list, "Data of type ISM_DIRECTIVITY is expected" for dir in cast(list, data): assert type(dir) == DIRECTIVITY, "Orientation PI Data expects a data of type list[DIRECTIVITY]" inner_ang_idx = getListIndex(innerOuterAngles, dir.inner_ang) outer_ang_idx = getListIndex(innerOuterAngles, dir.outer_ang) outer_att_idx = getListIndex(outerAttenuations, dir.outer_att) bitstrm.append(f'uint:5={inner_ang_idx}') bitstrm.append(f'uint:5={outer_ang_idx}') bitstrm.append(f'uint:5={outer_att_idx}') bitstrm.append(f'uint:1=0') PIDataUnpacker = [ unpackOrientation, # SCENE_ORIENTATION, Loading @@ -930,13 +1073,13 @@ PIDataUnpacker = [ unpackOrientation, # DEVICE_ORIENTATION_UNCOMPENSATED unpackAcousticEnv, # ACOUSTIC_ENVIRONMENT unpackAudioDescription, # AUDIO_DESCRIPTION unpackUnsupported, # ISM_NUM unpackUnsupported, # ISM_ID unpackUnsupported, # ISM_GAIN unpackISMNum, # ISM_NUM unpackISMID, # ISM_ID unpackISMGain, # ISM_GAIN unpackOrientations, # ISM_ORIENTATION unpackPositions, # ISM_POSITION unpackUnsupported, # ISM_DISTANCE_ATTENUATION unpackUnsupported, # ISM_DIRECTIVITY unpackISMDistanceAttenuation, # ISM_DISTANCE_ATTENUATION unpackISMDirectivity, # ISM_DIRECTIVITY unpackDiegetic, # DIEGETIC_TYPE unpackDAS, # DYNAMIC_AUDIO_SUPPRESSION_INDICATION unpackAudioFocus, # AUDIO_FOCUS_INDICATION Loading Loading @@ -965,13 +1108,13 @@ PIDataPacker = [ packOrientation, # DEVICE_ORIENTATION_UNCOMPENSATED packAcousticEnv, # ACOUSTIC_ENVIRONMENT packAudioDescription, # AUDIO_DESCRIPTION packUnsupported, # ISM_NUM packUnsupported, # ISM_ID packUnsupported, # ISM_GAIN packISMNum, # ISM_NUM packISMID, # ISM_ID packISMGain, # ISM_GAIN packOrientations, # ISM_ORIENTATION packPositions, # ISM_POSITION packUnsupported, # ISM_DISTANCE_ATTENUATION packUnsupported, # ISM_DIRECTIVITY packISMDistanceAttenuation, # ISM_DISTANCE_ATTENUATION packISMDirectivity, # ISM_DIRECTIVITY packDiegetic, # DIEGETIC_TYPE packDAS, # DYNAMIC_AUDIO_SUPPRESSION_INDICATION packAudioFocus, # AUDIO_FOCUS_INDICATION Loading