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#include "libyuv/row.h"
12#include "libyuv/rotate_row.h"
13
14#ifdef __cplusplus
15namespace libyuv {
16extern "C" {
17#endif
18
19void TransposeWx8_C(const uint8* src, int src_stride,
20                    uint8* dst, int dst_stride, int width) {
21  int i;
22  for (i = 0; i < width; ++i) {
23    dst[0] = src[0 * src_stride];
24    dst[1] = src[1 * src_stride];
25    dst[2] = src[2 * src_stride];
26    dst[3] = src[3 * src_stride];
27    dst[4] = src[4 * src_stride];
28    dst[5] = src[5 * src_stride];
29    dst[6] = src[6 * src_stride];
30    dst[7] = src[7 * src_stride];
31    ++src;
32    dst += dst_stride;
33  }
34}
35
36void TransposeUVWx8_C(const uint8* src, int src_stride,
37                      uint8* dst_a, int dst_stride_a,
38                      uint8* dst_b, int dst_stride_b, int width) {
39  int i;
40  for (i = 0; i < width; ++i) {
41    dst_a[0] = src[0 * src_stride + 0];
42    dst_b[0] = src[0 * src_stride + 1];
43    dst_a[1] = src[1 * src_stride + 0];
44    dst_b[1] = src[1 * src_stride + 1];
45    dst_a[2] = src[2 * src_stride + 0];
46    dst_b[2] = src[2 * src_stride + 1];
47    dst_a[3] = src[3 * src_stride + 0];
48    dst_b[3] = src[3 * src_stride + 1];
49    dst_a[4] = src[4 * src_stride + 0];
50    dst_b[4] = src[4 * src_stride + 1];
51    dst_a[5] = src[5 * src_stride + 0];
52    dst_b[5] = src[5 * src_stride + 1];
53    dst_a[6] = src[6 * src_stride + 0];
54    dst_b[6] = src[6 * src_stride + 1];
55    dst_a[7] = src[7 * src_stride + 0];
56    dst_b[7] = src[7 * src_stride + 1];
57    src += 2;
58    dst_a += dst_stride_a;
59    dst_b += dst_stride_b;
60  }
61}
62
63void TransposeWxH_C(const uint8* src, int src_stride,
64                    uint8* dst, int dst_stride,
65                    int width, int height) {
66  int i;
67  for (i = 0; i < width; ++i) {
68    int j;
69    for (j = 0; j < height; ++j) {
70      dst[i * dst_stride + j] = src[j * src_stride + i];
71    }
72  }
73}
74
75void TransposeUVWxH_C(const uint8* src, int src_stride,
76                      uint8* dst_a, int dst_stride_a,
77                      uint8* dst_b, int dst_stride_b,
78                      int width, int height) {
79  int i;
80  for (i = 0; i < width * 2; i += 2) {
81    int j;
82    for (j = 0; j < height; ++j) {
83      dst_a[j + ((i >> 1) * dst_stride_a)] = src[i + (j * src_stride)];
84      dst_b[j + ((i >> 1) * dst_stride_b)] = src[i + (j * src_stride) + 1];
85    }
86  }
87}
88
89#ifdef __cplusplus
90}  // extern "C"
91}  // namespace libyuv
92#endif
93