Commit 738dfa03 authored by fbarchard@google.com's avatar fbarchard@google.com

Support odd widths for NV12 format when cropping vertically.

BUG=400
TESTED=CropNV12
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/39009004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1272 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 695f42fd
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1271
Version: 1272
License: BSD
License File: LICENSE
......
......@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1271
#define LIBYUV_VERSION 1272
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
......@@ -183,7 +183,8 @@ int ConvertToI420(const uint8* sample,
// Biplanar formats
case FOURCC_NV12:
src = sample + (src_width * crop_y + crop_x);
src_uv = sample + aligned_src_width * (src_height + crop_y / 2) + crop_x;
src_uv = sample + (src_width * src_height) +
((crop_y / 2) * aligned_src_width) + ((crop_x / 2) * 2);
r = NV12ToI420Rotate(src, src_width,
src_uv, aligned_src_width,
y, y_stride,
......@@ -193,7 +194,8 @@ int ConvertToI420(const uint8* sample,
break;
case FOURCC_NV21:
src = sample + (src_width * crop_y + crop_x);
src_uv = sample + aligned_src_width * (src_height + crop_y / 2) + crop_x;
src_uv = sample + (src_width * src_height) +
((crop_y / 2) * aligned_src_width) + ((crop_x / 2) * 2);
// Call NV12 but with u and v parameters swapped.
r = NV12ToI420Rotate(src, src_width,
src_uv, aligned_src_width,
......
......@@ -1135,7 +1135,7 @@ TEST_F(libyuvTest, CropNV12) {
const int crop_y =
((benchmark_height_ - (benchmark_height_ * 360 / 480)) / 2 + 1) & ~1;
const int kDestWidth = benchmark_width_;
const int kDestHeight = benchmark_height_ - crop_y * 2;;
const int kDestHeight = benchmark_height_ - crop_y * 2;
const int sample_size = kWidth * kHeight +
SUBSAMPLE(kWidth, SUBSAMP_X) *
SUBSAMPLE(kHeight, SUBSAMP_Y) * 2;
......@@ -1162,8 +1162,8 @@ TEST_F(libyuvTest, CropNV12) {
for (int i = 0; i < kHeight * kWidth; ++i) {
src_y[i] = (random() & 0xff);
}
for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y) *
SUBSAMPLE(kWidth, SUBSAMP_X) * 2; ++i) {
for (int i = 0; i < (SUBSAMPLE(kHeight, SUBSAMP_Y) *
SUBSAMPLE(kWidth, SUBSAMP_X)) * 2; ++i) {
src_uv[i] = (random() & 0xff);
}
memset(dst_y, 1, kDestWidth * kDestHeight);
......@@ -1187,7 +1187,8 @@ TEST_F(libyuvTest, CropNV12) {
libyuv::kRotate0, libyuv::FOURCC_NV12);
NV12ToI420(src_y + crop_y * kWidth, kWidth,
src_uv + (crop_y / 2) * kWidth, kWidth,
src_uv + (crop_y / 2) * SUBSAMPLE(kWidth, SUBSAMP_X) * 2,
SUBSAMPLE(kWidth, SUBSAMP_X) * 2,
dst_y, kDestWidth,
dst_u, SUBSAMPLE(kDestWidth, SUBSAMP_X),
dst_v, SUBSAMPLE(kDestWidth, SUBSAMP_X),
......
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