Commit 442b0ad0 authored by fbarchard@google.com's avatar fbarchard@google.com

Call CanonicalCode in convert functions and add unittest for function.

BUG=none
TEST=video_common_test added
Review URL: https://webrtc-codereview.appspot.com/1001007

git-svn-id: http://libyuv.googlecode.com/svn/trunk@521 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent f491a094
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 520 Version: 521
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 520 #define LIBYUV_VERSION 521
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
'unit_test/scale_argb_test.cc', 'unit_test/scale_argb_test.cc',
'unit_test/scale_test.cc', 'unit_test/scale_test.cc',
'unit_test/unit_test.cc', 'unit_test/unit_test.cc',
'unit_test/video_common_test.cc',
'unit_test/version_test.cc', 'unit_test/version_test.cc',
], ],
'conditions': [ 'conditions': [
......
...@@ -1848,7 +1848,8 @@ int ConvertToI420(const uint8* sample, ...@@ -1848,7 +1848,8 @@ int ConvertToI420(const uint8* sample,
int src_width, int src_height, int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
RotationMode rotation, RotationMode rotation,
uint32 format) { uint32 fourcc) {
uint32 format = CanonicalFourCC(fourcc);
if (!y || !u || !v || !sample || if (!y || !u || !v || !sample ||
src_width <= 0 || dst_width <= 0 || src_width <= 0 || dst_width <= 0 ||
src_height == 0 || dst_height == 0) { src_height == 0 || dst_height == 0) {
......
...@@ -1033,7 +1033,8 @@ int ConvertToARGB(const uint8* sample, size_t sample_size, ...@@ -1033,7 +1033,8 @@ int ConvertToARGB(const uint8* sample, size_t sample_size,
int src_width, int src_height, int src_width, int src_height,
int dst_width, int dst_height, int dst_width, int dst_height,
RotationMode rotation, RotationMode rotation,
uint32 format) { uint32 fourcc) {
uint32 format = CanonicalFourCC(fourcc);
if (dst_argb == NULL || sample == NULL || if (dst_argb == NULL || sample == NULL ||
src_width <= 0 || dst_width <= 0 || src_width <= 0 || dst_width <= 0 ||
src_height == 0 || dst_height == 0) { src_height == 0 || dst_height == 0) {
......
...@@ -1060,7 +1060,8 @@ int ConvertFromI420(const uint8* y, int y_stride, ...@@ -1060,7 +1060,8 @@ int ConvertFromI420(const uint8* y, int y_stride,
const uint8* v, int v_stride, const uint8* v, int v_stride,
uint8* dst_sample, int dst_sample_stride, uint8* dst_sample, int dst_sample_stride,
int width, int height, int width, int height,
uint32 format) { uint32 fourcc) {
uint32 format = CanonicalFourCC(fourcc);
if (!y || !u|| !v || !dst_sample || if (!y || !u|| !v || !dst_sample ||
width <= 0 || height == 0) { width <= 0 || height == 0) {
return -1; return -1;
......
...@@ -982,6 +982,8 @@ int ARGBColorTable(uint8* dst_argb, int dst_stride_argb, ...@@ -982,6 +982,8 @@ int ARGBColorTable(uint8* dst_argb, int dst_stride_argb,
// e.g. rgb / qvalue * qvalue + qvalue / 2 // e.g. rgb / qvalue * qvalue + qvalue / 2
// But the low levels implement efficiently with 3 parameters, and could be // But the low levels implement efficiently with 3 parameters, and could be
// used for other high level operations. // used for other high level operations.
// dst_argb[0] = (b * scale >> 16) * interval_size + interval_offset;
// where scale is 1 / interval_size as a fixed point value.
// The divide is replaces with a multiply by reciprocal fixed point multiply. // The divide is replaces with a multiply by reciprocal fixed point multiply.
// Caveat - although SSE2 saturates, the C function does not and should be used // Caveat - although SSE2 saturates, the C function does not and should be used
// with care if doing anything but quantization. // with care if doing anything but quantization.
......
/*
* Copyright 2012 The LibYuv Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <stdlib.h>
#include <string.h>
#include "libyuv/video_common.h"
#include "../unit_test/unit_test.h"
namespace libyuv {
// Tests SVN version against include/libyuv/version.h
// SVN version is bumped by documentation changes as well as code.
// Although the versions should match, once checked in, a tolerance is allowed.
TEST_F(libyuvTest, TestCanonicalFourCC) {
EXPECT_EQ(FOURCC_YUY2, CanonicalFourCC(FOURCC_YUYV));
EXPECT_EQ(FOURCC_YUY2, CanonicalFourCC(FOURCC_YUVS));
}
} // namespace libyuv
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment