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

Unified Diff: cc/resources/video_resource_updater.cc

Issue 178133005: Audit/fix use of media::VideoFrame::coded_size() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 6f577dde Comments. Created 6 years, 10 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
Index: cc/resources/video_resource_updater.cc
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc
index b170be6784b2a443978d6d2fcc94782fb7a4fe2d..d91d00f8ae1fa088d4a0c0e5ef0a1b36bfa6aa1f 100644
--- a/cc/resources/video_resource_updater.cc
+++ b/cc/resources/video_resource_updater.cc
@@ -85,41 +85,6 @@ bool VideoResourceUpdater::VerifyFrame(
return false;
}
-// For frames that we receive in software format, determine the dimensions of
-// each plane in the frame.
-static gfx::Size SoftwarePlaneDimension(
- media::VideoFrame::Format input_frame_format,
- const gfx::Size& coded_size,
- ResourceFormat output_resource_format,
- int plane_index) {
- if (output_resource_format == kYUVResourceFormat) {
- if (plane_index == media::VideoFrame::kYPlane ||
- plane_index == media::VideoFrame::kAPlane)
- return coded_size;
-
- switch (input_frame_format) {
- case media::VideoFrame::YV12:
- case media::VideoFrame::YV12A:
- case media::VideoFrame::YV12J:
- return gfx::ToFlooredSize(gfx::ScaleSize(coded_size, 0.5f, 0.5f));
- case media::VideoFrame::YV16:
- return gfx::ToFlooredSize(gfx::ScaleSize(coded_size, 0.5f, 1.f));
-
- case media::VideoFrame::UNKNOWN:
- case media::VideoFrame::I420:
- case media::VideoFrame::NATIVE_TEXTURE:
- case media::VideoFrame::HISTOGRAM_MAX:
-#if defined(VIDEO_HOLE)
- case media::VideoFrame::HOLE:
-#endif // defined(VIDEO_HOLE)
- NOTREACHED();
- }
- }
-
- DCHECK_EQ(output_resource_format, kRGBResourceFormat);
- return coded_size;
-}
-
VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
const scoped_refptr<media::VideoFrame>& video_frame) {
media::VideoFrame::Format input_frame_format = video_frame->format();
@@ -146,8 +111,7 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
bool software_compositor = context_provider_ == NULL;
ResourceFormat output_resource_format = kYUVResourceFormat;
- size_t output_plane_count =
- (input_frame_format == media::VideoFrame::YV12A) ? 4 : 3;
+ size_t output_plane_count = media::VideoFrame::NumPlanes(input_frame_format);
// TODO(skaslev): If we're in software compositing mode, we do the YUV -> RGB
// conversion here. That involves an extra copy of each frame to a bitmap.
@@ -159,17 +123,17 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
}
int max_resource_size = resource_provider_->max_texture_size();
- gfx::Size coded_frame_size = video_frame->coded_size();
-
std::vector<PlaneResource> plane_resources;
bool allocation_success = true;
for (size_t i = 0; i < output_plane_count; ++i) {
- gfx::Size output_plane_resource_size =
- SoftwarePlaneDimension(input_frame_format,
- coded_frame_size,
- output_resource_format,
- i);
+ gfx::Size output_plane_resource_size = video_frame->coded_size();
+ if (output_resource_format == kYUVResourceFormat) {
+ output_plane_resource_size = media::VideoFrame::PlaneSize(
+ video_frame->format(), i, video_frame->coded_size());
+ } else {
+ DCHECK_EQ(output_resource_format, kRGBResourceFormat);
+ }
if (output_plane_resource_size.IsEmpty() ||
output_plane_resource_size.width() > max_resource_size ||
output_plane_resource_size.height() > max_resource_size) {

Powered by Google App Engine
This is Rietveld 408576698