Examples of IBuffer


Examples of com.xuggle.ferry.IBuffer

    // Let's add some fake data
    byte[] fakeData = new byte[64*576];
    for(int i = 0; i < fakeData.length; i++)
      fakeData[i] = (byte)i; // garbage
   
    IBuffer buffer = IBuffer.make(null, fakeData, 0, fakeData.length);
    IAudioSamples samples = IAudioSamples.make(buffer,
        coder.getChannels(), coder.getSampleFormat());
    samples.setComplete(true,
        fakeData.length/2, coder.getSampleRate(),
        coder.getChannels(), coder.getSampleFormat(), 0);
View Full Code Here

Examples of com.xuggle.ferry.IBuffer

    retval = mCoder.open();
    assertTrue("Could not open codec", retval >= 0);
    int extraDataSize = mCoder.getExtraDataSize();
    assertEquals(expected.length, extraDataSize);

    IBuffer buffer = mCoder.getExtraData();
    assertNotNull(buffer);
    assertEquals(extraDataSize, buffer.getBufferSize());
    retval = mCoder.close();
    assertTrue("Could not close codec", retval >= 0);
    byte[] actual = new byte[expected.length];
    buffer.get(0, actual, 0, actual.length);
    for(int i = 0; i < expected.length; i++)
      assertEquals("differ at: "+i, expected[i], actual[i]);
  }
View Full Code Here

Examples of com.xuggle.ferry.IBuffer

  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

Examples of com.xuggle.ferry.IBuffer

  }

  @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

Examples of com.xuggle.ferry.IBuffer

  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

Examples of com.xuggle.ferry.IBuffer

  }
 
  @Test
  public void testReadingSamplesIntoIBuffer()
  {
    IBuffer buffer = IBuffer.make(null, 192000*2);
    Helper h = new Helper();
   
    h.setupReadingObject(h.sampleFile);
   
    int retval = -1;
View Full Code Here

Examples of com.xuggle.ferry.IBuffer

    samples.setComplete(true, sampleRate, sampleRate,
        channels, IAudioSamples.Format.FMT_S16, 0);
    assertTrue(samples.isComplete());
   
    IBuffer buffer;
    buffer = samples.getData();
    assertEquals(IBuffer.Type.IBUFFER_SINT16, buffer.getType());

    samples.setComplete(true, sampleRate, sampleRate,
        channels, IAudioSamples.Format.FMT_S32, 0);
    assertTrue(samples.isComplete());
    buffer = samples.getData();
    assertEquals(IBuffer.Type.IBUFFER_SINT32, buffer.getType());
}
View Full Code Here

Examples of com.xuggle.ferry.IBuffer

       
    log.trace("create a frame");
    IVideoPicture obj = IVideoPicture.make(IPixelFormat.Type.YUV420P, 2000,
        2000);
    log.trace("force frame data allocation");
    IBuffer buffer = obj.getData(); // Force an allocation
    buffer.delete(); // (and delete the reference)
    log.trace("copy frame reference");
    IVideoPicture copy = obj.copyReference();
    log.trace("do ref count check");
    assertEquals(2, copy.getCurrentRefCount());
    assertEquals(2, obj.getCurrentRefCount());
View Full Code Here

Examples of com.xuggle.ferry.IBuffer

    {
      IVideoPicture obj = IVideoPicture.make(IPixelFormat.Type.YUV420P, 2000,
          2000); // that's 2000x2000x3 bytes... if we're not freeing right it'll
                 // show up quick.
      assertNotNull("could not allocate object", obj);
      IBuffer buffer = obj.getData();
      assertNotNull("could not allocate underlying buffer", buffer);
      // log.trace("allocated frame: {} @ time: {}", i,
      buffer.delete();
      obj.delete();
    }
    assertEquals("objects already allocated?",
        0, JNIMemoryManager.getMgr().getNumPinnedObjects());
    mSuccess = true;
View Full Code Here

Examples of com.xuggle.ferry.IBuffer

      leakyMedia = new LinkedList<Tuple>();
      while (true)
      {
       
        IMediaData media = null;
        IBuffer buffer = null;
        AtomicReference<JNIReference> reference
        = new AtomicReference<JNIReference>(null);
        try {
          media = allocator.getMedia();
 
          buffer = media.getData();
          if (buffer == null) {
            log.debug("Could not get IBuffer");
            throw new OutOfMemoryError();
          }
 
          ByteBuffer bBuf = buffer.getByteBuffer(0,
              media.getSize(), reference);
          if (bBuf == null) {
            log.debug("Could not get ByteBuffer");
            throw new OutOfMemoryError();
          }
          // some OSes will cheat and not actually commit the
          // pages to memory unless you use them; so let's do
          // exactly that.
          for(int j = 0; i < media.getSize(); i++)
            bBuf.put(j, (byte) 0);
          Tuple tuple = new Tuple(bBuf, reference.get());
          leakyMedia.add(tuple);
          assertNotNull(tuple.getBuffer());
          assertNotNull(tuple.getReference());
          bytesBeforeFailure += media.getSize();
         
          if (bytesBeforeFailure > 4*1024*1024*1024)
          {
            // this test causes too much swapping on 64 bit machines, so
            // if we get this far, just return
            mSuccess = true;
            return;
          }
         
        } finally {
          if (media != null)
            media.delete();
          if (buffer != null)
            buffer.delete();
          if (i %100 == 0) {
            log.trace(
                "iteration: {}; allocated {} bytes; pinned: {}; holding: {}",
                new Object[]{i,
                bytesBeforeFailure,
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.