Simplify effective src_diff address computation
[platform/upstream/libvpx.git] / vp9 / encoder / vp9_encoder.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_ENCODER_H_
12 #define VP9_ENCODER_VP9_ENCODER_H_
13
14 #include <stdio.h>
15
16 #include "./vpx_config.h"
17 #include "vpx/internal/vpx_codec_internal.h"
18 #include "vpx/vp8cx.h"
19
20 #include "vp9/common/vp9_alloccommon.h"
21 #include "vp9/common/vp9_ppflags.h"
22 #include "vp9/common/vp9_entropymode.h"
23 #include "vp9/common/vp9_thread_common.h"
24 #include "vp9/common/vp9_onyxc_int.h"
25 #include "vp9/common/vp9_thread.h"
26
27 #include "vp9/encoder/vp9_aq_cyclicrefresh.h"
28 #include "vp9/encoder/vp9_context_tree.h"
29 #include "vp9/encoder/vp9_encodemb.h"
30 #include "vp9/encoder/vp9_firstpass.h"
31 #include "vp9/encoder/vp9_lookahead.h"
32 #include "vp9/encoder/vp9_mbgraph.h"
33 #include "vp9/encoder/vp9_mcomp.h"
34 #include "vp9/encoder/vp9_quantize.h"
35 #include "vp9/encoder/vp9_ratectrl.h"
36 #include "vp9/encoder/vp9_rd.h"
37 #include "vp9/encoder/vp9_speed_features.h"
38 #include "vp9/encoder/vp9_svc_layercontext.h"
39 #include "vp9/encoder/vp9_tokenize.h"
40 #include "vp9/encoder/vp9_variance.h"
41
42 #if CONFIG_VP9_TEMPORAL_DENOISING
43 #include "vp9/encoder/vp9_denoiser.h"
44 #endif
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 #define DEFAULT_GF_INTERVAL         10
51
52 typedef struct {
53   int nmvjointcost[MV_JOINTS];
54   int nmvcosts[2][MV_VALS];
55   int nmvcosts_hp[2][MV_VALS];
56
57   vp9_prob segment_pred_probs[PREDICTION_PROBS];
58
59   unsigned char *last_frame_seg_map_copy;
60
61   // 0 = Intra, Last, GF, ARF
62   signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
63   // 0 = ZERO_MV, MV
64   signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
65
66   FRAME_CONTEXT fc;
67 } CODING_CONTEXT;
68
69
70 typedef enum {
71   // encode_breakout is disabled.
72   ENCODE_BREAKOUT_DISABLED = 0,
73   // encode_breakout is enabled.
74   ENCODE_BREAKOUT_ENABLED = 1,
75   // encode_breakout is enabled with small max_thresh limit.
76   ENCODE_BREAKOUT_LIMITED = 2
77 } ENCODE_BREAKOUT_TYPE;
78
79 typedef enum {
80   NORMAL      = 0,
81   FOURFIVE    = 1,
82   THREEFIVE   = 2,
83   ONETWO      = 3
84 } VPX_SCALING;
85
86 typedef enum {
87   // Good Quality Fast Encoding. The encoder balances quality with the amount of
88   // time it takes to encode the output. Speed setting controls how fast.
89   GOOD,
90
91   // The encoder places priority on the quality of the output over encoding
92   // speed. The output is compressed at the highest possible quality. This
93   // option takes the longest amount of time to encode. Speed setting ignored.
94   BEST,
95
96   // Realtime/Live Encoding. This mode is optimized for realtime encoding (for
97   // example, capturing a television signal or feed from a live camera). Speed
98   // setting controls how fast.
99   REALTIME
100 } MODE;
101
102 typedef enum {
103   FRAMEFLAGS_KEY    = 1 << 0,
104   FRAMEFLAGS_GOLDEN = 1 << 1,
105   FRAMEFLAGS_ALTREF = 1 << 2,
106 } FRAMETYPE_FLAGS;
107
108 typedef enum {
109   NO_AQ = 0,
110   VARIANCE_AQ = 1,
111   COMPLEXITY_AQ = 2,
112   CYCLIC_REFRESH_AQ = 3,
113   AQ_MODE_COUNT  // This should always be the last member of the enum
114 } AQ_MODE;
115
116 typedef enum {
117   RESIZE_NONE = 0,    // No frame resizing allowed (except for SVC).
118   RESIZE_FIXED = 1,   // All frames are coded at the specified dimension.
119   RESIZE_DYNAMIC = 2  // Coded size of each frame is determined by the codec.
120 } RESIZE_TYPE;
121
122 typedef struct VP9EncoderConfig {
123   BITSTREAM_PROFILE profile;
124   vpx_bit_depth_t bit_depth;     // Codec bit-depth.
125   int width;  // width of data passed to the compressor
126   int height;  // height of data passed to the compressor
127   unsigned int input_bit_depth;  // Input bit depth.
128   double init_framerate;  // set to passed in framerate
129   int64_t target_bandwidth;  // bandwidth to be used in kilobits per second
130
131   int noise_sensitivity;  // pre processing blur: recommendation 0
132   int sharpness;  // sharpening output: recommendation 0:
133   int speed;
134   // maximum allowed bitrate for any intra frame in % of bitrate target.
135   unsigned int rc_max_intra_bitrate_pct;
136   // maximum allowed bitrate for any inter frame in % of bitrate target.
137   unsigned int rc_max_inter_bitrate_pct;
138   // percent of rate boost for golden frame in CBR mode.
139   unsigned int gf_cbr_boost_pct;
140
141   MODE mode;
142   int pass;
143
144   // Key Framing Operations
145   int auto_key;  // autodetect cut scenes and set the keyframes
146   int key_freq;  // maximum distance to key frame.
147
148   int lag_in_frames;  // how many frames lag before we start encoding
149
150   // ----------------------------------------------------------------
151   // DATARATE CONTROL OPTIONS
152
153   // vbr, cbr, constrained quality or constant quality
154   enum vpx_rc_mode rc_mode;
155
156   // buffer targeting aggressiveness
157   int under_shoot_pct;
158   int over_shoot_pct;
159
160   // buffering parameters
161   int64_t starting_buffer_level_ms;
162   int64_t optimal_buffer_level_ms;
163   int64_t maximum_buffer_size_ms;
164
165   // Frame drop threshold.
166   int drop_frames_water_mark;
167
168   // controlling quality
169   int fixed_q;
170   int worst_allowed_q;
171   int best_allowed_q;
172   int cq_level;
173   AQ_MODE aq_mode;  // Adaptive Quantization mode
174
175   // Internal frame size scaling.
176   RESIZE_TYPE resize_mode;
177   int scaled_frame_width;
178   int scaled_frame_height;
179
180   // Enable feature to reduce the frame quantization every x frames.
181   int frame_periodic_boost;
182
183   // two pass datarate control
184   int two_pass_vbrbias;        // two pass datarate control tweaks
185   int two_pass_vbrmin_section;
186   int two_pass_vbrmax_section;
187   // END DATARATE CONTROL OPTIONS
188   // ----------------------------------------------------------------
189
190   // Spatial and temporal scalability.
191   int ss_number_layers;  // Number of spatial layers.
192   int ts_number_layers;  // Number of temporal layers.
193   // Bitrate allocation for spatial layers.
194   int ss_target_bitrate[VPX_SS_MAX_LAYERS];
195   int ss_enable_auto_arf[VPX_SS_MAX_LAYERS];
196   // Bitrate allocation (CBR mode) and framerate factor, for temporal layers.
197   int ts_target_bitrate[VPX_TS_MAX_LAYERS];
198   int ts_rate_decimator[VPX_TS_MAX_LAYERS];
199
200   int enable_auto_arf;
201
202   int encode_breakout;  // early breakout : for video conf recommend 800
203
204   /* Bitfield defining the error resiliency features to enable.
205    * Can provide decodable frames after losses in previous
206    * frames and decodable partitions after losses in the same frame.
207    */
208   unsigned int error_resilient_mode;
209
210   /* Bitfield defining the parallel decoding mode where the
211    * decoding in successive frames may be conducted in parallel
212    * just by decoding the frame headers.
213    */
214   unsigned int frame_parallel_decoding_mode;
215
216   int arnr_max_frames;
217   int arnr_strength;
218
219   int tile_columns;
220   int tile_rows;
221
222   int max_threads;
223
224   vpx_fixed_buf_t two_pass_stats_in;
225   struct vpx_codec_pkt_list *output_pkt_list;
226
227 #if CONFIG_FP_MB_STATS
228   vpx_fixed_buf_t firstpass_mb_stats_in;
229 #endif
230
231   vp8e_tuning tuning;
232   vp9e_tune_content content;
233 #if CONFIG_VP9_HIGHBITDEPTH
234   int use_highbitdepth;
235 #endif
236   vpx_color_space_t color_space;
237 } VP9EncoderConfig;
238
239 static INLINE int is_lossless_requested(const VP9EncoderConfig *cfg) {
240   return cfg->best_allowed_q == 0 && cfg->worst_allowed_q == 0;
241 }
242
243 // TODO(jingning) All spatially adaptive variables should go to TileDataEnc.
244 typedef struct TileDataEnc {
245   TileInfo tile_info;
246   int thresh_freq_fact[BLOCK_SIZES][MAX_MODES];
247   int mode_map[BLOCK_SIZES][MAX_MODES];
248 } TileDataEnc;
249
250 typedef struct RD_COUNTS {
251   vp9_coeff_count coef_counts[TX_SIZES][PLANE_TYPES];
252   int64_t comp_pred_diff[REFERENCE_MODES];
253   int64_t tx_select_diff[TX_MODES];
254   int64_t filter_diff[SWITCHABLE_FILTER_CONTEXTS];
255 } RD_COUNTS;
256
257 typedef struct ThreadData {
258   MACROBLOCK mb;
259   RD_COUNTS rd_counts;
260   FRAME_COUNTS *counts;
261
262   PICK_MODE_CONTEXT *leaf_tree;
263   PC_TREE *pc_tree;
264   PC_TREE *pc_root;
265 } ThreadData;
266
267 struct EncWorkerData;
268
269 typedef struct ActiveMap {
270   int enabled;
271   int update;
272   unsigned char *map;
273 } ActiveMap;
274
275 typedef struct VP9_COMP {
276   QUANTS quants;
277   ThreadData td;
278   DECLARE_ALIGNED(16, int16_t, y_dequant[QINDEX_RANGE][8]);
279   DECLARE_ALIGNED(16, int16_t, uv_dequant[QINDEX_RANGE][8]);
280   VP9_COMMON common;
281   VP9EncoderConfig oxcf;
282   struct lookahead_ctx    *lookahead;
283   struct lookahead_entry  *alt_ref_source;
284
285   YV12_BUFFER_CONFIG *Source;
286   YV12_BUFFER_CONFIG *Last_Source;  // NULL for first frame and alt_ref frames
287   YV12_BUFFER_CONFIG *un_scaled_source;
288   YV12_BUFFER_CONFIG scaled_source;
289   YV12_BUFFER_CONFIG *unscaled_last_source;
290   YV12_BUFFER_CONFIG scaled_last_source;
291
292   TileDataEnc *tile_data;
293
294   // For a still frame, this flag is set to 1 to skip partition search.
295   int partition_search_skippable_frame;
296
297   int scaled_ref_idx[MAX_REF_FRAMES];
298   int lst_fb_idx;
299   int gld_fb_idx;
300   int alt_fb_idx;
301
302   int refresh_last_frame;
303   int refresh_golden_frame;
304   int refresh_alt_ref_frame;
305
306   int ext_refresh_frame_flags_pending;
307   int ext_refresh_last_frame;
308   int ext_refresh_golden_frame;
309   int ext_refresh_alt_ref_frame;
310
311   int ext_refresh_frame_context_pending;
312   int ext_refresh_frame_context;
313
314   YV12_BUFFER_CONFIG last_frame_uf;
315
316   TOKENEXTRA *tile_tok[4][1 << 6];
317   unsigned int tok_count[4][1 << 6];
318
319   // Ambient reconstruction err target for force key frames
320   int64_t ambient_err;
321
322   RD_OPT rd;
323
324   CODING_CONTEXT coding_context;
325
326   int *nmvcosts[2];
327   int *nmvcosts_hp[2];
328   int *nmvsadcosts[2];
329   int *nmvsadcosts_hp[2];
330
331   int64_t last_time_stamp_seen;
332   int64_t last_end_time_stamp_seen;
333   int64_t first_time_stamp_ever;
334
335   RATE_CONTROL rc;
336   double framerate;
337
338   int interp_filter_selected[MAX_REF_FRAMES][SWITCHABLE];
339
340   struct vpx_codec_pkt_list  *output_pkt_list;
341
342   MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
343   int mbgraph_n_frames;             // number of frames filled in the above
344   int static_mb_pct;                // % forced skip mbs by segmentation
345   int ref_frame_flags;
346
347   SPEED_FEATURES sf;
348
349   unsigned int max_mv_magnitude;
350   int mv_step_param;
351
352   int allow_comp_inter_inter;
353
354   // Default value is 1. From first pass stats, encode_breakout may be disabled.
355   ENCODE_BREAKOUT_TYPE allow_encode_breakout;
356
357   // Get threshold from external input. A suggested threshold is 800 for HD
358   // clips, and 300 for < HD clips.
359   int encode_breakout;
360
361   unsigned char *segmentation_map;
362
363   // segment threashold for encode breakout
364   int  segment_encode_breakout[MAX_SEGMENTS];
365
366   CYCLIC_REFRESH *cyclic_refresh;
367   ActiveMap active_map;
368
369   fractional_mv_step_fp *find_fractional_mv_step;
370   vp9_full_search_fn_t full_search_sad;
371   vp9_diamond_search_fn_t diamond_search_sad;
372   vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES];
373   uint64_t time_receive_data;
374   uint64_t time_compress_data;
375   uint64_t time_pick_lpf;
376   uint64_t time_encode_sb_row;
377
378 #if CONFIG_FP_MB_STATS
379   int use_fp_mb_stats;
380 #endif
381
382   TWO_PASS twopass;
383
384   YV12_BUFFER_CONFIG alt_ref_buffer;
385
386
387 #if CONFIG_INTERNAL_STATS
388   unsigned int mode_chosen_counts[MAX_MODES];
389
390   int    count;
391   double total_y;
392   double total_u;
393   double total_v;
394   double total;
395   uint64_t total_sq_error;
396   uint64_t total_samples;
397
398   double totalp_y;
399   double totalp_u;
400   double totalp_v;
401   double totalp;
402   uint64_t totalp_sq_error;
403   uint64_t totalp_samples;
404
405   int    bytes;
406   double summed_quality;
407   double summed_weights;
408   double summedp_quality;
409   double summedp_weights;
410   unsigned int tot_recode_hits;
411
412
413   double total_ssimg_y;
414   double total_ssimg_u;
415   double total_ssimg_v;
416   double total_ssimg_all;
417
418   int b_calculate_ssimg;
419 #endif
420   int b_calculate_psnr;
421
422   int droppable;
423
424   int initial_width;
425   int initial_height;
426   int initial_mbs;  // Number of MBs in the full-size frame; to be used to
427                     // normalize the firstpass stats. This will differ from the
428                     // number of MBs in the current frame when the frame is
429                     // scaled.
430
431   int use_svc;
432
433   SVC svc;
434
435   // Store frame variance info in SOURCE_VAR_BASED_PARTITION search type.
436   diff *source_diff_var;
437   // The threshold used in SOURCE_VAR_BASED_PARTITION search type.
438   unsigned int source_var_thresh;
439   int frames_till_next_var_check;
440
441   int frame_flags;
442
443   search_site_config ss_cfg;
444
445   int mbmode_cost[INTRA_MODES];
446   unsigned int inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES];
447   int intra_uv_mode_cost[FRAME_TYPES][INTRA_MODES];
448   int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
449   int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
450   int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES];
451
452   int multi_arf_allowed;
453   int multi_arf_enabled;
454   int multi_arf_last_grp_enabled;
455
456 #if CONFIG_VP9_TEMPORAL_DENOISING
457   VP9_DENOISER denoiser;
458 #endif
459
460   int resize_pending;
461
462   // VAR_BASED_PARTITION thresholds
463   int64_t vbp_threshold;
464   int64_t vbp_threshold_bsize_min;
465   int64_t vbp_threshold_bsize_max;
466   int64_t vbp_threshold_16x16;
467   BLOCK_SIZE vbp_bsize_min;
468
469   // Multi-threading
470   int num_workers;
471   VP9Worker *workers;
472   struct EncWorkerData *tile_thr_data;
473   VP9LfSync lf_row_sync;
474 } VP9_COMP;
475
476 void vp9_initialize_enc(void);
477
478 struct VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
479                                        BufferPool *const pool);
480 void vp9_remove_compressor(VP9_COMP *cpi);
481
482 void vp9_change_config(VP9_COMP *cpi, const VP9EncoderConfig *oxcf);
483
484   // receive a frames worth of data. caller can assume that a copy of this
485   // frame is made and not just a copy of the pointer..
486 int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags,
487                           YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
488                           int64_t end_time_stamp);
489
490 int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
491                             size_t *size, uint8_t *dest,
492                             int64_t *time_stamp, int64_t *time_end, int flush);
493
494 int vp9_get_preview_raw_frame(VP9_COMP *cpi, YV12_BUFFER_CONFIG *dest,
495                               vp9_ppflags_t *flags);
496
497 int vp9_use_as_reference(VP9_COMP *cpi, int ref_frame_flags);
498
499 void vp9_update_reference(VP9_COMP *cpi, int ref_frame_flags);
500
501 int vp9_copy_reference_enc(VP9_COMP *cpi, VP9_REFFRAME ref_frame_flag,
502                            YV12_BUFFER_CONFIG *sd);
503
504 int vp9_set_reference_enc(VP9_COMP *cpi, VP9_REFFRAME ref_frame_flag,
505                           YV12_BUFFER_CONFIG *sd);
506
507 int vp9_update_entropy(VP9_COMP *cpi, int update);
508
509 int vp9_set_active_map(VP9_COMP *cpi, unsigned char *map, int rows, int cols);
510
511 int vp9_get_active_map(VP9_COMP *cpi, unsigned char *map, int rows, int cols);
512
513 int vp9_set_internal_size(VP9_COMP *cpi,
514                           VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
515
516 int vp9_set_size_literal(VP9_COMP *cpi, unsigned int width,
517                          unsigned int height);
518
519 void vp9_set_svc(VP9_COMP *cpi, int use_svc);
520
521 int vp9_get_quantizer(struct VP9_COMP *cpi);
522
523 static INLINE int frame_is_kf_gf_arf(const VP9_COMP *cpi) {
524   return frame_is_intra_only(&cpi->common) ||
525          cpi->refresh_alt_ref_frame ||
526          (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref);
527 }
528
529 static INLINE int get_ref_frame_map_idx(const VP9_COMP *cpi,
530                                         MV_REFERENCE_FRAME ref_frame) {
531   if (ref_frame == LAST_FRAME) {
532     return cpi->lst_fb_idx;
533   } else if (ref_frame == GOLDEN_FRAME) {
534     return cpi->gld_fb_idx;
535   } else {
536     return cpi->alt_fb_idx;
537   }
538 }
539
540 static INLINE int get_ref_frame_buf_idx(const VP9_COMP *const cpi,
541                                         int ref_frame) {
542   const VP9_COMMON *const cm = &cpi->common;
543   const int map_idx = get_ref_frame_map_idx(cpi, ref_frame);
544   return (map_idx != INVALID_IDX) ? cm->ref_frame_map[map_idx] : INVALID_IDX;
545 }
546
547 static INLINE YV12_BUFFER_CONFIG *get_ref_frame_buffer(
548     VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
549   VP9_COMMON *const cm = &cpi->common;
550   const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
551   return
552       buf_idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[buf_idx].buf : NULL;
553 }
554
555 static INLINE int get_token_alloc(int mb_rows, int mb_cols) {
556   // TODO(JBB): double check we can't exceed this token count if we have a
557   // 32x32 transform crossing a boundary at a multiple of 16.
558   // mb_rows, cols are in units of 16 pixels. We assume 3 planes all at full
559   // resolution. We assume up to 1 token per pixel, and then allow
560   // a head room of 4.
561   return mb_rows * mb_cols * (16 * 16 * 3 + 4);
562 }
563
564 // Get the allocated token size for a tile. It does the same calculation as in
565 // the frame token allocation.
566 static INLINE int allocated_tokens(TileInfo tile) {
567   int tile_mb_rows = (tile.mi_row_end - tile.mi_row_start + 1) >> 1;
568   int tile_mb_cols = (tile.mi_col_end - tile.mi_col_start + 1) >> 1;
569
570   return get_token_alloc(tile_mb_rows, tile_mb_cols);
571 }
572
573 int64_t vp9_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
574 #if CONFIG_VP9_HIGHBITDEPTH
575 int64_t vp9_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a,
576                              const YV12_BUFFER_CONFIG *b);
577 #endif  // CONFIG_VP9_HIGHBITDEPTH
578
579 void vp9_alloc_compressor_data(VP9_COMP *cpi);
580
581 void vp9_scale_references(VP9_COMP *cpi);
582
583 void vp9_update_reference_frames(VP9_COMP *cpi);
584
585 void vp9_set_high_precision_mv(VP9_COMP *cpi, int allow_high_precision_mv);
586
587 YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm,
588                                           YV12_BUFFER_CONFIG *unscaled,
589                                           YV12_BUFFER_CONFIG *scaled);
590
591 void vp9_apply_encoding_flags(VP9_COMP *cpi, vpx_enc_frame_flags_t flags);
592
593 static INLINE int is_two_pass_svc(const struct VP9_COMP *const cpi) {
594   return cpi->use_svc &&
595          ((cpi->svc.number_spatial_layers > 1) ||
596          (cpi->svc.number_temporal_layers > 1 && cpi->oxcf.pass != 0));
597 }
598
599 static INLINE int is_altref_enabled(const VP9_COMP *const cpi) {
600   return cpi->oxcf.mode != REALTIME && cpi->oxcf.lag_in_frames > 0 &&
601          (cpi->oxcf.enable_auto_arf &&
602           (!is_two_pass_svc(cpi) ||
603            cpi->oxcf.ss_enable_auto_arf[cpi->svc.spatial_layer_id]));
604 }
605
606 static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd,
607                                 MV_REFERENCE_FRAME ref0,
608                                 MV_REFERENCE_FRAME ref1) {
609   xd->block_refs[0] = &cm->frame_refs[ref0 >= LAST_FRAME ? ref0 - LAST_FRAME
610                                                          : 0];
611   xd->block_refs[1] = &cm->frame_refs[ref1 >= LAST_FRAME ? ref1 - LAST_FRAME
612                                                          : 0];
613 }
614
615 static INLINE int get_chessboard_index(const int frame_index) {
616   return frame_index & 0x1;
617 }
618
619 static INLINE int *cond_cost_list(const struct VP9_COMP *cpi, int *cost_list) {
620   return cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? cost_list : NULL;
621 }
622
623 void vp9_new_framerate(VP9_COMP *cpi, double framerate);
624
625 #ifdef __cplusplus
626 }  // extern "C"
627 #endif
628
629 #endif  // VP9_ENCODER_VP9_ENCODER_H_