src/main/java/net/sourceforge/jaad/aac/sbr/FBT.java
public static int master_frequency_table_fs0(SBR sbr, int k0, int k2,
		boolean bs_alter_scale) {
		int incr;
		int k;
		int dk;
		int nrBands, k2Achieved;
		int k2Diff;
		int[] vDk = new int[64];

		/* mft only defined for k2 > k0 */
		if(k2<=k0) {
			sbr.N_master = 0;
			return 1;
		}

		dk = bs_alter_scale ? 2 : 1;

		if(bs_alter_scale) {
			nrBands = (((k2-k0+2)>>2)<<1);
		}
		else {
			nrBands = (((k2-k0)>>1)<<1);
		}
		nrBands = Math.min(nrBands, 63);
		if(nrBands<=0)
			return 1;

		k2Achieved = k0+nrBands*dk;
		k2Diff = k2-k2Achieved;
		for(k = 0; k<nrBands; k++) {
			vDk[k] = dk;
		}

		if(k2Diff!=0) {
			incr = (k2Diff>0) ? -1 : 1;
			k = ((k2Diff>0) ? (nrBands-1) : 0);

			while(k2Diff!=0) {
				vDk[k] -= incr;
				k += incr;
				k2Diff += incr;
			}
		}

		sbr.f_master[0] = k0;
		for(k = 1; k<=nrBands; k++) {
			sbr.f_master[k] = (sbr.f_master[k-1]+vDk[k-1]);
		}

		sbr.N_master = nrBands;
		sbr.N_master = Math.min(sbr.N_master, 64);

		return 0;
	}
public static int master_frequency_table_fs0(SBR sbr, int k0, int k2,
		boolean bs_alter_scale) {
		int incr;
		int k;
		int dk;
		int nrBands, k2Achieved;
		int k2Diff;
		int[] vDk = new int[64];

		/* mft only defined for k2 > k0 */
		if(k2<=k0) {
			sbr.N_master = 0;
			return 1;
		}

		dk = bs_alter_scale ? 2 : 1;

		if(bs_alter_scale) {
			nrBands = (((k2-k0+2)>>2)<<1);
		}
		else {
			nrBands = (((k2-k0)>>1)<<1);
		}
		nrBands = Math.min(nrBands, 63);
		if(nrBands<=0)
			return 1;

		k2Achieved = k0+nrBands*dk;
		k2Diff = k2-k2Achieved;
		for(k = 0; k<nrBands; k++) {
			vDk[k] = dk;
		}

		if(k2Diff!=0) {
			incr = (k2Diff>0) ? -1 : 1;
			k = ((k2Diff>0) ? (nrBands-1) : 0);

			while(k2Diff!=0) {
				vDk[k] -= incr;
				k += incr;
				k2Diff += incr;
			}
		}

		sbr.f_master[0] = k0;
		for(k = 1; k<=nrBands; k++) {
			sbr.f_master[k] = (sbr.f_master[k-1]+vDk[k-1]);
		}

		sbr.N_master = nrBands;
		sbr.N_master = Math.min(sbr.N_master, 64);

		return 0;
	}
/* calculate the master frequency table from k0, k2, bs_freq_scale
and bs_alter_scale

version for bs_freq_scale = 0