/// <summary> /// Encodes a frame. /// </summary> /// <seealso cref="IVideoEncoder.EncodeFrame"/> public int EncodeFrame(byte[] source, int srcOffset, byte[] destination, int destOffset, out bool isKeyFrame) { BitmapUtils.FlipVertical(source, srcOffset, sourceBuffer, 0, height, width * 4); BitmapUtils.Bgr32ToBgr24(sourceBuffer, 0, destination, destOffset, width * height); isKeyFrame = true; return(MaxEncodedSize); }
/// <summary> /// Encodes a frame. /// </summary> /// <seealso cref="IVideoEncoder.EncodeFrame"/> public int EncodeFrame(byte[] source, int srcOffset, byte[] destination, int destOffset, out bool isKeyFrame) { BitmapUtils.FlipVertical(source, srcOffset, sourceBuffer, 0, height, width * 4); for (var i = 0; i < height; i++) { BitmapUtils.Bgr32ToBgr24(sourceBuffer, i * width * 4, destination, destOffset + i * stride, width); } isKeyFrame = true; return(MaxEncodedSize); }
/// <summary> /// Encodes a frame. /// </summary> public int EncodeFrame(ReadOnlySpan <byte> source, Span <byte> destination, out bool isKeyFrame) { Argument.ConditionIsMet(4 * width * height <= source.Length, "Source end offset exceeds the source length."); // Flip vertical and convert to 24 bpp for (var y = 0; y < height; y++) { var srcOffset = y * width * 4; var destOffset = (height - 1 - y) * stride; BitmapUtils.Bgr32ToBgr24(source.Slice(srcOffset), destination.Slice(destOffset), width); } isKeyFrame = true; return(MaxEncodedSize); }
/// <summary> /// Encodes a frame. /// </summary> public int EncodeFrame(byte[] source, int srcOffset, byte[] destination, int destOffset, out bool isKeyFrame) { Argument.IsNotNull(source, nameof(source)); Argument.IsNotNegative(srcOffset, nameof(srcOffset)); Argument.ConditionIsMet(srcOffset + 4 * width * height <= source.Length, "Source end offset exceeds the source length."); Argument.IsNotNull(destination, nameof(destination)); Argument.IsNotNegative(destOffset, nameof(destOffset)); #if NET5_0_OR_GREATER return(EncodeFrame(source.AsSpan(srcOffset), destination.AsSpan(destOffset), out isKeyFrame)); #else // Flip vertical and convert to 24 bpp for (var y = 0; y < height; y++) { var srcLineOffset = srcOffset + y * width * 4; var destLineOffset = destOffset + (height - 1 - y) * stride; BitmapUtils.Bgr32ToBgr24(source, srcLineOffset, destination, destLineOffset, width); } isKeyFrame = true; return(MaxEncodedSize); #endif }