2
0

rotate_common.cc 3.0 KB

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