rotate_common.cc 2.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS. All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "libyuv/row.h"
12
#include "libyuv/rotate_row.h"
13 14 15 16 17 18

#ifdef __cplusplus
namespace libyuv {
extern "C" {
#endif

Frank Barchard's avatar
Frank Barchard committed
19 20 21 22 23
void TransposeWx8_C(const uint8* src,
                    int src_stride,
                    uint8* dst,
                    int dst_stride,
                    int width) {
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
  int i;
  for (i = 0; i < width; ++i) {
    dst[0] = src[0 * src_stride];
    dst[1] = src[1 * src_stride];
    dst[2] = src[2 * src_stride];
    dst[3] = src[3 * src_stride];
    dst[4] = src[4 * src_stride];
    dst[5] = src[5 * src_stride];
    dst[6] = src[6 * src_stride];
    dst[7] = src[7 * src_stride];
    ++src;
    dst += dst_stride;
  }
}

Frank Barchard's avatar
Frank Barchard committed
39 40 41 42 43 44 45
void TransposeUVWx8_C(const uint8* src,
                      int src_stride,
                      uint8* dst_a,
                      int dst_stride_a,
                      uint8* dst_b,
                      int dst_stride_b,
                      int width) {
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
  int i;
  for (i = 0; i < width; ++i) {
    dst_a[0] = src[0 * src_stride + 0];
    dst_b[0] = src[0 * src_stride + 1];
    dst_a[1] = src[1 * src_stride + 0];
    dst_b[1] = src[1 * src_stride + 1];
    dst_a[2] = src[2 * src_stride + 0];
    dst_b[2] = src[2 * src_stride + 1];
    dst_a[3] = src[3 * src_stride + 0];
    dst_b[3] = src[3 * src_stride + 1];
    dst_a[4] = src[4 * src_stride + 0];
    dst_b[4] = src[4 * src_stride + 1];
    dst_a[5] = src[5 * src_stride + 0];
    dst_b[5] = src[5 * src_stride + 1];
    dst_a[6] = src[6 * src_stride + 0];
    dst_b[6] = src[6 * src_stride + 1];
    dst_a[7] = src[7 * src_stride + 0];
    dst_b[7] = src[7 * src_stride + 1];
    src += 2;
    dst_a += dst_stride_a;
    dst_b += dst_stride_b;
  }
}

Frank Barchard's avatar
Frank Barchard committed
70 71 72 73 74 75
void TransposeWxH_C(const uint8* src,
                    int src_stride,
                    uint8* dst,
                    int dst_stride,
                    int width,
                    int height) {
76 77 78 79 80 81 82 83 84
  int i;
  for (i = 0; i < width; ++i) {
    int j;
    for (j = 0; j < height; ++j) {
      dst[i * dst_stride + j] = src[j * src_stride + i];
    }
  }
}

Frank Barchard's avatar
Frank Barchard committed
85 86 87 88 89 90 91 92
void TransposeUVWxH_C(const uint8* src,
                      int src_stride,
                      uint8* dst_a,
                      int dst_stride_a,
                      uint8* dst_b,
                      int dst_stride_b,
                      int width,
                      int height) {
93 94 95 96 97 98 99 100 101 102 103 104 105 106
  int i;
  for (i = 0; i < width * 2; i += 2) {
    int j;
    for (j = 0; j < height; ++j) {
      dst_a[j + ((i >> 1) * dst_stride_a)] = src[i + (j * src_stride)];
      dst_b[j + ((i >> 1) * dst_stride_b)] = src[i + (j * src_stride) + 1];
    }
  }
}

#ifdef __cplusplus
}  // extern "C"
}  // namespace libyuv
#endif