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

Side by Side Diff: media/base/video_util.cc

Issue 1737253002: Handle Alpha channel in Canvas capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bbudge@ nit. Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « media/base/video_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/video_util.h" 5 #include "media/base/video_util.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
11 #include "base/numerics/safe_math.h" 11 #include "base/numerics/safe_math.h"
12 #include "media/base/video_frame.h" 12 #include "media/base/video_frame.h"
13 #include "media/base/yuv_convert.h" 13 #include "media/base/yuv_convert.h"
14 14
15 namespace media { 15 namespace media {
16 16
17 namespace {
18
19 // Empty method used for keeping a reference to the original media::VideoFrame.
20 void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) {}
21
22 } // namespace
23
17 gfx::Size GetNaturalSize(const gfx::Size& visible_size, 24 gfx::Size GetNaturalSize(const gfx::Size& visible_size,
18 int aspect_ratio_numerator, 25 int aspect_ratio_numerator,
19 int aspect_ratio_denominator) { 26 int aspect_ratio_denominator) {
20 if (aspect_ratio_denominator == 0 || 27 if (aspect_ratio_denominator == 0 ||
21 aspect_ratio_numerator < 0 || 28 aspect_ratio_numerator < 0 ||
22 aspect_ratio_denominator < 0) 29 aspect_ratio_denominator < 0)
23 return gfx::Size(); 30 return gfx::Size();
24 31
25 double aspect_ratio = aspect_ratio_numerator / 32 double aspect_ratio = aspect_ratio_numerator /
26 static_cast<double>(aspect_ratio_denominator); 33 static_cast<double>(aspect_ratio_denominator);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 frame->data(kY) + y_offset, 316 frame->data(kY) + y_offset,
310 frame->data(kU) + uv_offset, 317 frame->data(kU) + uv_offset,
311 frame->data(kV) + uv_offset, 318 frame->data(kV) + uv_offset,
312 region_in_frame.width(), 319 region_in_frame.width(),
313 region_in_frame.height(), 320 region_in_frame.height(),
314 stride, 321 stride,
315 frame->stride(kY), 322 frame->stride(kY),
316 uv_stride); 323 uv_stride);
317 } 324 }
318 325
326 scoped_refptr<VideoFrame> WrapAsI420VideoFrame(
327 const scoped_refptr<VideoFrame>& frame) {
328 DCHECK_EQ(VideoFrame::STORAGE_OWNED_MEMORY, frame->storage_type());
329 DCHECK_EQ(PIXEL_FORMAT_YV12A, frame->format());
330
331 scoped_refptr<media::VideoFrame> wrapped_frame =
332 media::VideoFrame::WrapVideoFrame(frame, PIXEL_FORMAT_I420,
333 frame->visible_rect(),
334 frame->natural_size());
335 if (!wrapped_frame)
336 return nullptr;
337 wrapped_frame->AddDestructionObserver(
338 base::Bind(&ReleaseOriginalFrame, frame));
339 return wrapped_frame;
340 }
341
319 } // namespace media 342 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698