aboutsummaryrefslogtreecommitdiff
path: root/source/row_common.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2021-03-24 13:45:04 -0700
committerFrank Barchard <fbarchard@chromium.org>2021-03-24 21:37:10 +0000
commit312c02a5aad4adda67cb2e0cc93a497d12845522 (patch)
treece776a4db30d2319fad3bbf41fe48d6cdf1e2602 /source/row_common.cc
parentd8f1bfc9816a9fc76f3a25cc0ee272fb9c07622a (diff)
downloadlibyuv-312c02a5aad4adda67cb2e0cc93a497d12845522.tar.gz
Fixes for SplitUVPlane_16 and MergeUVPlane_16
Planar functions pass depth instead of scale factor. Row functions pass shift instead of depth. Add assert to C. AVX shift instruction expects a single shift value in XMM. Neon pass shift as input (not output). Split Neon reimplemented as left shift on shorts by negative to achieve right shift. Add planar unitests Bug: libyuv:888 Change-Id: I8fe62d3d777effc5321c361cd595c58b7f93807e Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/2782086 Reviewed-by: richard winterton <rrwinterton@gmail.com> Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Diffstat (limited to 'source/row_common.cc')
-rw-r--r--source/row_common.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/row_common.cc b/source/row_common.cc
index b80e0b3b..0e84961b 100644
--- a/source/row_common.cc
+++ b/source/row_common.cc
@@ -10,6 +10,7 @@
#include "libyuv/row.h"
+#include <assert.h>
#include <stdio.h>
#include <string.h> // For memcpy and memset.
@@ -3045,6 +3046,8 @@ void MergeUVRow_16_C(const uint16_t* src_u,
int depth,
int width) {
int shift = 16 - depth;
+ assert(depth >= 8);
+ assert(depth <= 16);
int x;
for (x = 0; x < width; ++x) {
dst_uv[0] = src_u[x] << shift;
@@ -3061,6 +3064,8 @@ void SplitUVRow_16_C(const uint16_t* src_uv,
int width) {
int shift = 16 - depth;
int x;
+ assert(depth >= 8);
+ assert(depth <= 16);
for (x = 0; x < width; ++x) {
dst_u[x] = src_uv[0] >> shift;
dst_v[x] = src_uv[1] >> shift;
@@ -3098,6 +3103,9 @@ void Convert16To8Row_C(const uint16_t* src_y,
int scale,
int width) {
int x;
+ assert(scale >= 256);
+ assert(scale <= 32768);
+
for (x = 0; x < width; ++x) {
dst_y[x] = clamp255((src_y[x] * scale) >> 16);
}