Commit a844b956 authored by fbarchard@google.com's avatar fbarchard@google.com

YU12 has a normal fourcc instead of an alias, allowing code to treat it as different, if needed.

BUG=112
TEST=unittests still pass
Review URL: https://webrtc-codereview.appspot.com/864008

git-svn-id: http://libyuv.googlecode.com/svn/trunk@391 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 6d629809
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 390
Version: 391
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 390
#define LIBYUV_VERSION 391
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -45,6 +45,7 @@ enum FourCC {
FOURCC_I444 = FOURCC('I', '4', '4', '4'),
FOURCC_I411 = FOURCC('I', '4', '1', '1'),
FOURCC_I400 = FOURCC('I', '4', '0', '0'),
FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Linux version of I420.
FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
......@@ -76,7 +77,6 @@ enum FourCC {
// Aliases for canonical fourcc codes, replaced with their canonical
// equivalents by CanonicalFourCC().
FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420.
FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Alias for I420.
FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'), // Alias for I422.
FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'), // Alias for I444.
FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'), // Alias for YUY2.
......@@ -100,6 +100,7 @@ enum FourCCBpp {
FOURCC_BPP_I444 = 24,
FOURCC_BPP_I411 = 12,
FOURCC_BPP_I400 = 8,
FOURCC_BPP_YU12 = 12,
FOURCC_BPP_YV12 = 12,
FOURCC_BPP_YV16 = 16,
FOURCC_BPP_YV24 = 24,
......@@ -131,7 +132,6 @@ enum FourCCBpp {
// Aliases for canonical fourcc codes, replaced with their canonical
// equivalents by CanonicalFourCC().
FOURCC_BPP_IYUV = 12,
FOURCC_BPP_YU12 = 12,
FOURCC_BPP_YU16 = 16,
FOURCC_BPP_YU24 = 24,
FOURCC_BPP_YUYV = 16,
......
......@@ -1749,9 +1749,9 @@ int ConvertToI420(const uint8* sample,
// and then rotate the I420 to the final destination buffer.
// For in-place conversion, if destination y is same as source sample,
// also enable temporary buffer.
bool need_buf = (rotation && format != FOURCC_NV12 &&
format != FOURCC_NV21 && format != FOURCC_I420 &&
format != FOURCC_YV12) || y == sample;
bool need_buf = (rotation && format != FOURCC_I420 &&
format != FOURCC_NV12 && format != FOURCC_NV21 &&
format != FOURCC_YU12 && format != FOURCC_YV12) || y == sample;
uint8* tmp_y = y;
uint8* tmp_u = u;
uint8* tmp_v = v;
......@@ -1965,21 +1965,22 @@ int ConvertToI420(const uint8* sample,
break;
// Triplanar formats
case FOURCC_I420:
case FOURCC_YU12:
case FOURCC_YV12: {
const uint8* src_y = sample + (src_width * crop_y + crop_x);
const uint8* src_u;
const uint8* src_v;
int halfwidth = (src_width + 1) / 2;
int halfheight = (abs_src_height + 1) / 2;
if (format == FOURCC_I420) {
src_u = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2;
if (format == FOURCC_YV12) {
src_v = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2;
src_u = sample + src_width * abs_src_height +
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
} else {
src_v = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2;
src_u = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2;
src_v = sample + src_width * abs_src_height +
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
}
r = I420Rotate(src_y, src_width,
......@@ -1997,15 +1998,15 @@ int ConvertToI420(const uint8* sample,
const uint8* src_u;
const uint8* src_v;
int halfwidth = (src_width + 1) / 2;
if (format == FOURCC_I422) {
src_u = sample + src_width * abs_src_height +
halfwidth * crop_y + crop_x / 2;
if (format == FOURCC_YV16) {
src_v = sample + src_width * abs_src_height +
halfwidth * crop_y + crop_x / 2;
src_u = sample + src_width * abs_src_height +
halfwidth * (abs_src_height + crop_y) + crop_x / 2;
} else {
src_v = sample + src_width * abs_src_height +
halfwidth * crop_y + crop_x / 2;
src_u = sample + src_width * abs_src_height +
halfwidth * crop_y + crop_x / 2;
src_v = sample + src_width * abs_src_height +
halfwidth * (abs_src_height + crop_y) + crop_x / 2;
}
r = I422ToI420(src_y, src_width,
......@@ -2022,12 +2023,12 @@ int ConvertToI420(const uint8* sample,
const uint8* src_y = sample + src_width * crop_y + crop_x;
const uint8* src_u;
const uint8* src_v;
if (format == FOURCC_I444) {
src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
} else {
if (format == FOURCC_YV24) {
src_v = sample + src_width * (abs_src_height + crop_y) + crop_x;
src_u = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
} else {
src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
}
r = I444ToI420(src_y, src_width,
src_u, src_width,
......
......@@ -1173,21 +1173,22 @@ int ConvertToARGB(const uint8* sample, size_t sample_size,
// break;
// Triplanar formats
case FOURCC_I420:
case FOURCC_YU12:
case FOURCC_YV12: {
const uint8* src_y = sample + (src_width * crop_y + crop_x);
const uint8* src_u;
const uint8* src_v;
int halfwidth = (src_width + 1) / 2;
int halfheight = (abs_src_height + 1) / 2;
if (format == FOURCC_I420) {
src_u = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2;
if (format == FOURCC_YV12) {
src_v = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2;
src_u = sample + src_width * abs_src_height +
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
} else {
src_v = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2;
src_u = sample + src_width * abs_src_height +
(halfwidth * crop_y + crop_x) / 2;
src_v = sample + src_width * abs_src_height +
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
}
r = I420ToARGB(src_y, src_width,
......@@ -1203,15 +1204,15 @@ int ConvertToARGB(const uint8* sample, size_t sample_size,
const uint8* src_u;
const uint8* src_v;
int halfwidth = (src_width + 1) / 2;
if (format == FOURCC_I422) {
src_u = sample + src_width * abs_src_height +
halfwidth * crop_y + crop_x / 2;
if (format == FOURCC_YV16) {
src_v = sample + src_width * abs_src_height +
halfwidth * crop_y + crop_x / 2;
src_u = sample + src_width * abs_src_height +
halfwidth * (abs_src_height + crop_y) + crop_x / 2;
} else {
src_v = sample + src_width * abs_src_height +
halfwidth * crop_y + crop_x / 2;
src_u = sample + src_width * abs_src_height +
halfwidth * crop_y + crop_x / 2;
src_v = sample + src_width * abs_src_height +
halfwidth * (abs_src_height + crop_y) + crop_x / 2;
}
r = I422ToARGB(src_y, src_width,
......@@ -1226,12 +1227,12 @@ int ConvertToARGB(const uint8* sample, size_t sample_size,
const uint8* src_y = sample + src_width * crop_y + crop_x;
const uint8* src_u;
const uint8* src_v;
if (format == FOURCC_I444) {
src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
} else {
if (format == FOURCC_YV24) {
src_v = sample + src_width * (abs_src_height + crop_y) + crop_x;
src_u = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
} else {
src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
}
r = I444ToARGB(src_y, src_width,
src_u, src_width,
......
......@@ -1370,17 +1370,18 @@ int ConvertFromI420(const uint8* y, int y_stride,
// Triplanar formats
// TODO(fbarchard): halfstride instead of halfwidth
case FOURCC_I420:
case FOURCC_YU12:
case FOURCC_YV12: {
int halfwidth = (width + 1) / 2;
int halfheight = (height + 1) / 2;
uint8* dst_u;
uint8* dst_v;
if (format == FOURCC_I420) {
dst_u = dst_sample + width * height;
dst_v = dst_u + halfwidth * halfheight;
} else {
if (format == FOURCC_YV12) {
dst_v = dst_sample + width * height;
dst_u = dst_v + halfwidth * halfheight;
} else {
dst_u = dst_sample + width * height;
dst_v = dst_u + halfwidth * halfheight;
}
r = I420Copy(y, y_stride,
u, u_stride,
......@@ -1396,12 +1397,12 @@ int ConvertFromI420(const uint8* y, int y_stride,
int halfwidth = (width + 1) / 2;
uint8* dst_u;
uint8* dst_v;
if (format == FOURCC_I422) {
dst_u = dst_sample + width * height;
dst_v = dst_u + halfwidth * height;
} else {
if (format == FOURCC_YV16) {
dst_v = dst_sample + width * height;
dst_u = dst_v + halfwidth * height;
} else {
dst_u = dst_sample + width * height;
dst_v = dst_u + halfwidth * height;
}
r = I420ToI422(y, y_stride,
u, u_stride,
......@@ -1416,12 +1417,12 @@ int ConvertFromI420(const uint8* y, int y_stride,
case FOURCC_YV24: {
uint8* dst_u;
uint8* dst_v;
if (format == FOURCC_I444) {
dst_u = dst_sample + width * height;
dst_v = dst_u + width * height;
} else {
if (format == FOURCC_YV24) {
dst_v = dst_sample + width * height;
dst_u = dst_v + width * height;
} else {
dst_u = dst_sample + width * height;
dst_v = dst_u + width * height;
}
r = I420ToI444(y, y_stride,
u, u_stride,
......
......@@ -25,7 +25,6 @@ struct FourCCAliasEntry {
static const FourCCAliasEntry kFourCCAliases[] = {
{FOURCC_IYUV, FOURCC_I420},
{FOURCC_YU12, FOURCC_I420},
{FOURCC_YU16, FOURCC_I422},
{FOURCC_YU24, FOURCC_I444},
{FOURCC_YUYV, FOURCC_YUY2},
......
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