diff options
author | wjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-19 18:51:01 +0000 |
---|---|---|
committer | wjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-19 18:51:01 +0000 |
commit | 30591e06f6c96933813d700ae255b2182f6e15e5 (patch) | |
tree | 9721347c1de135304b0e2766f7c3a99e6c5fe4bd /media/video | |
parent | c667115d4da70673aea8e6ff069872bd1197339c (diff) | |
download | chromium_src-30591e06f6c96933813d700ae255b2182f6e15e5.zip chromium_src-30591e06f6c96933813d700ae255b2182f6e15e5.tar.gz chromium_src-30591e06f6c96933813d700ae255b2182f6e15e5.tar.bz2 |
Add test for RotatePlaneByPixels.
This is a follow-up patch for https://codereview.chromium.org/11860002/
BUG=161417
Review URL: https://codereview.chromium.org/12207190
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video')
-rw-r--r-- | media/video/capture/android/video_capture_device_android.cc | 99 |
1 files changed, 1 insertions, 98 deletions
diff --git a/media/video/capture/android/video_capture_device_android.cc b/media/video/capture/android/video_capture_device_android.cc index 06daab4..26b80a8 100644 --- a/media/video/capture/android/video_capture_device_android.cc +++ b/media/video/capture/android/video_capture_device_android.cc @@ -12,6 +12,7 @@ #include "base/stringprintf.h" #include "jni/Camera_jni.h" #include "jni/VideoCapture_jni.h" +#include "media/base/video_util.h" using base::android::AttachCurrentThread; using base::android::CheckException; @@ -30,104 +31,6 @@ void ResetBufferI420(uint8* buffer, int width, int height) { memset(buffer, 128, y_size / 2); } -// TODO(wjia): add test for this function. -void RotatePlaneByPixels( - uint8* src, - uint8* dest, - int width, - int height, - int rotation, // Clockwise. - bool flip_vert, - bool flip_horiz) { - // Consolidate cases. Only 0 and 90 are left. - if (rotation == 180 || rotation == 270) { - rotation -= 180; - flip_vert = !flip_vert; - flip_horiz = !flip_horiz; - } - - int num_rows = height; - int num_cols = width; - int src_stride = width; - // During pixel copying, the corresponding incremental of dest pointer - // when src pointer moves to next row. - int dest_row_step = width; - // During pixel copying, the corresponding incremental of dest pointer - // when src pointer moves to next column. - int dest_col_step = 1; - - if (rotation == 0) { - if (flip_horiz) { - // Use pixel copying. - dest_col_step = -1; - if (flip_vert) { - // Rotation 180. - dest_row_step = -width; - dest += height * width - 1; - } else { - dest += width - 1; - } - } else { - if (flip_vert) { - // Fast copy by rows. - dest += width * (height - 1); - for (int row = 0; row < height; ++row) { - memcpy(dest, src, width); - src += width; - dest -= width; - } - } else { - memcpy(dest, src, width * height); - } - return; - } - } else if (rotation == 90) { - int offset; - if (width > height) { - offset = (width - height) / 2; - src += offset; - num_rows = num_cols = height; - } else { - offset = (height - width) / 2; - src += width * offset; - num_rows = num_cols = width; - } - - dest_col_step = (flip_vert ? -width : width); - dest_row_step = (flip_horiz ? 1 : -1); - if (flip_horiz) { - if (flip_vert) { - dest += (width > height ? width * (height - 1) + offset : - width * (height - offset - 1)); - } else { - dest += (width > height ? offset : width * offset); - } - } else { - if (flip_vert) { - dest += (width > height ? width * height - offset - 1 : - width * (height - offset) - 1); - } else { - dest += (width > height ? width - offset - 1 : - width * (offset + 1) - 1); - } - } - } else { - NOTREACHED(); - } - - // Copy pixels. - for (int row = 0; row < num_rows; ++row) { - uint8* src_ptr = src; - uint8* dest_ptr = dest; - for (int col = 0; col < num_cols; ++col) { - *dest_ptr = *src_ptr++; - dest_ptr += dest_col_step; - } - src += src_stride; - dest += dest_row_step; - } -} - int GetIntField(JNIEnv* env, const JavaRef<jclass>& clazz, const JavaRef<jobject>& instance, |