FileDocCategorySizeDatePackage
JavaDecoder.javaAPI DocJMF 2.1.1e3496Mon May 12 12:21:02 BST 2003com.ibm.media.codec.audio.g723

JavaDecoder

public class JavaDecoder extends com.ibm.media.codec.audio.AudioCodec
Implements an G723 codec which uses native methods to do the decoding.

Fields Summary
protected G723Dec
decoder
Constructors Summary
public JavaDecoder()

       	supportedInputFormats = new AudioFormat[] { new AudioFormat(AudioFormat.G723),
						    new AudioFormat(AudioFormat.G723_RTP)};
        defaultOutputFormats  = new AudioFormat[] { new AudioFormat(AudioFormat.LINEAR) };
        PLUGIN_NAME="G723 Decoder";
    
Methods Summary
protected intcalculateOutputSize(int inputSize)

        return inputSize/24*480;
    
public voidclose()

        freeDecoder();
    
protected voiddecode(byte[] inpData, int readPtr, byte[] outData, int writePtr, int inpLength)

        int numberOfFrames = (inpLength/24);
        int frameSize =24;
        int n;

        // loop for all G.723 frames in the current block ("Frame")
        for (n=0; n<numberOfFrames ; n++, readPtr += frameSize, writePtr += 2*240) {
            decoder.decodeFrame(inpData, readPtr,outData,writePtr);
        }
    
protected voidfreeDecoder()

 	decoder=null;
    
public java.lang.Object[]getControls()

        if (controls==null) {
             controls=new Control[1];
             controls[0]=new SilenceSuppressionAdapter(this,true,false);
	}
        return (Object[])controls;
    
protected Format[]getMatchingOutputFormats(Format in)


        AudioFormat af =(AudioFormat) in;

        supportedOutputFormats = new AudioFormat[] {
                new AudioFormat(
                AudioFormat.LINEAR,
                af.getSampleRate(),
                16,
                1,
                AudioFormat.LITTLE_ENDIAN, //isBigEndian(),
                AudioFormat.SIGNED //isSigned());
                )                };
        return  supportedOutputFormats;
    
protected voidinitDecoder()

        decoder.decoderReset();
    
public voidopen()

        decoder=new G723Dec();
        decoder.decoderOpen();
   
public intprocess(Buffer inputBuffer, Buffer outputBuffer)


        if (!checkInputBuffer(inputBuffer) ) {
            return BUFFER_PROCESSED_FAILED;
        }

        if (isEOM(inputBuffer) ) {
            propagateEOM(outputBuffer);
            return BUFFER_PROCESSED_OK;
        }

        int inpLength=inputBuffer.getLength();
        int outLength = calculateOutputSize(inputBuffer.getLength() );

        byte[] inpData = (byte[]) inputBuffer.getData();
        byte[] outData = validateByteArraySize(outputBuffer, outLength);

        // get offset for both RTP and non RTP streams
        decode(inpData, inputBuffer.getOffset(), outData, 0, inpLength);

        updateOutput(outputBuffer, outputFormat, outLength, 0);
        return BUFFER_PROCESSED_OK;
    
public voidreset()

        resetDecoder();
    
protected voidresetDecoder()

        decoder.decoderReset();