javaFlacEncoder
Class Subframe_LPC

java.lang.Object
  extended by javaFlacEncoder.Subframe
      extended by javaFlacEncoder.Subframe_LPC

public class Subframe_LPC
extends Subframe

Implements the Subframe abstract class, providing encoding support for the FLAC LPC Subframe.

Author:
Preston Lacey

Field Summary
static int DEBUG_LEV
          For debugging: Higher values equals greater output, generally in increments of 10
static int MAX_LPC_ORDER
          Maximum LPC order that is supported by this subframe
static long totalTime
           
static EncodingConfiguration.SubframeType type
          Subframe type implemented by this subframe.
 
Fields inherited from class javaFlacEncoder.Subframe
ec, lastEncodedSize, sc
 
Method Summary
 int encodeSamples(int[] samples, int count, int start, int skip, EncodedElement dataEle, int offset, int unencSampleSize)
          Encodes samples into the appropriate compressed format, saving the result in the given “data” EncodedElement list.
 int encodeSamples(int[] samples, int count, int start, int skip, int offset, int unencSampleSize)
           
 int estimatedSize()
          Return the estimated size of the previous encode attempt in bits.
 EncodedElement getData()
          Get the data from the last encode attempt.
 boolean registerConfiguration(EncodingConfiguration ec)
          This method is used to set the encoding configuration.
 
Methods inherited from class javaFlacEncoder.Subframe
getEncodedSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

totalTime

public static long totalTime

MAX_LPC_ORDER

public static final int MAX_LPC_ORDER
Maximum LPC order that is supported by this subframe

See Also:
Constant Field Values

DEBUG_LEV

public static int DEBUG_LEV
For debugging: Higher values equals greater output, generally in increments of 10


type

public static final EncodingConfiguration.SubframeType type
Subframe type implemented by this subframe.

Method Detail

registerConfiguration

public boolean registerConfiguration(EncodingConfiguration ec)
This method is used to set the encoding configuration.

Overrides:
registerConfiguration in class Subframe
Parameters:
ec - encoding configuration to use.
Returns:
true if configuration was changed, false otherwise

encodeSamples

public int encodeSamples(int[] samples,
                         int count,
                         int start,
                         int skip,
                         int offset,
                         int unencSampleSize)

estimatedSize

public int estimatedSize()
Return the estimated size of the previous encode attempt in bits. Since returning the data from an encode is costly(due to the rice encoding and FLAC compliant bit-packing), this allows us to estimate the size first, and therefore choose another subframe type if this is larger.

Returns:
estimated size in bits of encoded subframe.

getData

public EncodedElement getData()
Get the data from the last encode attempt. Data is returned in an EncodedElement, properly packed at the bit-level to be added directly to a FLAC stream.

Returns:
EncodedElement containing encoded subframe

encodeSamples

public int encodeSamples(int[] samples,
                         int count,
                         int start,
                         int skip,
                         EncodedElement dataEle,
                         int offset,
                         int unencSampleSize)
Description copied from class: Subframe
Encodes samples into the appropriate compressed format, saving the result in the given “data” EncodedElement list. Encodes 'count' samples, from index 'start', to index 'start' times 'skip', where “skip” is the format that samples may be packed in an array. For example, 'samples' may include both left and right samples of a stereo stream, while this SubFrame is only encoding the 'right' channel(channel 2). Therefore, “skip” would equal 2, resulting in the valid indices being only those where “index mod 2 equals 1”.

Specified by:
encodeSamples in class Subframe
Parameters:
samples - the audio samples to encode. This array may contain samples for multiple channels, interleaved; only one of these channels is encoded by a subframe.
count - the number of samples to encode.
start - the index to start at in the array.
skip - the number of indices to skip between successive samples (for use when channels are interleaved in the given array).
dataEle - the EncodedElement to attach encoded data to. Data in EncodedElement given is not altered. New data is attached starting with “data.getNext()”. If “data” already has a “next” set, it will be lost!
unencSampleSize - Number of bits per single-channel sample. This may differ from the StreamConfiguration's sample size, depending on the subframe used(i.e, the "side-channel" of a FLAC stream uses one extra bit compared to the input channels).
Returns:
number of encoded samples, or negative value indicating an error has occurred.