⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umc_mpeg2ts_spl.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
             }             break;        case 16: //MPEG4 video            if(m_bIgnoreVideo)                break;             if(UNDEF_VIDEO == m_pESArray[index].m_videoStreamInfo.stream_type)             {                 //m_sSplInfo.m_audio_info.stream_type             = MPEG2_AUDIO;                 //TBD fill corresponding program info                 CheckEndian(false);                 m_pESArray[index].m_videoStreamInfo.stream_type  = MPEG4_VIDEO;                 m_pESArray[index].m_uiStreamID = elementary_PID;                 if(m_pVideoAuxData)                 {                    m_pVideoAuxData->Close();                    m_pVideoAuxData = NULL;                 }             }             break;        case 26: //MC H.264 video        case 27: //ML H.264 video            if(m_bIgnoreVideo)                break;             if(UNDEF_VIDEO == m_pESArray[index].m_videoStreamInfo.stream_type)             {                 //m_sSplInfo.m_audio_info.stream_type             = MPEG2_AUDIO;                 //TBD fill corresponding program info                 m_pESArray[index].m_videoStreamInfo.stream_type  = H264_VIDEO;                 m_pESArray[index].m_uiStreamID = elementary_PID;                 CheckEndian(true);             }             break;        case 0x81: //AC3 audio            if(m_bIgnoreAudio)                break;/*             m_sSplInfo.m_audio_info.stream_type = LPCM_AUDIO;             m_pESArray[index]->m_audioStreamInfo.stream_type  = LPCM_AUDIO;             m_sSplInfo.m_audio_info.bitPerSample = 16;             m_sSplInfo.m_audio_info.channels     = 2;             m_sSplInfo.m_audio_info.sample_frequency = 48000;             m_sSplInfo.m_audio_info.bitrate      = 1536000;             m_pESArray[index].audio_pid = elementary_PID;*/             if(UNDEF_AUDIO == m_pESArray[index].m_audioStreamInfo.stream_type)             {                 //m_sSplInfo.m_audio_info.stream_type = AC3_AUDIO;                 //TBD fill corresponding program info                 m_pESArray[index].m_audioStreamInfo.stream_type  = AC3_AUDIO;                 m_pESArray[index].m_uiStreamSubID = elementary_PID;             }             break;        default:            break;        }        if(ES_info_length > section_length - bytecount)            ES_info_length = section_length - bytecount;        bytecount += ES_info_length;        signed_ES_info_length = ES_info_length;        while (signed_ES_info_length > 0)        {            signed_ES_info_length -= GetDescriptor(index);            if(signed_ES_info_length < 0)            {                bytecount += -signed_ES_info_length;            }        }    }    //CRC_32 32 bits    err = m_pDataReader->GetUInt(&CRC_32);    if(UMC_OK != err) return err;    bytecount += 4;    return bytecount;}int MPEG2TSSplitter::GetDescriptor(int index){    unsigned char  descriptor_tag ;    unsigned char  descriptor_length;    int            retSize;    unsigned int  regIdentifier;    Status err;    err = m_pDataReader->GetByte(&descriptor_tag); // 8bits descriptor_tag    err = m_pDataReader->GetByte(&descriptor_length);//8bits descriptor_length    switch(descriptor_tag)    {    case 0:    case 1://reserved        return descriptor_length + 2;    case 2:        retSize = VideoStreamDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 3:        retSize = AudioStreamDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 4:        retSize = HierarchyDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 5:        retSize = RegistrationDescriptor(descriptor_length, regIdentifier);        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 6:        retSize = DataStreamAlignmentDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 7:        retSize = TargetBackgroundGridDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 8:        retSize = VideoWindowDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 9:        retSize = CADescriptor(descriptor_length);        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 10:        retSize = ISO639LanguageDescriptor(descriptor_length);        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 11:        retSize = SystemClockDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 12:        retSize = MultiplexBufferUtilizationDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 13:        retSize = CopyrightDescriptor(descriptor_length);        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 14:        retSize = MaximumBitrateDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 15:        retSize = PrivateDataIndicatorDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 16:        retSize = SmoothingBufferDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 17:        retSize = STDDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 18:        retSize = IBPDescriptor();        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    case 0x81://AC-3 descriptor from ATSC A52        AC3AudioStreamDescriptor(retSize, index);        if(descriptor_length > retSize)           err = m_pDataReader->MovePosition(descriptor_length - retSize);        //VM_ASSERT(descriptor_length >= retSize);        return  retSize + 2;    default:        err = m_pDataReader->MovePosition(descriptor_length);        return descriptor_length + 2;    }}int MPEG2TSSplitter:: AC3AudioStreamDescriptor(int& gotBytes, int /*index*/){    unsigned char sample_rate_code;    unsigned char bsid;    unsigned char bit_rate_code;    unsigned char surround_mode;    unsigned char bsmod;    unsigned char num_channels;    unsigned char full_svc;    unsigned char lang_code;    unsigned char lang_code2;    unsigned char reserved;    unsigned char text_len;    unsigned char text_code;    unsigned char asvcflag;    unsigned char text;    Status err;    gotBytes = 0;    //3 bits sample_rate_code    //5 bits bsid    err = m_pDataReader->GetByte(&sample_rate_code);    if(err != UMC_OK) return err;    gotBytes++;    //sample_rate_code Sample rate    //'000' 48   kHz    //'001' 44.1 kHz    //'010' 32   kHz    //'011' reserved    //'100' 48   kHz or 44.1 kHz    //'101' 48   kHz or 32   kHz    //'110' 44.1 kHz or 32   kHz    //'111' 48   kHz or 44.1 kHz or 32 kHz    bsid             = sample_rate_code & 31;    sample_rate_code = sample_rate_code >> 5;    //6 bits bit_rate_code    //2 bits surround_mode    err = m_pDataReader->GetByte(&bit_rate_code);    if(err != UMC_OK) return err;    gotBytes++;    //bit_rate_code exact bit rate bit_rate_code bit rate upper limit    //'000000' (0.)  32  kbps '100000' (32.) 32  kbps    //'000001' (1.)  40  kbps '100001' (33.) 40  kbps    //'000010' (2.)  48  kbps '100010' (34.) 48  kbps    //'000011' (3.)  56  kbps '100011' (35.) 56  kbps    //'000100' (4.)  64  kbps '100100' (36.) 64  kbps    //'000101' (5.)  80  kbps '100101' (37.) 80  kbps    //'000110' (6.)  96  kbps '100110' (38.) 96  kbps    //'000111' (7.)  112 kbps '100111' (39.) 112 kbps    //'001000' (8.)  128 kbps '101000' (40.) 128 kbps    //'001001' (9.)  160 kbps '101001' (41.) 160 kbps    //'001010' (10.) 192 kbps '101010' (42.) 192 kbps    //'001011' (11.) 224 kbps '101011' (43.) 224 kbps    //'001100' (12.) 256 kbps '101100' (44.) 256 kbps    //'001101' (13.) 320 kbps '101101' (45.) 320 kbps    //'001110' (14.) 384 kbps '101110' (46.) 384 kbps    //'001111' (15.) 448 kbps '101111' (47.) 448 kbps    //'010000' (16.) 512 kbps '110000' (48.) 512 kbps    //'010001' (17.) 576 kbps '110001' (49.) 576 kbps    //'010010' (18.) 640 kbps '110010' (50.) 640 kbps    surround_mode    = bit_rate_code & 3;    bit_rate_code    = bit_rate_code >> 2;    //3 bits bsmod    //4 bits num_channels    //1 bits full_svc    err = m_pDataReader->GetByte(&full_svc);    if(err != UMC_OK) return err;    gotBytes++;    //num_channels number of encodedchannels    //'0000'        1+1     '1000'        1    //'0001'        1/0     '1001'        2    //'0010'        2/0     '1010'        3    //'0011'        3/0     '1011'        4    //'0100'        2/1     '1100'        5    //'0101'        3/1     '1101'        6    //'0110'        2/2     '1110'      reserved    //'0111'        3/2     '1111'      reserved    bsmod        =  full_svc >> 5;    num_channels = (full_svc >> 1) & 15;    full_svc     =  full_svc & 1;    err = m_pDataReader->GetByte(&lang_code);    if(err != UMC_OK) return err;    gotBytes++;    if(num_channels == 0)    {        err = m_pDataReader->GetByte(&lang_code2);        if(err != UMC_OK) return err;        gotBytes++;    }    if(bsmod < 2)    {        //2 bits mainid        //6 bits reserved        err = m_pDataReader->GetByte(&reserved);        if(err != UMC_OK) return err;        gotBytes++;    }    else    {        err = m_pDataReader->GetByte(&asvcflag);        if(err != UMC_OK) return err;        gotBytes++;    }    //7 bits textlen    //1 bit  text_code    err = m_pDataReader->GetByte(&text_code);    if(err != UMC_OK) return err;    gotBytes++;    text_len  = text_code >> 1;    text_code = text_code & 1;    for(int i = 0; i < (int)text_len; i++)    {        err = m_pDataReader->GetByte(&text);        if(err != UMC_OK) return err;        gotBytes++;    }    VM_ASSERT(bit_rate_code > 0 && bit_rate_code <= 50);    //TBD fill corresponding program info    //m_pESArray[index].m_audioStreamInfo.bitPerSample    = 16;    //m_pESArray[index].m_audioStreamInfo.bitrate         = AC3FrameSize[bit_rate_code&0x1f].bit_rate;    //m_pESArray[index].m_audioStreamInfo.channels        = AC3NumChannels[num_channels];    //m_pESArray[index].m_audioStreamInfo.channel_mask    = 0;    //m_pESArray[index].m_audioStreamInfo.sample_frequency= AC3FequencyExt[sample_rate_code];    //m_pESArray[index].m_audioStreamInfo.stream_type     = AC3_AUDIO;    return gotBytes;}int MPEG2TSSplitter:: VideoStreamDescriptor(){    unsigned char multiple_frame_rate_flag;    unsigned char frame_rate_code;    unsigned char MPEG_1_only_flag;    unsigned char constrained_parameter_flag;    unsigned char still_picture_flag;    Status err;    err = m_pDataReader->GetByte(&still_picture_flag);    multiple_frame_rate_flag    = (still_picture_flag&0x80)>>7;//1bit  multiple_frame_rate_flag    frame_rate_code             = (still_picture_flag&0x78)>>3;//4bits frame_rate_code    //0000    forbidden    //0001    24 000?1001 (23,976 )    //0010    24    //0011    25    //0100    30 000?1001 (29,97 )    //0101    30    //0110    50    //0111    60 000?1001 (59,94 )    //1000    60    //. . .    reserved    //1111    reserved    MPEG_1_only_flag            = (still_picture_flag&0x04)>>2;//1bit  MPEG_1_only_flag    constrained_parameter_flag  = (still_picture_flag&0x02)>>1;//1bit  constrained_parameter_flag    still_picture_flag          = (still_picture_flag&0x01);   //1bit  still_picture_flag    if(MPEG_1_only_flag == 0)    {        unsigned char profile_and_level_indication;        unsigned char chroma_format;        unsigned char frame_rate_extension_flag;        unsigned char reserved;        //8 bits profile_and_level_indication        //[7:7]    1    Escape bit

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -