From: Thomas D. <tj...@us...> - 2005-01-24 16:58:55
|
Update of /cvsroot/dirac/compress/libdirac_common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13953/libdirac_common Modified Files: common.h mv_codec.cpp mv_codec.h Log Message: Changed prediction of block modes to be bitwise - bit 0 indicates the presence of a Ref1 MV, and bit 1 indicated the presence of a Ref2 MV. This is also reflected in selecting modes in motion estimation. Index: mv_codec.h =================================================================== RCS file: /cvsroot/dirac/compress/libdirac_common/mv_codec.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** mv_codec.h 29 Nov 2004 12:55:05 -0000 1.10 --- mv_codec.h 24 Jan 2005 16:58:47 -0000 1.11 *************** *** 127,131 **** int ChooseMBSContext(const MvData& data, const int BinNumber) const; int ChooseMBCContext(const MvData& data) const; - int ChoosePredContext(const MvData& data, const int BinNumber) const; int ChooseREF1xContext(const MvData& data, const int BinNumber) const; int ChooseREF1xSignContext(const MvData& data) const; --- 127,130 ---- Index: common.h =================================================================== RCS file: /cvsroot/dirac/compress/libdirac_common/common.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** common.h 29 Nov 2004 12:55:05 -0000 1.17 --- common.h 24 Jan 2005 16:58:46 -0000 1.18 *************** *** 155,165 **** REF2y_SIGNN_CTX, //40 -sign, REF2 y vals, previous value -ve ! PMODE_BIN1_CTX, //41 -bin 1, prediction mode value ! PMODE_BIN2_CTX, //42 -bin 2, prediction mode value ! PMODE_BIN3_CTX, //43 -bin 3, prediction mode value. Bin 4 not required ! MB_CMODE_CTX, //44 -context for MB common block mode ! MB_SPLIT_BIN1_CTX, //45 -bin1, MB split mode vals ! MB_SPLIT_BIN2_CTX //46 -bin2, MB split mode vals. Bin 3 not required }; --- 155,164 ---- REF2y_SIGNN_CTX, //40 -sign, REF2 y vals, previous value -ve ! PMODE_BIT0_CTX, //41 -bit 0, prediction mode value ! PMODE_BIT1_CTX, //42 -bin 1, prediction mode value ! MB_CMODE_CTX, //43 -context for MB common block mode ! MB_SPLIT_BIN1_CTX, //44 -bin1, MB split mode vals ! MB_SPLIT_BIN2_CTX //45 -bin2, MB split mode vals. Bin 3 not required }; Index: mv_codec.cpp =================================================================== RCS file: /cvsroot/dirac/compress/libdirac_common/mv_codec.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** mv_codec.cpp 22 Nov 2004 14:05:02 -0000 1.8 --- mv_codec.cpp 24 Jan 2005 16:58:47 -0000 1.9 *************** *** 124,137 **** } - inline int MvDataCodec::ChoosePredContext(const MvData& data, const int BinNumber) const - { - if (BinNumber == 1) - return PMODE_BIN1_CTX; - else if (BinNumber == 2) - return PMODE_BIN2_CTX; - else - return PMODE_BIN3_CTX; - } - inline int MvDataCodec::ChooseREF1xContext(const MvData& data, const int BinNumber) const { --- 124,127 ---- *************** *** 295,312 **** { unsigned int result = (unsigned int)(REF1_ONLY); ! std::vector <unsigned int> nbrs; if (b_xp > 0 && b_yp > 0) { ! nbrs.push_back( (unsigned int)( preddata[b_yp-1][b_xp] ) ); ! nbrs.push_back( (unsigned int)( preddata[b_yp-1][b_xp-1] ) ); ! nbrs.push_back( (unsigned int)( preddata[b_yp][b_xp-1] ) ); ! result = GetMean(nbrs); } else if (b_xp > 0 && b_yp == 0) ! result = preddata[b_yp][b_xp-1]; else if (b_xp == 0 && b_yp > 0) ! result = preddata[b_yp-1][b_xp]; return result; --- 285,311 ---- { unsigned int result = (unsigned int)(REF1_ONLY); ! ! unsigned int num_ref1_nbrs( 0 ); ! unsigned int num_ref2_nbrs( 0 ); if (b_xp > 0 && b_yp > 0) { ! num_ref1_nbrs += ((unsigned int)( preddata[b_yp-1][b_xp] ) ) & 1; ! num_ref1_nbrs += ((unsigned int)( preddata[b_yp-1][b_xp-1] ) ) & 1; ! num_ref1_nbrs += ((unsigned int)( preddata[b_yp][b_xp-1] ) ) & 1; ! result = num_ref1_nbrs>>1; ! ! num_ref2_nbrs += ((unsigned int)( preddata[b_yp-1][b_xp] ) ) & 2; ! num_ref2_nbrs += ((unsigned int)( preddata[b_yp-1][b_xp-1] ) ) & 2; ! num_ref2_nbrs += ((unsigned int)( preddata[b_yp][b_xp-1] ) ) & 2; ! num_ref2_nbrs >>= 1; ! ! result ^= ( (num_ref2_nbrs>>1)<<1 ); } else if (b_xp > 0 && b_yp == 0) ! result = (unsigned int)( preddata[0][b_xp-1] ); else if (b_xp == 0 && b_yp > 0) ! result = (unsigned int)( preddata[b_yp-1][0] ); return result; *************** *** 531,544 **** void MvDataCodec::CodePredmode(const MvData& in_data) { ! int val = in_data.Mode()[b_yp][b_xp] - BlockModePrediction( in_data.Mode() ); ! ! if (val < 0) ! val += 4; //produce value mod 4 ! for (int bin = 1; bin<= val; ++bin) ! EncodeSymbol( 0 , ChoosePredContext( in_data , bin ) ); ! ! if (val != 3) //if we've had three zeroes, know we must have value 3 ! EncodeSymbol( 1 , ChoosePredContext( in_data , val + 1 ) ); } --- 530,543 ---- void MvDataCodec::CodePredmode(const MvData& in_data) { ! // Xor with the prediction so we predict whether REF1 is used or REF2 is ! // used, separately ! unsigned int residue = in_data.Mode()[b_yp][b_xp] ^ BlockModePrediction( in_data.Mode() ); ! // Code REF1 part of the prediction residue (ie the first bit) ! EncodeSymbol( residue & 1 , PMODE_BIT0_CTX ); ! ! // Code REF2 part of the prediction residue (ie the second bit) ! EncodeSymbol( residue & 2 , PMODE_BIT1_CTX ); ! } *************** *** 767,786 **** void MvDataCodec::DecodePredmode( MvData& out_data ) { ! int val = 0; ! int bin = 1; ! bool bit; ! do ! { ! DecodeSymbol( bit , ChoosePredContext( out_data , bin ) ); ! ! if (!bit) ! val++; ! ! bin++; ! } ! while (!bit && val != 3); ! out_data.Mode()[b_yp][b_xp] = PredMode( ( val + BlockModePrediction (out_data.Mode() ) ) %4); } --- 766,783 ---- void MvDataCodec::DecodePredmode( MvData& out_data ) { ! // Xor with the prediction so we predict whether REF1 is used or REF2 is ! // used, separately ! unsigned int residue; ! // Decode REF1 part of the prediction residue (ie the first bit) ! bool bit; ! DecodeSymbol( bit , PMODE_BIT0_CTX ); ! residue = (unsigned int) bit; ! ! // Decode REF2 part of the prediction residue (ie the second bit) ! DecodeSymbol( bit , PMODE_BIT1_CTX ); ! residue |= ( (unsigned int) bit ) << 1; ! out_data.Mode()[b_yp][b_xp] = PredMode( BlockModePrediction (out_data.Mode() ) ^ residue ); } |