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

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: 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
« media/base/video_util.h ('K') | « 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 // The reference to |frame| is kept in the closure that calls this method.
mcasas 2016/02/29 23:48:01 nit: This second sentence doesn't make sense :)
emircan 2016/03/01 20:07:55 Done.
21 void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) {}
mcasas 2016/02/29 23:48:01 Can we use base::DeletePointer? [1] Also, no empt
emircan 2016/03/01 20:07:55 DeletePointer doesn't support ref_ptr as it only e
22
23 } // namespace
24
17 gfx::Size GetNaturalSize(const gfx::Size& visible_size, 25 gfx::Size GetNaturalSize(const gfx::Size& visible_size,
18 int aspect_ratio_numerator, 26 int aspect_ratio_numerator,
19 int aspect_ratio_denominator) { 27 int aspect_ratio_denominator) {
20 if (aspect_ratio_denominator == 0 || 28 if (aspect_ratio_denominator == 0 ||
21 aspect_ratio_numerator < 0 || 29 aspect_ratio_numerator < 0 ||
22 aspect_ratio_denominator < 0) 30 aspect_ratio_denominator < 0)
23 return gfx::Size(); 31 return gfx::Size();
24 32
25 double aspect_ratio = aspect_ratio_numerator / 33 double aspect_ratio = aspect_ratio_numerator /
26 static_cast<double>(aspect_ratio_denominator); 34 static_cast<double>(aspect_ratio_denominator);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 frame->data(kY) + y_offset, 317 frame->data(kY) + y_offset,
310 frame->data(kU) + uv_offset, 318 frame->data(kU) + uv_offset,
311 frame->data(kV) + uv_offset, 319 frame->data(kV) + uv_offset,
312 region_in_frame.width(), 320 region_in_frame.width(),
313 region_in_frame.height(), 321 region_in_frame.height(),
314 stride, 322 stride,
315 frame->stride(kY), 323 frame->stride(kY),
316 uv_stride); 324 uv_stride);
317 } 325 }
318 326
327 scoped_refptr<VideoFrame> DropYV12AAlphaChannel(
328 const scoped_refptr<VideoFrame>& frame) {
329 DCHECK_EQ(VideoFrame::STORAGE_OWNED_MEMORY, frame->storage_type());
330 DCHECK_EQ(PIXEL_FORMAT_YV12A, frame->format());
331
332 scoped_refptr<media::VideoFrame> wrapped_frame =
333 media::VideoFrame::WrapVideoFrame(frame, PIXEL_FORMAT_I420,
334 frame->visible_rect(),
335 frame->natural_size());
336 if (!wrapped_frame)
337 return nullptr;
338 wrapped_frame->AddDestructionObserver(
339 base::Bind(&ReleaseOriginalFrame, frame));
340 return wrapped_frame;
341 }
342
319 } // namespace media 343 } // namespace media
OLDNEW
« media/base/video_util.h ('K') | « media/base/video_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698