diff options
author | rileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-05 19:10:51 +0000 |
---|---|---|
committer | rileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-05 19:10:51 +0000 |
commit | f125f922278ba8ca2558da2bda7914742931d3c2 (patch) | |
tree | dc21baa750007b06091818f740af1a013347714d /media | |
parent | 3725485f625bba24fc5537029e8a683cd3785c23 (diff) | |
download | chromium_src-f125f922278ba8ca2558da2bda7914742931d3c2.zip chromium_src-f125f922278ba8ca2558da2bda7914742931d3c2.tar.gz chromium_src-f125f922278ba8ca2558da2bda7914742931d3c2.tar.bz2 |
Remove RGB32 from VideoFrame::Format.
It wasn't used anywhere outside of the unit tests.
BUG=313827
TBR=danakj
Review URL: https://codereview.chromium.org/56713002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233046 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/video_frame.cc | 31 | ||||
-rw-r--r-- | media/base/video_frame.h | 5 | ||||
-rw-r--r-- | media/base/video_frame_unittest.cc | 44 | ||||
-rw-r--r-- | media/filters/video_renderer_base_unittest.cc | 2 |
4 files changed, 24 insertions, 58 deletions
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc index 9c07251..f706cde 100644 --- a/media/base/video_frame.cc +++ b/media/base/video_frame.cc @@ -28,9 +28,6 @@ scoped_refptr<VideoFrame> VideoFrame::CreateFrame( scoped_refptr<VideoFrame> frame(new VideoFrame( format, coded_size, visible_rect, natural_size, timestamp)); switch (format) { - case VideoFrame::RGB32: - frame->AllocateRGB(4u); - break; case VideoFrame::YV12: case VideoFrame::YV12A: case VideoFrame::YV16: @@ -48,8 +45,6 @@ std::string VideoFrame::FormatToString(VideoFrame::Format format) { switch (format) { case VideoFrame::UNKNOWN: return "UNKNOWN"; - case VideoFrame::RGB32: - return "RGB32"; case VideoFrame::YV12: return "YV12"; case VideoFrame::YV16: @@ -231,8 +226,6 @@ size_t VideoFrame::NumPlanes(Format format) { case VideoFrame::HOLE: #endif return 0; - case VideoFrame::RGB32: - return 1; case VideoFrame::YV12: case VideoFrame::YV16: case VideoFrame::I420: @@ -256,8 +249,6 @@ static inline size_t RoundUp(size_t value, size_t alignment) { // static size_t VideoFrame::AllocationSize(Format format, const gfx::Size& coded_size) { switch (format) { - case VideoFrame::RGB32: - return coded_size.GetArea() * 4; case VideoFrame::YV12: case VideoFrame::I420: { const size_t rounded_size = @@ -286,27 +277,12 @@ size_t VideoFrame::AllocationSize(Format format, const gfx::Size& coded_size) { return 0; } -// Release data allocated by AllocateRGB() or AllocateYUV(). +// Release data allocated by AllocateYUV(). static void ReleaseData(uint8* data) { DCHECK(data); base::AlignedFree(data); } -void VideoFrame::AllocateRGB(size_t bytes_per_pixel) { - // Round up to align at least at a 16-byte boundary for each row. - // This is sufficient for MMX and SSE2 reads (movq/movdqa). - size_t bytes_per_row = RoundUp(coded_size_.width(), - kFrameSizeAlignment) * bytes_per_pixel; - size_t aligned_height = RoundUp(coded_size_.height(), kFrameSizeAlignment); - strides_[VideoFrame::kRGBPlane] = bytes_per_row; - data_[VideoFrame::kRGBPlane] = reinterpret_cast<uint8*>( - base::AlignedAlloc(bytes_per_row * aligned_height + kFrameSizePadding, - kFrameAddressAlignment)); - no_longer_needed_cb_ = base::Bind(&ReleaseData, data_[VideoFrame::kRGBPlane]); - DCHECK(!(reinterpret_cast<intptr_t>(data_[VideoFrame::kRGBPlane]) & 7)); - COMPILE_ASSERT(0 == VideoFrame::kRGBPlane, RGB_data_must_be_index_0); -} - void VideoFrame::AllocateYUV() { DCHECK(format_ == VideoFrame::YV12 || format_ == VideoFrame::YV16 || format_ == VideoFrame::YV12A || format_ == VideoFrame::I420); @@ -394,10 +370,6 @@ int VideoFrame::row_bytes(size_t plane) const { DCHECK(IsValidPlane(plane)); int width = coded_size_.width(); switch (format_) { - // 32bpp. - case RGB32: - return width * 4; - // Planar, 8bpp. case YV12A: if (plane == kAPlane) @@ -423,7 +395,6 @@ int VideoFrame::rows(size_t plane) const { DCHECK(IsValidPlane(plane)); int height = coded_size_.height(); switch (format_) { - case RGB32: case YV16: return height; diff --git a/media/base/video_frame.h b/media/base/video_frame.h index fa8aa96..df0ed23 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -28,8 +28,6 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { enum { kMaxPlanes = 4, - kRGBPlane = 0, - kYPlane = 0, kUPlane = 1, kVPlane = 2, @@ -41,7 +39,6 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { // http://www.fourcc.org/yuv.php enum Format { UNKNOWN = 0, // Unknown format value. - RGB32 = 4, // 32bpp RGB packed with extra byte 8:8:8 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples EMPTY = 9, // An empty frame. @@ -251,8 +248,6 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { base::TimeDelta timestamp); virtual ~VideoFrame(); - // Used internally by CreateFrame(). - void AllocateRGB(size_t bytes_per_pixel); void AllocateYUV(); // Used to DCHECK() plane parameters. diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc index b88d20c..710c69f 100644 --- a/media/base/video_frame_unittest.cc +++ b/media/base/video_frame_unittest.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/format_macros.h" +#include "base/memory/aligned_memory.h" #include "base/memory/scoped_ptr.h" #include "base/strings/stringprintf.h" #include "media/base/buffers.h" @@ -46,40 +47,41 @@ void ExpectFrameColor(media::VideoFrame* yv12_frame, uint32 expect_rgb_color) { ASSERT_EQ(VideoFrame::YV12, yv12_frame->format()); ASSERT_EQ(yv12_frame->stride(VideoFrame::kUPlane), yv12_frame->stride(VideoFrame::kVPlane)); - - scoped_refptr<media::VideoFrame> rgb_frame; - rgb_frame = media::VideoFrame::CreateFrame(VideoFrame::RGB32, - yv12_frame->coded_size(), - yv12_frame->visible_rect(), - yv12_frame->natural_size(), - yv12_frame->GetTimestamp()); - - ASSERT_EQ(yv12_frame->coded_size().width(), - rgb_frame->coded_size().width()); - ASSERT_EQ(yv12_frame->coded_size().height(), - rgb_frame->coded_size().height()); + ASSERT_EQ( + yv12_frame->coded_size().width() & (VideoFrame::kFrameSizeAlignment - 1), + 0); + ASSERT_EQ( + yv12_frame->coded_size().height() & (VideoFrame::kFrameSizeAlignment - 1), + 0); + + size_t bytes_per_row = yv12_frame->coded_size().width() * 4u; + uint8* rgb_data = reinterpret_cast<uint8*>( + base::AlignedAlloc(bytes_per_row * yv12_frame->coded_size().height() + + VideoFrame::kFrameSizePadding, + VideoFrame::kFrameAddressAlignment)); media::ConvertYUVToRGB32(yv12_frame->data(VideoFrame::kYPlane), yv12_frame->data(VideoFrame::kUPlane), yv12_frame->data(VideoFrame::kVPlane), - rgb_frame->data(VideoFrame::kRGBPlane), - rgb_frame->coded_size().width(), - rgb_frame->coded_size().height(), + rgb_data, + yv12_frame->coded_size().width(), + yv12_frame->coded_size().height(), yv12_frame->stride(VideoFrame::kYPlane), yv12_frame->stride(VideoFrame::kUPlane), - rgb_frame->stride(VideoFrame::kRGBPlane), + bytes_per_row, media::YV12); - for (int row = 0; row < rgb_frame->coded_size().height(); ++row) { + for (int row = 0; row < yv12_frame->coded_size().height(); ++row) { uint32* rgb_row_data = reinterpret_cast<uint32*>( - rgb_frame->data(VideoFrame::kRGBPlane) + - (rgb_frame->stride(VideoFrame::kRGBPlane) * row)); - for (int col = 0; col < rgb_frame->coded_size().width(); ++col) { + rgb_data + (bytes_per_row * row)); + for (int col = 0; col < yv12_frame->coded_size().width(); ++col) { SCOPED_TRACE( base::StringPrintf("Checking (%d, %d)", row, col)); EXPECT_EQ(expect_rgb_color, rgb_row_data[col]); } } + + base::AlignedFree(rgb_data); } // Fill each plane to its reported extents and verify accessors report non @@ -204,8 +206,6 @@ TEST(VideoFrame, CheckFrameExtents) { // and the expected hash of all planes if filled with kFillByte (defined in // ExpectFrameExtents). ExpectFrameExtents( - VideoFrame::RGB32, 1, 4, "de6d3d567e282f6a38d478f04fc81fb0"); - ExpectFrameExtents( VideoFrame::YV12, 3, 1, "71113bdfd4c0de6cf62f48fb74f7a0b1"); ExpectFrameExtents( VideoFrame::YV16, 3, 1, "9bb99ac3ff350644ebff4d28dc01b461"); diff --git a/media/filters/video_renderer_base_unittest.cc b/media/filters/video_renderer_base_unittest.cc index 84d356d..db87b61 100644 --- a/media/filters/video_renderer_base_unittest.cc +++ b/media/filters/video_renderer_base_unittest.cc @@ -186,7 +186,7 @@ class VideoRendererBaseTest : public ::testing::Test { gfx::Size natural_size = TestVideoConfig::NormalCodedSize(); scoped_refptr<VideoFrame> frame = VideoFrame::CreateFrame( - VideoFrame::RGB32, natural_size, gfx::Rect(natural_size), natural_size, + VideoFrame::YV12, natural_size, gfx::Rect(natural_size), natural_size, next_frame_timestamp_); decode_results_.push_back(std::make_pair( VideoDecoder::kOk, frame)); |