OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 size_t CalcBufferSize(VideoType type, int width, int height); | 62 size_t CalcBufferSize(VideoType type, int width, int height); |
63 | 63 |
64 // TODO(mikhal): Add unit test for these two functions and determine location. | 64 // TODO(mikhal): Add unit test for these two functions and determine location. |
65 // Print VideoFrame to file | 65 // Print VideoFrame to file |
66 // Input: | 66 // Input: |
67 // - frame : Reference to video frame. | 67 // - frame : Reference to video frame. |
68 // - file : pointer to file object. It is assumed that the file is | 68 // - file : pointer to file object. It is assumed that the file is |
69 // already open for writing. | 69 // already open for writing. |
70 // Return value: 0 if OK, < 0 otherwise. | 70 // Return value: 0 if OK, < 0 otherwise. |
71 int PrintVideoFrame(const VideoFrame& frame, FILE* file); | 71 int PrintVideoFrame(const VideoFrame& frame, FILE* file); |
72 int PrintVideoFrame(const VideoFrameBuffer& frame, FILE* file); | |
73 | 72 |
74 // Extract buffer from VideoFrame or VideoFrameBuffer (consecutive | 73 // Extract buffer from VideoFrame or VideoFrameBuffer (consecutive |
75 // planes, no stride) | 74 // planes, no stride) |
76 // Input: | 75 // Input: |
77 // - frame : Reference to video frame. | 76 // - frame : Reference to video frame. |
78 // - size : pointer to the size of the allocated buffer. If size is | 77 // - size : pointer to the size of the allocated buffer. If size is |
79 // insufficient, an error will be returned. | 78 // insufficient, an error will be returned. |
80 // - buffer : Pointer to buffer | 79 // - buffer : Pointer to buffer |
81 // Return value: length of buffer if OK, < 0 otherwise. | 80 // Return value: length of buffer if OK, < 0 otherwise. |
82 int ExtractBuffer(const rtc::scoped_refptr<VideoFrameBuffer>& input_frame, | 81 int ExtractBuffer(const rtc::scoped_refptr<VideoFrameBuffer>& input_frame, |
83 size_t size, | 82 size_t size, |
84 uint8_t* buffer); | 83 uint8_t* buffer); |
85 int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer); | 84 int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer); |
86 // Convert To I420 | 85 // Convert To I420 |
87 // Input: | 86 // Input: |
88 // - src_video_type : Type of input video. | 87 // - src_video_type : Type of input video. |
89 // - src_frame : Pointer to a source frame. | 88 // - src_frame : Pointer to a source frame. |
90 // - crop_x/crop_y : Starting positions for cropping (0 for no crop). | 89 // - crop_x/crop_y : Starting positions for cropping (0 for no crop). |
91 // - src_width : src width in pixels. | 90 // - src_width : src width in pixels. |
92 // - src_height : src height in pixels. | 91 // - src_height : src height in pixels. |
93 // - sample_size : Required only for the parsing of MJPG (set to 0 else). | 92 // - sample_size : Required only for the parsing of MJPG (set to 0 else). |
94 // - rotate : Rotation mode of output image. | 93 // - rotate : Rotation mode of output image. |
95 // Output: | 94 // Output: |
96 // - dst_buffer : Reference to a destination frame buffer. | 95 // - dst_frame : Reference to a destination frame. |
97 // Return value: 0 if OK, < 0 otherwise. | 96 // Return value: 0 if OK, < 0 otherwise. |
98 | 97 |
99 // TODO(nisse): Delete this wrapper, and let users call libyuv directly. Most | 98 // TODO(nisse): Deprecated, see |
100 // calls pass |src_video_type| == kI420, and should use libyuv::I420Copy. The | 99 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5921. |
101 // only exception at the time of this writing is | |
102 // VideoCaptureImpl::IncomingFrame, which still needs libyuv::ConvertToI420. | |
103 int ConvertToI420(VideoType src_video_type, | 100 int ConvertToI420(VideoType src_video_type, |
104 const uint8_t* src_frame, | 101 const uint8_t* src_frame, |
105 int crop_x, | 102 int crop_x, |
106 int crop_y, | 103 int crop_y, |
107 int src_width, | 104 int src_width, |
108 int src_height, | 105 int src_height, |
109 size_t sample_size, | 106 size_t sample_size, |
110 VideoRotation rotation, | 107 VideoRotation rotation, |
111 I420Buffer* dst_buffer); | 108 VideoFrame* dst_frame); |
112 | 109 |
113 // Convert From I420 | 110 // Convert From I420 |
114 // Input: | 111 // Input: |
115 // - src_frame : Reference to a source frame. | 112 // - src_frame : Reference to a source frame. |
116 // - dst_video_type : Type of output video. | 113 // - dst_video_type : Type of output video. |
117 // - dst_sample_size : Required only for the parsing of MJPG. | 114 // - dst_sample_size : Required only for the parsing of MJPG. |
118 // - dst_frame : Pointer to a destination frame. | 115 // - dst_frame : Pointer to a destination frame. |
119 // Return value: 0 if OK, < 0 otherwise. | 116 // Return value: 0 if OK, < 0 otherwise. |
120 // It is assumed that source and destination have equal height. | 117 // It is assumed that source and destination have equal height. |
121 int ConvertFromI420(const VideoFrame& src_frame, | 118 int ConvertFromI420(const VideoFrame& src_frame, |
(...skipping 24 matching lines...) Expand all Loading... |
146 uint8_t* dst_u, int dst_stride_u, | 143 uint8_t* dst_u, int dst_stride_u, |
147 uint8_t* dst_v, int dst_stride_v, | 144 uint8_t* dst_v, int dst_stride_v, |
148 int dst_width, int dst_height); | 145 int dst_width, int dst_height); |
149 private: | 146 private: |
150 std::vector<uint8_t> tmp_uv_planes_; | 147 std::vector<uint8_t> tmp_uv_planes_; |
151 }; | 148 }; |
152 | 149 |
153 } // namespace webrtc | 150 } // namespace webrtc |
154 | 151 |
155 #endif // WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_WEBRTC_LIBYUV_H_ | 152 #endif // WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_WEBRTC_LIBYUV_H_ |
OLD | NEW |