From 00112748e187c16693363ec157e42a7738312128 Mon Sep 17 00:00:00 2001 From: Sergio Garcia Murillo Date: Mon, 4 Apr 2022 12:41:24 +0200 Subject: [PATCH] rename functions to be moved to libyuv Bug: webrtc:13826 Change-Id: I0d694cbe35a272fbe5da9dc6e74c88a976458df8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257441 Reviewed-by: Ilya Nikolaevskiy Reviewed-by: Niels Moller Commit-Queue: Mirko Bonadei Reviewed-by: Frank Barchard Cr-Commit-Position: refs/heads/main@{#36468} --- api/video/i422_buffer.cc | 87 ++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/api/video/i422_buffer.cc b/api/video/i422_buffer.cc index 92f0c21f7d..d6cf0d6c97 100644 --- a/api/video/i422_buffer.cc +++ b/api/video/i422_buffer.cc @@ -32,21 +32,25 @@ int I422DataSize(int height, int stride_y, int stride_u, int stride_v) { return stride_y * height + stride_u * height + stride_v * height; } -int I422Rotate(const uint8_t* src_y, - int src_stride_y, - const uint8_t* src_u, - int src_stride_u, - const uint8_t* src_v, - int src_stride_v, - uint8_t* dst_y, - int dst_stride_y, - uint8_t* dst_u, - int dst_stride_u, - uint8_t* dst_v, - int dst_stride_v, - int width, - int height, - enum libyuv::RotationMode mode) { +// TODO(sergio.garcia.murillo@gmail.com): Remove as soon it is available in +// libyuv. Due to the rotate&scale required, this function may not be merged in +// to libyuv inmediatelly. +// https://bugs.chromium.org/p/libyuv/issues/detail?id=926 +int webrtcI422Rotate(const uint8_t* src_y, + int src_stride_y, + const uint8_t* src_u, + int src_stride_u, + const uint8_t* src_v, + int src_stride_v, + uint8_t* dst_y, + int dst_stride_y, + uint8_t* dst_u, + int dst_stride_u, + uint8_t* dst_v, + int dst_stride_v, + int width, + int height, + enum libyuv::RotationMode mode) { int halfwidth = (width + 1) >> 1; int halfheight = (height + 1) >> 1; if (!src_y || !src_u || !src_v || width <= 0 || height == 0 || !dst_y || @@ -115,23 +119,25 @@ int I422Rotate(const uint8_t* src_y, return -1; } -int I422Scale(const uint8_t* src_y, - int src_stride_y, - const uint8_t* src_u, - int src_stride_u, - const uint8_t* src_v, - int src_stride_v, - int src_width, - int src_height, - uint8_t* dst_y, - int dst_stride_y, - uint8_t* dst_u, - int dst_stride_u, - uint8_t* dst_v, - int dst_stride_v, - int dst_width, - int dst_height, - enum libyuv::FilterMode filtering) { +// TODO(sergio.garcia.murillo@gmail.com): Remove this function with libyuv one +// as soon as the dependency is updated. +int webrtcI422Scale(const uint8_t* src_y, + int src_stride_y, + const uint8_t* src_u, + int src_stride_u, + const uint8_t* src_v, + int src_stride_v, + int src_width, + int src_height, + uint8_t* dst_y, + int dst_stride_y, + uint8_t* dst_u, + int dst_stride_u, + uint8_t* dst_v, + int dst_stride_v, + int dst_width, + int dst_height, + enum libyuv::FilterMode filtering) { if (!src_y || !src_u || !src_v || src_width <= 0 || src_height == 0 || src_width > 32768 || src_height > 32768 || !dst_y || !dst_u || !dst_v || dst_width <= 0 || dst_height <= 0) { @@ -250,13 +256,13 @@ rtc::scoped_refptr I422Buffer::Rotate( rtc::scoped_refptr buffer = I422Buffer::Create(rotated_width, rotated_height); - RTC_CHECK_EQ( - 0, - I422Rotate(src.DataY(), src.StrideY(), src.DataU(), src.StrideU(), - src.DataV(), src.StrideV(), buffer->MutableDataY(), - buffer->StrideY(), buffer->MutableDataU(), buffer->StrideU(), - buffer->MutableDataV(), buffer->StrideV(), src.width(), - src.height(), static_cast(rotation))); + RTC_CHECK_EQ(0, + webrtcI422Rotate( + src.DataY(), src.StrideY(), src.DataU(), src.StrideU(), + src.DataV(), src.StrideV(), buffer->MutableDataY(), + buffer->StrideY(), buffer->MutableDataU(), buffer->StrideU(), + buffer->MutableDataV(), buffer->StrideV(), src.width(), + src.height(), static_cast(rotation))); return buffer; } @@ -337,7 +343,8 @@ void I422Buffer::CropAndScaleFrom(const I422BufferInterface& src, src.DataU() + src.StrideU() * uv_offset_y + uv_offset_x; const uint8_t* v_plane = src.DataV() + src.StrideV() * uv_offset_y + uv_offset_x; - int res = I422Scale(y_plane, src.StrideY(), u_plane, src.StrideU(), v_plane, + int res = + webrtcI422Scale(y_plane, src.StrideY(), u_plane, src.StrideU(), v_plane, src.StrideV(), crop_width, crop_height, MutableDataY(), StrideY(), MutableDataU(), StrideU(), MutableDataV(), StrideV(), width(), height(), libyuv::kFilterBox);