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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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
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 #ifndef MEDIA_BASE_VIDEO_UTIL_H_ 5 #ifndef MEDIA_BASE_VIDEO_UTIL_H_
6 #define MEDIA_BASE_VIDEO_UTIL_H_ 6 #define MEDIA_BASE_VIDEO_UTIL_H_
7 7
8 #include "base/basictypes.h"
9 #include "media/base/media_export.h" 8 #include "media/base/media_export.h"
10 #include "ui/gfx/geometry/rect.h" 9 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h" 10 #include "ui/gfx/geometry/size.h"
12 11
13 namespace media { 12 namespace media {
14 13
15 class VideoFrame; 14 class VideoFrame;
16 15
17 // Computes the size of |visible_size| for a given aspect ratio. 16 // Computes the size of |visible_size| for a given aspect ratio.
18 MEDIA_EXPORT gfx::Size GetNaturalSize(const gfx::Size& visible_size, 17 MEDIA_EXPORT gfx::Size GetNaturalSize(const gfx::Size& visible_size,
19 int aspect_ratio_numerator, 18 int aspect_ratio_numerator,
20 int aspect_ratio_denominator); 19 int aspect_ratio_denominator);
21 20
22 // Fills |frame| containing YUV data to the given color values. 21 // Fills |frame| containing YUV data to the given color values.
23 MEDIA_EXPORT void FillYUV(VideoFrame* frame, uint8 y, uint8 u, uint8 v); 22 MEDIA_EXPORT void FillYUV(VideoFrame* frame, uint8_t y, uint8_t u, uint8_t v);
24 23
25 // Fills |frame| containing YUVA data with the given color values. 24 // Fills |frame| containing YUVA data with the given color values.
26 MEDIA_EXPORT void FillYUVA(VideoFrame* frame, 25 MEDIA_EXPORT void FillYUVA(VideoFrame* frame,
27 uint8 y, 26 uint8_t y,
28 uint8 u, 27 uint8_t u,
29 uint8 v, 28 uint8_t v,
30 uint8 a); 29 uint8_t a);
31 30
32 // Creates a border in |frame| such that all pixels outside of 31 // Creates a border in |frame| such that all pixels outside of
33 // |view_area| are black. The size and position of |view_area| 32 // |view_area| are black. The size and position of |view_area|
34 // must be even to align correctly with the color planes. 33 // must be even to align correctly with the color planes.
35 // Only YV12 format video frames are currently supported. 34 // Only YV12 format video frames are currently supported.
36 MEDIA_EXPORT void LetterboxYUV(VideoFrame* frame, 35 MEDIA_EXPORT void LetterboxYUV(VideoFrame* frame,
37 const gfx::Rect& view_area); 36 const gfx::Rect& view_area);
38 37
39 // Rotates |src| plane by |rotation| degree with possible flipping vertically 38 // Rotates |src| plane by |rotation| degree with possible flipping vertically
40 // and horizontally. 39 // and horizontally.
41 // |rotation| is limited to {0, 90, 180, 270}. 40 // |rotation| is limited to {0, 90, 180, 270}.
42 // |width| and |height| are expected to be even numbers. 41 // |width| and |height| are expected to be even numbers.
43 // Both |src| and |dest| planes are packed and have same |width| and |height|. 42 // Both |src| and |dest| planes are packed and have same |width| and |height|.
44 // When |width| != |height| and rotated by 90/270, only the maximum square 43 // When |width| != |height| and rotated by 90/270, only the maximum square
45 // portion located in the center is rotated. For example, for width=640 and 44 // portion located in the center is rotated. For example, for width=640 and
46 // height=480, the rotated area is 480x480 located from row 0 through 479 and 45 // height=480, the rotated area is 480x480 located from row 0 through 479 and
47 // from column 80 through 559. The leftmost and rightmost 80 columns are 46 // from column 80 through 559. The leftmost and rightmost 80 columns are
48 // ignored for both |src| and |dest|. 47 // ignored for both |src| and |dest|.
49 // The caller is responsible for blanking out the margin area. 48 // The caller is responsible for blanking out the margin area.
50 MEDIA_EXPORT void RotatePlaneByPixels( 49 MEDIA_EXPORT void RotatePlaneByPixels(const uint8_t* src,
51 const uint8* src, 50 uint8_t* dest,
52 uint8* dest, 51 int width,
53 int width, 52 int height,
54 int height, 53 int rotation, // Clockwise.
55 int rotation, // Clockwise. 54 bool flip_vert,
56 bool flip_vert, 55 bool flip_horiz);
57 bool flip_horiz);
58 56
59 // Return the largest centered rectangle with the same aspect ratio of |content| 57 // Return the largest centered rectangle with the same aspect ratio of |content|
60 // that fits entirely inside of |bounds|. If |content| is empty, its aspect 58 // that fits entirely inside of |bounds|. If |content| is empty, its aspect
61 // ratio would be undefined; and in this case an empty Rect would be returned. 59 // ratio would be undefined; and in this case an empty Rect would be returned.
62 MEDIA_EXPORT gfx::Rect ComputeLetterboxRegion(const gfx::Rect& bounds, 60 MEDIA_EXPORT gfx::Rect ComputeLetterboxRegion(const gfx::Rect& bounds,
63 const gfx::Size& content); 61 const gfx::Size& content);
64 62
65 // Return a scaled |size| whose area is less than or equal to |target|, where 63 // Return a scaled |size| whose area is less than or equal to |target|, where
66 // one of its dimensions is equal to |target|'s. The aspect ratio of |size| is 64 // one of its dimensions is equal to |target|'s. The aspect ratio of |size| is
67 // preserved as closely as possible. If |size| is empty, the result will be 65 // preserved as closely as possible. If |size| is empty, the result will be
(...skipping 12 matching lines...) Expand all
80 // matches the aspect ratio of |target|. This is different from 78 // matches the aspect ratio of |target|. This is different from
81 // ScaleSizeToEncompassTarget() in two ways: 1) The goal is to match the aspect 79 // ScaleSizeToEncompassTarget() in two ways: 1) The goal is to match the aspect
82 // ratio of |target| rather than that of |size|. 2) Only one of the dimensions 80 // ratio of |target| rather than that of |size|. 2) Only one of the dimensions
83 // of |size| may change, and it may only be increased (padded). If either 81 // of |size| may change, and it may only be increased (padded). If either
84 // |size| or |target| is empty, the result will be empty. 82 // |size| or |target| is empty, the result will be empty.
85 MEDIA_EXPORT gfx::Size PadToMatchAspectRatio(const gfx::Size& size, 83 MEDIA_EXPORT gfx::Size PadToMatchAspectRatio(const gfx::Size& size,
86 const gfx::Size& target); 84 const gfx::Size& target);
87 85
88 // Copy an RGB bitmap into the specified |region_in_frame| of a YUV video frame. 86 // Copy an RGB bitmap into the specified |region_in_frame| of a YUV video frame.
89 // Fills the regions outside |region_in_frame| with black. 87 // Fills the regions outside |region_in_frame| with black.
90 MEDIA_EXPORT void CopyRGBToVideoFrame(const uint8* source, 88 MEDIA_EXPORT void CopyRGBToVideoFrame(const uint8_t* source,
91 int stride, 89 int stride,
92 const gfx::Rect& region_in_frame, 90 const gfx::Rect& region_in_frame,
93 VideoFrame* frame); 91 VideoFrame* frame);
94 92
95 } // namespace media 93 } // namespace media
96 94
97 #endif // MEDIA_BASE_VIDEO_UTIL_H_ 95 #endif // MEDIA_BASE_VIDEO_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698