summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authormcasas <mcasas@chromium.org>2015-11-17 11:53:24 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-17 19:54:32 +0000
commit3255e7da75ec61125ddbb21f7fba0acf97a45bb7 (patch)
treee03361cf6ebc9912ff9eecbdd9f027cd675d4a6b /media
parent43d7d78afce408bab56dd3a47790de20ee1438ec (diff)
downloadchromium_src-3255e7da75ec61125ddbb21f7fba0acf97a45bb7.zip
chromium_src-3255e7da75ec61125ddbb21f7fba0acf97a45bb7.tar.gz
chromium_src-3255e7da75ec61125ddbb21f7fba0acf97a45bb7.tar.bz2
Media: Use libyuv::I420Copy instead of Copy{Y,U,V,A}Plane() in unittests
Because the former are as fast as the latter (mempcy) and usually faster. This CL is the last in its row, and removes the last uses of the said Copy functions, which only affects unit tests, and which are then removed. Incidentally it also removes MakeOpaqueAPlane() since it's unused. BUG=554196 TEST= all media_unittests passing, but in particular: ./out/Debug/media_unittests --gtest_filter='Pipeline**.*' and ./out/Debug/media_unittests --gtest_filter='Sk*Video*.*' Review URL: https://codereview.chromium.org/1449293002 Cr-Commit-Position: refs/heads/master@{#360135}
Diffstat (limited to 'media')
-rw-r--r--media/BUILD.gn1
-rw-r--r--media/base/video_util.cc41
-rw-r--r--media/base/video_util.h22
-rw-r--r--media/base/video_util_unittest.cc26
-rw-r--r--media/filters/vpx_video_decoder.cc6
-rw-r--r--media/media.gyp1
-rw-r--r--media/renderers/skcanvas_video_renderer_unittest.cc11
7 files changed, 13 insertions, 95 deletions
diff --git a/media/BUILD.gn b/media/BUILD.gn
index b5e2e40..913c052 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -683,6 +683,7 @@ test("media_unittests") {
"//skia", # Direct dependency required to inherit config.
"//testing/gmock",
"//testing/gtest",
+ "//third_party/libyuv",
"//third_party/widevine/cdm:version_h",
"//ui/gfx:test_support",
"//url",
diff --git a/media/base/video_util.cc b/media/base/video_util.cc
index cddbb9c..414e57b 100644
--- a/media/base/video_util.cc
+++ b/media/base/video_util.cc
@@ -29,47 +29,6 @@ gfx::Size GetNaturalSize(const gfx::Size& visible_size,
visible_size.height());
}
-void CopyPlane(size_t plane, const uint8* source, int stride, int rows,
- VideoFrame* frame) {
- uint8* dest = frame->data(plane);
- int dest_stride = frame->stride(plane);
-
- // Clamp in case source frame has smaller stride.
- int bytes_to_copy_per_row = std::min(frame->row_bytes(plane), stride);
-
- // Clamp in case source frame has smaller height.
- int rows_to_copy = std::min(frame->rows(plane), rows);
-
- // Copy!
- for (int row = 0; row < rows_to_copy; ++row) {
- memcpy(dest, source, bytes_to_copy_per_row);
- source += stride;
- dest += dest_stride;
- }
-}
-
-void CopyYPlane(const uint8* source, int stride, int rows, VideoFrame* frame) {
- CopyPlane(VideoFrame::kYPlane, source, stride, rows, frame);
-}
-
-void CopyUPlane(const uint8* source, int stride, int rows, VideoFrame* frame) {
- CopyPlane(VideoFrame::kUPlane, source, stride, rows, frame);
-}
-
-void CopyVPlane(const uint8* source, int stride, int rows, VideoFrame* frame) {
- CopyPlane(VideoFrame::kVPlane, source, stride, rows, frame);
-}
-
-void CopyAPlane(const uint8* source, int stride, int rows, VideoFrame* frame) {
- CopyPlane(VideoFrame::kAPlane, source, stride, rows, frame);
-}
-
-void MakeOpaqueAPlane(int stride, int rows, VideoFrame* frame) {
- int rows_to_clear = std::min(frame->rows(VideoFrame::kAPlane), rows);
- memset(frame->data(VideoFrame::kAPlane), 255,
- frame->stride(VideoFrame::kAPlane) * rows_to_clear);
-}
-
void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v) {
// Fill the Y plane.
uint8* y_plane = frame->data(VideoFrame::kYPlane);
diff --git a/media/base/video_util.h b/media/base/video_util.h
index abbcad4..77c6523 100644
--- a/media/base/video_util.h
+++ b/media/base/video_util.h
@@ -19,28 +19,6 @@ MEDIA_EXPORT gfx::Size GetNaturalSize(const gfx::Size& visible_size,
int aspect_ratio_numerator,
int aspect_ratio_denominator);
-// Copies a plane of YUV(A) source into a VideoFrame object, taking into account
-// source and destinations dimensions.
-//
-// NOTE: rows is *not* the same as height!
-MEDIA_EXPORT void CopyYPlane(const uint8* source, int stride, int rows,
- VideoFrame* frame);
-MEDIA_EXPORT void CopyUPlane(const uint8* source, int stride, int rows,
- VideoFrame* frame);
-MEDIA_EXPORT void CopyVPlane(const uint8* source, int stride, int rows,
- VideoFrame* frame);
-MEDIA_EXPORT void CopyAPlane(const uint8* source, int stride, int rows,
- VideoFrame* frame);
-
-// Sets alpha plane values to be completely opaque (all 255's).
-MEDIA_EXPORT void MakeOpaqueAPlane(int stride, int rows, VideoFrame* frame);
-
-// |plane| is one of VideoFrame::kYPlane, VideoFrame::kUPlane,
-// VideoFrame::kVPlane or VideoFrame::kAPlane
-MEDIA_EXPORT void CopyPlane(size_t plane, const uint8* source, int stride,
- int rows, VideoFrame* frame);
-
-
// Fills |frame| containing YUV data to the given color values.
MEDIA_EXPORT void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v);
diff --git a/media/base/video_util_unittest.cc b/media/base/video_util_unittest.cc
index a62f0cb..ba53a58 100644
--- a/media/base/video_util_unittest.cc
+++ b/media/base/video_util_unittest.cc
@@ -42,14 +42,6 @@ class VideoUtilTest : public testing::Test {
PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, base::TimeDelta());
}
- void CopyPlanes() {
- CopyYPlane(y_plane_.get(), y_stride_, height_, destination_frame_.get());
- CopyUPlane(
- u_plane_.get(), u_stride_, height_ / 2, destination_frame_.get());
- CopyVPlane(
- v_plane_.get(), v_stride_, height_ / 2, destination_frame_.get());
- }
-
private:
scoped_ptr<uint8[]> y_plane_;
scoped_ptr<uint8[]> u_plane_;
@@ -94,24 +86,6 @@ TEST_F(VideoUtilTest, GetNaturalSize) {
EXPECT_EQ(gfx::Size(207, 240), GetNaturalSize(visible_size, 11, 17));
}
-TEST_F(VideoUtilTest, CopyPlane_Exact) {
- CreateSourceFrame(16, 16, 16, 8, 8);
- CreateDestinationFrame(16, 16);
- CopyPlanes();
-}
-
-TEST_F(VideoUtilTest, CopyPlane_SmallerSource) {
- CreateSourceFrame(8, 8, 8, 4, 4);
- CreateDestinationFrame(16, 16);
- CopyPlanes();
-}
-
-TEST_F(VideoUtilTest, CopyPlane_SmallerDestination) {
- CreateSourceFrame(16, 16, 16, 8, 8);
- CreateDestinationFrame(8, 8);
- CopyPlanes();
-}
-
namespace {
uint8 src6x4[] = {
diff --git a/media/filters/vpx_video_decoder.cc b/media/filters/vpx_video_decoder.cc
index 10b8d91..e3cc170 100644
--- a/media/filters/vpx_video_decoder.cc
+++ b/media/filters/vpx_video_decoder.cc
@@ -543,9 +543,9 @@ bool VpxVideoDecoder::VpxDecode(const scoped_refptr<DecoderBuffer>& buffer,
void VpxVideoDecoder::CopyVpxImageToVideoFrame(
const struct vpx_image* vpx_image,
scoped_refptr<VideoFrame>* video_frame) {
- CHECK(vpx_image);
- CHECK(vpx_image->fmt == VPX_IMG_FMT_I420 ||
- vpx_image->fmt == VPX_IMG_FMT_I444);
+ DCHECK(vpx_image);
+ DCHECK(vpx_image->fmt == VPX_IMG_FMT_I420 ||
+ vpx_image->fmt == VPX_IMG_FMT_I444);
VideoPixelFormat codec_format = PIXEL_FORMAT_YV12;
if (vpx_image->fmt == VPX_IMG_FMT_I444)
diff --git a/media/media.gyp b/media/media.gyp
index d0c3f78..c5cc228 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -1187,6 +1187,7 @@
'../skia/skia.gyp:skia',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
+ '../third_party/libyuv/libyuv.gyp:libyuv',
'../third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
diff --git a/media/renderers/skcanvas_video_renderer_unittest.cc b/media/renderers/skcanvas_video_renderer_unittest.cc
index d787bf0..fad340d 100644
--- a/media/renderers/skcanvas_video_renderer_unittest.cc
+++ b/media/renderers/skcanvas_video_renderer_unittest.cc
@@ -10,6 +10,7 @@
#include "media/base/video_util.h"
#include "media/renderers/skcanvas_video_renderer.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/libyuv/include/libyuv/convert.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
@@ -189,9 +190,13 @@ SkCanvasVideoRendererTest::SkCanvasVideoRendererTest()
107, 107, 107, 107, 21, 21, 21, 21, 107, 107, 107, 107,
};
- media::CopyYPlane(cropped_y_plane, 16, 16, cropped_frame().get());
- media::CopyUPlane(cropped_u_plane, 8, 8, cropped_frame().get());
- media::CopyVPlane(cropped_v_plane, 8, 8, cropped_frame().get());
+ libyuv::I420Copy(cropped_y_plane, 16, cropped_u_plane, 8, cropped_v_plane, 8,
+ cropped_frame()->data(VideoFrame::kYPlane),
+ cropped_frame()->stride(VideoFrame::kYPlane),
+ cropped_frame()->data(VideoFrame::kUPlane),
+ cropped_frame()->stride(VideoFrame::kUPlane),
+ cropped_frame()->data(VideoFrame::kVPlane),
+ cropped_frame()->stride(VideoFrame::kVPlane), 16, 16);
}
SkCanvasVideoRendererTest::~SkCanvasVideoRendererTest() {}