[email protected] | a101cf3 | 2012-01-14 00:34:23 | [diff] [blame^] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | c3af26f33 | 2010-10-06 22:46:00 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef REMOTING_BASE_UTIL_H_ |
| 6 | #define REMOTING_BASE_UTIL_H_ |
| 7 | |
[email protected] | 82156e8 | 2011-12-20 07:09:01 | [diff] [blame] | 8 | #include <string> |
| 9 | |
[email protected] | 3adf1b2 | 2010-11-09 23:22:20 | [diff] [blame] | 10 | #include "media/base/video_frame.h" |
[email protected] | dc454a7c | 2011-08-12 22:01:13 | [diff] [blame] | 11 | #include "third_party/skia/include/core/SkRect.h" |
[email protected] | c3af26f33 | 2010-10-06 22:46:00 | [diff] [blame] | 12 | |
| 13 | namespace remoting { |
| 14 | |
[email protected] | a101cf3 | 2012-01-14 00:34:23 | [diff] [blame^] | 15 | // Return a string that contains the current date formatted as 'MMDD/HHMMSS:'. |
[email protected] | 82d105e | 2011-08-04 03:19:35 | [diff] [blame] | 16 | std::string GetTimestampString(); |
| 17 | |
[email protected] | 5068614 | 2011-02-04 02:08:32 | [diff] [blame] | 18 | // TODO(sergeyu): Move these methods to media. |
[email protected] | 3adf1b2 | 2010-11-09 23:22:20 | [diff] [blame] | 19 | int GetBytesPerPixel(media::VideoFrame::Format format); |
[email protected] | c3af26f33 | 2010-10-06 22:46:00 | [diff] [blame] | 20 | |
[email protected] | 5068614 | 2011-02-04 02:08:32 | [diff] [blame] | 21 | // Convert YUV to RGB32 on a specific rectangle. |
| 22 | void ConvertYUVToRGB32WithRect(const uint8* y_plane, |
| 23 | const uint8* u_plane, |
| 24 | const uint8* v_plane, |
| 25 | uint8* rgb_plane, |
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 26 | const SkIRect& rect, |
[email protected] | 5068614 | 2011-02-04 02:08:32 | [diff] [blame] | 27 | int y_stride, |
| 28 | int uv_stride, |
| 29 | int rgb_stride); |
| 30 | |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 31 | void ScaleYUVToRGB32WithRect(const uint8* y_plane, |
| 32 | const uint8* u_plane, |
| 33 | const uint8* v_plane, |
| 34 | uint8* rgb_plane, |
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 35 | const SkIRect& source_rect, |
| 36 | const SkIRect& dest_rect, |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 37 | int y_stride, |
| 38 | int uv_stride, |
| 39 | int rgb_stride); |
| 40 | |
[email protected] | 5068614 | 2011-02-04 02:08:32 | [diff] [blame] | 41 | void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane, |
| 42 | uint8* y_plane, |
| 43 | uint8* u_plane, |
| 44 | uint8* v_plane, |
| 45 | int x, |
| 46 | int y, |
| 47 | int width, |
| 48 | int height, |
| 49 | int rgb_stride, |
| 50 | int y_stride, |
| 51 | int uv_stride); |
| 52 | |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 53 | int RoundToTwosMultiple(int x); |
| 54 | |
| 55 | // Align the sides of the rectangle to multiples of 2 (expanding outwards). |
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 56 | SkIRect AlignRect(const SkIRect& rect); |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 57 | |
[email protected] | 15e7b6c | 2011-12-22 10:20:33 | [diff] [blame] | 58 | // Scales the supplied rectangle from |in_size| coordinates to |out_size|. |
| 59 | // If the result has non-integer coordinates then the smallest integer- |
| 60 | // coordinate rectangle that wholly encloses it is returned. |
[email protected] | bcad268 | 2011-09-30 20:35:26 | [diff] [blame] | 61 | SkIRect ScaleRect(const SkIRect& rect, |
[email protected] | 15e7b6c | 2011-12-22 10:20:33 | [diff] [blame] | 62 | const SkISize& in_size, |
| 63 | const SkISize& out_size); |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 64 | |
[email protected] | 2cc0ec84 | 2011-08-01 19:59:42 | [diff] [blame] | 65 | // Copy pixels in the rectangle from source to destination. |
| 66 | void CopyRect(const uint8* src_plane, |
| 67 | int src_plane_stride, |
| 68 | uint8* dest_plane, |
| 69 | int dest_plane_stride, |
| 70 | int bytes_per_pixel, |
[email protected] | dc454a7c | 2011-08-12 22:01:13 | [diff] [blame] | 71 | const SkIRect& rect); |
[email protected] | 2cc0ec84 | 2011-08-01 19:59:42 | [diff] [blame] | 72 | |
[email protected] | c3af26f33 | 2010-10-06 22:46:00 | [diff] [blame] | 73 | } // namespace remoting |
| 74 | |
| 75 | #endif // REMOTING_BASE_UTIL_H_ |