diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-29 01:49:55 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-29 01:49:55 +0000 |
commit | 6fdf57766b26fdec6374bbfce16d230f9ec3e5a7 (patch) | |
tree | a8cc0c851fb0e09527947dd9c4f7a5baf868bb89 /media | |
parent | 9b36f289370e3bfa542d2d047e6d52e0cc131c33 (diff) | |
download | chromium_src-6fdf57766b26fdec6374bbfce16d230f9ec3e5a7.zip chromium_src-6fdf57766b26fdec6374bbfce16d230f9ec3e5a7.tar.gz chromium_src-6fdf57766b26fdec6374bbfce16d230f9ec3e5a7.tar.bz2 |
Delete media::VideoFrame::planes() and ::planes_ since they can be derived from format().
This lets us delete craxy code that first asks for format() and then ensures
that the world hasn't gone crazy and given an RGB frame 4 planes (for example).
BUG=107043
TEST=trybots.
Review URL: http://codereview.chromium.org/8989067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/video_frame.cc | 5 | ||||
-rw-r--r-- | media/base/video_frame.h | 9 | ||||
-rw-r--r-- | media/base/video_frame_unittest.cc | 9 | ||||
-rw-r--r-- | media/tools/player_x11/gl_video_renderer.cc | 14 | ||||
-rw-r--r-- | media/tools/player_x11/x11_video_renderer.cc | 1 | ||||
-rw-r--r-- | media/tools/shader_bench/cpu_color_painter.cc | 6 | ||||
-rw-r--r-- | media/tools/shader_bench/gpu_color_painter.cc | 10 | ||||
-rw-r--r-- | media/tools/shader_bench/gpu_color_painter_exp.cc | 8 |
8 files changed, 21 insertions, 41 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 29c4223..918b3d3 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -55,7 +55,6 @@ scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( const base::Closure& no_longer_needed) { scoped_refptr<VideoFrame> frame( new VideoFrame(NATIVE_TEXTURE, width, height, timestamp, duration)); - frame->planes_ = 0; frame->texture_id_ = texture_id; frame->texture_no_longer_needed_ = no_longer_needed; return frame; @@ -114,7 +113,6 @@ void VideoFrame::AllocateRGB(size_t bytes_per_pixel) { // Round up to align at a 64-bit (8 byte) boundary for each row. This // is sufficient for MMX reads (movq). size_t bytes_per_row = RoundUp(width_ * bytes_per_pixel, 8); - planes_ = VideoFrame::kNumRGBPlanes; strides_[VideoFrame::kRGBPlane] = bytes_per_row; data_[VideoFrame::kRGBPlane] = new uint8[bytes_per_row * height_]; DCHECK(!(reinterpret_cast<intptr_t>(data_[VideoFrame::kRGBPlane]) & 7)); @@ -142,7 +140,6 @@ void VideoFrame::AllocateYUV() { size_t uv_bytes = uv_height * uv_stride; uint8* data = new uint8[y_bytes + (uv_bytes * 2) + kFramePadBytes]; - planes_ = VideoFrame::kNumYUVPlanes; COMPILE_ASSERT(0 == VideoFrame::kYPlane, y_plane_data_must_be_index_0); data_[VideoFrame::kYPlane] = data; data_[VideoFrame::kUPlane] = data + y_bytes; @@ -160,7 +157,6 @@ VideoFrame::VideoFrame(VideoFrame::Format format, : format_(format), width_(width), height_(height), - planes_(0), texture_id_(0) { SetTimestamp(timestamp); SetDuration(duration); @@ -268,7 +264,6 @@ uint8* VideoFrame::data(size_t plane) const { uint32 VideoFrame::texture_id() const { DCHECK_EQ(format_, NATIVE_TEXTURE); - DCHECK_EQ(planes_, 0U); return texture_id_; } diff --git a/media/base/video_frame.h b/media/base/video_frame.h index c776f5f..e9e95fd 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -15,11 +15,8 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { enum { kMaxPlanes = 3, - kNumRGBPlanes = 1, kRGBPlane = 0, - kNumYUVPlanes = 3, - kNumNV12Planes = 2, kYPlane = 0, kUPlane = 1, kVPlane = 2, @@ -78,8 +75,6 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { size_t height() const { return height_; } - size_t planes() const { return planes_; } - int stride(size_t plane) const; // Returns the number of bytes per row and number of rows for a given plane. @@ -124,10 +119,6 @@ class MEDIA_EXPORT VideoFrame : public StreamSample { size_t width_; size_t height_; - // Number of planes, typically 1 for packed RGB formats, 3 for planar - // YUV formats, and 0 for native textures. - size_t planes_; - // Array of strides for each plane, typically greater or equal to the width // of the surface divided by the horizontal sampling period. Note that // strides can be negative. diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc index 2d4a2fe..d90469b 100644 --- a/media/base/video_frame_unittest.cc +++ b/media/base/video_frame_unittest.cc @@ -40,14 +40,7 @@ void InitializeYV12Frame(VideoFrame* frame, double white_to_black) { // Given a |yv12_frame| this method converts the YV12 frame to RGBA and // makes sure that all the pixels of the RBG frame equal |expect_rgb_color|. void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) { - // On linux and mac builds if you directly compare using EXPECT_EQ and use - // the VideoFrame::kNumxxxPlanes constants, it generates an error when - // linking. These are declared so that we can compare against locals. - const size_t expect_yuv_planes = VideoFrame::kNumYUVPlanes; - const size_t expect_rgb_planes = VideoFrame::kNumRGBPlanes; - ASSERT_EQ(VideoFrame::YV12, yv12_frame->format()); - ASSERT_EQ(expect_yuv_planes, yv12_frame->planes()); ASSERT_EQ(yv12_frame->stride(VideoFrame::kUPlane), yv12_frame->stride(VideoFrame::kVPlane)); @@ -60,7 +53,6 @@ void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) { ASSERT_EQ(yv12_frame->width(), rgb_frame->width()); ASSERT_EQ(yv12_frame->height(), rgb_frame->height()); - ASSERT_EQ(expect_rgb_planes, rgb_frame->planes()); media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane), yv12_frame->data(VideoFrame::kUPlane), @@ -150,7 +142,6 @@ TEST(VideoFrame, CreateBlackFrame) { EXPECT_EQ(VideoFrame::YV12, frame->format()); EXPECT_EQ(kWidth, frame->width()); EXPECT_EQ(kHeight, frame->height()); - EXPECT_EQ(3u, frame->planes()); // Test frames themselves. uint8* y_plane = frame->data(VideoFrame::kYPlane); diff --git a/media/tools/player_x11/gl_video_renderer.cc b/media/tools/player_x11/gl_video_renderer.cc index fc36991..ee3c59b 100644 --- a/media/tools/player_x11/gl_video_renderer.cc +++ b/media/tools/player_x11/gl_video_renderer.cc @@ -13,6 +13,8 @@ #include "media/base/yuv_convert.h" #include "ui/gfx/gl/gl_implementation.h" +enum { kNumYUVPlanes = 3 }; + static GLXContext InitGLContext(Display* display, Window window) { // Some versions of NVIDIA's GL libGL.so include a broken version of // dlopen/dlsym, and so linking it into chrome breaks it. So we dynamically @@ -126,18 +128,14 @@ void GlVideoRenderer::Paint(media::VideoFrame* video_frame) { video_frame->format() == media::VideoFrame::YV16); DCHECK(video_frame->stride(media::VideoFrame::kUPlane) == video_frame->stride(media::VideoFrame::kVPlane)); - DCHECK(video_frame->planes() == media::VideoFrame::kNumYUVPlanes); if (glXGetCurrentContext() != gl_context_ || glXGetCurrentDrawable() != window_) { glXMakeCurrent(display_, window_, gl_context_); } - for (unsigned int i = 0; i < media::VideoFrame::kNumYUVPlanes; ++i) { - unsigned int width = (i == media::VideoFrame::kYPlane) ? - video_frame->width() : video_frame->width() / 2; - unsigned int height = (i == media::VideoFrame::kYPlane || - video_frame->format() == media::VideoFrame::YV16) ? - video_frame->height() : video_frame->height() / 2; + for (unsigned int i = 0; i < kNumYUVPlanes; ++i) { + unsigned int width = video_frame->stride(i); + unsigned int height = video_frame->rows(i); glActiveTexture(GL_TEXTURE0 + i); glPixelStorei(GL_UNPACK_ROW_LENGTH, video_frame->stride(i)); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, @@ -160,7 +158,7 @@ void GlVideoRenderer::Initialize(int width, int height) { // Create 3 textures, one for each plane, and bind them to different // texture units. - glGenTextures(media::VideoFrame::kNumYUVPlanes, textures_); + glGenTextures(3, textures_); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures_[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); diff --git a/media/tools/player_x11/x11_video_renderer.cc b/media/tools/player_x11/x11_video_renderer.cc index 9cde66d..b1f0cff 100644 --- a/media/tools/player_x11/x11_video_renderer.cc +++ b/media/tools/player_x11/x11_video_renderer.cc @@ -101,7 +101,6 @@ void X11VideoRenderer::Paint(media::VideoFrame* video_frame) { video_frame->format() == media::VideoFrame::YV16); DCHECK(video_frame->stride(media::VideoFrame::kUPlane) == video_frame->stride(media::VideoFrame::kVPlane)); - DCHECK(video_frame->planes() == media::VideoFrame::kNumYUVPlanes); DCHECK(image_->data); media::YUVType yuv_type = diff --git a/media/tools/shader_bench/cpu_color_painter.cc b/media/tools/shader_bench/cpu_color_painter.cc index 7743e7e..e8b7562 100644 --- a/media/tools/shader_bench/cpu_color_painter.cc +++ b/media/tools/shader_bench/cpu_color_painter.cc @@ -5,6 +5,8 @@ #include "media/base/yuv_convert.h" #include "media/tools/shader_bench/cpu_color_painter.h" +enum { kNumRGBPlanes = 1 }; + // Pass-through vertex shader. static const char kVertexShader[] = "precision highp float;\n" @@ -39,12 +41,12 @@ CPUColorPainter::CPUColorPainter() CPUColorPainter::~CPUColorPainter() { if (program_id_) { glDeleteProgram(program_id_); - glDeleteTextures(media::VideoFrame::kNumRGBPlanes, textures_); + glDeleteTextures(kNumRGBPlanes, textures_); } } void CPUColorPainter::Initialize(int width, int height) { - glGenTextures(media::VideoFrame::kNumRGBPlanes, textures_); + glGenTextures(kNumRGBPlanes, textures_); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures_[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); diff --git a/media/tools/shader_bench/gpu_color_painter.cc b/media/tools/shader_bench/gpu_color_painter.cc index 908bb9f..82d3056 100644 --- a/media/tools/shader_bench/gpu_color_painter.cc +++ b/media/tools/shader_bench/gpu_color_painter.cc @@ -5,6 +5,8 @@ #include "media/tools/shader_bench/gpu_color_painter.h" #include "ui/gfx/gl/gl_context.h" +enum { kNumYUVPlanes = 3 }; + // Matrix used for the YUV to RGB conversion. static const float kYUV2RGB[9] = { 1.f, 0.f, 1.403f, @@ -59,16 +61,16 @@ GPUColorWithLuminancePainter::GPUColorWithLuminancePainter() GPUColorWithLuminancePainter::~GPUColorWithLuminancePainter() { if (program_id_) { glDeleteProgram(program_id_); - glDeleteTextures(media::VideoFrame::kNumYUVPlanes, textures_); + glDeleteTextures(kNumYUVPlanes, textures_); } } void GPUColorWithLuminancePainter::Initialize(int width, int height) { // Create 3 textures, one for each plane, and bind them to different // texture units. - glGenTextures(media::VideoFrame::kNumYUVPlanes, textures_); + glGenTextures(kNumYUVPlanes, textures_); - for (unsigned int i = 0; i < media::VideoFrame::kNumYUVPlanes; ++i) { + for (unsigned int i = 0; i < kNumYUVPlanes; ++i) { unsigned int texture_width = (i == media::VideoFrame::kYPlane) ? width : width / 2; unsigned int texture_height = (i == media::VideoFrame::kYPlane) ? @@ -102,7 +104,7 @@ void GPUColorWithLuminancePainter::Initialize(int width, int height) { void GPUColorWithLuminancePainter::Paint( scoped_refptr<media::VideoFrame> video_frame) { - for (unsigned int i = 0; i < media::VideoFrame::kNumYUVPlanes; ++i) { + for (unsigned int i = 0; i < kNumYUVPlanes; ++i) { unsigned int width = (i == media::VideoFrame::kYPlane) ? video_frame->width() : video_frame->width() / 2; unsigned int height = (i == media::VideoFrame::kYPlane) ? diff --git a/media/tools/shader_bench/gpu_color_painter_exp.cc b/media/tools/shader_bench/gpu_color_painter_exp.cc index 668fb0f..860c1bf 100644 --- a/media/tools/shader_bench/gpu_color_painter_exp.cc +++ b/media/tools/shader_bench/gpu_color_painter_exp.cc @@ -4,6 +4,8 @@ #include "media/tools/shader_bench/gpu_color_painter_exp.h" +enum { kNumYUVPlanes = 3 }; + // Matrix used for the YUV to RGB conversion. static const float kYUV2RGB[9] = { 1.f, 0.f, 1.403f, @@ -74,13 +76,13 @@ GPUColorRGBALumHackPainter::GPUColorRGBALumHackPainter() GPUColorRGBALumHackPainter::~GPUColorRGBALumHackPainter() { if (program_id_) { glDeleteProgram(program_id_); - glDeleteTextures(media::VideoFrame::kNumYUVPlanes, textures_); + glDeleteTextures(kNumYUVPlanes, textures_); } } void GPUColorRGBALumHackPainter::Initialize(int width, int height) { glGenTextures(3, textures_); - for (unsigned int i = 0; i < media::VideoFrame::kNumYUVPlanes; ++i) { + for (unsigned int i = 0; i < kNumYUVPlanes; ++i) { unsigned int texture_width = (i == media::VideoFrame::kYPlane) ? width : width / 2; unsigned int texture_height = (i == media::VideoFrame::kYPlane) ? @@ -115,7 +117,7 @@ void GPUColorRGBALumHackPainter::Initialize(int width, int height) { void GPUColorRGBALumHackPainter::Paint( scoped_refptr<media::VideoFrame> video_frame) { - for (unsigned int i = 0; i < media::VideoFrame::kNumYUVPlanes; ++i) { + for (unsigned int i = 0; i < kNumYUVPlanes; ++i) { unsigned int width = (i == media::VideoFrame::kYPlane) ? video_frame->width() : video_frame->width() / 2; unsigned int height = (i == media::VideoFrame::kYPlane) ? |