/media/libvpx/vp8/common/recon.c

http://github.com/zpao/v8monkey · C · 181 lines · 134 code · 34 blank · 13 comment · 15 complexity · 3ab6cac90b212b257d3fe6b98e8a865c MD5 · raw file

  1. /*
  2. * Copyright (c) 2010 The WebM 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 "vpx_ports/config.h"
  11. #include "recon.h"
  12. #include "blockd.h"
  13. void vp8_recon_b_c
  14. (
  15. unsigned char *pred_ptr,
  16. short *diff_ptr,
  17. unsigned char *dst_ptr,
  18. int stride
  19. )
  20. {
  21. int r, c;
  22. for (r = 0; r < 4; r++)
  23. {
  24. for (c = 0; c < 4; c++)
  25. {
  26. int a = diff_ptr[c] + pred_ptr[c] ;
  27. if (a < 0)
  28. a = 0;
  29. if (a > 255)
  30. a = 255;
  31. dst_ptr[c] = (unsigned char) a ;
  32. }
  33. dst_ptr += stride;
  34. diff_ptr += 16;
  35. pred_ptr += 16;
  36. }
  37. }
  38. void vp8_recon4b_c
  39. (
  40. unsigned char *pred_ptr,
  41. short *diff_ptr,
  42. unsigned char *dst_ptr,
  43. int stride
  44. )
  45. {
  46. int r, c;
  47. for (r = 0; r < 4; r++)
  48. {
  49. for (c = 0; c < 16; c++)
  50. {
  51. int a = diff_ptr[c] + pred_ptr[c] ;
  52. if (a < 0)
  53. a = 0;
  54. if (a > 255)
  55. a = 255;
  56. dst_ptr[c] = (unsigned char) a ;
  57. }
  58. dst_ptr += stride;
  59. diff_ptr += 16;
  60. pred_ptr += 16;
  61. }
  62. }
  63. void vp8_recon2b_c
  64. (
  65. unsigned char *pred_ptr,
  66. short *diff_ptr,
  67. unsigned char *dst_ptr,
  68. int stride
  69. )
  70. {
  71. int r, c;
  72. for (r = 0; r < 4; r++)
  73. {
  74. for (c = 0; c < 8; c++)
  75. {
  76. int a = diff_ptr[c] + pred_ptr[c] ;
  77. if (a < 0)
  78. a = 0;
  79. if (a > 255)
  80. a = 255;
  81. dst_ptr[c] = (unsigned char) a ;
  82. }
  83. dst_ptr += stride;
  84. diff_ptr += 8;
  85. pred_ptr += 8;
  86. }
  87. }
  88. void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
  89. {
  90. #if ARCH_ARM
  91. BLOCKD *b = &x->block[0];
  92. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  93. /*b = &x->block[4];*/
  94. b += 4;
  95. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  96. /*b = &x->block[8];*/
  97. b += 4;
  98. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  99. /*b = &x->block[12];*/
  100. b += 4;
  101. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  102. #else
  103. int i;
  104. for (i = 0; i < 16; i += 4)
  105. {
  106. BLOCKD *b = &x->block[i];
  107. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  108. }
  109. #endif
  110. }
  111. void vp8_recon_mb_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
  112. {
  113. #if ARCH_ARM
  114. BLOCKD *b = &x->block[0];
  115. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  116. b += 4;
  117. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  118. b += 4;
  119. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  120. b += 4;
  121. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  122. b += 4;
  123. /*b = &x->block[16];*/
  124. RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  125. b++;
  126. b++;
  127. RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  128. b++;
  129. b++;
  130. RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  131. b++;
  132. b++;
  133. RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  134. #else
  135. int i;
  136. for (i = 0; i < 16; i += 4)
  137. {
  138. BLOCKD *b = &x->block[i];
  139. RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  140. }
  141. for (i = 16; i < 24; i += 2)
  142. {
  143. BLOCKD *b = &x->block[i];
  144. RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
  145. }
  146. #endif
  147. }