📄 audio.cpp
字号:
if ( audioObjectType == 8 ) { // CelpSpecificConfig(), defined in ISO/IEC 14496-3 subpart 3 printf(" CelpSpecificConfig\n"); uint32_t excitationMode = bs->GetBits(1); printf(" excitationMode (1 bit) - 0x%x\n", excitationMode); temp = bs->GetBits(1); printf(" sampleRateMode (1 bit) - 0x%x\n", temp); temp = bs->GetBits(1); printf(" fineRateMode (1 bit) - 0x%x\n", temp); if(excitationMode == 1) { printf(" excitationMode == RegularPulseExc\n"); temp = bs->GetBits(3); printf(" RPE_Configuration (3 bit) - 0x%x\n", temp); } else { printf(" excitationMode == MultiPulseExc\n"); temp = bs->GetBits(5); printf(" MPE_Configuration (5 bit) - 0x%x\n", temp); temp = bs->GetBits(2); printf(" numEnhLayers (2 bit) - 0x%x\n", temp); temp = bs->GetBits(1); printf(" bandwidthScalabilityMode (1 bit) - 0x%x\n", temp); } printf(" End of CelpSpecificConfig\n"); } if ( audioObjectType == 9 ) { //HvxcSpecificConfig(); printf(" HvxcSpecificConfig not implemented yet, defined in ISO/IEC 14496-3 subpart 2.\n"); } if ( audioObjectType == 12 ) { // TTSSpecificConfig(); printf(" TTSSpecificConfig not implemented yet, defined in ISO/IEC 14496-3 subpart 6.\n"); } if ( audioObjectType == 13 || audioObjectType == 14 || audioObjectType == 15 || audioObjectType==16) { // StructuredAudioSpecificConfig(); printf(" StructuredAudioSpecificConfig not implemented yet, defined in ISO/IEC 14496-3 subpart 5.\n"); } if ( audioObjectType == 24) { // ErrorResilientCelpSpecificConfig(); printf(" ErrorResilientCelpSpecificConfig not implemented yet, defined in ISO/IEC 14496-3 subpart 3.\n"); } if ( audioObjectType == 25) { temp = bs->GetBits(1); printf(" HVXCvarMode (1 bit) - 0x%x\n", temp); temp = bs->GetBits(2); printf(" HVXCreateMode (2 bit) - 0x%x\n", temp); temp = bs->GetBits(1); printf(" extensionFlag (1 bit) - 0x%x\n", temp); if(temp) { temp = bs->GetBits(1); printf(" var_ScalableFlag (1 bit)- 0x%x\n", temp); } } if ( audioObjectType == 26 || audioObjectType == 27) { // ParametricSpecificConfig(); printf(" ParametricSpecificConfig not implemented yet, defined in ISO/IEC 14496-3 subpart 7.\n"); } // This is different in amd 1, which to follow? if ( audioObjectType == 17 || audioObjectType == 19 || audioObjectType == 20 || audioObjectType == 21 || audioObjectType == 22 || audioObjectType == 23 || audioObjectType == 24 || audioObjectType == 25 || audioObjectType == 26 || audioObjectType == 27 ) { uint32_t epConfig = bs->GetBits(2); printf(" epConfig (2 bit) - 0x%x\n", temp); if ( epConfig == 2 || epConfig == 3 ) { // ErrorProtectionSpecificConfig(); uint32_t number_of_predefined_set = bs->GetBits(8); printf(" number_of_predefined_set (8 bit) - 0x%x\n", number_of_predefined_set); uint32_t interleave_type = bs->GetBits(2); printf(" interleave_type (2 bit) - 0x%x\n", interleave_type); temp = bs->GetBits(3); printf(" bit_stuffing (3 bit) - 0x%x\n", temp); uint32_t number_of_concatenated_frame = bs->GetBits(3); printf(" number_of_concatenated_frame (3 bit) - 0x%x\n", number_of_concatenated_frame); for ( i = 0; i < number_of_predefined_set; i++ ) { printf(" predefined_set - %i\n", i); uint32_t number_of_class = bs->GetBits(6); printf(" number_of_class[%i] (6 bit) - 0x%x\n", i, number_of_class); for ( j = 0; j < number_of_class; j++) { printf(" class - %i\n", j); uint32_t length_escape = bs->GetBits(1); printf(" length_escape[%i][%i] (1 bit) - 0x%x\n", i, j, length_escape); uint32_t rate_escape = bs->GetBits(1); printf(" rate_escape[%i][%i] (1 bit) - 0x%x\n", i, j, rate_escape); uint32_t crclen_escape = bs->GetBits(1); printf(" crclen_escape[%i][%i] (1 bit) - 0x%x\n", i, j, crclen_escape); if ( number_of_concatenated_frame != 1) { temp = bs->GetBits(1); printf(" concatenate_flag[%i][%i] (1 bit) - 0x%x\n", i, j, temp); } uint32_t fec_type = bs->GetBits(2); printf(" fec_type[%i][%i] (2 bit) - 0x%x\n", i, j, fec_type); if( fec_type == 0) { temp = bs->GetBits(1); printf(" termination_switch[%i][%i] (1 bit) - 0x%x\n", i, j, temp); } if (interleave_type == 2) { temp = bs->GetBits(2); printf(" interleave_switch[%i][%i] (2 bit) - 0x%x\n", i, j, temp); } temp = bs->GetBits(1); printf(" class_optional (1 bit) - 0x%x\n", temp); if ( length_escape == 1 ) { /* ESC */ temp = bs->GetBits(4); printf(" number_of_bits_for_length[%i][%i] (4 bit) - 0x%x\n", i, j, temp); } else { temp = bs->GetBits(16); printf(" class_length[%i][%i] (16 bit) - 0x%x\n", i, j, temp); } if ( rate_escape != 1 ) { /* not ESC */ if(fec_type) { temp = bs->GetBits(7); printf(" class_rate[%i][%i] (7 bit) - 0x%x\n", i, j, temp); } else { temp = bs->GetBits(5); printf(" class_rate[%i][%i] (5 bit) - 0x%x\n", i, j, temp); } } if ( crclen_escape != 1 ) { /* not ESC */ temp = bs->GetBits(5); printf(" class_crclen[%i][%i] - 0x%x\n", i, j, temp); } } temp = bs->GetBits(1); printf(" class_recorded_output (1 bit) - 0x%x\n", temp); if ( temp == 1 ) { for ( j = 0; j < number_of_class; j++ ) { printf(" class - %i\n", j); temp = bs->GetBits(6); printf(" class_output_order[%i][%i] (6 bit) - 0x%x\n", i, j, temp); } } } temp = bs->GetBits(1); printf(" header_protection (1 bit) - 0x%x\n", temp); if(temp == 1) { temp = bs->GetBits(5); printf(" header_rate (5 bit) - 0x%x\n", temp); temp = bs->GetBits(5); printf(" header_crclen (5 bit) - 0x%x\n", temp); } temp = bs->GetBits(7); printf(" rs_fec_capability (7 bit) - 0x%x\n", temp); } if ( epConfig == 3 ) { temp = bs->GetBits(1); printf(" directMapping (1 bit) - 0x%x\n", temp); if ( ! temp ) { /* tbd */ } } } printf("End of AudioSpecificConfig\n");}void CheckStreamMuxConfig (CBitstream *bs) { uint32_t temp; printf("StreamMuxConfig\n"); temp = bs->GetBits(1); printf(" audioMuxVersion (1 bit) - 0x%x\n", temp); if(temp == 0) { uint32_t streamCnt=0; uint32_t progSIndx[255]; uint32_t laySIndx[255]; uint32_t streamID[255][255]; uint32_t allStreamsSameTimeFraming = bs->GetBits(1); printf(" allStreamsSameTimeFraming (1 bit) - 0x%x\n", allStreamsSameTimeFraming); uint32_t numSubFrames = bs->GetBits(6); printf(" numSubFrames (6 bit) - 0x%x\n", numSubFrames); uint32_t numProgram = bs->GetBits(4); printf(" numProgram (4 bit) - 0x%x\n", numProgram); for ( uint32_t prog = 0; prog <= numProgram; prog++ ) { uint32_t numLayer = bs->GetBits(3); printf(" numLayer (3 bit) - 0x%x\n", numLayer); for ( uint32_t lay = 0; lay <= numLayer; lay++ ) { progSIndx[streamCnt] = prog; laySIndx[streamCnt] = lay; streamID [ prog][ lay] = streamCnt++; if ( prog == 0 && lay == 0 ) { CheckAudioSpecificConfig(bs); } else { temp = bs->GetBits(1); printf(" useSameConfig (1 bit) - 0x%x\n", temp); if ( !temp ) CheckAudioSpecificConfig(bs); } temp = bs->GetBits(3); printf(" frameLengthType[%i] (3 bit) - 0x%x\n", streamID[prog][lay], temp); if ( temp == 0 ) { temp = bs->GetBits(8); printf(" latmBufferFullness[%i] (8 bit) - 0x%x\n", streamID[prog][lay], temp); if ( !allStreamsSameTimeFraming ) { /* if ((AudioObjectType[lay]==6 || AudioObjectType[lay]== 20) && (AudioObjectType[lay-1]==8 || AudioObjectType[lay-1]==24)) { temp = bs->GetBits(6); printf(" coreFrameOffset (6 bit) - 0x%x\n", temp); }*/ } } else if( temp == 1 ) { temp = bs->GetBits(9); printf(" frameLength[%i] (9 bit) - 0x%x\n", streamID[prog][lay], temp); } else if ( temp == 4 || temp == 5 || temp == 3 ) { temp = bs->GetBits(6); printf(" CELPframeLengthTableIndex[%i] (6 bit) - 0x%x\n", streamID[prog][lay], temp); } else if ( temp == 6 || temp == 7 ) { temp = bs->GetBits(1); printf(" HVXCframeLengthTableIndex[%i] (1 bit) - 0x%x\n", streamID[prog][lay], temp); } } } temp = bs->GetBits(1); printf(" otherDataPresent (1 bit) - 0x%x\n", temp); if (temp) { uint32_t otherDataLenBits = 0; /* helper variable 32bit */ uint32_t otherDataLenEsc, otherDataLenTmp; do { otherDataLenBits = otherDataLenBits * 2^8; otherDataLenEsc = bs->GetBits(1); printf(" otherDataLenEsc (1 bit) - 0x%x\n", otherDataLenEsc); otherDataLenTmp = bs->GetBits(8); printf(" otherDataLenTmp (8 bit) - 0x%x\n", otherDataLenTmp); otherDataLenBits = otherDataLenBits + otherDataLenTmp; } while (otherDataLenEsc); } temp = bs->GetBits(1); printf(" crcCheckPresent (1 bit) - 0x%x\n", temp); if( temp ) { temp = bs->GetBits(8); printf(" crcCheckSum (8 bit) - 0x%x\n", temp); } } else { /* tbd */ } printf("End of StreamMuxConfig\n");}void decode_audio (uint8_t *vol, uint32_t len) { uint32_t ix;#if 1 for (ix = 0; ix < len; ix++) { printf("%02x ", vol[ix]); } printf("\n");#endif CBitstream *bs = new CBitstream(vol, len * 8); //bs->set_verbose(1); try { CheckStreamMuxConfig(bs); int bits_remain = bs->bits_remain(); if(bits_remain >0) { printf("%i bits remain\n", bits_remain); } } catch (...) { fprintf(stderr, "bitstream read error\n"); } return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -