📄 umc_vc1_spl_frame_constr.cpp
字号:
a = (a<<8)| (Ipp32s)(*readPos);
b = a & 0x00FFFFFF;
}
//check end of read buffer
if(readPos < (readBuf + readBufSize - 1))
{
if(*readPos == 0x01)
{
if((*(readPos + 1) == VC1_Slice) || (*(readPos + 1) == VC1_Field))
{
readPos+=2;
ptr = readPos - 5;
//trim zero bytes
while ( (*ptr==0) && (ptr > readBuf) )
ptr--;
//slice or field size
size = (Ipp32u)(ptr - readBuf - readDataSize+1);
if(frameSize + size > frameBufSize)
return UMC_ERR_NOT_ENOUGH_BUFFER;
ippsCopy_8u(readBuf + readDataSize, currFramePos, size);
currFramePos = currFramePos + size;
frameSize = frameSize + size;
zeroNum = frameSize - 4*((frameSize)/4);
if(zeroNum!=0)
zeroNum = 4 - zeroNum;
memset(currFramePos, 0, zeroNum);
//set write parameters
currFramePos = currFramePos + zeroNum;
frameSize = frameSize + zeroNum;
stCodes->offsets[stCodes->count] = frameSize;
//stCodes->values[stCodes->count] =*(Ipp32u*)(readPos - 4);
stCodes->values[stCodes->count] = ((*(readPos-1))<<24) + ((*(readPos-2))<<16) + ((*(readPos-3))<<8) + (*(readPos-4));
readDataSize = (Ipp32u)(readPos - readBuf - 4);
a = 0x00010b00 |(Ipp32s)(*readPos);
b = a & 0x00FFFFFF;
zeroNum = 0;
stCodes->count++;
}
else if(stCodes->count != 0)
{
//end of frame
readPos = readPos - 2;
ptr = readPos - 1;
//trim zero bytes
while ( (*ptr==0) && (ptr > readBuf) )
ptr--;
//slice or field size
size = (Ipp32u)(ptr - readBuf - readDataSize +1);
if(frameSize + size > frameBufSize)
return UMC_ERR_NOT_ENOUGH_BUFFER;
ippsCopy_8u(readBuf + readDataSize, currFramePos, size);
out->SetDataSize(frameSize + size);
//prepare read buffer
size = (Ipp32u)(readPos - readBuf - readDataSize);
readDataSize = readDataSize + size;
in->SetDataSize(readDataSize);
return UMC_OK;
}
else
{
//beginning of frame
readPos++;
a = 0x00000100 |(Ipp32s)(*readPos);
b = a & 0x00FFFFFF;
stCodes->offsets[stCodes->count] = (Ipp32u)(0);
stCodes->values[stCodes->count] = ((*(readPos))<<24) + ((*(readPos-1))<<16) + ((*(readPos-2))<<8) + (*(readPos-3));
stCodes->count++;
zeroNum = 0;
}
}
else //if(*readPos == 0x03)
{
//000003
if((*(readPos + 1) < 0x04) && splMode)
{
size = (Ipp32u)(readPos - readBuf - readDataSize);
if(frameSize + size > frameBufSize)
return UMC_ERR_NOT_ENOUGH_BUFFER;
ippsCopy_8u(readBuf + readDataSize, currFramePos, size);
frameSize = frameSize + size;
currFramePos = currFramePos + size;
zeroNum = 0;
readPos++;
a = (a<<8)| (Ipp32s)(*readPos);
b = a & 0x00FFFFFF;
readDataSize = readDataSize + size + 1;
}
else
{
readPos++;
a = (a<<8)| (Ipp32s)(*readPos);
b = a & 0x00FFFFFF;
}
}
}
else //if (readPos >= (readBuf + readBufSize - 1 ))
{
if(readBufSize > 4)
{
readPos = readBuf + readBufSize;
size = (Ipp32u)(readBufSize - readDataSize - 4);
VM_ASSERT(size < 1024);
if(size >= 0)
{
if(frameSize + size > frameBufSize)
return UMC_ERR_NOT_ENOUGH_BUFFER;
ippsCopy_8u(readBuf + readDataSize, currFramePos, size);
out->SetDataSize(frameSize + size);
ptr = readBuf;
*ptr = *(readPos - 4);
ptr++;
*ptr = *(readPos - 3);
ptr++;
*ptr = *(readPos - 2);
ptr++;
*ptr = *(readPos - 1);
in->SetDataSize(4);
}
else
{
out->SetDataSize(frameSize);
if(frameSize + size > frameBufSize)
return UMC_ERR_NOT_ENOUGH_BUFFER;
ippsCopy_8u(readBuf + readDataSize, readBuf, readBufSize - readDataSize);
in->SetDataSize(readBufSize - readDataSize);
}
return UMC_ERR_NOT_ENOUGH_DATA;
}
else
{
//end of stream
size = (Ipp32u)(readPos- readBuf - readDataSize);
if(frameSize + size > frameBufSize)
return UMC_ERR_NOT_ENOUGH_BUFFER;
ippsCopy_8u(readBuf + readDataSize, currFramePos, size);
out->SetDataSize(frameSize + size);
in->SetDataSize(size);
return UMC_OK;
}
}
}
//field or slice start code
if(frameSize + 4 > frameBufSize)
return UMC_ERR_NOT_ENOUGH_BUFFER;
if(readBufSize > readDataSize)
{
memcpy(currFramePos,readPos - 4, 4);
out->SetDataSize(frameSize + 4);
in->SetDataSize(0);
return UMC_ERR_NOT_ENOUGH_DATA;
}
else
return UMC_ERR_END_OF_STREAM;
}
void vc1_frame_constructor_vc1::Reset()
{
}
Status vc1_frame_constructor_vc1::ParseVC1SeqHeader (Ipp8u *data,
Ipp32u* bufferSize,SplitterInfo* info)
{
UMC::Status umcSts = UMC_OK;
VideoStreamInfo* video_info = (VideoStreamInfo *)info->m_ppTrackInfo[0]->m_pStreamInfo;
Ipp32u tempData;
Ipp32u tempData1;
Ipp32u i=0;
Ipp32u *pbs;
Ipp32s bitOffset = 31;
pbs = (Ipp32u *)data;
*bufferSize = 0;
video_info->streamPID = 0;
video_info->stream_type = VC1_VIDEO;
video_info->stream_subtype = VC1_VIDEO_VC1;
video_info->interlace_type = PROGRESSIVE;
video_info->framerate = 0;
video_info->bitrate = 0;
video_info->duration = 0;
video_info->color_format = YUV420;
video_info->clip_info.height = 0;
video_info->clip_info.width = 0;
//default value for advanced profile
//Simple/main profile
video_info->aspect_ratio_width = 1;
video_info->aspect_ratio_height = 1;
//PROFILE
VC1GetNBits(pbs, bitOffset, 2, tempData);
if(tempData == VC1_PROFILE_ADVANCED) //PROFILE
{
//LEVEL
VC1GetNBits(pbs, bitOffset, 3, tempData);
//CHROMAFORMAT
VC1GetNBits(pbs, bitOffset, 2,tempData);
//FRMRTQ_POSTPROC
VC1GetNBits(pbs, bitOffset, 3, video_info->framerate);
//BITRTQ_POSTPROC
VC1GetNBits(pbs, bitOffset, 5, video_info->bitrate);
//for advanced profile
if ((video_info->framerate == 0)
&& (video_info->bitrate == 31))
{
//Post processing indicators for Frame Rate and Bit Rate are undefined
video_info->bitrate = 0;
}
else if ((video_info->framerate == 0)
&& (video_info->bitrate == 30))
{
video_info->framerate = 2;
video_info->bitrate = 1952;
}
else if ((video_info->framerate == 1)
&& (video_info->bitrate == 31))
{
video_info->framerate = 6;
video_info->bitrate = 2016;
}
else
{
if (video_info->framerate == 7)
video_info->framerate = 30;
else
video_info->framerate = (2+video_info->framerate*4);
if (video_info->bitrate == 31)
video_info->bitrate = 2016;
else
video_info->bitrate = (32 + video_info->bitrate * 64);
}
//POSTPROCFLAG
VC1GetNBits(pbs, bitOffset, 1, tempData);
//MAX_CODED_WIDTH
VC1GetNBits(pbs, bitOffset, 12, video_info->clip_info.width);
video_info->clip_info.width = (video_info->clip_info.width +1)*2;
//MAX_CODED_HEIGHT
VC1GetNBits(pbs, bitOffset, 12, video_info->clip_info.height);
video_info->clip_info.height = (video_info->clip_info.height + 1)*2;
//PULLDOWN
VC1GetNBits(pbs, bitOffset, 1, tempData);
//INTERLACE
VC1GetNBits(pbs, bitOffset, 1, tempData);
if(tempData)
video_info->interlace_type = INTERLEAVED_TOP_FIELD_FIRST;
//TFCNTRFLAG
VC1GetNBits(pbs, bitOffset, 1, tempData);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -