Examples of IVideoPicture


Examples of com.xuggle.xuggler.IVideoPicture

        break;
      }
    }
    assertTrue("Could not find video stream", videoStream >= 0);
   
    IVideoPicture picture = IVideoPicture.make(buffer,
        h.mCoders[videoStream].getPixelType(),
        h.mCoders[videoStream].getWidth(),
        h.mCoders[videoStream].getHeight());
    assertNotNull(picture);
    while (h.mContainer.readNextPacket(h.mPacket) == 0)
    {
      if (h.mPacket.getStreamIndex() == videoStream)
      {
        int offset = 0;
        while (offset < h.mPacket.getSize())
        {
          retval = h.mCoders[videoStream].decodeVideo(
              picture,
              h.mPacket,
              offset);
          assertTrue("could not decode any video", retval >0);
          offset += retval;
          if (picture.isComplete())
          {
            totalFrames ++;
            if (picture.isKeyFrame())
              totalKeyFrames++;
          }
        }
      } else {
        log.debug("skipping audio packet");
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

  public void testGetDataLineSize()
  {
    final int WIDTH = 420;
    final int HEIGHT= 360;
    final IPixelFormat.Type TYPE = IPixelFormat.Type.YUV420P;
    IVideoPicture pic = IVideoPicture.make(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));
    assertEquals(0, pic.getDataLineSize(3));
    assertEquals(-1, pic.getDataLineSize(-1));
    assertEquals(-1, pic.getDataLineSize(4));
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

  {
    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));
    assertEquals(0, pic.getDataLineSize(3));
    assertEquals(-1, pic.getDataLineSize(-1));
    assertEquals(-1, pic.getDataLineSize(4));
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    log.debug("Testing {}", "testCorrectRefCounting");
    assertEquals("objects already allocated?",
        0, JNIMemoryManager.getMgr().getNumPinnedObjects());
       
    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());
    log.trace("delete object");
    obj.delete();
    log.trace("do second ref count check");
    assertEquals(1, copy.getCurrentRefCount());
    copy.delete();
    assertEquals("Looks like at least one object is pinned", 0,
        JNIMemoryManager.getMgr().getNumPinnedObjects());
    mSuccess = true;
  }
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

        0, JNIMemoryManager.getMgr().getNumPinnedObjects());
       
    int numLoops = 100;
    for (int i = 0; i < numLoops; i++)
    {
      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.xuggler.IVideoPicture

    int numLoops = 1000;
    for (int i = 0; i < numLoops; i++)
    {
      // that's 2000x2000x3 bytes... if we're not freeing right it'll
      // show up quick.
      IVideoPicture obj = IVideoPicture.make(
          IPixelFormat.Type.YUV420P, 2000, 2000);
      assertNotNull("could not allocate frame", obj);
      assertNotNull("could not allocate underlying data", obj.getData());
      obj = null;
    }

    // everything should be
    log.debug("Test finished; cleaning up: {}",
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    log.debug("Testing {}", "testLeakLargeFrame");

    log.trace("create a frame");
    // that's 2000x2000x3 bytes... if we're not freeing right it'll
    // show up quick.
    IVideoPicture obj = IVideoPicture.make(
        IPixelFormat.Type.YUV420P, 2000, 2000);
    assertNotNull("could not allocate frame", obj);
    log.trace("force frame data allocation");
   
    // Force an allocation
    assertNotNull("could not allocate underlying data", obj.getData());

    log.trace("create java byte array for fun");
    Byte[] arrayToLeak = new Byte[1000000]; // Who'd miss 1 Meg?
    assertNotNull("could not allocate large array to leak", arrayToLeak);
    log.trace("leak java byte array");
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

  public void testOutOfMemoryIVideoPicture()
  {
    IMediaAllocator allocator = new IMediaAllocator(){
      public IMediaData getMedia()
      {
        IVideoPicture media = IVideoPicture.make(IPixelFormat.Type.YUV420P,
            1024, 1024);
        if (media == null)
          throw new OutOfMemoryError();
        media.setComplete(true,
            IPixelFormat.Type.YUV420P, 1024, 1024, 0);
        return media;
      }
    };
    log.debug("Testing Video Picture Out Of Memory Handling");
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    }

    // create the video picture and get it's underling buffer

    final AtomicReference<JNIReference> ref = new AtomicReference<JNIReference>(null);
    IVideoPicture resamplePicture = null;
    try
    {
      IVideoPicture picture = IVideoPicture.make(getRequiredPictureType(), image.getWidth(),
          image.getHeight());

      ByteBuffer pictureByteBuffer = picture.getByteBuffer(ref);

      if (imageInts != null)
      {
        pictureByteBuffer.order(ByteOrder.BIG_ENDIAN);
        IntBuffer pictureIntBuffer = pictureByteBuffer.asIntBuffer();
        pictureIntBuffer.put(imageInts);
      }
      else
      {
        pictureByteBuffer.put(imageBytes);
      }
      pictureByteBuffer = null;
      picture.setComplete(true, getRequiredPictureType(), image.getWidth(),
          image.getHeight(), timestamp);

      // resample as needed
      if (willResample()) {
        resamplePicture = picture;
View Full Code Here

Examples of com.xuggle.xuggler.IVideoPicture

    validatePicture(picture);

    // resample as needed

    IVideoPicture resamplePic = null;
    final AtomicReference<JNIReference> ref =
      new AtomicReference<JNIReference>(null);
    try
    {
      if (willResample())
      {
        resamplePic = resample(picture, mToImageResampler);
        picture = resamplePic;
      }
      // get picture parameters

      final int w = picture.getWidth();
      final int h = picture.getHeight();

      // make a copy of the raw bytes in the picture and convert those to
      // integers

      final ByteBuffer byteBuf = picture.getByteBuffer(ref);

      // now, for this class of problems, we don't want the code
      // to switch byte order, so we'll pretend it's in native java order

      byteBuf.order(ByteOrder.BIG_ENDIAN);
      final IntBuffer intBuf = byteBuf.asIntBuffer();
      final int[] ints = new int[picture.getSize() / 4];
      intBuf.get(ints, 0, ints.length);

      // create the data buffer from the ints

      final DataBufferInt db = new DataBufferInt(ints, ints.length);

      // create an a sample model which matches the byte layout of the
      // image data and raster which contains the data which now can be
      // properly interpreted

      final SampleModel sm = new SinglePixelPackedSampleModel(db.getDataType(),
          w, h, mBitMasks);
      final WritableRaster wr = Raster.createWritableRaster(sm, db, null);

      // return a new image created from the color model and raster

      return new BufferedImage(mColorModel, wr, false, null);
    }
    finally
    {
      if (resamplePic != null)
        resamplePic.delete();
      if (ref.get() != null)
        ref.get().delete();
    }
  }
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.