fi.helsinki.cs.ohtu.mpeg2.audio.mpa
Class ScaleFactors

java.lang.Object
  extended by fi.helsinki.cs.ohtu.mpeg2.audio.mpa.ScaleFactors

public class ScaleFactors
extends java.lang.Object

Implements scale factor calculations for MPEG-1 Layer I and II audio. The scale factors are used in the encoding process to implement an application specific (read 'home-made') floating-point representation of sub-band samples: The scale factor indices are coded along the scaled (and quantized) sub-band samples. Thus the scaling can be reversed while decoding.


Nested Class Summary
private static class ScaleFactors.TxPattern
          Transmission pattern defines how the three scale factors of a single sub-band are coded into the output stream.
 
Field Summary
private static double[] SCALEFACTORS
          Scalefactors, taken from table 3-B.1 of ISO 11172-3.
private static ScaleFactors.TxPattern[][] TRANS_PATTERN
          Transmission patterns tabulated in 3-C.4 of the 11172
 
Constructor Summary
private ScaleFactors()
           
 
Method Summary
static int calcScale(double[] samples)
          Calculates scale factor index for an array of samples.
static int[] calcScale(double[][] samples)
          Calculates scale factor indices for an array of sample arrays.
static int calcScfsi(int[] scfis)
          Calculates scale factor select information for given three scale factor indices and adjusts the indices accordingly.
static double scale(double sample, int scfi)
          Scales the given sample with the scale factor indicated by the scale factor select index.
static int search(double max)
          Finds next largest scalefactor for a given value from SCALEFACTORS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCALEFACTORS

private static final double[] SCALEFACTORS
Scalefactors, taken from table 3-B.1 of ISO 11172-3.


TRANS_PATTERN

private static final ScaleFactors.TxPattern[][] TRANS_PATTERN
Transmission patterns tabulated in 3-C.4 of the 11172

Constructor Detail

ScaleFactors

private ScaleFactors()
Method Detail

calcScale

public static int calcScale(double[] samples)
Calculates scale factor index for an array of samples.

Parameters:
samples - The array of samples
Returns:
The scale factor index

calcScale

public static int[] calcScale(double[][] samples)
Calculates scale factor indices for an array of sample arrays.

Parameters:
samples - The array of sample arrays [CHANNEL][SUBBAND]
Returns:
The array of scale factor indices [SBSLIMIT]

calcScfsi

public static int calcScfsi(int[] scfis)
Calculates scale factor select information for given three scale factor indices and adjusts the indices accordingly.

Parameters:
scfis - The array of three scale factor indices, contents adjusted to match with the select information
Returns:
The scale factor select information

search

public static int search(double max)
Finds next largest scalefactor for a given value from SCALEFACTORS. Uses binary search.

Parameters:
max - A value that is compared to the scalefactors
Returns:
Index of the next largest scalefactor

scale

public static double scale(double sample,
                           int scfi)
Scales the given sample with the scale factor indicated by the scale factor select index.

Parameters:
sample - The sample to scale
scfi - The scale factor index
Returns:
The scaled sample