|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfi.helsinki.cs.ohtu.mpeg2.audio.AudioEncoder
fi.helsinki.cs.ohtu.mpeg2.audio.mpa.MP2Encoder
public class MP2Encoder
Implements an MPEG-1 Layer II encoder. The encoder supports the sample rates specified in the MPEG-1 standard: 32, 44.1 and 48 kHz. In addition, the MPEG-2 Lower Sampling Frequencies extension is supported in a degraded mode: for the sample rates 16, 22.05 and 24 kHz, the encoder by-passes the psychoacoustic model.
A basic usage scheme for the encoder:
MP2Encoder mp2enc = new MP2Encoder(AudioEncoder.Mode.SINGLE_CHANNEL,
AudioEncoder.SampleRate.SRATE_48000);
double[] samples = new double[mp2enc.getSampleFrameSize()];
mp2enc.setBitrate(192000);
...
while (...) {
AudioFrame aframe;
...
/* Generate or read the samples. */
aframe = mp2enc.encode(samples);
...
}
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class fi.helsinki.cs.ohtu.mpeg2.audio.AudioEncoder |
|---|
AudioEncoder.Mode, AudioEncoder.SampleRate |
| Field Summary | |
|---|---|
private int |
bitrate
|
private boolean |
crcProtected
|
private static int |
DEFAULT_BITRATE
|
private double[][] |
delayBuf
|
private AudioEncoder.SampleRate |
fs
|
private AudioEncoder.Mode |
mode
|
static int |
MP2_FRAME
Number of samples per input frame |
private PsychoacousticModel |
pam
|
private PolyphaseQuadratureFilter[] |
pqf
|
private static int |
PQF_DELAY
|
private QuantizationTables.QuantizationTable |
quantizationTable
|
static int |
SBLIMIT
Number of sub-bands |
static int |
SBSLIMIT
Number of sub-band sections |
static int |
SBSSAMPLES
Number of samples per sub-band section |
| Constructor Summary | |
|---|---|
MP2Encoder(AudioEncoder.Mode mode,
AudioEncoder.SampleRate fs)
Creates a new MPEG-1 Layer II encoder instance. |
|
| Method Summary | |
|---|---|
AudioFrame |
encode(double[][] samples)
Encode 1152 input samples and pack them in an audio frame. |
int |
getBitrate()
Returns the current bitrate of this encoder. |
int |
getSampleFrameSize()
Returns size of next accepted sample frame. |
boolean |
isCRCProtected()
Returns whether CRC checksums are calculated for audio frames. |
void |
setBitrate(int bitrate)
Sets bitrate for this encoder. |
void |
setCRCProtection(boolean crcProtected)
Sets whether to calculate CRC checksums for audio frames. |
| Methods inherited from class fi.helsinki.cs.ohtu.mpeg2.audio.AudioEncoder |
|---|
encode |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MP2_FRAME
public static final int SBLIMIT
public static final int SBSLIMIT
public static final int SBSSAMPLES
private static final int DEFAULT_BITRATE
private static final int PQF_DELAY
private final PolyphaseQuadratureFilter[] pqf
private final PsychoacousticModel pam
private final AudioEncoder.Mode mode
private final AudioEncoder.SampleRate fs
private QuantizationTables.QuantizationTable quantizationTable
private int bitrate
private boolean crcProtected
private double[][] delayBuf
| Constructor Detail |
|---|
public MP2Encoder(AudioEncoder.Mode mode,
AudioEncoder.SampleRate fs)
mode - Encoding mode, @see AudioEncoder.Modefs - Sample rate, @see AudioEncoder.SampleRate| Method Detail |
|---|
public boolean isCRCProtected()
true if and only if CRC checksums are calculated.public int getBitrate()
public final int getSampleFrameSize()
AudioEncoder
getSampleFrameSize in class AudioEncoderpublic void setBitrate(int bitrate)
bitrate - Bitrate in bits per secondpublic void setCRCProtection(boolean crcProtected)
crcProtected - true is CRC protection should
be used; false otherwisepublic AudioFrame encode(double[][] samples)
encode in class AudioEncodersamples - 1152 input PCM samples in ]-1, 1[.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||