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