Ejemplo n.º 1
0
void MvDataCodec::CodeMBCom(const MvData& in_data)
{
    bool val = in_data.MBCommonMode()[mb_yp][mb_xp]; 
    
    if (val != MBCBModePrediction( in_data.MBCommonMode() ))
        EncodeSymbol( 1 , ChooseMBCContext( in_data ) ); 
    else
        EncodeSymbol( 0 , ChooseMBCContext( in_data ) ); 
}
Ejemplo n.º 2
0
void MvDataCodec::DecodeMBCom( MvData& out_data )
{
    bool bit; 
    DecodeSymbol( bit , ChooseMBCContext( out_data ) ); 
    
    if ( bit )
        out_data.MBCommonMode()[mb_yp][mb_xp] = !MBCBModePrediction( out_data.MBCommonMode() ); 
    else
        out_data.MBCommonMode()[mb_yp][mb_xp] = MBCBModePrediction( out_data.MBCommonMode() ); 
}
Ejemplo n.º 3
0
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

}
Ejemplo n.º 4
0
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

}