Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #ifndef MEDIA_BASE_VIDEO_UTIL_H_ |
michael@0 | 6 | #define MEDIA_BASE_VIDEO_UTIL_H_ |
michael@0 | 7 | |
michael@0 | 8 | #include "mp4_demuxer/basictypes.h" |
michael@0 | 9 | |
michael@0 | 10 | namespace mp4_demuxer { |
michael@0 | 11 | |
michael@0 | 12 | class VideoFrame; |
michael@0 | 13 | |
michael@0 | 14 | // Computes the size of |visible_size| for a given aspect ratio. |
michael@0 | 15 | IntSize GetNaturalSize(const IntSize& visible_size, |
michael@0 | 16 | int aspect_ratio_numerator, |
michael@0 | 17 | int aspect_ratio_denominator); |
michael@0 | 18 | /* |
michael@0 | 19 | // Copies a plane of YUV(A) source into a VideoFrame object, taking into account |
michael@0 | 20 | // source and destinations dimensions. |
michael@0 | 21 | // |
michael@0 | 22 | // NOTE: rows is *not* the same as height! |
michael@0 | 23 | void CopyYPlane(const uint8_t* source, int stride, int rows, |
michael@0 | 24 | VideoFrame* frame); |
michael@0 | 25 | void CopyUPlane(const uint8_t* source, int stride, int rows, |
michael@0 | 26 | VideoFrame* frame); |
michael@0 | 27 | void CopyVPlane(const uint8_t* source, int stride, int rows, |
michael@0 | 28 | VideoFrame* frame); |
michael@0 | 29 | void CopyAPlane(const uint8_t* source, int stride, int rows, |
michael@0 | 30 | VideoFrame* frame); |
michael@0 | 31 | |
michael@0 | 32 | // Sets alpha plane values to be completely opaque (all 255's). |
michael@0 | 33 | void MakeOpaqueAPlane(int stride, int rows, VideoFrame* frame); |
michael@0 | 34 | |
michael@0 | 35 | // |plane| is one of VideoFrame::kYPlane, VideoFrame::kUPlane, |
michael@0 | 36 | // VideoFrame::kVPlane or VideoFrame::kAPlane |
michael@0 | 37 | void CopyPlane(size_t plane, const uint8_t* source, int stride, |
michael@0 | 38 | int rows, VideoFrame* frame); |
michael@0 | 39 | |
michael@0 | 40 | |
michael@0 | 41 | // Fills |frame| containing YUV data to the given color values. |
michael@0 | 42 | void FillYUV(VideoFrame* frame, uint8_t y, uint8_t u, uint8_t v); |
michael@0 | 43 | |
michael@0 | 44 | // Creates a border in |frame| such that all pixels outside of |
michael@0 | 45 | // |view_area| are black. The size and position of |view_area| |
michael@0 | 46 | // must be even to align correctly with the color planes. |
michael@0 | 47 | // Only YV12 format video frames are currently supported. |
michael@0 | 48 | void LetterboxYUV(VideoFrame* frame, |
michael@0 | 49 | const gfx::Rect& view_area); |
michael@0 | 50 | |
michael@0 | 51 | // Rotates |src| plane by |rotation| degree with possible flipping vertically |
michael@0 | 52 | // and horizontally. |
michael@0 | 53 | // |rotation| is limited to {0, 90, 180, 270}. |
michael@0 | 54 | // |width| and |height| are expected to be even numbers. |
michael@0 | 55 | // Both |src| and |dest| planes are packed and have same |width| and |height|. |
michael@0 | 56 | // When |width| != |height| and rotated by 90/270, only the maximum square |
michael@0 | 57 | // portion located in the center is rotated. For example, for width=640 and |
michael@0 | 58 | // height=480, the rotated area is 480x480 located from row 0 through 479 and |
michael@0 | 59 | // from column 80 through 559. The leftmost and rightmost 80 columns are |
michael@0 | 60 | // ignored for both |src| and |dest|. |
michael@0 | 61 | // The caller is responsible for blanking out the margin area. |
michael@0 | 62 | void RotatePlaneByPixels( |
michael@0 | 63 | const uint8_t* src, |
michael@0 | 64 | uint8_t* dest, |
michael@0 | 65 | int width, |
michael@0 | 66 | int height, |
michael@0 | 67 | int rotation, // Clockwise. |
michael@0 | 68 | bool flip_vert, |
michael@0 | 69 | bool flip_horiz); |
michael@0 | 70 | |
michael@0 | 71 | // Return the largest centered rectangle with the same aspect ratio of |content| |
michael@0 | 72 | // that fits entirely inside of |bounds|. |
michael@0 | 73 | gfx::Rect ComputeLetterboxRegion(const gfx::Rect& bounds, |
michael@0 | 74 | const IntSize& content); |
michael@0 | 75 | |
michael@0 | 76 | // Copy an RGB bitmap into the specified |region_in_frame| of a YUV video frame. |
michael@0 | 77 | // Fills the regions outside |region_in_frame| with black. |
michael@0 | 78 | void CopyRGBToVideoFrame(const uint8_t* source, |
michael@0 | 79 | int stride, |
michael@0 | 80 | const gfx::Rect& region_in_frame, |
michael@0 | 81 | VideoFrame* frame); |
michael@0 | 82 | */ |
michael@0 | 83 | |
michael@0 | 84 | } // namespace mp4_demuxer |
michael@0 | 85 | |
michael@0 | 86 | #endif // MEDIA_BASE_VIDEO_UTIL_H_ |