Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: webrtc/common_video/libyuv/libyuv_unittest.cc

Issue 1935443002: Revert of Delete webrtc::VideoFrame methods buffer and stride. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/common_video/i420_video_frame_unittest.cc ('k') | webrtc/common_video/libyuv/scaler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_video/libyuv/libyuv_unittest.cc
diff --git a/webrtc/common_video/libyuv/libyuv_unittest.cc b/webrtc/common_video/libyuv/libyuv_unittest.cc
index 0e43e2edfb5f1eead04ac2ed903c222b8db94a80..9f92b8bb15cf19f4ef6e9d8623aeb907ba3c3fd5 100644
--- a/webrtc/common_video/libyuv/libyuv_unittest.cc
+++ b/webrtc/common_video/libyuv/libyuv_unittest.cc
@@ -20,6 +20,61 @@
#include "webrtc/video_frame.h"
namespace webrtc {
+
+int PrintBuffer(const uint8_t* buffer, int width, int height, int stride) {
+ if (buffer == NULL)
+ return -1;
+ int k;
+ const uint8_t* tmp_buffer = buffer;
+ for (int i = 0; i < height; i++) {
+ k = 0;
+ for (int j = 0; j < width; j++) {
+ printf("%d ", tmp_buffer[k++]);
+ }
+ tmp_buffer += stride;
+ printf(" \n");
+ }
+ printf(" \n");
+ return 0;
+}
+
+int PrintFrame(const VideoFrame* frame, const char* str) {
+ if (frame == NULL)
+ return -1;
+ printf("%s %dx%d \n", str, frame->width(), frame->height());
+
+ int ret = 0;
+ for (int plane_num = 0; plane_num < kNumOfPlanes; ++plane_num) {
+ PlaneType plane_type = static_cast<PlaneType>(plane_num);
+ int width = (plane_num ? (frame->width() + 1) / 2 : frame->width());
+ int height = (plane_num ? (frame->height() + 1) / 2 : frame->height());
+ ret += PrintBuffer(frame->buffer(plane_type), width, height,
+ frame->stride(plane_type));
+ }
+ return ret;
+}
+
+
+// Create an image from on a YUV frame. Every plane value starts with a start
+// value, and will be set to increasing values.
+void CreateImage(VideoFrame* frame, int plane_offset[kNumOfPlanes]) {
+ if (frame == NULL)
+ return;
+ for (int plane_num = 0; plane_num < kNumOfPlanes; ++plane_num) {
+ int width = (plane_num != kYPlane ? (frame->width() + 1) / 2 :
+ frame->width());
+ int height = (plane_num != kYPlane ? (frame->height() + 1) / 2 :
+ frame->height());
+ PlaneType plane_type = static_cast<PlaneType>(plane_num);
+ uint8_t *data = frame->buffer(plane_type);
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ data[j] = static_cast<uint8_t>(i + plane_offset[plane_num] + j);
+ }
+ data += frame->stride(plane_type);
+ }
+ }
+}
class TestLibYuv : public ::testing::Test {
protected:
« no previous file with comments | « webrtc/common_video/i420_video_frame_unittest.cc ('k') | webrtc/common_video/libyuv/scaler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698