Class JavaEncoder

  • All Implemented Interfaces:
    javax.media.Codec, javax.media.Controls, javax.media.PlugIn

    public class JavaEncoder
    extends com.ibm.media.codec.audio.AudioCodec
    The ALAW Encoder. Used the FMJ ALawEncoderUtil.
    Author:
    Damian Minkov
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX
      maximum that can be held in 15 bits
      static int MAX_USHORT
      65535
      • Fields inherited from class com.ibm.media.codec.audio.AudioCodec

        DEBUG, defaultOutputFormats, inputFormat, outputFormat, PLUGIN_NAME, supportedInputFormats, supportedOutputFormats
      • Fields inherited from class net.sf.fmj.media.BasicCodec

        inputFormats, opened, outputFormats, pendingEOM
      • Fields inherited from class net.sf.fmj.media.BasicPlugIn

        controls
      • Fields inherited from interface javax.media.PlugIn

        BUFFER_PROCESSED_FAILED, BUFFER_PROCESSED_OK, INPUT_BUFFER_NOT_CONSUMED, OUTPUT_BUFFER_NOT_FILLED, PLUGIN_TERMINATED
    • Constructor Summary

      Constructors 
      Constructor Description
      JavaEncoder()
      Constructs the encoder and init the supported formats.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void aLawEncode​(boolean bigEndian, byte[] data, int offset, int length, byte[] target)
      Encode an array of pcm values into a pre-allocated target array
      static byte aLawEncode​(int pcm)
      Encode a pcm value into a a-law byte
      static void aLawEncodeBigEndian​(byte[] data, int offset, int length, byte[] target)
      Encode big endian data.
      static void aLawEncodeLittleEndian​(byte[] data, int offset, int length, byte[] target)
      Encode little endian data.
      void close()
      No resources used to be cleared.
      protected javax.media.Format[] getMatchingOutputFormats​(javax.media.Format in)
      Returns the output formats according to the input.
      void open()
      No resources to be opened.
      int process​(javax.media.Buffer inputBuffer, javax.media.Buffer outputBuffer)
      Encodes the input buffer passing it to the output one
      static int uShortToInt​(short value)
      Unsigned short to integer.
      • Methods inherited from class com.ibm.media.codec.audio.AudioCodec

        checkFormat, getInputFormat, getName, getOutputFormat, getSupportedInputFormats, getSupportedOutputFormats, setInputFormat, setOutputFormat
      • Methods inherited from class net.sf.fmj.media.BasicCodec

        checkEOM, checkInputBuffer, getArrayElementSize, isEOM, processAtEOM, propagateEOM, reset, updateOutput, updateRGBFormat
      • Methods inherited from class net.sf.fmj.media.BasicPlugIn

        error, getClassForName, getControl, getControls, getInputData, getNativeData, getOutputData, matches, plugInExists, validateByteArraySize, validateData, validateIntArraySize, validateShortArraySize
      • Methods inherited from interface javax.media.Controls

        getControl, getControls
    • Constructor Detail

      • JavaEncoder

        public JavaEncoder()
        Constructs the encoder and init the supported formats.
    • Method Detail

      • getMatchingOutputFormats

        protected javax.media.Format[] getMatchingOutputFormats​(javax.media.Format in)
        Returns the output formats according to the input.
        Overrides:
        getMatchingOutputFormats in class com.ibm.media.codec.audio.AudioCodec
        Parameters:
        in - the input format.
        Returns:
        the possible output formats.
      • open

        public void open()
                  throws javax.media.ResourceUnavailableException
        No resources to be opened.
        Specified by:
        open in interface javax.media.PlugIn
        Overrides:
        open in class net.sf.fmj.media.BasicCodec
        Throws:
        javax.media.ResourceUnavailableException - if open failed (which cannot happend for this codec since no resources are to be opened)
      • close

        public void close()
        No resources used to be cleared.
        Specified by:
        close in interface javax.media.PlugIn
        Overrides:
        close in class net.sf.fmj.media.BasicCodec
      • process

        public int process​(javax.media.Buffer inputBuffer,
                           javax.media.Buffer outputBuffer)
        Encodes the input buffer passing it to the output one
        Parameters:
        inputBuffer - Buffer
        outputBuffer - Buffer
        Returns:
        int
      • uShortToInt

        public static int uShortToInt​(short value)
        Unsigned short to integer.
        Parameters:
        value - unsigned short.
        Returns:
        integer.
      • aLawEncode

        public static void aLawEncode​(boolean bigEndian,
                                      byte[] data,
                                      int offset,
                                      int length,
                                      byte[] target)
        Encode an array of pcm values into a pre-allocated target array
        Parameters:
        bigEndian - the data byte order.
        data - An array of bytes in Little-Endian format
        target - A pre-allocated array to receive the A-law bytes. This array must be at least half the size of the source.
        offset - of the input.
        length - of the input.
      • aLawEncodeLittleEndian

        public static void aLawEncodeLittleEndian​(byte[] data,
                                                  int offset,
                                                  int length,
                                                  byte[] target)
        Encode little endian data.
        Parameters:
        data - the input data.
        offset - the input offset.
        length - the input length.
        target - the target array to fill.
      • aLawEncodeBigEndian

        public static void aLawEncodeBigEndian​(byte[] data,
                                               int offset,
                                               int length,
                                               byte[] target)
        Encode big endian data.
        Parameters:
        data - the input data.
        offset - the input offset.
        length - the input length.
        target - the target array to fill.
      • aLawEncode

        public static byte aLawEncode​(int pcm)
        Encode a pcm value into a a-law byte
        Parameters:
        pcm - A 16-bit pcm value
        Returns:
        A a-law encoded byte