FileDocCategorySizeDatePackage
JavaEncoder_ms.javaAPI DocJMF 2.1.1e4159Mon May 12 12:21:02 BST 2003com.ibm.media.codec.audio.gsm

JavaEncoder_ms

public class JavaEncoder_ms extends JavaEncoder
MS GSM encoder plugin wrapper, which uses Java methods to do the encoding.
author
Shay Ben-David bendavid@haifa.vnet.ibm.com

Fields Summary
public static final String
a_copyright_notice
Licensed Materials - Property of IBM

"Restricted Materials of IBM"

5648-B81

(c) Copyright IBM Corporation 1997,1999 All Rights Reserved

US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corporation.
Constructors Summary
public JavaEncoder_ms()


     ////////////////////////////////////////////////////////////////////////////
    // Methods

      
       	supportedInputFormats = new AudioFormat[] {
	                                new AudioFormat(AudioFormat.LINEAR,
					        Format.NOT_SPECIFIED,
						16,
						1,
						AudioFormat.LITTLE_ENDIAN,
						AudioFormat.SIGNED,
                                                Format.NOT_SPECIFIED,
                                                Format.NOT_SPECIFIED,
                                                Format.byteArray

						) };

        defaultOutputFormats  = new AudioFormat[] {new WavAudioFormat(AudioFormat.GSM_MS)};

        PLUGIN_NAME="MS GSM Encoder";
        historySize = 640;
    
Methods Summary
protected intcalculateFramesNumber(int inputSize)

        return inputSize / 640;
    
protected intcalculateOutputSize(int inputSize)

        return calculateFramesNumber(inputSize) * 65 ;
    
protected booleancodecProcess(byte[] inpData, int readPtr, byte[] outData, int writePtr, int inpLength, int[] readBytes, int[] writeBytes, int[] frameNumber, int[] regions, int[] regionsTypes)


        int inCount = 0;
        int outCount = 0;
        int channels=inputFormat.getChannels();
        boolean isStereo = ( channels == 2);

        final int frames = inpLength/(640);

        regions[0]=writePtr;

        for (int frameCounter = 0; frameCounter<frames ; frameCounter++) {
              encoder.gsm_encode_frame(inpData, readPtr , outData,writePtr);
              readPtr += 640;
              inCount += 640;

              outCount += 65;
              writePtr += 65;

              regions     [frameCounter+1]= outCount + writePtr;
              regionsTypes[frameCounter  ]= 0;

//            System.out.println(inCount+" "+outCount+" "+inpLength);
        }

        readBytes [0]=inCount;
        writeBytes[0]=outCount;
        frameNumber[0]=frames;

        return true;
    
protected javax.media.Format[]getMatchingOutputFormats(javax.media.Format in)


        AudioFormat af =(AudioFormat) in;

        supportedOutputFormats = new AudioFormat[] {
                new WavAudioFormat(
                    AudioFormat.GSM_MS,
                    af.getSampleRate(),
                    0,
                    af.getChannels(),
                    65*8,
                    (int) (af.getSampleRate() * af.getChannels() / 320 * 65),
                    Format.NOT_SPECIFIED,
                    Format.NOT_SPECIFIED,
                    Format.NOT_SPECIFIED,
                    Format.byteArray,
                    new byte[] { (byte)0x40, (byte)0x01}

                )
        };
        return  supportedOutputFormats;
    
public voidopen()

        encoder=new GsmEncoder_ms();
        encoder.gsm_encoder_reset();