2
0

rdopt.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #ifndef VPX_VP8_ENCODER_RDOPT_H_
  11. #define VPX_VP8_ENCODER_RDOPT_H_
  12. #include "./vpx_config.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #define RDCOST(RM, DM, R, D) (((128 + (R) * (RM)) >> 8) + (DM) * (D))
  17. void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex);
  18. void vp8_auto_select_speed(VP8_COMP *cpi);
  19. static INLINE void insertsortmv(int arr[], int len) {
  20. int i, j, k;
  21. for (i = 1; i <= len - 1; ++i) {
  22. for (j = 0; j < i; ++j) {
  23. if (arr[j] > arr[i]) {
  24. int temp;
  25. temp = arr[i];
  26. for (k = i; k > j; k--) arr[k] = arr[k - 1];
  27. arr[j] = temp;
  28. }
  29. }
  30. }
  31. }
  32. static INLINE void insertsortsad(int arr[], int idx[], int len) {
  33. int i, j, k;
  34. for (i = 1; i <= len - 1; ++i) {
  35. for (j = 0; j < i; ++j) {
  36. if (arr[j] > arr[i]) {
  37. int temp, tempi;
  38. temp = arr[i];
  39. tempi = idx[i];
  40. for (k = i; k > j; k--) {
  41. arr[k] = arr[k - 1];
  42. idx[k] = idx[k - 1];
  43. }
  44. arr[j] = temp;
  45. idx[j] = tempi;
  46. }
  47. }
  48. }
  49. }
  50. void vp8_initialize_rd_consts(VP8_COMP *cpi, MACROBLOCK *x, int Qvalue);
  51. void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
  52. int recon_uvoffset, int *returnrate,
  53. int *returndistortion, int *returnintra, int mb_row,
  54. int mb_col);
  55. void vp8_rd_pick_intra_mode(MACROBLOCK *x, int *rate);
  56. static INLINE void get_plane_pointers(const YV12_BUFFER_CONFIG *fb,
  57. unsigned char *plane[3],
  58. unsigned int recon_yoffset,
  59. unsigned int recon_uvoffset) {
  60. plane[0] = fb->y_buffer + recon_yoffset;
  61. plane[1] = fb->u_buffer + recon_uvoffset;
  62. plane[2] = fb->v_buffer + recon_uvoffset;
  63. }
  64. static INLINE void get_predictor_pointers(const VP8_COMP *cpi,
  65. unsigned char *plane[4][3],
  66. unsigned int recon_yoffset,
  67. unsigned int recon_uvoffset) {
  68. if (cpi->ref_frame_flags & VP8_LAST_FRAME) {
  69. get_plane_pointers(&cpi->common.yv12_fb[cpi->common.lst_fb_idx],
  70. plane[LAST_FRAME], recon_yoffset, recon_uvoffset);
  71. }
  72. if (cpi->ref_frame_flags & VP8_GOLD_FRAME) {
  73. get_plane_pointers(&cpi->common.yv12_fb[cpi->common.gld_fb_idx],
  74. plane[GOLDEN_FRAME], recon_yoffset, recon_uvoffset);
  75. }
  76. if (cpi->ref_frame_flags & VP8_ALTR_FRAME) {
  77. get_plane_pointers(&cpi->common.yv12_fb[cpi->common.alt_fb_idx],
  78. plane[ALTREF_FRAME], recon_yoffset, recon_uvoffset);
  79. }
  80. }
  81. static INLINE void get_reference_search_order(const VP8_COMP *cpi,
  82. int ref_frame_map[4]) {
  83. int i = 0;
  84. ref_frame_map[i++] = INTRA_FRAME;
  85. if (cpi->ref_frame_flags & VP8_LAST_FRAME) ref_frame_map[i++] = LAST_FRAME;
  86. if (cpi->ref_frame_flags & VP8_GOLD_FRAME) ref_frame_map[i++] = GOLDEN_FRAME;
  87. if (cpi->ref_frame_flags & VP8_ALTR_FRAME) ref_frame_map[i++] = ALTREF_FRAME;
  88. for (; i < 4; ++i) ref_frame_map[i] = -1;
  89. }
  90. void vp8_mv_pred(VP8_COMP *cpi, MACROBLOCKD *xd, const MODE_INFO *here,
  91. int_mv *mvp, int refframe, int *ref_frame_sign_bias, int *sr,
  92. int near_sadidx[]);
  93. void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x,
  94. int recon_yoffset, int near_sadidx[]);
  95. int VP8_UVSSE(MACROBLOCK *x);
  96. int vp8_cost_mv_ref(MB_PREDICTION_MODE m, const int near_mv_ref_ct[4]);
  97. void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv);
  98. #ifdef __cplusplus
  99. } // extern "C"
  100. #endif
  101. #endif // VPX_VP8_ENCODER_RDOPT_H_