reconintra.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_config.h"
  11. #include "./vpx_dsp_rtcd.h"
  12. #include "./vp8_rtcd.h"
  13. #include "vpx_mem/vpx_mem.h"
  14. #include "vpx_ports/vpx_once.h"
  15. #include "blockd.h"
  16. #include "vp8/common/reconintra.h"
  17. #include "vp8/common/reconintra4x4.h"
  18. enum {
  19. SIZE_16,
  20. SIZE_8,
  21. NUM_SIZES,
  22. };
  23. typedef void (*intra_pred_fn)(uint8_t *dst, ptrdiff_t stride,
  24. const uint8_t *above, const uint8_t *left);
  25. static intra_pred_fn pred[4][NUM_SIZES];
  26. static intra_pred_fn dc_pred[2][2][NUM_SIZES];
  27. static void vp8_init_intra_predictors_internal(void)
  28. {
  29. #define INIT_SIZE(sz) \
  30. pred[V_PRED][SIZE_##sz] = vpx_v_predictor_##sz##x##sz; \
  31. pred[H_PRED][SIZE_##sz] = vpx_h_predictor_##sz##x##sz; \
  32. pred[TM_PRED][SIZE_##sz] = vpx_tm_predictor_##sz##x##sz; \
  33. \
  34. dc_pred[0][0][SIZE_##sz] = vpx_dc_128_predictor_##sz##x##sz; \
  35. dc_pred[0][1][SIZE_##sz] = vpx_dc_top_predictor_##sz##x##sz; \
  36. dc_pred[1][0][SIZE_##sz] = vpx_dc_left_predictor_##sz##x##sz; \
  37. dc_pred[1][1][SIZE_##sz] = vpx_dc_predictor_##sz##x##sz
  38. INIT_SIZE(16);
  39. INIT_SIZE(8);
  40. vp8_init_intra4x4_predictors_internal();
  41. }
  42. void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
  43. unsigned char * yabove_row,
  44. unsigned char * yleft,
  45. int left_stride,
  46. unsigned char * ypred_ptr,
  47. int y_stride)
  48. {
  49. MB_PREDICTION_MODE mode = x->mode_info_context->mbmi.mode;
  50. DECLARE_ALIGNED(16, uint8_t, yleft_col[16]);
  51. int i;
  52. intra_pred_fn fn;
  53. for (i = 0; i < 16; i++)
  54. {
  55. yleft_col[i] = yleft[i* left_stride];
  56. }
  57. if (mode == DC_PRED)
  58. {
  59. fn = dc_pred[x->left_available][x->up_available][SIZE_16];
  60. }
  61. else
  62. {
  63. fn = pred[mode][SIZE_16];
  64. }
  65. fn(ypred_ptr, y_stride, yabove_row, yleft_col);
  66. }
  67. void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x,
  68. unsigned char * uabove_row,
  69. unsigned char * vabove_row,
  70. unsigned char * uleft,
  71. unsigned char * vleft,
  72. int left_stride,
  73. unsigned char * upred_ptr,
  74. unsigned char * vpred_ptr,
  75. int pred_stride)
  76. {
  77. MB_PREDICTION_MODE uvmode = x->mode_info_context->mbmi.uv_mode;
  78. unsigned char uleft_col[8];
  79. unsigned char vleft_col[8];
  80. int i;
  81. intra_pred_fn fn;
  82. for (i = 0; i < 8; i++)
  83. {
  84. uleft_col[i] = uleft[i * left_stride];
  85. vleft_col[i] = vleft[i * left_stride];
  86. }
  87. if (uvmode == DC_PRED)
  88. {
  89. fn = dc_pred[x->left_available][x->up_available][SIZE_8];
  90. }
  91. else
  92. {
  93. fn = pred[uvmode][SIZE_8];
  94. }
  95. fn(upred_ptr, pred_stride, uabove_row, uleft_col);
  96. fn(vpred_ptr, pred_stride, vabove_row, vleft_col);
  97. }
  98. void vp8_init_intra_predictors(void)
  99. {
  100. once(vp8_init_intra_predictors_internal);
  101. }