reconintra4x4.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 <string.h>
  11. #include "vpx_config.h"
  12. #include "./vpx_dsp_rtcd.h"
  13. #include "vp8_rtcd.h"
  14. #include "blockd.h"
  15. #include "reconintra4x4.h"
  16. #include "vp8/common/common.h"
  17. #include "vpx_ports/mem.h"
  18. typedef void (*intra_pred_fn)(uint8_t *dst, ptrdiff_t stride,
  19. const uint8_t *above, const uint8_t *left);
  20. static intra_pred_fn pred[10];
  21. void vp8_init_intra4x4_predictors_internal(void) {
  22. pred[B_DC_PRED] = vpx_dc_predictor_4x4;
  23. pred[B_TM_PRED] = vpx_tm_predictor_4x4;
  24. pred[B_VE_PRED] = vpx_ve_predictor_4x4;
  25. pred[B_HE_PRED] = vpx_he_predictor_4x4;
  26. pred[B_LD_PRED] = vpx_d45e_predictor_4x4;
  27. pred[B_RD_PRED] = vpx_d135_predictor_4x4;
  28. pred[B_VR_PRED] = vpx_d117_predictor_4x4;
  29. pred[B_VL_PRED] = vpx_d63e_predictor_4x4;
  30. pred[B_HD_PRED] = vpx_d153_predictor_4x4;
  31. pred[B_HU_PRED] = vpx_d207_predictor_4x4;
  32. }
  33. void vp8_intra4x4_predict(unsigned char *above, unsigned char *yleft,
  34. int left_stride, B_PREDICTION_MODE b_mode,
  35. unsigned char *dst, int dst_stride,
  36. unsigned char top_left) {
  37. /* Power PC implementation uses "vec_vsx_ld" to read 16 bytes from
  38. Above (aka, Aboveb + 4). Play it safe by reserving enough stack
  39. space here. Similary for "Left". */
  40. #if HAVE_VSX
  41. unsigned char Aboveb[20];
  42. #else
  43. unsigned char Aboveb[12];
  44. #endif
  45. unsigned char *Above = Aboveb + 4;
  46. #if HAVE_NEON
  47. // Neon intrinsics are unable to load 32 bits, or 4 8 bit values. Instead, it
  48. // over reads but does not use the extra 4 values.
  49. unsigned char Left[8];
  50. #if VPX_WITH_ASAN
  51. // Silence an 'uninitialized read' warning. Although uninitialized values are
  52. // indeed read, they are not used.
  53. vp8_zero_array(Left, 8);
  54. #endif // VPX_WITH_ASAN
  55. #elif HAVE_VSX
  56. unsigned char Left[16];
  57. #else
  58. unsigned char Left[4];
  59. #endif // HAVE_NEON
  60. Left[0] = yleft[0];
  61. Left[1] = yleft[left_stride];
  62. Left[2] = yleft[2 * left_stride];
  63. Left[3] = yleft[3 * left_stride];
  64. memcpy(Above, above, 8);
  65. Above[-1] = top_left;
  66. pred[b_mode](dst, dst_stride, Above, Left);
  67. }