Commit 4d67b3e8 authored by Frank Barchard's avatar Frank Barchard Committed by Commit Bot

Add H420 and H422 to ConvertToARGB()

H420/H422 are bt.720 variants

TBR=braveyao@chromium.org
BUG=libyuv:799
TESTED=try bots tested build on all platforms

Change-Id: I007d8981d91ca0748c59403759109bbcd88f286c
Reviewed-on: https://chromium-review.googlesource.com/1115719
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: 's avatarFrank Barchard <fbarchard@chromium.org>
parent a37e7bfe
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1711 Version: 1712
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -66,7 +66,7 @@ The following is extracted from video_common.h as a complete list of formats sup ...@@ -66,7 +66,7 @@ The following is extracted from video_common.h as a complete list of formats sup
// 1 Primary Compressed YUV format. // 1 Primary Compressed YUV format.
FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'), FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
// 7 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias. // 8 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'), FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'), FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'), FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
...@@ -74,6 +74,7 @@ The following is extracted from video_common.h as a complete list of formats sup ...@@ -74,6 +74,7 @@ The following is extracted from video_common.h as a complete list of formats sup
FOURCC_J420 = FOURCC('J', '4', '2', '0'), FOURCC_J420 = FOURCC('J', '4', '2', '0'),
FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc
FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc
FOURCC_H422 = FOURCC('H', '4', '2', '2'), // unofficial fourcc
// 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc. // 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc.
FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420. FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420.
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ #ifndef INCLUDE_LIBYUV_VERSION_H_
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1711 #define LIBYUV_VERSION 1712
#endif // INCLUDE_LIBYUV_VERSION_H_ #endif // INCLUDE_LIBYUV_VERSION_H_
...@@ -30,7 +30,8 @@ extern "C" { ...@@ -30,7 +30,8 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
#define FOURCC(a, b, c, d) \ #define FOURCC(a, b, c, d) \
((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \
(static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) (static_cast<uint32_t>(c) << 16) | /* NOLINT */ \
(static_cast<uint32_t>(d) << 24)) /* NOLINT */
#else #else
#define FOURCC(a, b, c, d) \ #define FOURCC(a, b, c, d) \
(((uint32_t)(a)) | ((uint32_t)(b) << 8) | /* NOLINT */ \ (((uint32_t)(a)) | ((uint32_t)(b) << 8) | /* NOLINT */ \
...@@ -79,7 +80,7 @@ enum FourCC { ...@@ -79,7 +80,7 @@ enum FourCC {
// 1 Primary Compressed YUV format. // 1 Primary Compressed YUV format.
FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'), FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
// 7 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias. // 8 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'), FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'), FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'), FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
...@@ -87,6 +88,7 @@ enum FourCC { ...@@ -87,6 +88,7 @@ enum FourCC {
FOURCC_J420 = FOURCC('J', '4', '2', '0'), FOURCC_J420 = FOURCC('J', '4', '2', '0'),
FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc
FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc
FOURCC_H422 = FOURCC('H', '4', '2', '2'), // unofficial fourcc
// 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc. // 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc.
FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420. FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420.
...@@ -155,6 +157,7 @@ enum FourCCBpp { ...@@ -155,6 +157,7 @@ enum FourCCBpp {
FOURCC_BPP_J420 = 12, FOURCC_BPP_J420 = 12,
FOURCC_BPP_J400 = 8, FOURCC_BPP_J400 = 8,
FOURCC_BPP_H420 = 12, FOURCC_BPP_H420 = 12,
FOURCC_BPP_H422 = 16,
FOURCC_BPP_H010 = 24, FOURCC_BPP_H010 = 24,
FOURCC_BPP_MJPG = 0, // 0 means unknown. FOURCC_BPP_MJPG = 0, // 0 means unknown.
FOURCC_BPP_H264 = 0, FOURCC_BPP_H264 = 0,
......
...@@ -31,8 +31,6 @@ extern "C" { ...@@ -31,8 +31,6 @@ extern "C" {
// TODO(fbarchard): Add the following: // TODO(fbarchard): Add the following:
// H010ToARGB // H010ToARGB
// H420ToARGB
// H422ToARGB
// I010ToARGB // I010ToARGB
// J400ToARGB // J400ToARGB
// J422ToARGB // J422ToARGB
...@@ -167,13 +165,15 @@ int ConvertToARGB(const uint8_t* sample, ...@@ -167,13 +165,15 @@ int ConvertToARGB(const uint8_t* sample,
// Biplanar formats // Biplanar formats
case FOURCC_NV12: case FOURCC_NV12:
src = sample + (src_width * crop_y + crop_x); src = sample + (src_width * crop_y + crop_x);
src_uv = sample + aligned_src_width * (abs_src_height + crop_y / 2) + crop_x; src_uv =
sample + aligned_src_width * (abs_src_height + crop_y / 2) + crop_x;
r = NV12ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb, r = NV12ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb,
dst_stride_argb, crop_width, inv_crop_height); dst_stride_argb, crop_width, inv_crop_height);
break; break;
case FOURCC_NV21: case FOURCC_NV21:
src = sample + (src_width * crop_y + crop_x); src = sample + (src_width * crop_y + crop_x);
src_uv = sample + aligned_src_width * (abs_src_height + crop_y / 2) + crop_x; src_uv =
sample + aligned_src_width * (abs_src_height + crop_y / 2) + crop_x;
// Call NV12 but with u and v parameters swapped. // Call NV12 but with u and v parameters swapped.
r = NV21ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb, r = NV21ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb,
dst_stride_argb, crop_width, inv_crop_height); dst_stride_argb, crop_width, inv_crop_height);
...@@ -208,15 +208,26 @@ int ConvertToARGB(const uint8_t* sample, ...@@ -208,15 +208,26 @@ int ConvertToARGB(const uint8_t* sample,
break; break;
} }
case FOURCC_J420: { case FOURCC_H420: {
int halfwidth = (src_width + 1) / 2;
int halfheight = (abs_src_height + 1) / 2;
const uint8_t* src_y = sample + (src_width * crop_y + crop_x); const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
const uint8_t* src_u; const uint8_t* src_u = sample + src_width * abs_src_height +
const uint8_t* src_v; (halfwidth * crop_y + crop_x) / 2;
const uint8_t* src_v = sample + src_width * abs_src_height +
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
r = H420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
break;
}
case FOURCC_J420: {
int halfwidth = (src_width + 1) / 2; int halfwidth = (src_width + 1) / 2;
int halfheight = (abs_src_height + 1) / 2; int halfheight = (abs_src_height + 1) / 2;
src_u = sample + src_width * abs_src_height + const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
const uint8_t* src_u = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2; (halfwidth * crop_y + crop_x) / 2;
src_v = sample + src_width * abs_src_height + const uint8_t* src_v = sample + src_width * abs_src_height +
halfwidth * (halfheight + crop_y / 2) + crop_x / 2; halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
r = J420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth, r = J420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
dst_argb, dst_stride_argb, crop_width, inv_crop_height); dst_argb, dst_stride_argb, crop_width, inv_crop_height);
...@@ -225,10 +236,10 @@ int ConvertToARGB(const uint8_t* sample, ...@@ -225,10 +236,10 @@ int ConvertToARGB(const uint8_t* sample,
case FOURCC_I422: case FOURCC_I422:
case FOURCC_YV16: { case FOURCC_YV16: {
int halfwidth = (src_width + 1) / 2;
const uint8_t* src_y = sample + src_width * crop_y + crop_x; const uint8_t* src_y = sample + src_width * crop_y + crop_x;
const uint8_t* src_u; const uint8_t* src_u;
const uint8_t* src_v; const uint8_t* src_v;
int halfwidth = (src_width + 1) / 2;
if (format == FOURCC_YV16) { if (format == FOURCC_YV16) {
src_v = sample + src_width * abs_src_height + halfwidth * crop_y + src_v = sample + src_width * abs_src_height + halfwidth * crop_y +
crop_x / 2; crop_x / 2;
...@@ -244,6 +255,19 @@ int ConvertToARGB(const uint8_t* sample, ...@@ -244,6 +255,19 @@ int ConvertToARGB(const uint8_t* sample,
dst_argb, dst_stride_argb, crop_width, inv_crop_height); dst_argb, dst_stride_argb, crop_width, inv_crop_height);
break; break;
} }
case FOURCC_H422: {
int halfwidth = (src_width + 1) / 2;
const uint8_t* src_y = sample + src_width * crop_y + crop_x;
const uint8_t* src_u =
sample + src_width * abs_src_height + halfwidth * crop_y + crop_x / 2;
const uint8_t* src_v = sample + src_width * abs_src_height +
halfwidth * (abs_src_height + crop_y) + crop_x / 2;
r = H422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
break;
}
case FOURCC_I444: case FOURCC_I444:
case FOURCC_YV24: { case FOURCC_YV24: {
const uint8_t* src_y = sample + src_width * crop_y + crop_x; const uint8_t* src_y = sample + src_width * crop_y + crop_x;
......
...@@ -79,6 +79,7 @@ TEST_F(LibYUVBaseTest, TestFourCC) { ...@@ -79,6 +79,7 @@ TEST_F(LibYUVBaseTest, TestFourCC) {
EXPECT_TRUE(TestValidFourCC(FOURCC_RGBO, FOURCC_BPP_RGBO)); EXPECT_TRUE(TestValidFourCC(FOURCC_RGBO, FOURCC_BPP_RGBO));
EXPECT_TRUE(TestValidFourCC(FOURCC_R444, FOURCC_BPP_R444)); EXPECT_TRUE(TestValidFourCC(FOURCC_R444, FOURCC_BPP_R444));
EXPECT_TRUE(TestValidFourCC(FOURCC_H420, FOURCC_BPP_H420)); EXPECT_TRUE(TestValidFourCC(FOURCC_H420, FOURCC_BPP_H420));
EXPECT_TRUE(TestValidFourCC(FOURCC_H422, FOURCC_BPP_H422));
EXPECT_TRUE(TestValidFourCC(FOURCC_H010, FOURCC_BPP_H010)); EXPECT_TRUE(TestValidFourCC(FOURCC_H010, FOURCC_BPP_H010));
EXPECT_TRUE(TestValidFourCC(FOURCC_MJPG, FOURCC_BPP_MJPG)); EXPECT_TRUE(TestValidFourCC(FOURCC_MJPG, FOURCC_BPP_MJPG));
EXPECT_TRUE(TestValidFourCC(FOURCC_YV12, FOURCC_BPP_YV12)); EXPECT_TRUE(TestValidFourCC(FOURCC_YV12, FOURCC_BPP_YV12));
......
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