Package tvi.webrtc

Class YuvHelper


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

      Constructors 
      Constructor Description
      YuvHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void ABGRToI420​(java.nio.ByteBuffer src, int srcStride, java.nio.ByteBuffer dstY, int dstStrideY, java.nio.ByteBuffer dstU, int dstStrideU, java.nio.ByteBuffer dstV, int dstStrideV, int width, int height)
      Converts ABGR little endian (rgba in memory) to I420.
      static void copyPlane​(java.nio.ByteBuffer src, int srcStride, java.nio.ByteBuffer dst, int dstStride, int width, int height)
      Helper method for copying a single colour plane.
      static void I420Copy​(java.nio.ByteBuffer srcY, int srcStrideY, java.nio.ByteBuffer srcU, int srcStrideU, java.nio.ByteBuffer srcV, int srcStrideV, java.nio.ByteBuffer dst, int dstWidth, int dstHeight)
      Helper method for copying I420 to tightly packed destination buffer.
      static void I420Copy​(java.nio.ByteBuffer srcY, int srcStrideY, java.nio.ByteBuffer srcU, int srcStrideU, java.nio.ByteBuffer srcV, int srcStrideV, java.nio.ByteBuffer dst, int dstWidth, int dstHeight, int dstStrideY, int dstSliceHeightY, int dstStrideU, int dstSliceHeightU)
      Copy I420 Buffer to a contiguously allocated buffer.
      static void I420Copy​(java.nio.ByteBuffer srcY, int srcStrideY, java.nio.ByteBuffer srcU, int srcStrideU, java.nio.ByteBuffer srcV, int srcStrideV, java.nio.ByteBuffer dstY, int dstStrideY, java.nio.ByteBuffer dstU, int dstStrideU, java.nio.ByteBuffer dstV, int dstStrideV, int width, int height)
      Copies I420 to the I420 dst buffer.
      static void I420Rotate​(java.nio.ByteBuffer srcY, int srcStrideY, java.nio.ByteBuffer srcU, int srcStrideU, java.nio.ByteBuffer srcV, int srcStrideV, java.nio.ByteBuffer dst, int srcWidth, int srcHeight, int rotationMode)
      Helper method for rotating I420 to tightly packed destination buffer.
      static void I420Rotate​(java.nio.ByteBuffer srcY, int srcStrideY, java.nio.ByteBuffer srcU, int srcStrideU, java.nio.ByteBuffer srcV, int srcStrideV, java.nio.ByteBuffer dstY, int dstStrideY, java.nio.ByteBuffer dstU, int dstStrideU, java.nio.ByteBuffer dstV, int dstStrideV, int srcWidth, int srcHeight, int rotationMode)  
      static void I420ToNV12​(java.nio.ByteBuffer srcY, int srcStrideY, java.nio.ByteBuffer srcU, int srcStrideU, java.nio.ByteBuffer srcV, int srcStrideV, java.nio.ByteBuffer dst, int dstWidth, int dstHeight)
      Helper method for copying I420 to tightly packed NV12 destination buffer.
      static void I420ToNV12​(java.nio.ByteBuffer srcY, int srcStrideY, java.nio.ByteBuffer srcU, int srcStrideU, java.nio.ByteBuffer srcV, int srcStrideV, java.nio.ByteBuffer dst, int dstWidth, int dstHeight, int dstStrideY, int dstSliceHeightY)
      Copy I420 Buffer to a contiguously allocated buffer.
      static void I420ToNV12​(java.nio.ByteBuffer srcY, int srcStrideY, java.nio.ByteBuffer srcU, int srcStrideU, java.nio.ByteBuffer srcV, int srcStrideV, java.nio.ByteBuffer dstY, int dstStrideY, java.nio.ByteBuffer dstUV, int dstStrideUV, int width, int height)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • YuvHelper

        public YuvHelper()
    • Method Detail

      • I420Copy

        public static void I420Copy​(java.nio.ByteBuffer srcY,
                                    int srcStrideY,
                                    java.nio.ByteBuffer srcU,
                                    int srcStrideU,
                                    java.nio.ByteBuffer srcV,
                                    int srcStrideV,
                                    java.nio.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​(java.nio.ByteBuffer srcY,
                                    int srcStrideY,
                                    java.nio.ByteBuffer srcU,
                                    int srcStrideU,
                                    java.nio.ByteBuffer srcV,
                                    int srcStrideV,
                                    java.nio.ByteBuffer dst,
                                    int dstWidth,
                                    int dstHeight)
        Helper method for copying I420 to tightly packed destination buffer.
      • I420ToNV12

        public static void I420ToNV12​(java.nio.ByteBuffer srcY,
                                      int srcStrideY,
                                      java.nio.ByteBuffer srcU,
                                      int srcStrideU,
                                      java.nio.ByteBuffer srcV,
                                      int srcStrideV,
                                      java.nio.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​(java.nio.ByteBuffer srcY,
                                      int srcStrideY,
                                      java.nio.ByteBuffer srcU,
                                      int srcStrideU,
                                      java.nio.ByteBuffer srcV,
                                      int srcStrideV,
                                      java.nio.ByteBuffer dst,
                                      int dstWidth,
                                      int dstHeight)
        Helper method for copying I420 to tightly packed NV12 destination buffer.
      • I420Rotate

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

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

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

        public static void I420Copy​(java.nio.ByteBuffer srcY,
                                    int srcStrideY,
                                    java.nio.ByteBuffer srcU,
                                    int srcStrideU,
                                    java.nio.ByteBuffer srcV,
                                    int srcStrideV,
                                    java.nio.ByteBuffer dstY,
                                    int dstStrideY,
                                    java.nio.ByteBuffer dstU,
                                    int dstStrideU,
                                    java.nio.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​(java.nio.ByteBuffer srcY,
                                      int srcStrideY,
                                      java.nio.ByteBuffer srcU,
                                      int srcStrideU,
                                      java.nio.ByteBuffer srcV,
                                      int srcStrideV,
                                      java.nio.ByteBuffer dstY,
                                      int dstStrideY,
                                      java.nio.ByteBuffer dstUV,
                                      int dstStrideUV,
                                      int width,
                                      int height)
      • I420Rotate

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