• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS. All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef INCLUDE_LIBYUV_ROTATE_H_
12 #define INCLUDE_LIBYUV_ROTATE_H_
13 
14 #include "libyuv/basic_types.h"
15 
16 #ifdef __cplusplus
17 namespace libyuv {
18 extern "C" {
19 #endif
20 
21 // Supported rotation.
22 typedef enum RotationMode {
23   kRotate0 = 0,      // No rotation.
24   kRotate90 = 90,    // Rotate 90 degrees clockwise.
25   kRotate180 = 180,  // Rotate 180 degrees.
26   kRotate270 = 270,  // Rotate 270 degrees clockwise.
27 
28   // Deprecated.
29   kRotateNone = 0,
30   kRotateClockwise = 90,
31   kRotateCounterClockwise = 270,
32 } RotationModeEnum;
33 
34 // Rotate I420 frame.
35 LIBYUV_API
36 int I420Rotate(const uint8_t* src_y,
37                int src_stride_y,
38                const uint8_t* src_u,
39                int src_stride_u,
40                const uint8_t* src_v,
41                int src_stride_v,
42                uint8_t* dst_y,
43                int dst_stride_y,
44                uint8_t* dst_u,
45                int dst_stride_u,
46                uint8_t* dst_v,
47                int dst_stride_v,
48                int width,
49                int height,
50                enum RotationMode mode);
51 
52 // Rotate I422 frame.
53 LIBYUV_API
54 int I422Rotate(const uint8_t* src_y,
55                int src_stride_y,
56                const uint8_t* src_u,
57                int src_stride_u,
58                const uint8_t* src_v,
59                int src_stride_v,
60                uint8_t* dst_y,
61                int dst_stride_y,
62                uint8_t* dst_u,
63                int dst_stride_u,
64                uint8_t* dst_v,
65                int dst_stride_v,
66                int width,
67                int height,
68                enum RotationMode mode);
69 
70 // Rotate I444 frame.
71 LIBYUV_API
72 int I444Rotate(const uint8_t* src_y,
73                int src_stride_y,
74                const uint8_t* src_u,
75                int src_stride_u,
76                const uint8_t* src_v,
77                int src_stride_v,
78                uint8_t* dst_y,
79                int dst_stride_y,
80                uint8_t* dst_u,
81                int dst_stride_u,
82                uint8_t* dst_v,
83                int dst_stride_v,
84                int width,
85                int height,
86                enum RotationMode mode);
87 
88 // Rotate NV12 input and store in I420.
89 LIBYUV_API
90 int NV12ToI420Rotate(const uint8_t* src_y,
91                      int src_stride_y,
92                      const uint8_t* src_uv,
93                      int src_stride_uv,
94                      uint8_t* dst_y,
95                      int dst_stride_y,
96                      uint8_t* dst_u,
97                      int dst_stride_u,
98                      uint8_t* dst_v,
99                      int dst_stride_v,
100                      int width,
101                      int height,
102                      enum RotationMode mode);
103 
104 // Convert Android420 to I420 with rotation.
105 // "rotation" can be 0, 90, 180 or 270.
106 LIBYUV_API
107 int Android420ToI420Rotate(const uint8_t* src_y,
108                            int src_stride_y,
109                            const uint8_t* src_u,
110                            int src_stride_u,
111                            const uint8_t* src_v,
112                            int src_stride_v,
113                            int src_pixel_stride_uv,
114                            uint8_t* dst_y,
115                            int dst_stride_y,
116                            uint8_t* dst_u,
117                            int dst_stride_u,
118                            uint8_t* dst_v,
119                            int dst_stride_v,
120                            int width,
121                            int height,
122                            enum RotationMode rotation);
123 
124 // Rotate a plane by 0, 90, 180, or 270.
125 LIBYUV_API
126 int RotatePlane(const uint8_t* src,
127                 int src_stride,
128                 uint8_t* dst,
129                 int dst_stride,
130                 int width,
131                 int height,
132                 enum RotationMode mode);
133 
134 // Rotate planes by 90, 180, 270. Deprecated.
135 LIBYUV_API
136 void RotatePlane90(const uint8_t* src,
137                    int src_stride,
138                    uint8_t* dst,
139                    int dst_stride,
140                    int width,
141                    int height);
142 
143 LIBYUV_API
144 void RotatePlane180(const uint8_t* src,
145                     int src_stride,
146                     uint8_t* dst,
147                     int dst_stride,
148                     int width,
149                     int height);
150 
151 LIBYUV_API
152 void RotatePlane270(const uint8_t* src,
153                     int src_stride,
154                     uint8_t* dst,
155                     int dst_stride,
156                     int width,
157                     int height);
158 
159 // Rotations for when U and V are interleaved.
160 // These functions take one UV input pointer and
161 // split the data into two buffers while
162 // rotating them.
163 // width and height expected to be half size for NV12.
164 LIBYUV_API
165 int SplitRotateUV(const uint8_t* src_uv,
166                   int src_stride_uv,
167                   uint8_t* dst_u,
168                   int dst_stride_u,
169                   uint8_t* dst_v,
170                   int dst_stride_v,
171                   int width,
172                   int height,
173                   enum RotationMode mode);
174 
175 LIBYUV_API
176 void SplitRotateUV90(const uint8_t* src,
177                      int src_stride,
178                      uint8_t* dst_a,
179                      int dst_stride_a,
180                      uint8_t* dst_b,
181                      int dst_stride_b,
182                      int width,
183                      int height);
184 
185 LIBYUV_API
186 void SplitRotateUV180(const uint8_t* src,
187                       int src_stride,
188                       uint8_t* dst_a,
189                       int dst_stride_a,
190                       uint8_t* dst_b,
191                       int dst_stride_b,
192                       int width,
193                       int height);
194 
195 LIBYUV_API
196 void SplitRotateUV270(const uint8_t* src,
197                       int src_stride,
198                       uint8_t* dst_a,
199                       int dst_stride_a,
200                       uint8_t* dst_b,
201                       int dst_stride_b,
202                       int width,
203                       int height);
204 
205 // The 90 and 270 functions are based on transposes.
206 // Doing a transpose with reversing the read/write
207 // order will result in a rotation by +- 90 degrees.
208 // Deprecated.
209 LIBYUV_API
210 void TransposePlane(const uint8_t* src,
211                     int src_stride,
212                     uint8_t* dst,
213                     int dst_stride,
214                     int width,
215                     int height);
216 
217 LIBYUV_API
218 void SplitTransposeUV(const uint8_t* src,
219                       int src_stride,
220                       uint8_t* dst_a,
221                       int dst_stride_a,
222                       uint8_t* dst_b,
223                       int dst_stride_b,
224                       int width,
225                       int height);
226 
227 #ifdef __cplusplus
228 }  // extern "C"
229 }  // namespace libyuv
230 #endif
231 
232 #endif  // INCLUDE_LIBYUV_ROTATE_H_
233