本文整理汇总了C++中MvData::MBSplit方法的典型用法代码示例。如果您正苦于以下问题:C++ MvData::MBSplit方法的具体用法?C++ MvData::MBSplit怎么用?C++ MvData::MBSplit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MvData
的用法示例。
在下文中一共展示了MvData::MBSplit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CodeMBSplit
void MvDataCodec::CodeMBSplit(const MvData& in_data)
{
int val = in_data.MBSplit()[mb_yp][mb_xp] - MBSplitPrediction( in_data.MBSplit() );
if (val < 0)
val += 3; //produce prediction mod 3
int ctx;
for (int bin = 1; bin <= val; ++bin)
{
ctx = ChooseMBSContext(in_data,bin);
EncodeSymbol(0,ctx);
}
if (val != 2)//if we've had two zeroes, know we must have value 2
EncodeSymbol(1,ChooseMBSContext(in_data,val+1));
}
示例2: DecodeMBSplit
void MvDataCodec::DecodeMBSplit(MvData& out_data)
{
int val = 0;
int bin = 1;
bool bit;
do
{
DecodeSymbol( bit , ChooseMBSContext( out_data , bin ) );
if (!bit)
val++;
bin++;
}
while (!bit && val != 2);
out_data.MBSplit()[mb_yp][mb_xp] = ( val + MBSplitPrediction( out_data.MBSplit() ) ) % 3;
}
示例3: DoWorkDecode
void MvDataCodec::DoWorkDecode( MvData& out_data, int num_bits)
{
int step,max;
int pstep,pmax;
int split_depth;
bool common_ref;
int xstart,ystart;
for (mb_yp = 0,mb_tlb_y = 0; mb_yp < out_data.MBSplit().LengthY(); ++mb_yp,mb_tlb_y += 4)
{
for (mb_xp = 0,mb_tlb_x = 0; mb_xp < out_data.MBSplit().LengthX(); ++mb_xp,mb_tlb_x += 4)
{
//start with split mode
DecodeMBSplit( out_data );
split_depth = out_data.MBSplit()[mb_yp][mb_xp];
step = 4 >> (split_depth);
max = (1 << split_depth);
//next do common_ref
if(split_depth != 0)
{
DecodeMBCom( out_data );
pstep = step;
pmax = max;
}
else
{
out_data.MBCommonMode()[mb_yp][mb_xp] = true;
pstep = 4;
pmax = 1;
}
common_ref = out_data.MBCommonMode()[mb_yp][mb_xp];
// do prediction modes
for (b_yp = mb_tlb_y; b_yp < mb_tlb_y + 4; b_yp += pstep)
{
for (b_xp = mb_tlb_x; b_xp < mb_tlb_x + 4; b_xp += pstep)
{
DecodePredmode(out_data);
// propagate throughout MB
for (int y = b_yp; y < b_yp + pstep; y++)
for (int x = b_xp; x < b_xp + pstep; x++)
out_data.Mode()[y][x] = out_data.Mode()[b_yp][b_xp];
}
}
//now do all the block mvs in the mb
for (int j = 0; j < max; ++j)
{
for (int i = 0; i < max; ++i)
{
xstart = b_xp = mb_tlb_x + i * step;
ystart = b_yp = mb_tlb_y + j * step;
if (out_data.Mode()[b_yp][b_xp] == REF1_ONLY || out_data.Mode()[b_yp][b_xp] == REF1AND2 )
DecodeMv1( out_data );
if (out_data.Mode()[b_yp][b_xp] == REF2_ONLY || out_data.Mode()[b_yp][b_xp] == REF1AND2 )
DecodeMv2( out_data );
if(out_data.Mode()[b_yp][b_xp] == INTRA)
DecodeDC( out_data );
//propagate throughout MB
for (b_yp = ystart; b_yp < ystart+step; b_yp++)
{
for (b_xp = xstart; b_xp < xstart+step; b_xp++)
{
out_data.Vectors(1)[b_yp][b_xp].x = out_data.Vectors(1)[ystart][xstart].x;
out_data.Vectors(1)[b_yp][b_xp].y = out_data.Vectors(1)[ystart][xstart].y;
out_data.Vectors(2)[b_yp][b_xp].x = out_data.Vectors(2)[ystart][xstart].x;
out_data.Vectors(2)[b_yp][b_xp].y = out_data.Vectors(2)[ystart][xstart].y;
out_data.DC( Y_COMP )[b_yp][b_xp] = out_data.DC( Y_COMP )[ystart][xstart];
out_data.DC( U_COMP )[b_yp][b_xp] = out_data.DC( U_COMP )[ystart][xstart];
out_data.DC( V_COMP )[b_yp][b_xp] = out_data.DC( V_COMP )[ystart][xstart];
}//b_xp
}//b_yp
}//i
}//j
}//mb_xp
}//mb_yp
}
示例4: DoWorkCode
void MvDataCodec::DoWorkCode( MvData& in_data )
{
int step,max;
int pstep,pmax;
int split_depth;
bool common_ref;
MB_count = 0;
for (mb_yp = 0, mb_tlb_y = 0; mb_yp < in_data.MBSplit().LengthY(); ++mb_yp, mb_tlb_y += 4)
{
for (mb_xp = 0,mb_tlb_x = 0; mb_xp < in_data.MBSplit().LengthX(); ++mb_xp,mb_tlb_x += 4)
{
//start with split mode
CodeMBSplit(in_data);
split_depth = in_data.MBSplit()[mb_yp][mb_xp];
step = 4 >> (split_depth);
max = (1 << split_depth);
//next do common_ref
if(split_depth != 0)
{
CodeMBCom(in_data);
pstep = step;
pmax = max;
}
else
{
pstep = 4;
pmax = 1;
}
common_ref = in_data.MBCommonMode()[mb_yp][mb_xp];
//do prediction modes
for (b_yp = mb_tlb_y; b_yp < mb_tlb_y+4; b_yp += pstep)
for (b_xp = mb_tlb_x; b_xp < mb_tlb_x+4; b_xp += pstep)
CodePredmode(in_data);
step = 4 >> (split_depth);
//now do all the block mvs in the mb
for (b_yp = mb_tlb_y; b_yp < mb_tlb_y+4; b_yp += step)
{
for (b_xp = mb_tlb_x; b_xp < mb_tlb_x+4; b_xp += step)
{
if (in_data.Mode()[b_yp][b_xp] == REF1_ONLY || in_data.Mode()[b_yp][b_xp] == REF1AND2 )
CodeMv1(in_data);
if (in_data.Mode()[b_yp][b_xp] == REF2_ONLY || in_data.Mode()[b_yp][b_xp] == REF1AND2 )
CodeMv2(in_data);
if(in_data.Mode()[b_yp][b_xp] == INTRA)
CodeDC(in_data);
}//b_xp
}//b_yp
//TODO: Update all contexts here?
}//mb_xp
}//mb_yp
}
示例5: CompensateComponent
void MotionCompensator::CompensateComponent( Frame& picframe ,
const Frame &ref1frame ,
const Frame& ref2frame ,
const MvData& mv_data ,
const CompSort cs)
{
// Set up references to pictures and references
PicArray& pic_data_out = picframe.Data( cs );
// Size of frame component being motion compensated
const PicArray& ref1up = ref1frame.UpData( cs );
const PicArray& ref2up = ref2frame.UpData( cs );
// Set up a row of blocks which will contain the MC data, which
// we'll add or subtract to pic_data_out
TwoDArray<ValueType> pic_data(m_bparams.Yblen(), pic_data_out.LengthX(), 0 );
// Factors to compensate for subsampling of chroma
int xscale_shift = 0;
int yscale_shift = 0;
if ( cs != Y_COMP )
{
if (m_cformat == format420)
{
xscale_shift = 1;
yscale_shift = 1;
}
else if (m_cformat == format422)
{
xscale_shift = 1;
yscale_shift = 0;
}
}
ImageCoords orig_pic_size(picframe.GetFparams().OrigXl(), picframe.GetFparams().OrigYl());
if ( cs != Y_COMP )
{
orig_pic_size.x = picframe.GetFparams().OrigChromaXl();
orig_pic_size.y = picframe.GetFparams().OrigChromaYl();
}
// Reference to the relevant DC array
const TwoDArray<ValueType>& dcarray = mv_data.DC( cs );
// Set up references to the vectors
const int num_refs = picframe.GetFparams().Refs().size();
const MvArray* mv_array1;
const MvArray* mv_array2;
mv_array1 = &mv_data.Vectors(1);
if (num_refs ==2 )
mv_array2 = &mv_data.Vectors(2);
else
mv_array2 = &mv_data.Vectors(1);
ReConfig();//set all the weighting blocks up
//Blocks are listed left to right, line by line.
MVector mv1,mv2;
PredMode block_mode;
//Coords of the top-left corner of a block
ImageCoords pos;
//Loop for each block in the output image.
//The CompensateBlock function will use the image pointed to by ref1up
//and add the compensated pixels to the image pointed to by pic_data.
size_t wgt_idx;
int save_from_row = m_bparams.Ybsep()-m_bparams.Yoffset();
// unpadded picture dimensions
const int x_end_data = pic_data_out.FirstX() + std::min(pic_data_out.LengthX(), orig_pic_size.x );
const int y_end_data = pic_data_out.FirstY() + std::min(pic_data_out.LengthY(), orig_pic_size.y );
const int blocks_per_mb_row = m_cparams.XNumBlocks()/m_cparams.XNumMB();
const int blocks_per_sb_row = blocks_per_mb_row>>1;
// The picture does not contain integral number of blocks. So not all
// blocks need to be processed. Compute the relevant blocks to be
// processed using the original picturesize and not the padded pic size
int y_num_blocks = NUM_USED_BLKS(orig_pic_size.y,m_bparams.Ybsep(),m_bparams.Yblen());
int x_num_blocks = NUM_USED_BLKS(orig_pic_size.x,m_bparams.Xbsep(),m_bparams.Xblen());
//Loop over all the block rows
pos.y = -m_bparams.Yoffset();
for(int yblock = 0; yblock < y_num_blocks; ++yblock)
{
pos.x = -m_bparams.Xoffset();
int xincr, xb_incr = 0;
//loop over all the blocks in a row
for(int xblock = 0 ; xblock < x_num_blocks; xblock+=xb_incr)
{
int split_mode = mv_data.MBSplit()[yblock/blocks_per_mb_row][xblock/blocks_per_mb_row];
int blk_len_x, blk_len_y = m_bparams.Yblen();
switch (split_mode)
{
//.........这里部分代码省略.........