📄 umc_mpeg2ts_spl.cpp
字号:
//[6:4] 3 Profile identification //[3:0] 4 Level identification //Profile //110 to 111 (reserved) //101 Simple //100 Main //011 SNR Scalable //010 Spatially Scalable //001 High //000 (reserved) //Level //1011 to 1111 (reserved) //1010 Low //1001 (reserved) //1000 Main //0111 (reserved) //0110 High 1440 //0101 (reserved) //0100 High //0000 to 0011 (reserved) err = m_pDataReader->GetByte(&profile_and_level_indication); //2 bits chroma_format //1 bit frame_rate_extension_flag //5 bits reserved err = m_pDataReader->GetByte(&reserved); //01 4:2:0 //10 4:2:2 //11 4:4:4 chroma_format = (reserved & 0xc0) >> 6; frame_rate_extension_flag = (reserved & 0x20) >> 5; } return (MPEG_1_only_flag == 0)*2 + 1;}int MPEG2TSSplitter::AudioStreamDescriptor(){ unsigned char free_format_flag; unsigned char ID; unsigned char layer; unsigned char variable_rate_audio_indicator; unsigned char reserved; Status err; //1 bit (free_format_flag); //1 bit (ID); //2 bits(layer); //1 bit (variable_rate_audio_indicator); //3 bits(reserved); err = m_pDataReader->GetByte(&reserved); free_format_flag = (reserved&0x80) >> 7; ID = (reserved&0x40) >> 6; layer = (reserved&0x30) >> 4; variable_rate_audio_indicator = (reserved&0x08) >> 3; reserved = (reserved&0x07); return 0;}int MPEG2TSSplitter::HierarchyDescriptor(){// unsigned char reserved; unsigned char hierarchy_type; unsigned char hierarchy_layer_index; unsigned char hierarchy_embedded_layer_index; unsigned char hierarchy_channel; Status err; //hierarchy_type can be //0 reserved //1 ITU-T Rec. H.262 | ISO/IEC 13818-2 Spatial Scalability //2 ITU-T Rec. H.262 | ISO/IEC 13818-2 SNR Scalability //3 ITU-T Rec. H.262 | ISO/IEC 13818-2 Temporal Scalability //4 ITU-T Rec. H.262 | ISO/IEC 13818-2 Data partitioning //5 ISO/IEC 13818-3 Extension bitstream //6 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Private Stream //7-14 reserved //15 Base layer err = m_pDataReader->GetByte(&hierarchy_type); //reserved 4bits //hierarchy_type 4bits hierarchy_type &= 0x0f; err = m_pDataReader->GetByte(&hierarchy_layer_index);//reserved 2bits //hierarchy_layer_index 6bits hierarchy_layer_index &= 0x3f; err = m_pDataReader->GetByte(&hierarchy_embedded_layer_index);//reserved 2bits //hierarchy_embedded_layer_index 6bits hierarchy_embedded_layer_index &= 0x3f; err = m_pDataReader->GetByte(&hierarchy_channel);//reserved 2bits //hierarchy_channel 6bits hierarchy_channel &= 0x3f; return 4;}int MPEG2TSSplitter::RegistrationDescriptor(int dscrLen, unsigned int& format_identifier){ unsigned char additional_identification_info; int gotByte = 4; Status err; //It must be "AC-3" 0x41432d33 for AC3 err = m_pDataReader->GetUInt(&format_identifier); //32 bits dscrLen -= 4; if(dscrLen > 0) { do { err = m_pDataReader->GetByte(&additional_identification_info); // 8bits dscrLen--; gotByte++; }while (dscrLen); } return gotByte;}int MPEG2TSSplitter::DataStreamAlignmentDescriptor(){ unsigned char alignment_type; // 8bit Status err; err = m_pDataReader->GetByte(&alignment_type); //8bits alignment_type switch(alignment_type) { case 0://reserved case 1://slice or video access unit case 2://video access unit case 3://gop or seq case 4:// seq VM_ASSERT(1); break; default://reserved VM_ASSERT(1); } return 1;}int MPEG2TSSplitter::TargetBackgroundGridDescriptor(){ unsigned int horizontal_size; unsigned int vertical_size; unsigned int aspect_ratio_information; Status err; //14 bits(horizontal_size); //14 bits(vertical_size); // 4 bits(aspect_ratio_information); err = m_pDataReader->GetUInt(&aspect_ratio_information); horizontal_size = (aspect_ratio_information & 0xfffc0000) >> 18; vertical_size = (aspect_ratio_information & 0x0003fff0) >> 4; aspect_ratio_information = (aspect_ratio_information & 0xf); return 4;}int MPEG2TSSplitter::VideoWindowDescriptor(){ unsigned int horizontal_offset; unsigned int vertical_offset; unsigned int window_priority; Status err; //14 bits(horizontal_offset); //14 bits(vertical_offset); // 4 bits(window_priority); err = m_pDataReader->GetUInt(&window_priority); horizontal_offset = (window_priority & 0xfffc0000) >> 18; vertical_offset = (window_priority & 0x0003fff0) >> 4; window_priority = (window_priority & 0xf); return 4;}int MPEG2TSSplitter::CADescriptor(int dscrLen){ unsigned short CA_system_ID; unsigned short CA_PID; unsigned char private_data_byte; int gotByte = 4; Status err; //16 bits(CA_system_ID); err = m_pDataReader->GetShort(&CA_system_ID); //3 bits( reserved); //13 bits(CA_PID); err = m_pDataReader->GetShort(&CA_PID); CA_PID &= 0x1fff; if(dscrLen > 0) { do { err = m_pDataReader->GetByte(&private_data_byte); // 8bits dscrLen--; gotByte++; }while (dscrLen); } return gotByte;}int MPEG2TSSplitter::SystemClockDescriptor(){ unsigned char external_clock_reference_indicator; unsigned char reserved; unsigned char clock_accuracy_integer; unsigned char clock_accuracy_exponent; Status err; //1 bit (external_clock_reference_indicator); //1 bit ( reserved); //6 bits(clock_accuracy_integer); err = m_pDataReader->GetByte(&reserved); external_clock_reference_indicator = (reserved&0x80) >> 7; clock_accuracy_integer = (reserved&0x3f); //3 bits( clock_accuracy_exponent); //5 bits(reserved); err = m_pDataReader->GetByte(&reserved); clock_accuracy_exponent = (reserved&0xe0) >> 5; return 2;}int MPEG2TSSplitter::MultiplexBufferUtilizationDescriptor(){ unsigned char bound_valid_flag; unsigned short LTW_offset_lower_bound; unsigned short reserved; unsigned short LTW_offset_upper_bound; Status err; err = m_pDataReader->GetShort(<W_offset_lower_bound); //1 bit (bound_valid_flag); //15 bits(LTW_offset_lower_bound); bound_valid_flag = LTW_offset_lower_bound>>15; LTW_offset_lower_bound &= 0x7fff; err = m_pDataReader->GetShort(&reserved); //1 bit(reserved); //15 bits(LTW_offset_upper_bound); LTW_offset_upper_bound = reserved & 0x7fff; return 4;}int MPEG2TSSplitter::CopyrightDescriptor(int dscrLen){ unsigned int copyright_identifier; unsigned char additional_copyright_info; int gotByte = 4; Status err; err = m_pDataReader->GetUInt(©right_identifier); //32 bits dscrLen -= 4; if(dscrLen > 0) { do { err = m_pDataReader->GetByte(&additional_copyright_info); // 8bits dscrLen--; gotByte++; }while (dscrLen); } return gotByte;}int MPEG2TSSplitter::MaximumBitrateDescriptor(){ int maximum_bitrate = 0; unsigned int size = 3; Status err; //2 bits(reserved); //22bits(maximum_bitrate); err = m_pDataReader->GetData((void*)&maximum_bitrate, &size); return 3;}int MPEG2TSSplitter::PrivateDataIndicatorDescriptor(){ unsigned int private_data_indicator; Status err; err = m_pDataReader->GetUInt(&private_data_indicator); //32 bits return 4;}int MPEG2TSSplitter::ISO639LanguageDescriptor(int descrLen){ unsigned int ISO_639_language_code; unsigned int audio_type; int i; Status err; for (i = 0; i < descrLen/4; i++) { //24 bits ISO_639_language_code // 0x656e67 for "eng" English //8 bits audio_type err = m_pDataReader->GetUInt(&audio_type); ISO_639_language_code = (audio_type >> 8); audio_type &= 0xff; } return (descrLen/4)*4;}int MPEG2TSSplitter::SmoothingBufferDescriptor (){ unsigned char reserved[6];// int sb_leak_rate;// int sb_size; unsigned int size = 6; Status err; //2 bits (reserved); //22 bits (sb_leak_rate); //2 bits (reserved); //22 bits (sb_size); err = m_pDataReader->GetData((void*)reserved, &size); return 6;}int MPEG2TSSplitter::STDDescriptor (){ unsigned char leak_valid_flag; Status err; //7 (reserved); //1 (leak_valid_flag); err = m_pDataReader->GetByte(&leak_valid_flag); leak_valid_flag &= 1; return 1;}int MPEG2TSSplitter::IBPDescriptor(){ unsigned short closed_gop_flag; unsigned short identical_gop_flag; unsigned short max_gop_length; Status err; err = m_pDataReader->GetShort(&max_gop_length); //1 bit(closed_gop_flag); //1 bit(identical_gop_flag); //14 bits(max_gop_length); closed_gop_flag = max_gop_length >> 15; identical_gop_flag = (max_gop_length >> 14) & 1; max_gop_length = max_gop_length & 0x3fff; return 2;}int MPEG2TSSplitter::CheckIfNewES(bool isAudio, int streamID, int index){ int i = 0; unsigned char bExist = false; if(index == -1) { i = MPEG2PESSplitter::CheckIfNewES(isAudio,streamID,index); } else { if(isAudio) { if(m_pESArray[index].m_uiProgramNum == m_uiChoosedProgram) { i = index; m_iChoosedAudio[0] = streamID; } } else { if(m_pESArray[index].m_uiProgramNum == m_uiChoosedProgram) { i = index; m_iChoosedVideo = streamID; } } } return i;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -