private float calculateFMD(int bd, int wd, boolean prev, int maxLocGain, int samples,
			int[] loc, float[] lev, float[] fmd) {
		final int[] m = new int[samples/2];
		final int[] lct = prev ? locationPrev[bd][wd] : location[bd][wd];
		final int[] lvl = prev ? levelPrev[bd][wd] : level[bd][wd];
		final int length = lct.length;

		int lngain;
		int i;
		for(i = 0; i<length; i++) {
			loc[i+1] = 8*lct[i]; //gainc
			lngain = getGainChangePointID(lvl[i]); //gainc
			if(lngain<0) lev[i+1] = 1.0f/(float) Math.pow(2, -lngain);
			else lev[i+1] = (float) Math.pow(2, lngain);
		}

		//set start point values
		loc[0] = 0;
		if(length==0) lev[0] = 1.0f;
		else lev[0] = lev[1];
		float secLevel = lev[0];

		//set end point values
		loc[length+1] = maxLocGain;
		lev[length+1] = 1.0f;

		int j;
		for(i = 0; i<maxLocGain; i++) {
			m[i] = 0;
			for(j = 0; j<=length+1; j++) {
				if(loc[j]<=i) m[i] = j;
			}
		}

		for(i = 0; i<maxLocGain; i++) {
			if((i>=loc[m[i]])&&(i<=loc[m[i]]+7)) fmd[i] = interpolateGain(lev[m[i]], lev[m[i]+1], i-loc[m[i]]);
			else fmd[i] = lev[m[i]+1];
		}

		return secLevel;
	}
private float calculateFMD(int bd, int wd, boolean prev, int maxLocGain, int samples,
			int[] loc, float[] lev, float[] fmd) {
		final int[] m = new int[samples/2];
		final int[] lct = prev ? locationPrev[bd][wd] : location[bd][wd];
		final int[] lvl = prev ? levelPrev[bd][wd] : level[bd][wd];
		final int length = lct.length;

		int lngain;
		int i;
		for(i = 0; i<length; i++) {
			loc[i+1] = 8*lct[i]; 
			lngain = getGainChangePointID(lvl[i]); 
			if(lngain<0) lev[i+1] = 1.0f/(float) Math.pow(2, -lngain);
			else lev[i+1] = (float) Math.pow(2, lngain);
		}

		
		loc[0] = 0;
		if(length==0) lev[0] = 1.0f;
		else lev[0] = lev[1];
		float secLevel = lev[0];

		
		loc[length+1] = maxLocGain;
		lev[length+1] = 1.0f;

		int j;
		for(i = 0; i<maxLocGain; i++) {
			m[i] = 0;
			for(j = 0; j<=length+1; j++) {
				if(loc[j]<=i) m[i] = j;
			}
		}

		for(i = 0; i<maxLocGain; i++) {
			if((i>=loc[m[i]])&&(i<=loc[m[i]]+7)) fmd[i] = interpolateGain(lev[m[i]], lev[m[i]+1], i-loc[m[i]]);
			else fmd[i] = lev[m[i]+1];
		}

		return secLevel;
	}
private float calculateFMD ( int bd , int wd , boolean prev , int maxLocGain , int samples , int [ ] loc , float [ ] lev , float [ ] fmd ) { final int [ ] m = new int [ samples / 2 ] ; final int [ ] lct = prev ? locationPrev [ bd ] [ wd ] : location [ bd ] [ wd ] ; final int [ ] lvl = prev ? levelPrev [ bd ] [ wd ] : level [ bd ] [ wd ] ; final int length = lct . length ; int lngain ; int i ; for ( i = 0 ; i < length ; i ++ ) { loc [ i + 1 ] = 8 * lct [ i ] ; //gainc lngain = getGainChangePointID ( lvl [ i ] ) ; //gainc if ( lngain < 0 ) lev [ i + 1 ] = 1.0f / ( float ) Math . pow ( 2 , - lngain ) ; else lev [ i + 1 ] = ( float ) Math . pow ( 2 , lngain ) ; } //set start point values loc [ 0 ] = 0 ; if ( length == 0 ) lev [ 0 ] = 1.0f ; else lev [ 0 ] = lev [ 1 ] ; float secLevel = lev [ 0 ] ; //set end point values loc [ length + 1 ] = maxLocGain ; lev [ length + 1 ] = 1.0f ; int j ; for ( i = 0 ; i < maxLocGain ; i ++ ) { m [ i ] = 0 ; for ( j = 0 ; j <= length + 1 ; j ++ ) { if ( loc [ j ] <= i ) m [ i ] = j ; } } for ( i = 0 ; i < maxLocGain ; i ++ ) { if ( ( i >= loc [ m [ i ] ] ) && ( i <= loc [ m [ i ] ] + 7 ) ) fmd [ i ] = interpolateGain ( lev [ m [ i ] ] , lev [ m [ i ] + 1 ] , i - loc [ m [ i ] ] ) ; else fmd [ i ] = lev [ m [ i ] + 1 ] ; } return secLevel ; }
/*
calculates a fragment modification function by interpolating the gain
values of the gain change positions
/ * calculates a fragment modification function by interpolating the gain values of the gain change positions