Examples of YUVFormat


Examples of javax.media.format.YUVFormat

    }
   
    {
      final MyBasicCodec c = new MyBasicCodec();
      final Buffer b = new Buffer();
      final Format f = new YUVFormat();
      b.setFormat(f);
      c.setInputFormat(new RGBFormat());
     
      assertEquals(c.doCheckInputBuffer(b), true);
    }
View Full Code Here

Examples of javax.media.format.YUVFormat

     
    }
    else if (c == YUVFormat.class)
    {
 
      final YUVFormat o = (YUVFormat) f;
      return "new YUVFormat(" +
      toLiteral(o.getSize()) +
      ", " + o.getMaxDataLength() +
      ", " + dataTypeToStr(o.getDataType()) +
      ", " + CGUtils.toLiteral(o.getFrameRate()) +
      ", " + o.getYuvType() // TODO: use constants
      ", " + o.getStrideY() +
      ", " + o.getStrideUV() +
      ", " + o.getOffsetY() +
      ", " + o.getOffsetU() +
      ", " + o.getOffsetV()
      + ")";
     
    }
    else if (c == JPEGFormat.class)
    {
 
      final JPEGFormat o = (JPEGFormat) f;
      return "new JPEGFormat(" +
      toLiteral(o.getSize()) +
      ", " + o.getMaxDataLength() +
      ", " + dataTypeToStr(o.getDataType()) +
      ", " + CGUtils.toLiteral(o.getFrameRate()) +
      ", " + o.getQFactor()
      ", " + o.getDecimation()
      + ")";

     
    }
    else if (c == IndexedColorFormat.class)
    {
 

      final IndexedColorFormat o = (IndexedColorFormat) f;
      return "new IndexedColorFormat(" +
      toLiteral(o.getSize()) +
      ", " + o.getMaxDataLength() +
      ", " + dataTypeToStr(o.getDataType()) +
      ", " + CGUtils.toLiteral(o.getFrameRate()) +
      ", " + o.getLineStride() // TODO: use constants
      ", " + o.getMapSize() +
      ", " + CGUtils.toLiteral(o.getRedValues()) +
      ", " + CGUtils.toLiteral(o.getGreenValues()) +
      ", " + CGUtils.toLiteral(o.getBlueValues())
      + ")";

     
    }
    else if (c == H263Format.class)
    {

      final H263Format o = (H263Format) f;
      return "new H263Format(" +
      toLiteral(o.getSize()) +
      ", " + o.getMaxDataLength() +
      ", " + dataTypeToStr(o.getDataType()) +
      ", " + CGUtils.toLiteral(o.getFrameRate()) +
      ", " + o.getAdvancedPrediction()
      ", " + o.getArithmeticCoding() +
      ", " + o.getErrorCompensation() +
      ", " + o.getHrDB() +
      ", " + o.getPBFrames() +
      ", " + o.getUnrestrictedVector()
      + ")";

     
    }
    else if (c == H261Format.class)
    {
 
      final H261Format o = (H261Format) f;
      return "new H261Format(" +
      toLiteral(o.getSize()) +
      ", " + o.getMaxDataLength() +
      ", " + dataTypeToStr(o.getDataType()) +
      ", " + CGUtils.toLiteral(o.getFrameRate()) +
      ", " + o.getStillImageTransmission()
      + ")";

     
    }
    else if (c == AudioFormat.class)
    {
      final AudioFormat o = (AudioFormat) f;
      return "new AudioFormat(" +
      CGUtils.toLiteral(o.getEncoding()) +
      ", " + CGUtils.toLiteral(o.getSampleRate()) +
      ", " + CGUtils.toLiteral(o.getSampleSizeInBits()) +
      ", " + CGUtils.toLiteral(o.getChannels()) +
      ", " + CGUtils.toLiteral(o.getEndian()) +
      ", " + CGUtils.toLiteral(o.getSigned()) +
      ", " + CGUtils.toLiteral(o.getFrameSizeInBits()) +
      ", " + CGUtils.toLiteral(o.getFrameRate()) +
      ", " + dataTypeToStr(o.getDataType())
      + ")";

     
    }
    else if (c == VideoFormat.class)
    {
     
      final VideoFormat o = (VideoFormat) f;
      return "new VideoFormat(" +
      CGUtils.toLiteral(o.getEncoding()) +
      ", " + toLiteral(o.getSize()) +
      ", " + o.getMaxDataLength() +
      ", " + dataTypeToStr(o.getDataType()) +
      ", " + CGUtils.toLiteral(o.getFrameRate())
      + ")";

     
    }
    else if (c == Format.class)
    {
 
      final Format o = (Format) f;
      return "new Format(" +
      CGUtils.toLiteral(o.getEncoding()) +
      ", " + dataTypeToStr(o.getDataType())
      + ")";

     
    }
    else if (c == FileTypeDescriptor.class)
    {
      final FileTypeDescriptor o = (FileTypeDescriptor) f;
      return "new FileTypeDescriptor(" +
      CGUtils.toLiteral(o.getEncoding())
      + ")";
    }
    else if (c == ContentDescriptor.class)
    {
      final ContentDescriptor o = (ContentDescriptor) f;
      return "new ContentDescriptor(" +
      CGUtils.toLiteral(o.getEncoding())
      + ")";
    }
    else if (c == com.sun.media.format.WavAudioFormat.class)
    {
      // TODO: are the parameters correct?
      final com.sun.media.format.WavAudioFormat o = (com.sun.media.format.WavAudioFormat) f;
      return "new com.sun.media.format.WavAudioFormat(" +
      CGUtils.toLiteral(o.getEncoding()) +
      ", " + CGUtils.toLiteral(o.getSampleRate()) +
      //", -1" + // int arg TODO - what is this?
      ", " + CGUtils.toLiteral(o.getSampleSizeInBits()) +
      ", " + CGUtils.toLiteral(o.getChannels()) +
      ", " + CGUtils.toLiteral(o.getFrameSizeInBits()) +
      ", " + CGUtils.toLiteral(o.getAverageBytesPerSecond()) +
      ", " + CGUtils.toLiteral(o.getEndian()) +
      ", " + CGUtils.toLiteral(o.getSigned()) +
      ", " + CGUtils.toLiteral((float) o.getFrameRate()) +
      ", " + dataTypeToStr(o.getDataType()) +
      ", " + CGUtils.toLiteral(o.getCodecSpecificHeader())
      + ")";
    }
    else
    throw new IllegalArgumentException("" + f.getClass());
      //System.err.println(f.getClass());
View Full Code Here

Examples of javax.media.format.YUVFormat

  }
 
  public void testBitMapInfo7()
  {
    {
      BitMapInfo b = new BitMapInfo(new YUVFormat());
      assertEquals(b.biBitCount, 24);
      assertEquals(b.biWidth, 320);
      assertEquals(b.biHeight, 240);
      assertEquals(b.biPlanes, 1);
      assertEquals(b.biSizeImage, -1);
      assertEquals(b.fourcc, "yuv");
      assertEquals(b.biXPelsPerMeter, 0);
      assertEquals(b.biYPelsPerMeter, 0);
      assertEquals(b.biClrUsed, 0);
      assertEquals(b.biClrImportant, 0);
      assertEquals(b.extraSize, 0);
      assertEquals(b.extraBytes, null);
      test(b);

    }
   
    int[] yuvTypes = new int[]{
        YUVFormat.YUV_411,
        YUVFormat.YUV_420,
        YUVFormat.YUV_422,
        YUVFormat.YUV_111,
        YUVFormat.YUV_YVU9,
        YUVFormat.YUV_YUYV,
        YUVFormat.YUV_SIGNED   
    };
    for (int i = 0; i < yuvTypes.length; ++i)
    {
      final int yuvType = yuvTypes[i];
      //System.out.println(yuvType);
     
      // TODO: test other constructors
      // TODO: how to get I420?
     
      YUVFormat f = new YUVFormat(yuvType);
      //System.out.println(f.getEncoding());
      BitMapInfo b = new BitMapInfo(f);
      if (yuvType == YUVFormat.YUV_411)
      { 
        assertEquals(b.biBitCount, 24);
View Full Code Here

Examples of javax.media.format.YUVFormat

       
       
      }
      else if (b.fourcc.equals("YV12"))
      {
        final YUVFormat f;
        if (j == 0)
          f = (YUVFormat) b.createVideoFormat(classes[i]);
        else
          f = (YUVFormat) b.createVideoFormat(classes[i], frameRates[j]);
       
        assertEquals(f.getEncoding(), "yuv");
        assertEquals(f.getYuvType(), YUVFormat.YUV_420);
        assertEquals(f.getDataType(), byte[].class);
        assertEquals(f.getFrameRate(), j == 0 ? -1.f : frameRates[j]);
        assertEquals(f.getSize(), new Dimension(b.biWidth, b.biHeight));
       
        assertEquals(f.getMaxDataLength(), b.biSizeImage); // sometimes 0
        assertEquals(f.getOffsetY(), 0);
        assertEquals(f.getOffsetU(), b.biWidth *  b.biHeight + (b.biWidth *  b.biHeight) / 4)// empirically determined
        //320x240: 96000
        // 96000 - 76800 = 19200.  96000 / 76800 = 1.25
        //
        assertEquals(f.getOffsetV(), b.biWidth *  b.biHeight);
       
        assertEquals(f.getStrideUV(), b.biWidth / 2);
        assertEquals(f.getStrideY(), b.biWidth)
       
      }
      else
      {
        final com.sun.media.format.AviVideoFormat f;
        if (j == 0)
          f = (com.sun.media.format.AviVideoFormat) b.createVideoFormat(classes[i]);
        else
          f = (com.sun.media.format.AviVideoFormat) b.createVideoFormat(classes[i], frameRates[j]);
        assertEquals(f.getEncoding(), b.fourcc);
        assertEquals(f.getBitsPerPixel(), b.biBitCount);
        assertEquals(f.getClrImportant(), b.biClrImportant);
        assertEquals(f.getClrUsed(), b.biClrUsed);
        assertEquals(f.getCodecSpecificHeader(), b.extraBytes);
        assertEquals(f.getDataType(), classes[i]);
        assertEquals(f.getFrameRate(), j == 0 ? -1.f : frameRates[j]);
        assertEquals(f.getImageSize(), b.biSizeImage);
        assertEquals(f.getMaxDataLength(), b.biSizeImage);
        assertEquals(f.getPlanes(), b.biPlanes);
        assertEquals(f.getSize(), new Dimension(b.biWidth, b.biHeight));
        assertEquals(f.getXPelsPerMeter(), b.biXPelsPerMeter);
        assertEquals(f.getYPelsPerMeter(), b.biYPelsPerMeter);
      }
    }
   

  }
View Full Code Here

Examples of javax.media.format.YUVFormat

  }
 
  public void testConstructors()
  {
    {
      final YUVFormat f1 = new YUVFormat();
      assertEquals(f1.getDataType(), byte[].class);
      assertEquals(f1.getFrameRate(), -1.f);
      assertEquals(f1.getMaxDataLength(), -1);
      assertEquals(f1.getSize(), null);
      assertEquals(f1.getYuvType(), -1);
      assertEquals(f1.getStrideY(), -1);
      assertEquals(f1.getStrideUV(), -1);
      assertEquals(f1.getOffsetY(), -1);
      assertEquals(f1.getOffsetU(), -1);
      assertEquals(f1.getOffsetV(), -1);
     
    }
   
   
    {
      final Dimension d = new Dimension(1, 2);
      final YUVFormat f1 = new YUVFormat(d, 1, int[].class, 2.f, 4, 5, 6, 7, 8, 9);
      assertEquals(f1.getDataType(), int[].class);
      assertEquals(f1.getFrameRate(), 2.f);
      assertEquals(f1.getMaxDataLength(), 1);
      assertEquals(f1.getSize(), new Dimension(1, 2));
      assertTrue(f1.getSize() != d);
      assertEquals(f1.getYuvType(), 4);
      assertEquals(f1.getStrideY(), 5);
      assertEquals(f1.getStrideUV(), 6);
      assertEquals(f1.getOffsetY(), 7);
      assertEquals(f1.getOffsetU(), 8);
      assertEquals(f1.getOffsetV(), 9);
    }
  }
View Full Code Here

Examples of javax.media.format.YUVFormat

  }
 
 
  public void testYUVFormat_ENCODING() throws Exception
  {
    assertEquals(new YUVFormat().getEncoding(), "yuv");
   
   
    final Field f = YUVFormat.class.getDeclaredField("ENCODING");
    f.setAccessible(true);
   
View Full Code Here

Examples of javax.media.format.YUVFormat

        if (input.hasToken(0)) {
            JMFImageToken jmfImageToken = (JMFImageToken) input.get(0);
            Buffer in = jmfImageToken.getValue();
            VideoFormat videoFormat = (VideoFormat) in.getFormat();
            YUVFormat yuvFormat = null;

            try {
                yuvFormat = (YUVFormat) videoFormat;
            } catch (ClassCastException ex) {
                throw new IllegalActionException(this, ex, "Failed to cast "
                        + videoFormat.getClass() + ":\n" + videoFormat
                        + "\nto YUVFormat\n" + "in.getFormat() was: "
                        + in.getFormat().getClass()
                        + "\nPerhaps the video source is not generating YUV?");
            }

            byte[] data = (byte[]) in.getData();

            if (data != null) {
                System.arraycopy(data, yuvFormat.getOffsetY(), YArray, 0,
                        YArray.length);
                System.arraycopy(data, yuvFormat.getOffsetU(), UArray, 0,
                        UArray.length);
                System.arraycopy(data, yuvFormat.getOffsetV(), VArray, 0,
                        VArray.length);

                for (int x = 0; x < _frameWidth; x += 1) {
                    for (int y = 0; y < _frameHeight; y += 1) {
                        int yComp = _getYComponent(x, y);
View Full Code Here

Examples of javax.media.format.YUVFormat

        // Set the video format type given which setting
        // the formatName parameter is set to.
        String typeName = formatName.getExpression();

        if (typeName.equals("YUV")) {
            _format = new YUVFormat();
        } else if (typeName.equals("RGB")) {
            _format = new RGBFormat();
        } else {
            throw new IllegalActionException(this,
                    "Unrecognized interpolation type: " + typeName);
View Full Code Here

Examples of javax.media.format.YUVFormat

        /** Return the supported input formats, which are YUV and RGB.
         *  @return the supported input formats.
         */
        public Format[] getSupportedInputFormats() {
            return new Format[] { new YUVFormat(), new RGBFormat() };
        }
View Full Code Here

Examples of javax.media.format.YUVFormat

         *  is non-null, then it is returned.
         *  @return the supported output formats.
         */
        public Format[] getSupportedOutputFormats(Format in) {
            if (in == null) {
                return new Format[] { new YUVFormat(), new RGBFormat() };
            } else {
                // If an input format is given, we use that input format
                // as the output since we are not modifying the bit stream
                // at all.
                Format[] outs = new Format[1];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.