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

📄 umc_mpeg2_spl_av.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    int            isSliceCode;    unsigned char* prev3bytes = sInfoFromPrevPES.m_Last5Bytes + 2;    sInfoFromPrevPES.m_bStartInPrevPES= false;    pucInData = (unsigned char*)input->GetDataPointer();    pucOutData= (unsigned char*)output->GetDataPointer() + output->GetDataSize();    uiStartCodeOff += m_returnedbytes; // they'll be put first    // statistic for backward motion    /*if (m_bSaveStatistic)    {        if (m_uiPosPrevPacket!=0)        {            int s = (m_uiPosPrevFrame==0)? 1:0;            if (((pucInData[s]>>3)&0x07)==1&&s<uiDataLen)            {                // I frame                vm_sizet curr_pos  = (m_uiPosPrevFrame==0)? (m_pDataReader->GetPosition()- input->GetDataSize()): m_uiPosPrevFrame;                vm_sizet curr_pack = (m_uiPosPrevFrame==0)? m_uiPosCurrPacket:m_uiPosPrevFrame;                //fprintf(f,"0:I frame (curr.) pos=%d, currPack = %d,(prev.) pos=%d, currPack = %d \n",(int)curr_pos,(int)curr_pack,(int)m_uiPosPacketWithGOPStart,(int)m_uiPosLastIFrame);                if (m_uiPosPacketWithGOPStart!=0 )                    m_uiMAXGOPLength = (curr_pos - m_uiPosPacketWithGOPStart>m_uiMAXGOPLength)?curr_pos - m_uiPosPacketWithGOPStart:m_uiMAXGOPLength;                //fprintf(f,"m_uiMAXGOPLength=%d  \n",m_uiMAXGOPLength );                //fflush(f);                m_uiPosLastIFrame=curr_pos;                m_uiPosPacketWithGOPStart =curr_pack;            }        }    }    m_uiPosPrevPacket=0;    m_uiPosPrevFrame=0;*/    //we will not check output buffer size here    //it is required to pass output buffer >= input buffer    //check boundary of 2 buffers to not lose a start code    if(prev3bytes[2] <= 1)    {        prev3bytes[3] = pucInData[0];        prev3bytes[4] = pucInData[1];        prev3bytes[5] = pucInData[2];        for(i = 0; i < 3; i++)        {            if(prev3bytes[i]   == 0 &&               prev3bytes[i+1] == 0 &&               prev3bytes[i+2] == 1)            {                if(code_count < rStartCodeMax)                {                    unsigned int code = // codebyte is in input                    pStartCodePos[code_count].m_startCode = 0x00000100|pucInData[i++];                    pStartCodePos[code_count].m_StartCodePos = uiStartCodeOff + i - 4;                    if(code == SEQUENCE_HEADER_CODE)                    {                        isSeqFound = true;                    }                    /*                    // statistic for backward motion                    if (m_bSaveStatistic)                    {                        if (pStartCodePos[code_count].m_startCode == PICTURE_START_CODE)                        {                            if (((pucInData[i+2]>>3)&0x07)==1&&(i+2<uiDataLen))                            {                                unsigned int cur_pos=m_pDataReader->GetPosition()- input->GetDataSize()+i+1;                                //fprintf(f,"1:I frame (curr.) pos=%d, currPack = %d,(prev.) pos=%d, currPack = %d \n",(int)cur_pos,(int)m_uiPosCurrPacket,(int)m_uiPosPacketWithGOPStart,(int)m_uiPosLastIFrame );                                if (m_uiPosPacketWithGOPStart!=0 )                                    m_uiMAXGOPLength = (cur_pos - m_uiPosPacketWithGOPStart>m_uiMAXGOPLength)?cur_pos - m_uiPosPacketWithGOPStart:m_uiMAXGOPLength;                                //fprintf(f,"m_uiMAXGOPLength=%d  \n",m_uiMAXGOPLength );                                m_uiPosLastIFrame=cur_pos;                                m_uiPosPacketWithGOPStart = m_uiPosCurrPacket;                            }                        }                    }*/                    // ....                    if(m_splitter_flags & FLAG_VSPL_COMPATIBLE){                      // stop on not slice start code when not new portion                      if(code == SEQUENCE_HEADER_CODE && breakIfSeq ||                          m_isInFrame && (code > 0x1AF || code == PICTURE_START_CODE)) {                        m_isInFrame = 0;                        ret = UMC_OK;                        //code_count++;                        sInfoFromPrevPES.m_bStartInPrevPES= true;                        break;                      }                    } else                    if((code == SEQUENCE_HEADER_CODE && breakIfSeq) ||                       (code == PICTURE_START_CODE)                 ||                       (code == SEQUENCE_END_CODE))                    {                        ret = UMC_OK;                        code_count++;                        sInfoFromPrevPES.m_bStartInPrevPES= true;                        break;                    }                    code_count++;                }    #ifdef _DEBUG                else                {                    VM_ASSERT(0);                }    #endif            }        }    }    if(ret != UMC_OK)    {        i = 0;        while(i < uiDataLen && ret != UMC_OK)        {            //search for first zero byte            if(m_splitter_flags & FLAG_VSPL_COMPATIBLE) {              i+=3;              while(i < uiDataLen &&                (pucInData[i-3] || pucInData[i-2] || pucInData[i-1]!=1)) i++;              if(i >= uiDataLen) {                i = uiDataLen;                break;              }            } else {              while(i < uiDataLen && pucInData[i++] != 0x00);              //check the second zero if present              if(i < uiDataLen && pucInData[i] != 0x00)              {                  continue;              }              //skip all rest zeroes until non zero byte                while(i < uiDataLen && pucInData[i++] == 0x00);                i--;              if(i >= uiDataLen) break;              //check for 0x01 byte in start code              if(i < uiDataLen && pucInData[i++] != 0x01)              {                  continue;              }            }            //it is a start code found if we are here            if(code_count < rStartCodeMax)            {                if(i < uiDataLen)                {                    unsigned int code =                    pStartCodePos[code_count].m_startCode = 0x00000100|pucInData[i++];                    /*//statistic for backward motion                    if (m_bSaveStatistic)                    {                        if (pStartCodePos[code_count].m_startCode == PICTURE_START_CODE)                        {                            if (i+1 < uiDataLen)                            {                                if (((pucInData[i+1]>>3)&0x07)==1)                                {                                    vm_sizet cur_pos=m_pDataReader->GetPosition()- input->GetDataSize()+i;                                    //fprintf(f,"2:I frame (curr.) pos=%d, currPack = %d,(prev.) pos=%d, currPack = %d \n",(int)cur_pos,(int)m_uiPosCurrPacket,(int)m_uiPosLastIFrame,(int)m_uiPosPacketWithGOPStart);                                    //fflush(f);                                    if (m_uiPosPacketWithGOPStart!=0 )                                            m_uiMAXGOPLength = (cur_pos - m_uiPosPacketWithGOPStart>m_uiMAXGOPLength)?cur_pos - m_uiPosPacketWithGOPStart:m_uiMAXGOPLength;                                    //fprintf(f,"m_uiMAXGOPLength=%d  \n",m_uiMAXGOPLength );                                    //fflush(f);                                    m_uiPosLastIFrame=cur_pos;                                    m_uiPosPacketWithGOPStart = m_uiPosCurrPacket;                                }                            }                            else                            {#ifdef _OLGA                                fprintf(f,"Picture type = in next pes\n");                                fflush(f);#endif                                m_uiPosPrevPacket=m_uiPosCurrPacket;                                m_uiPosPrevFrame = (i < uiDataLen)?(m_pDataReader->GetPosition()- input->GetDataSize()+i):0;                            }                        }                    }*/                    pStartCodePos[code_count].m_StartCodePos = uiStartCodeOff + i - 4;                    if(m_splitter_flags & FLAG_VSPL_COMPATIBLE){                      // stop on not slice start code when not new portion                      isSliceCode = (code <= 0x1AF && code != PICTURE_START_CODE);                      if(!isSliceCode) {                        if(m_isInFrame || code == SEQUENCE_HEADER_CODE && breakIfSeq ||                           code == PICTURE_START_CODE && (flagInit && isSeqFound) ) {                          m_isInFrame = 0;                          ret = UMC_OK;                        }                      } else { // slice code                        //if(!m_isInFrame)                        m_isInFrame = 1;                      }                    } else                    if((pStartCodePos[code_count].m_startCode ==                                                   SEQUENCE_HEADER_CODE && breakIfSeq) ||                       (pStartCodePos[code_count].m_startCode == PICTURE_START_CODE) ||                       (pStartCodePos[code_count].m_startCode ==                                                   SEQUENCE_END_CODE))                    {                        //picture accumulation complete                        ret = UMC_OK;                    }                    if(pStartCodePos[code_count].m_startCode ==                                               SEQUENCE_HEADER_CODE)                    {                        isSeqFound = true;                    }                    code_count ++;                }                else                {                    break;                }            }    #ifdef _DEBUG            else            {                //just increase MAX_CODE_COUNT definition                //if 300 too small                VM_ASSERT(0);            }    #endif        }    }    //else    //{    //    //if success on first bytes will copy 1 - 3 bytes only    //    i++;    //}    rStartCodeMax = code_count;    VM_ASSERT(uiDataLen - i >=0);    //this condition just for case of first SEQUENCE start code    if(!breakIfSeq)    {      if(m_returnedbytes > 0) {        memcpy(pucOutData, prev3bytes + 3 - m_returnedbytes, m_returnedbytes);        pucOutData += m_returnedbytes;        VM_ASSERT(output->GetDataSize() == 0);        output->SetDataSize(m_returnedbytes);        m_returnedbytes = 0;      }      if((m_splitter_flags & FLAG_VSPL_COMPATIBLE) && i<uiDataLen) {          i -= 4; // leave startcode or 4-byte tail          if(i<0) { // part from previous            m_returnedbytes = -i;          }      }      // copy new data to output buffer      // some tail bytes can can belong to next with FLAG_VSPL_COMPATIBLE      if(i>0) {        memcpy(pucOutData, input->GetDataPointer(), i);        //finalize size and move pointer of remain data in input buffer for future use        input->MoveDataPointer(i);      }      //increase output size      output->SetDataSize(output->GetDataSize() + i);    }    if(uiDataLen - i == 0)    {        //remember last 3 bytes if this buffer complete        prev3bytes[0] = pucInData[uiDataLen-3];        prev3bytes[1] = pucInData[uiDataLen-2];        prev3bytes[2] = pucInData[uiDataLen-1];    }    else if( i>0 ) // unchanged if startcode splitted    {        //reset previous bytes        /*prev3bytes[0] = 0xff;        prev3bytes[1] = 0xff;*/        prev3bytes[2] = 0xff;    }    return ret;}Status MPEG2AVSplitter::InitVideoHelperBuffer(int size){    Status err = UMC_OK;    if(m_pTmpDataBuffAct)    {        ippsFree(m_pTmpDataBuffAct);        m_pTmpDataBuffAct = NULL;    }    m_pTmpDataBuffAct = (unsigned char*)ippsMalloc_8u(size);    if(!m_pTmpDataBuffAct) return UMC_ALLOC;    m_readVideoStream.SetBufferPointer(m_pTmpDataBuffAct, size);    //lock buffer for video frames    err = m_pVideoBuffer->LockInputBuffer(&m_lockedVideoBuffer);    if(err != UMC_OK) return err;

⌨️ 快捷键说明

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