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

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: e6f9affb danakj@ 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..2988589e02bcc6e3c0453627953454203da05a5c 100644
--- a/cc/resources/video_resource_updater.cc
+++ b/cc/resources/video_resource_updater.cc
@@ -87,37 +87,17 @@ bool VideoResourceUpdater::VerifyFrame(
// 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,
+static gfx::Size SoftwarePlaneDimensions(
+ const scoped_refptr<media::VideoFrame>& input_frame,
ResourceFormat output_resource_format,
- int plane_index) {
+ size_t plane) {
danakj 2014/02/28 22:28:25 prefer keep this as |plane_index|
sheu 2014/03/01 01:56:57 Done.
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();
- }
+ return media::VideoFrame::PlaneSize(
+ input_frame->format(), plane, input_frame->coded_size());
+ } else {
danakj 2014/02/28 22:28:25 no need for else {} since the if{returns}.
sheu 2014/03/01 01:56:57 Done.
+ DCHECK_EQ(output_resource_format, kRGBResourceFormat);
+ return input_frame->coded_size();
}
-
- DCHECK_EQ(output_resource_format, kRGBResourceFormat);
- return coded_size;
}
VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
@@ -146,8 +126,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 +138,12 @@ 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);
+ SoftwarePlaneDimensions(video_frame, output_resource_format, i);
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