Package com.xuggle.ferry

Examples of com.xuggle.ferry.IBuffer


  {
    // free up any references from other tests
    JNIMemoryManager.getMgr().flush();
    char[] in = new char[]{ 0x38, 0x2C, 0x18, 0x7F };
    char[] out = new char[in.length];
    IBuffer buf = IBuffer.make(null, 1024);
    buf.put(in, 0, 0, in.length);
    buf.get(0, out, 0, in.length);
    for(int i = 0; i < in.length; i++)
      assertEquals("mismatched bytes at " + i,
          in[i], out[i]);
    buf.delete();
    assertEquals("more objects around than expected",
        0, JNIMemoryManager.getMgr().getNumPinnedObjects());
  }
View Full Code Here


  {
    // free up any references from other tests
    JNIMemoryManager.getMgr().flush();
    long[] in = new long[]{ 0x38, 0x2C, 0x18, 0x7F };
    long[] out = new long[in.length];
    IBuffer buf = IBuffer.make(null, 1024);
    buf.put(in, 0, 0, in.length);
    buf.get(0, out, 0, in.length);
    for(int i = 0; i < in.length; i++)
      assertEquals("mismatched bytes at " + i,
          in[i], out[i]);
    buf.delete();
    assertEquals("more objects around than expected",
        0, JNIMemoryManager.getMgr().getNumPinnedObjects());
  }
View Full Code Here

  {
    // free up any references from other tests
    JNIMemoryManager.getMgr().flush();
    double[] in = new double[]{ 0x38, 0x2C, 0x18, 0x7F };
    double[] out = new double[in.length];
    IBuffer buf = IBuffer.make(null, 1024);
    buf.put(in, 0, 0, in.length);
    buf.get(0, out, 0, in.length);
    for(int i = 0; i < in.length; i++)
      assertEquals("mismatched bytes at " + i,
          in[i], out[i]);
    buf.delete();
    assertEquals("more objects around than expected",
        0, JNIMemoryManager.getMgr().getNumPinnedObjects());
  }
View Full Code Here

  {
    // free up any references from other tests
    JNIMemoryManager.getMgr().flush();
    float[] in = new float[]{ 0x38, 0x2C, 0x18, 0x7F };
    float[] out = new float[in.length];
    IBuffer buf = IBuffer.make(null, 1024);
    buf.put(in, 0, 0, in.length);
    buf.get(0, out, 0, in.length);
    for(int i = 0; i < in.length; i++)
      assertEquals("mismatched bytes at " + i,
          in[i], out[i]);
    buf.delete();
    assertEquals("more objects around than expected",
        0, JNIMemoryManager.getMgr().getNumPinnedObjects());
  }
View Full Code Here

  public void testFrameCreationFromBuffer()
  {
    int width=100;
    int height=100;
    IPixelFormat.Type format = IPixelFormat.Type.BGR24;
    IBuffer buffer = IBuffer.make(null, width*height*3);
    // put fake data in buffer
    byte[] bytes=new byte[1];
    for(int i = 0; i < buffer.getBufferSize(); i++)
    {
      bytes[0] = (byte)i;
      buffer.put(bytes, 0, i, 1);
    }
    IVideoPicture picture = IVideoPicture.make(buffer, format, width, height);
    assertNotNull(picture);
    assertEquals(buffer.getBufferSize(), picture.getSize());
   
    for(int i = 0; i < picture.getSize(); i++)
    {
      picture.get(i, bytes, 0, 1);
      assertEquals((byte)i, bytes[0]);
View Full Code Here

  }

  @Test
  public void testReadingFramesIntoIBuffers()
  {
    IBuffer buffer = IBuffer.make(null, 424*176*3); // should be bigger than needed
    Helper h = new Helper();
   
    // CHANGE THESE IF YOU CHANGE THE INPUT FILE
    int expectedFrames = 2236;
    int expectedKeyFrames = 270;
View Full Code Here

  public void testGetDataLineSizeFromIBuffer()
  {
    final int WIDTH = 420;
    final int HEIGHT= 360;
    final IPixelFormat.Type TYPE = IPixelFormat.Type.YUV420P;
    final IBuffer buf = IBuffer.make(null, (int) (WIDTH*HEIGHT*1.5));
    IVideoPicture pic = IVideoPicture.make(buf, TYPE, WIDTH, HEIGHT);
    pic.setComplete(true, TYPE, WIDTH, HEIGHT, 0);
    assertEquals(WIDTH, pic.getDataLineSize(0));
    assertEquals(WIDTH/2, pic.getDataLineSize(1));
    assertEquals(WIDTH/2, pic.getDataLineSize(2));
View Full Code Here

   * Test we can create an ibuffer of the right size.
   */
  @Test
  public void testCreation()
  {
    IBuffer buf = IBuffer.make(null, 1024);
    assertNotNull(buf);
    assertTrue(buf.getBufferSize()>=1024);
  }
View Full Code Here

   */
  @Test
  public void testCreateFromBytes()
  {
    byte buffer[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9 };
    IBuffer buf = IBuffer.make(null, buffer, 0, buffer.length);
    assertNotNull(buf);
    assertEquals(buf.getBufferSize(), buffer.length);
    byte outBuffer[] = buf.getByteArray(0, buffer.length);
    assertNotNull(outBuffer);
    assertEquals(outBuffer.length, buffer.length);
    assertNotSame(buf, outBuffer);
    for(int i =0 ; i < buffer.length; i++)
    {
View Full Code Here

   */
  @Test
  public void testCanDirectlyModifyNativeBytes()
  {
    byte buffer[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9 };
    IBuffer buf = IBuffer.make(null, buffer, 0, buffer.length);
    assertNotNull(buf);
    assertEquals(buf.getBufferSize(), buffer.length);
   
    // this give us the native bytes
    java.nio.ByteBuffer nativeBytes = buf.getByteBuffer(0, buffer.length);
    assertNotNull(nativeBytes);
    for(int i = 0; i < buffer.length; i++)
    {
      nativeBytes.put(i, (byte)(9-buffer[i])); // reverse the order of the integers
    }
    // we can release it.  no "update" method should be required.  It should
    // have modified the underlying C++ bytes.
    nativeBytes = null;
   
    // now, get a copy of the bytes in the IBuffer and make sure
    // the order of bytes was reversed.
    byte outBuffer[] = buf.getByteArray(0, buffer.length);
    assertNotNull(outBuffer);
    assertEquals(outBuffer.length, buffer.length);
    assertNotSame(buf, outBuffer);
    for(int i =0 ; i < buffer.length; i++)
    {
View Full Code Here

TOP

Related Classes of com.xuggle.ferry.IBuffer

Copyright © 2018 www.massapicom. 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.