From: Thomas D. <tj...@us...> - 2005-07-19 14:17:37
|
Update of /cvsroot/dirac/compress/libdirac_common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13957/libdirac_common Modified Files: mv_codec.cpp Log Message: Fixed bug 1240709. Common mode is now used to reduce encoding of prediction modes. Common mode was also being set incorrectly in the motion estimation process, which caused divergence between the encoder and decoder values. Since common mode wasn't used, this bug was masked before. Both now fixed. Index: mv_codec.cpp =================================================================== RCS file: /cvsroot/dirac/compress/libdirac_common/mv_codec.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** mv_codec.cpp 6 Apr 2005 14:31:10 -0000 1.13 --- mv_codec.cpp 19 Jul 2005 14:17:25 -0000 1.14 *************** *** 240,258 **** { bool result = true; std::vector < unsigned int > nbrs; if (m_mb_xp > 0 && m_mb_yp > 0) { ! nbrs.push_back( (unsigned int)( cbm_data[m_mb_yp-1][m_mb_xp] ) ); ! nbrs.push_back( (unsigned int)( cbm_data[m_mb_yp-1][m_mb_xp-1] ) ); ! nbrs.push_back( (unsigned int)( cbm_data[m_mb_yp][m_mb_xp-1] ) ); ! result = bool(GetMean(nbrs)); } else if (m_mb_xp > 0 && m_mb_yp == 0) ! result = cbm_data[m_mb_yp][m_mb_xp-1]; else if (m_mb_xp == 0 && m_mb_yp > 0) ! result = cbm_data[m_mb_yp-1][m_mb_xp]; ! return result; } --- 240,259 ---- { bool result = true; + std::vector < unsigned int > nbrs; if (m_mb_xp > 0 && m_mb_yp > 0) { ! unsigned int sum = (unsigned int)( cbm_data[m_mb_yp-1][m_mb_xp] ); ! sum += (unsigned int)( cbm_data[m_mb_yp-1][m_mb_xp-1] ); ! sum += (unsigned int)( cbm_data[m_mb_yp][m_mb_xp-1] ); ! result = (sum>1); } else if (m_mb_xp > 0 && m_mb_yp == 0) ! result = cbm_data[0][m_mb_xp-1]; else if (m_mb_xp == 0 && m_mb_yp > 0) ! result = cbm_data[m_mb_yp-1][0]; ! return result; } *************** *** 412,416 **** { int step,max; ! int pstep,pmax; int split_depth; bool common_ref; --- 413,417 ---- { int step,max; ! int pstep,pmax,mode_step; int split_depth; bool common_ref; *************** *** 441,448 **** common_ref = in_data.MBCommonMode()[m_mb_yp][m_mb_xp]; ! ! //do prediction modes ! for (m_b_yp = m_mb_tlb_y; m_b_yp < m_mb_tlb_y+4; m_b_yp += pstep) ! for (m_b_xp = m_mb_tlb_x; m_b_xp < m_mb_tlb_x+4; m_b_xp += pstep) CodePredmode(in_data); --- 442,452 ---- common_ref = in_data.MBCommonMode()[m_mb_yp][m_mb_xp]; ! if (common_ref) ! mode_step = 4; ! else ! mode_step = pstep; ! ! for (m_b_yp = m_mb_tlb_y; m_b_yp < m_mb_tlb_y+4; m_b_yp += mode_step) ! for (m_b_xp = m_mb_tlb_x; m_b_xp < m_mb_tlb_x+4; m_b_xp += mode_step) CodePredmode(in_data); *************** *** 501,509 **** { bool val = in_data.MBCommonMode()[m_mb_yp][m_mb_xp]; ! ! if (val != MBCBModePrediction( in_data.MBCommonMode() )) ! EncodeSymbol( 1 , ChooseMBCContext( in_data ) ); ! else ! EncodeSymbol( 0 , ChooseMBCContext( in_data ) ); } --- 505,511 ---- { bool val = in_data.MBCommonMode()[m_mb_yp][m_mb_xp]; ! ! EncodeSymbol( val ^ int(MBCBModePrediction( in_data.MBCommonMode() )), ! ChooseMBCContext( in_data ) ); } *************** *** 629,633 **** { int step,max; ! int pstep,pmax; int split_depth; bool common_ref; --- 631,635 ---- { int step,max; ! int pstep,pmax,mode_step; int split_depth; bool common_ref; *************** *** 659,678 **** common_ref = out_data.MBCommonMode()[m_mb_yp][m_mb_xp]; // do prediction modes ! for (m_b_yp = m_mb_tlb_y; m_b_yp < m_mb_tlb_y + 4; m_b_yp += pstep) { ! for (m_b_xp = m_mb_tlb_x; m_b_xp < m_mb_tlb_x + 4; m_b_xp += pstep) { DecodePredmode(out_data); ! // propagate throughout MB ! for (int y = m_b_yp; y < m_b_yp + pstep; y++) ! for (int x = m_b_xp; x < m_b_xp + pstep; x++) ! out_data.Mode()[y][x] = out_data.Mode()[m_b_yp][m_b_xp]; } ! } ! //now do all the block mvs in the mb for (int j = 0; j < max; ++j) { --- 661,686 ---- common_ref = out_data.MBCommonMode()[m_mb_yp][m_mb_xp]; + + if (common_ref) + mode_step = 4; + else + mode_step = pstep; // do prediction modes ! for (m_b_yp = m_mb_tlb_y; m_b_yp < m_mb_tlb_y + 4; m_b_yp += mode_step) { ! for (m_b_xp = m_mb_tlb_x; m_b_xp < m_mb_tlb_x + 4; m_b_xp += mode_step) { DecodePredmode(out_data); ! // propagate throughout prediction unit/MB ! for (int y = m_b_yp; y < m_b_yp + mode_step; y++) ! for (int x = m_b_xp; x < m_b_xp + mode_step; x++) ! out_data.Mode()[y][x] = out_data.Mode()[m_b_yp][m_b_xp]; } ! } ! ! //now do all the block mvs in the mb for (int j = 0; j < max; ++j) { *************** *** 743,750 **** void MvDataCodec::DecodeMBCom( MvData& out_data ) { ! if ( DecodeSymbol( ChooseMBCContext( out_data ) ) ) ! out_data.MBCommonMode()[m_mb_yp][m_mb_xp] = !MBCBModePrediction( out_data.MBCommonMode() ); ! else ! out_data.MBCommonMode()[m_mb_yp][m_mb_xp] = MBCBModePrediction( out_data.MBCommonMode() ); } --- 751,757 ---- void MvDataCodec::DecodeMBCom( MvData& out_data ) { ! out_data.MBCommonMode()[m_mb_yp][m_mb_xp] = DecodeSymbol( ! ChooseMBCContext( out_data ) ) ^ ! int( MBCBModePrediction( out_data.MBCommonMode() ) ); } |