FileDocCategorySizeDatePackage
JavaDecoder.javaAPI DocJMF 2.1.1e3571Mon May 12 12:20:46 BST 2003com.sun.media.codec.video.cinepak

JavaDecoder

public class JavaDecoder extends VideoCodec

Fields Summary
private static final int
rMask
private static final int
gMask
private static final int
bMask
private int[]
refData
private CineStore
fOurStore
the cinepak java decoder
Constructors Summary
public JavaDecoder()



      
	supportedInputFormats = new VideoFormat[] {new VideoFormat(VideoFormat.CINEPAK) };
        defaultOutputFormats  = new VideoFormat[] {new RGBFormat(
                null, Format.NOT_SPECIFIED,
		Format.intArray,
		Format.NOT_SPECIFIED, // frame rate
		32,
		rMask, gMask, bMask,
		1,Format.NOT_SPECIFIED,
		Format.FALSE, // flipped
		Format.NOT_SPECIFIED // endian
                ) };
        PLUGIN_NAME = "Cinepak Decoder";

    
Methods Summary
public voidclose()

        fOurStore=null;
    
protected javax.media.Format[]getMatchingOutputFormats(javax.media.Format in)

      	VideoFormat     ivf  = (VideoFormat) in;
	Dimension       inSize = ivf.getSize();
	int lineStride = (inSize.width + 3) & ~3;
	int rowStride = (inSize.height + 3) & ~3;
	
        supportedOutputFormats= new  VideoFormat[] {
	    new RGBFormat (new Dimension(inSize),
			   lineStride * rowStride, Format.intArray,
			   ivf.getFrameRate(),			       
			   32,
			   rMask, gMask, bMask
			   )
	};

        return  supportedOutputFormats;
    
protected voidinitDecoder()

        fOurStore = new CineStore();
    
public voidopen()

        initDecoder();
    
public intprocess(javax.media.Buffer inputBuffer, javax.media.Buffer outputBuffer)


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

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

      VideoFormat ivf=(VideoFormat) inputBuffer.getFormat();
      int inLength=inputBuffer.getLength();
      int inMaxLength=ivf.getMaxDataLength();
      int outMaxLength=outputFormat.getMaxDataLength();

      byte[] inData =(byte[]) inputBuffer.getData();
      int[] outData = validateIntArraySize(outputBuffer,outMaxLength );

      if (refData == null) {
	  refData = outData;
	  outputBuffer.setData(null);
	  outData = validateIntArraySize(outputBuffer, outMaxLength);
      }

      outputBuffer.setData(refData); // temporarily
      
      // the java decoder relies on output Buffer format
      outputBuffer.setFormat(outputFormat);

      fOurStore.DoFrame(inputBuffer, outputBuffer, fOurStore);

      System.arraycopy(refData, 0,
		       outData, 0,
		       outMaxLength); // make a copy

      outputBuffer.setData(outData);  // put it back in the buffer
      
      updateOutput(outputBuffer,outputFormat, outMaxLength, 0);

      return BUFFER_PROCESSED_OK;
    
public voidreset()

        // no need to init decoder as first frame is always a key frame
    
protected voidvideoResized()

        initDecoder();