blob: 8bed6f47b4d5ffac838a3082665a345600f306bd [file] [log] [blame]
[email protected]50686142011-02-04 02:08:321// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]c3af26f332010-10-06 22:46:002// 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]82156e82011-12-20 07:09:018#include <string>
9
[email protected]3adf1b22010-11-09 23:22:2010#include "media/base/video_frame.h"
[email protected]dc454a7c2011-08-12 22:01:1311#include "third_party/skia/include/core/SkRect.h"
[email protected]c3af26f332010-10-06 22:46:0012
13namespace remoting {
14
[email protected]82d105e2011-08-04 03:19:3515std::string GetTimestampString();
16
[email protected]50686142011-02-04 02:08:3217// TODO(sergeyu): Move these methods to media.
[email protected]3adf1b22010-11-09 23:22:2018int GetBytesPerPixel(media::VideoFrame::Format format);
[email protected]c3af26f332010-10-06 22:46:0019
[email protected]50686142011-02-04 02:08:3220// Convert YUV to RGB32 on a specific rectangle.
21void ConvertYUVToRGB32WithRect(const uint8* y_plane,
22 const uint8* u_plane,
23 const uint8* v_plane,
24 uint8* rgb_plane,
[email protected]bcad2682011-09-30 20:35:2625 const SkIRect& rect,
[email protected]50686142011-02-04 02:08:3226 int y_stride,
27 int uv_stride,
28 int rgb_stride);
29
[email protected]47379e92011-07-26 15:33:1530void ScaleYUVToRGB32WithRect(const uint8* y_plane,
31 const uint8* u_plane,
32 const uint8* v_plane,
33 uint8* rgb_plane,
[email protected]bcad2682011-09-30 20:35:2634 const SkIRect& source_rect,
35 const SkIRect& dest_rect,
[email protected]47379e92011-07-26 15:33:1536 int y_stride,
37 int uv_stride,
38 int rgb_stride);
39
[email protected]50686142011-02-04 02:08:3240void ConvertRGB32ToYUVWithRect(const uint8* rgb_plane,
41 uint8* y_plane,
42 uint8* u_plane,
43 uint8* v_plane,
44 int x,
45 int y,
46 int width,
47 int height,
48 int rgb_stride,
49 int y_stride,
50 int uv_stride);
51
[email protected]47379e92011-07-26 15:33:1552int RoundToTwosMultiple(int x);
53
54// Align the sides of the rectangle to multiples of 2 (expanding outwards).
[email protected]bcad2682011-09-30 20:35:2655SkIRect AlignRect(const SkIRect& rect);
[email protected]47379e92011-07-26 15:33:1556
[email protected]15e7b6c2011-12-22 10:20:3357// Scales the supplied rectangle from |in_size| coordinates to |out_size|.
58// If the result has non-integer coordinates then the smallest integer-
59// coordinate rectangle that wholly encloses it is returned.
[email protected]bcad2682011-09-30 20:35:2660SkIRect ScaleRect(const SkIRect& rect,
[email protected]15e7b6c2011-12-22 10:20:3361 const SkISize& in_size,
62 const SkISize& out_size);
[email protected]47379e92011-07-26 15:33:1563
[email protected]2cc0ec842011-08-01 19:59:4264// Copy pixels in the rectangle from source to destination.
65void CopyRect(const uint8* src_plane,
66 int src_plane_stride,
67 uint8* dest_plane,
68 int dest_plane_stride,
69 int bytes_per_pixel,
[email protected]dc454a7c2011-08-12 22:01:1370 const SkIRect& rect);
[email protected]2cc0ec842011-08-01 19:59:4271
[email protected]c3af26f332010-10-06 22:46:0072} // namespace remoting
73
74#endif // REMOTING_BASE_UTIL_H_