Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / vp9 / encoder / vp9_rdopt.h
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 VP9_ENCODER_VP9_RDOPT_H_
12 #define VP9_ENCODER_VP9_RDOPT_H_
13
14 #include "vp9/encoder/vp9_onyx_int.h"
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #define RDDIV_BITS          7
21
22 #define RDCOST(RM, DM, R, D) \
23   (((128 + ((int64_t)R) * (RM)) >> 8) + (D << DM))
24 #define QIDX_SKIP_THRESH     115
25
26 #define RD_THRESH_MAX_FACT 64
27 #define RD_THRESH_INC      1
28 #define RD_THRESH_POW      1.25
29 #define RD_MULT_EPB_RATIO  64
30
31 #define MV_COST_WEIGHT      108
32 #define MV_COST_WEIGHT_SUB  120
33
34 #define INVALID_MV 0x80008000
35
36 struct TileInfo;
37
38 int vp9_compute_rd_mult(VP9_COMP *cpi, int qindex);
39
40 void vp9_initialize_rd_consts(VP9_COMP *cpi);
41
42 void vp9_initialize_me_consts(VP9_COMP *cpi, int qindex);
43
44 void vp9_setup_buffer_inter(VP9_COMP *cpi, MACROBLOCK *x,
45                             const TileInfo *const tile,
46                             MV_REFERENCE_FRAME ref_frame,
47                             BLOCK_SIZE block_size,
48                             int mi_row, int mi_col,
49                             int_mv frame_nearest_mv[MAX_REF_FRAMES],
50                             int_mv frame_near_mv[MAX_REF_FRAMES],
51                             struct buf_2d yv12_mb[4][MAX_MB_PLANE]);
52
53 const YV12_BUFFER_CONFIG *vp9_get_scaled_ref_frame(const VP9_COMP *cpi,
54                                                    int ref_frame);
55
56 void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
57                                int *r, int64_t *d, BLOCK_SIZE bsize,
58                                PICK_MODE_CONTEXT *ctx, int64_t best_rd);
59
60 int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
61                                   const struct TileInfo *const tile,
62                                   int mi_row, int mi_col,
63                                   int *returnrate,
64                                   int64_t *returndistortion,
65                                   BLOCK_SIZE bsize,
66                                   PICK_MODE_CONTEXT *ctx,
67                                   int64_t best_rd_so_far);
68
69 int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
70                                       const struct TileInfo *const tile,
71                                       int mi_row, int mi_col,
72                                       int *returnrate,
73                                       int64_t *returndistortion,
74                                       BLOCK_SIZE bsize,
75                                       PICK_MODE_CONTEXT *ctx,
76                                       int64_t best_rd_so_far);
77
78 void vp9_init_me_luts();
79
80 void vp9_set_mbmode_and_mvs(MACROBLOCKD *xd, MB_PREDICTION_MODE mode,
81                             const MV *mv);
82
83 void vp9_get_entropy_contexts(TX_SIZE tx_size,
84     ENTROPY_CONTEXT t_above[16], ENTROPY_CONTEXT t_left[16],
85     const ENTROPY_CONTEXT *above, const ENTROPY_CONTEXT *left,
86     int num_4x4_w, int num_4x4_h);
87
88 #ifdef __cplusplus
89 }  // extern "C"
90 #endif
91
92 #endif  // VP9_ENCODER_VP9_RDOPT_H_