Package tvi.webrtc

Class YuvHelper

java.lang.Object
tvi.webrtc.YuvHelper

public class YuvHelper extends Object
Wraps libyuv methods to Java. All passed byte buffers must be direct byte buffers.
  • Constructor Details

    • YuvHelper

      public YuvHelper()
  • Method Details

    • I420Copy

      public static void I420Copy(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int dstWidth, int dstHeight, int dstStrideY, int dstSliceHeightY, int dstStrideU, int dstSliceHeightU)
      Copy I420 Buffer to a contiguously allocated buffer.

      In Android, MediaCodec can request a buffer of a specific layout with the stride and slice-height (or plane height), and this function is used in this case.

      For more information, see https://cs.android.com/android/platform/superproject/+/64fea7e5726daebc40f46890100837c01091100d:frameworks/base/media/java/android/media/MediaFormat.java;l=568

      Parameters:
      dstStrideY - the stride of output buffers' Y plane.
      dstSliceHeightY - the slice-height of output buffer's Y plane.
      dstStrideU - the stride of output buffers' U (and V) plane.
      dstSliceHeightU - the slice-height of output buffer's U (and V) plane
    • I420Copy

      public static void I420Copy(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int dstWidth, int dstHeight)
      Helper method for copying I420 to tightly packed destination buffer.
    • I420ToNV12

      public static void I420ToNV12(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int dstWidth, int dstHeight, int dstStrideY, int dstSliceHeightY)
      Copy I420 Buffer to a contiguously allocated buffer.
      Parameters:
      dstStrideY - the stride of output buffers' Y plane.
      dstSliceHeightY - the slice-height of output buffer's Y plane.
    • I420ToNV12

      public static void I420ToNV12(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int dstWidth, int dstHeight)
      Helper method for copying I420 to tightly packed NV12 destination buffer.
    • I420Rotate

      public static void I420Rotate(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int srcWidth, int srcHeight, int rotationMode)
      Helper method for rotating I420 to tightly packed destination buffer.
    • copyPlane

      public static void copyPlane(ByteBuffer src, int srcStride, ByteBuffer dst, int dstStride, int width, int height)
      Helper method for copying a single colour plane.
    • ABGRToI420

      public static void ABGRToI420(ByteBuffer src, int srcStride, ByteBuffer dstY, int dstStrideY, ByteBuffer dstU, int dstStrideU, ByteBuffer dstV, int dstStrideV, int width, int height)
      Converts ABGR little endian (rgba in memory) to I420.
    • I420Copy

      public static void I420Copy(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dstY, int dstStrideY, ByteBuffer dstU, int dstStrideU, ByteBuffer dstV, int dstStrideV, int width, int height)
      Copies I420 to the I420 dst buffer.

      Unlike `libyuv::I420Copy`, this function checks if the height <= 0, so flipping is not supported.

    • I420ToNV12

      public static void I420ToNV12(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dstY, int dstStrideY, ByteBuffer dstUV, int dstStrideUV, int width, int height)
    • I420Rotate

      public static void I420Rotate(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dstY, int dstStrideY, ByteBuffer dstU, int dstStrideU, ByteBuffer dstV, int dstStrideV, int srcWidth, int srcHeight, int rotationMode)