00001
00002
00003
00004
00005
00006
00007 template<>
00008 void DCFmp< Rtmra<float,array> >::encode(
00009 Rtmra<float,array>& x, const char mcode
00010 )
00011 {
00012 float tmp;
00013 bytepack bp;
00014
00015 int n = 0;
00016 if (mcode_to_sw(mcode)) {
00017 n = ( (x.mrastep()) & ((1<<x.mmax())-1) ) >> mcode_to_m(mcode);
00018 }
00019
00020 clear();
00021 set( mcode, n );
00022
00023 for( int a = 0; a <= x.amax(); ++a ) {
00024 if ( mcode_to_sw(mcode) == 0 ) { tmp = x.scal( a, mcode_to_m(mcode) ); }
00025 else { tmp = x.wav( a, mcode_to_m(mcode) ); }
00026 if ( fabs(tmp) >= _threshold ) {
00027 push_back( bp( a, _bplen_a ) );
00028 push_back( bp( tmp, _bplen_coef ) );
00029 }
00030 }
00031
00032 };
00033
00034 template<>
00035 void DCFmp< Rtmra<float,array> >::replace( Rtmra<float,array>& x )
00036 {
00037 int a=0;
00038
00039 if ( !null() && !empty() ) {
00040 float tmp;
00041 bytepack bp;
00042 int next=0;
00043 int a1;
00044 for(int i=0; i < ((*_data).size() / ( _bplen_a + _bplen_coef )); ++i ) {
00045 bp( 0, _bplen_a );
00046 for( int j = 0; j < bp.size(); ++j ) { bp[j] = (*_data)[next++]; }
00047 a1=int(bp);
00048
00049 bp( 0, _bplen_coef );
00050 for( int j = 0; j < bp.size(); ++j) { bp[j] = (*_data)[next++]; }
00051 tmp = float(bp);
00052
00053 while ( a < a1 ) {
00054 if ( sw() ) { x.wav( a, m(), 0 ); }
00055 else { x.scal( a, m(), 0 ); }
00056 ++a;
00057 }
00058 if ( sw() ) { x.wav( a, m(), tmp ); }
00059 else { x.scal( a, m(), tmp ); }
00060 ++a;
00061 }
00062 }
00063
00064 while ( a <= x.amax() ) {
00065 if ( sw() ) { x.wav( a, m(), 0 ); }
00066 else { x.scal( a, m(), 0 ); }
00067 ++a;
00068 }
00069 };
00070