OLD | NEW |
(Empty) | |
| 1 # Introduction |
| 2 |
| 3 Rotation by multiplies of 90 degrees allows mobile devices to rotate webcams fro
m landscape to portrait. The higher level functions ConvertToI420 and ConvertTo
ARGB allow rotation of any format. Optimized functionality is supported for I42
0, ARGB, NV12 and NV21. |
| 4 |
| 5 # ConvertToI420 |
| 6 |
| 7 int ConvertToI420(const uint8* src_frame, size_t src_size, |
| 8 uint8* dst_y, int dst_stride_y, |
| 9 uint8* dst_u, int dst_stride_u, |
| 10 uint8* dst_v, int dst_stride_v, |
| 11 int crop_x, int crop_y, |
| 12 int src_width, int src_height, |
| 13 int crop_width, int crop_height, |
| 14 enum RotationMode rotation, |
| 15 uint32 format); |
| 16 |
| 17 This function crops, converts, and rotates. You should think of it in that orde
r. |
| 18 * Crops the original image, which is src_width x src_height, to crop_width x c
rop_height. At this point the image is still not rotated. |
| 19 * Converts the cropped region to I420. Supports inverted source for src_heigh
t negative. |
| 20 * Rotates by 90, 180 or 270 degrees. |
| 21 The buffer the caller provides should account for rotation. Be especially impor
tant to get stride of the destination correct. |
| 22 |
| 23 e.g. |
| 24 640 x 480 NV12 captured<br> |
| 25 Crop to 640 x 360<br> |
| 26 Rotate by 90 degrees to 360 x 640.<br> |
| 27 Caller passes stride of 360 for Y and 360 / 2 for U and V.<br> |
| 28 Caller passes crop_width of 640, crop_height of 360.<br> |
| 29 |
| 30 # ConvertToARGB |
| 31 |
| 32 int ConvertToARGB(const uint8* src_frame, size_t src_size, |
| 33 uint8* dst_argb, int dst_stride_argb, |
| 34 int crop_x, int crop_y, |
| 35 int src_width, int src_height, |
| 36 int crop_width, int crop_height, |
| 37 enum RotationMode rotation, |
| 38 uint32 format); |
| 39 |
| 40 Same as I420, but implementation is less optimized - reads columns and writes ro
ws, 16 bytes at a time. |
| 41 |
| 42 # I420Rotate |
| 43 |
| 44 int I420Rotate(const uint8* src_y, int src_stride_y, |
| 45 const uint8* src_u, int src_stride_u, |
| 46 const uint8* src_v, int src_stride_v, |
| 47 uint8* dst_y, int dst_stride_y, |
| 48 uint8* dst_u, int dst_stride_u, |
| 49 uint8* dst_v, int dst_stride_v, |
| 50 int src_width, int src_height, enum RotationMode mode); |
| 51 |
| 52 Destination is rotated, so pass dst_stride_y etc that consider rotation.<br> |
| 53 Rotate by 180 can be done in place, but 90 and 270 can not. |
| 54 |
| 55 Implementation (Neon/SSE2) uses 8 x 8 block transpose, so best efficiency is wit
h sizes and pointers that are aligned to 8. |
| 56 |
| 57 Cropping can be achieved by adjusting the src_y/u/v pointers and src_width, src_
height. |
| 58 |
| 59 Lower level plane functions are provided, allowing other planar formats to be ro
tated. (e.g. I444) |
| 60 |
| 61 For other planar YUV formats (I444, I422, I411, I400, NV16, NV24), the planar fu
nctions are exposed and can be called directly |
| 62 |
| 63 |
| 64 // Rotate a plane by 0, 90, 180, or 270. |
| 65 int RotatePlane(const uint8* src, int src_stride, |
| 66 uint8* dst, int dst_stride, |
| 67 int src_width, int src_height, enum RotationMode mode); |
| 68 |
| 69 # ARGBRotate |
| 70 |
| 71 LIBYUV_API |
| 72 int ARGBRotate(const uint8* src_argb, int src_stride_argb, |
| 73 uint8* dst_argb, int dst_stride_argb, |
| 74 int src_width, int src_height, enum RotationMode mode); |
| 75 |
| 76 Same as I420, but implementation is less optimized - reads columns and writes ro
ws. |
| 77 |
| 78 Rotate by 90, or any angle, can be achieved using ARGBAffine. |
| 79 |
| 80 # Mirror - Horizontal Flip |
| 81 |
| 82 Mirror functions for horizontally flipping an image, which can be useful for 'se
lf view' of a webcam. |
| 83 |
| 84 int I420Mirror(const uint8* src_y, int src_stride_y, |
| 85 const uint8* src_u, int src_stride_u, |
| 86 const uint8* src_v, int src_stride_v, |
| 87 uint8* dst_y, int dst_stride_y, |
| 88 uint8* dst_u, int dst_stride_u, |
| 89 uint8* dst_v, int dst_stride_v, |
| 90 int width, int height); |
| 91 int ARGBMirror(const uint8* src_argb, int src_stride_argb, |
| 92 uint8* dst_argb, int dst_stride_argb, |
| 93 int width, int height); |
| 94 |
| 95 Mirror functionality can also be achieved with the I420Scale and ARGBScale funct
ions by passing negative width and/or height. |
| 96 |
| 97 # Invert - Vertical Flip |
| 98 |
| 99 Inverting can be achieved with almost any libyuv function by passing a negative
source height. |
| 100 |
| 101 I420Mirror and ARGBMirror can also be used to rotate by 180 degrees by passing a
negative height. |
| 102 |
| 103 |
OLD | NEW |