Merge "remove postproc invokes" into experimental
[aom.git] / vp9 / encoder / vp9_onyx_int.h
blob79b35b41e8726a3bd1a01406acdd05e4a9ac63f6
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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 */
12 #ifndef __INC_ONYX_INT_H
13 #define __INC_ONYX_INT_H
15 #include <stdio.h>
16 #include "vpx_ports/config.h"
17 #include "vp9/common/vp9_onyx.h"
18 #include "vp9_treewriter.h"
19 #include "vp9_tokenize.h"
20 #include "vp9/common/vp9_onyxc_int.h"
21 #include "vp9_variance.h"
22 #include "vp9_encodemb.h"
23 #include "vp9_quantize.h"
24 #include "vp9/common/vp9_entropy.h"
25 #include "vp9/common/vp9_entropymode.h"
26 #include "vpx_ports/mem.h"
27 #include "vpx/internal/vpx_codec_internal.h"
28 #include "vp9_mcomp.h"
29 #include "vp9/common/vp9_findnearmv.h"
30 #include "vp9_lookahead.h"
32 // #define SPEEDSTATS 1
33 #define MIN_GF_INTERVAL 4
34 #define DEFAULT_GF_INTERVAL 7
36 #define KEY_FRAME_CONTEXT 5
38 #define MAX_LAG_BUFFERS 25
40 #define AF_THRESH 25
41 #define AF_THRESH2 100
42 #define ARF_DECAY_THRESH 12
44 #if CONFIG_PRED_FILTER
45 #if CONFIG_COMP_INTERINTRA_PRED
46 #define MAX_MODES 66
47 #else
48 #define MAX_MODES 54
49 #endif
50 #else // CONFIG_PRED_FILTER
51 #if CONFIG_COMP_INTERINTRA_PRED
52 #define MAX_MODES 54
53 #else
54 #define MAX_MODES 42
55 #endif
56 #endif // CONFIG_PRED_FILTER
58 #define MIN_THRESHMULT 32
59 #define MAX_THRESHMULT 512
61 #define GF_ZEROMV_ZBIN_BOOST 12
62 #define LF_ZEROMV_ZBIN_BOOST 6
63 #define MV_ZBIN_BOOST 4
64 #define ZBIN_OQ_MAX 192
66 #define VP9_TEMPORAL_ALT_REF 1
68 typedef struct {
69 nmv_context nmvc;
70 int nmvjointcost[MV_JOINTS];
71 int nmvcosts[2][MV_VALS];
72 int nmvcosts_hp[2][MV_VALS];
74 #ifdef MODE_STATS
75 // Stats
76 int y_modes[VP9_YMODES];
77 int uv_modes[VP9_UV_MODES];
78 int i8x8_modes[VP9_I8X8_MODES];
79 int b_modes[B_MODE_COUNT];
80 int inter_y_modes[MB_MODE_COUNT];
81 int inter_uv_modes[VP9_UV_MODES];
82 int inter_b_modes[B_MODE_COUNT];
83 #endif
85 vp9_prob segment_pred_probs[PREDICTION_PROBS];
86 unsigned char ref_pred_probs_update[PREDICTION_PROBS];
87 vp9_prob ref_pred_probs[PREDICTION_PROBS];
88 vp9_prob prob_comppred[COMP_PRED_CONTEXTS];
90 unsigned char *last_frame_seg_map_copy;
92 // 0 = Intra, Last, GF, ARF
93 signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
94 // 0 = BPRED, ZERO_MV, MV, SPLIT
95 signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
97 vp9_prob coef_probs[BLOCK_TYPES]
98 [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
99 vp9_prob hybrid_coef_probs[BLOCK_TYPES]
100 [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
102 vp9_prob coef_probs_8x8[BLOCK_TYPES_8X8]
103 [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
104 vp9_prob hybrid_coef_probs_8x8[BLOCK_TYPES_8X8]
105 [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
107 vp9_prob coef_probs_16x16[BLOCK_TYPES_16X16]
108 [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
109 vp9_prob hybrid_coef_probs_16x16[BLOCK_TYPES_16X16]
110 [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
112 #if CONFIG_SUPERBLOCKS
113 vp9_prob sb_ymode_prob[VP9_I32X32_MODES - 1];
114 #endif
115 vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */
116 vp9_prob uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1];
117 vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1];
118 vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1];
119 vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
120 vp9_prob mbsplit_prob[VP9_NUMMBSPLITS - 1];
122 vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
123 [VP9_SWITCHABLE_FILTERS - 1];
124 #if CONFIG_COMP_INTERINTRA_PRED
125 vp9_prob interintra_prob;
126 #endif
128 int mv_ref_ct[INTER_MODE_CONTEXTS][4][2];
129 int vp9_mode_contexts[INTER_MODE_CONTEXTS][4];
131 } CODING_CONTEXT;
133 typedef struct {
134 double frame;
135 double intra_error;
136 double coded_error;
137 double sr_coded_error;
138 double ssim_weighted_pred_err;
139 double pcnt_inter;
140 double pcnt_motion;
141 double pcnt_second_ref;
142 double pcnt_neutral;
143 double MVr;
144 double mvr_abs;
145 double MVc;
146 double mvc_abs;
147 double MVrv;
148 double MVcv;
149 double mv_in_out_count;
150 double new_mv_count;
151 double duration;
152 double count;
154 FIRSTPASS_STATS;
156 typedef struct {
157 int frames_so_far;
158 double frame_intra_error;
159 double frame_coded_error;
160 double frame_pcnt_inter;
161 double frame_pcnt_motion;
162 double frame_mvr;
163 double frame_mvr_abs;
164 double frame_mvc;
165 double frame_mvc_abs;
167 } ONEPASS_FRAMESTATS;
169 typedef struct {
170 struct {
171 int err;
172 union {
173 int_mv mv;
174 MB_PREDICTION_MODE mode;
175 } m;
176 } ref[MAX_REF_FRAMES];
177 } MBGRAPH_MB_STATS;
179 typedef struct {
180 MBGRAPH_MB_STATS *mb_stats;
181 } MBGRAPH_FRAME_STATS;
183 #if CONFIG_PRED_FILTER
184 typedef enum {
185 THR_ZEROMV,
186 THR_ZEROMV_FILT,
187 THR_DC,
189 THR_NEARESTMV,
190 THR_NEARESTMV_FILT,
191 THR_NEARMV,
192 THR_NEARMV_FILT,
194 THR_ZEROG,
195 THR_ZEROG_FILT,
196 THR_NEARESTG,
197 THR_NEARESTG_FILT,
199 THR_ZEROA,
200 THR_ZEROA_FILT,
201 THR_NEARESTA,
202 THR_NEARESTA_FILT,
204 THR_NEARG,
205 THR_NEARG_FILT,
206 THR_NEARA,
207 THR_NEARA_FILT,
209 THR_V_PRED,
210 THR_H_PRED,
211 THR_D45_PRED,
212 THR_D135_PRED,
213 THR_D117_PRED,
214 THR_D153_PRED,
215 THR_D27_PRED,
216 THR_D63_PRED,
217 THR_TM,
219 THR_NEWMV,
220 THR_NEWMV_FILT,
221 THR_NEWG,
222 THR_NEWG_FILT,
223 THR_NEWA,
224 THR_NEWA_FILT,
226 THR_SPLITMV,
227 THR_SPLITG,
228 THR_SPLITA,
230 THR_B_PRED,
231 THR_I8X8_PRED,
233 THR_COMP_ZEROLG,
234 THR_COMP_NEARESTLG,
235 THR_COMP_NEARLG,
237 THR_COMP_ZEROLA,
238 THR_COMP_NEARESTLA,
239 THR_COMP_NEARLA,
241 THR_COMP_ZEROGA,
242 THR_COMP_NEARESTGA,
243 THR_COMP_NEARGA,
245 THR_COMP_NEWLG,
246 THR_COMP_NEWLA,
247 THR_COMP_NEWGA,
249 THR_COMP_SPLITLG,
250 THR_COMP_SPLITLA,
251 THR_COMP_SPLITGA,
252 #if CONFIG_COMP_INTERINTRA_PRED
253 THR_COMP_INTERINTRA_ZEROL,
254 THR_COMP_INTERINTRA_NEARESTL,
255 THR_COMP_INTERINTRA_NEARL,
256 THR_COMP_INTERINTRA_NEWL,
258 THR_COMP_INTERINTRA_ZEROG,
259 THR_COMP_INTERINTRA_NEARESTG,
260 THR_COMP_INTERINTRA_NEARG,
261 THR_COMP_INTERINTRA_NEWG,
263 THR_COMP_INTERINTRA_ZEROA,
264 THR_COMP_INTERINTRA_NEARESTA,
265 THR_COMP_INTERINTRA_NEARA,
266 THR_COMP_INTERINTRA_NEWA,
267 #endif
269 THR_MODES;
270 #else
271 typedef enum {
272 THR_ZEROMV,
273 THR_DC,
275 THR_NEARESTMV,
276 THR_NEARMV,
278 THR_ZEROG,
279 THR_NEARESTG,
281 THR_ZEROA,
282 THR_NEARESTA,
284 THR_NEARG,
285 THR_NEARA,
287 THR_V_PRED,
288 THR_H_PRED,
289 THR_D45_PRED,
290 THR_D135_PRED,
291 THR_D117_PRED,
292 THR_D153_PRED,
293 THR_D27_PRED,
294 THR_D63_PRED,
295 THR_TM,
297 THR_NEWMV,
298 THR_NEWG,
299 THR_NEWA,
301 THR_SPLITMV,
302 THR_SPLITG,
303 THR_SPLITA,
305 THR_B_PRED,
306 THR_I8X8_PRED,
308 THR_COMP_ZEROLG,
309 THR_COMP_NEARESTLG,
310 THR_COMP_NEARLG,
312 THR_COMP_ZEROLA,
313 THR_COMP_NEARESTLA,
314 THR_COMP_NEARLA,
316 THR_COMP_ZEROGA,
317 THR_COMP_NEARESTGA,
318 THR_COMP_NEARGA,
320 THR_COMP_NEWLG,
321 THR_COMP_NEWLA,
322 THR_COMP_NEWGA,
324 THR_COMP_SPLITLG,
325 THR_COMP_SPLITLA,
326 THR_COMP_SPLITGA,
327 #if CONFIG_COMP_INTERINTRA_PRED
328 THR_COMP_INTERINTRA_ZEROL,
329 THR_COMP_INTERINTRA_NEARESTL,
330 THR_COMP_INTERINTRA_NEARL,
331 THR_COMP_INTERINTRA_NEWL,
333 THR_COMP_INTERINTRA_ZEROG,
334 THR_COMP_INTERINTRA_NEARESTG,
335 THR_COMP_INTERINTRA_NEARG,
336 THR_COMP_INTERINTRA_NEWG,
338 THR_COMP_INTERINTRA_ZEROA,
339 THR_COMP_INTERINTRA_NEARESTA,
340 THR_COMP_INTERINTRA_NEARA,
341 THR_COMP_INTERINTRA_NEWA,
342 #endif
344 THR_MODES;
345 #endif
347 typedef enum {
348 DIAMOND = 0,
349 NSTEP = 1,
350 HEX = 2
351 } SEARCH_METHODS;
353 typedef struct {
354 int RD;
355 SEARCH_METHODS search_method;
356 int improved_dct;
357 int auto_filter;
358 int recode_loop;
359 int iterative_sub_pixel;
360 int half_pixel_search;
361 int quarter_pixel_search;
362 int thresh_mult[MAX_MODES];
363 int max_step_search_steps;
364 int first_step;
365 int optimize_coefficients;
366 int no_skip_block4x4_search;
367 int improved_mv_pred;
368 int search_best_filter;
370 } SPEED_FEATURES;
372 typedef struct {
373 MACROBLOCK mb;
374 int totalrate;
375 } MB_ROW_COMP;
377 typedef struct {
378 TOKENEXTRA *start;
379 TOKENEXTRA *stop;
380 } TOKENLIST;
382 typedef struct {
383 int ithread;
384 void *ptr1;
385 void *ptr2;
386 } ENCODETHREAD_DATA;
387 typedef struct {
388 int ithread;
389 void *ptr1;
390 } LPFTHREAD_DATA;
393 typedef struct VP9_ENCODER_RTCD {
394 VP9_COMMON_RTCD *common;
395 } VP9_ENCODER_RTCD;
397 enum BlockSize {
398 BLOCK_16X8 = PARTITIONING_16X8,
399 BLOCK_8X16 = PARTITIONING_8X16,
400 BLOCK_8X8 = PARTITIONING_8X8,
401 BLOCK_4X4 = PARTITIONING_4X4,
402 BLOCK_16X16,
403 BLOCK_MAX_SEGMENTS,
404 BLOCK_32X32 = BLOCK_MAX_SEGMENTS,
405 BLOCK_MAX_SB_SEGMENTS,
408 typedef struct VP9_COMP {
410 DECLARE_ALIGNED(16, short, Y1quant[QINDEX_RANGE][16]);
411 DECLARE_ALIGNED(16, unsigned char, Y1quant_shift[QINDEX_RANGE][16]);
412 DECLARE_ALIGNED(16, short, Y1zbin[QINDEX_RANGE][16]);
413 DECLARE_ALIGNED(16, short, Y1round[QINDEX_RANGE][16]);
415 DECLARE_ALIGNED(16, short, Y2quant[QINDEX_RANGE][16]);
416 DECLARE_ALIGNED(16, unsigned char, Y2quant_shift[QINDEX_RANGE][16]);
417 DECLARE_ALIGNED(16, short, Y2zbin[QINDEX_RANGE][16]);
418 DECLARE_ALIGNED(16, short, Y2round[QINDEX_RANGE][16]);
420 DECLARE_ALIGNED(16, short, UVquant[QINDEX_RANGE][16]);
421 DECLARE_ALIGNED(16, unsigned char, UVquant_shift[QINDEX_RANGE][16]);
422 DECLARE_ALIGNED(16, short, UVzbin[QINDEX_RANGE][16]);
423 DECLARE_ALIGNED(16, short, UVround[QINDEX_RANGE][16]);
425 DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1[QINDEX_RANGE][16]);
426 DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2[QINDEX_RANGE][16]);
427 DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv[QINDEX_RANGE][16]);
429 DECLARE_ALIGNED(64, short, Y1zbin_8x8[QINDEX_RANGE][64]);
430 DECLARE_ALIGNED(64, short, Y2zbin_8x8[QINDEX_RANGE][64]);
431 DECLARE_ALIGNED(64, short, UVzbin_8x8[QINDEX_RANGE][64]);
432 DECLARE_ALIGNED(64, short, zrun_zbin_boost_y1_8x8[QINDEX_RANGE][64]);
433 DECLARE_ALIGNED(64, short, zrun_zbin_boost_y2_8x8[QINDEX_RANGE][64]);
434 DECLARE_ALIGNED(64, short, zrun_zbin_boost_uv_8x8[QINDEX_RANGE][64]);
436 DECLARE_ALIGNED(16, short, Y1zbin_16x16[QINDEX_RANGE][256]);
437 DECLARE_ALIGNED(16, short, Y2zbin_16x16[QINDEX_RANGE][256]);
438 DECLARE_ALIGNED(16, short, UVzbin_16x16[QINDEX_RANGE][256]);
439 DECLARE_ALIGNED(16, short, zrun_zbin_boost_y1_16x16[QINDEX_RANGE][256]);
440 DECLARE_ALIGNED(16, short, zrun_zbin_boost_y2_16x16[QINDEX_RANGE][256]);
441 DECLARE_ALIGNED(16, short, zrun_zbin_boost_uv_16x16[QINDEX_RANGE][256]);
443 MACROBLOCK mb;
444 VP9_COMMON common;
445 VP9_CONFIG oxcf;
447 struct lookahead_ctx *lookahead;
448 struct lookahead_entry *source;
449 struct lookahead_entry *alt_ref_source;
451 YV12_BUFFER_CONFIG *Source;
452 YV12_BUFFER_CONFIG *un_scaled_source;
453 YV12_BUFFER_CONFIG scaled_source;
455 int source_alt_ref_pending; // frame in src_buffers has been identified to be encoded as an alt ref
456 int source_alt_ref_active; // an alt ref frame has been encoded and is usable
458 int is_src_frame_alt_ref; // source of frame to encode is an exact copy of an alt ref frame
460 int gold_is_last; // golden frame same as last frame ( short circuit gold searches)
461 int alt_is_last; // Alt reference frame same as last ( short circuit altref search)
462 int gold_is_alt; // don't do both alt and gold search ( just do gold).
464 // int refresh_alt_ref_frame;
465 YV12_BUFFER_CONFIG last_frame_uf;
467 TOKENEXTRA *tok;
468 unsigned int tok_count;
471 unsigned int frames_since_key;
472 unsigned int key_frame_frequency;
473 unsigned int this_key_frame_forced;
474 unsigned int next_key_frame_forced;
476 // Ambient reconstruction err target for force key frames
477 int ambient_err;
479 unsigned int mode_check_freq[MAX_MODES];
480 unsigned int mode_test_hit_counts[MAX_MODES];
481 unsigned int mode_chosen_counts[MAX_MODES];
483 int rd_thresh_mult[MAX_MODES];
484 int rd_baseline_thresh[MAX_MODES];
485 int rd_threshes[MAX_MODES];
486 int64_t rd_comp_pred_diff[NB_PREDICTION_TYPES];
487 int rd_prediction_type_threshes[4][NB_PREDICTION_TYPES];
488 int comp_pred_count[COMP_PRED_CONTEXTS];
489 int single_pred_count[COMP_PRED_CONTEXTS];
490 // FIXME contextualize
491 int txfm_count[TX_SIZE_MAX];
492 int txfm_count_8x8p[TX_SIZE_MAX - 1];
493 int64_t rd_tx_select_diff[NB_TXFM_MODES];
494 int rd_tx_select_threshes[4][NB_TXFM_MODES];
496 int RDMULT;
497 int RDDIV;
499 CODING_CONTEXT coding_context;
501 // Rate targetting variables
502 int64_t prediction_error;
503 int64_t last_prediction_error;
504 int64_t intra_error;
505 int64_t last_intra_error;
507 int this_frame_target;
508 int projected_frame_size;
509 int last_q[2]; // Separate values for Intra/Inter
510 int last_boosted_qindex; // Last boosted GF/KF/ARF q
512 double rate_correction_factor;
513 double key_frame_rate_correction_factor;
514 double gf_rate_correction_factor;
516 int frames_till_gf_update_due; // Count down till next GF
517 int current_gf_interval; // GF interval chosen when we coded the last GF
519 int gf_overspend_bits; // Total bits overspent becasue of GF boost (cumulative)
521 int non_gf_bitrate_adjustment; // Used in the few frames following a GF to recover the extra bits spent in that GF
523 int kf_overspend_bits; // Extra bits spent on key frames that need to be recovered on inter frames
524 int kf_bitrate_adjustment; // Current number of bit s to try and recover on each inter frame.
525 int max_gf_interval;
526 int baseline_gf_interval;
527 int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames
529 int64_t key_frame_count;
530 int prior_key_frame_distance[KEY_FRAME_CONTEXT];
531 int per_frame_bandwidth; // Current section per frame bandwidth target
532 int av_per_frame_bandwidth; // Average frame size target for clip
533 int min_frame_bandwidth; // Minimum allocation that should be used for any frame
534 int inter_frame_target;
535 double output_frame_rate;
536 int64_t last_time_stamp_seen;
537 int64_t last_end_time_stamp_seen;
538 int64_t first_time_stamp_ever;
540 int ni_av_qi;
541 int ni_tot_qi;
542 int ni_frames;
543 int avg_frame_qindex;
544 double tot_q;
545 double avg_q;
547 int zbin_over_quant;
548 int zbin_mode_boost;
549 int zbin_mode_boost_enabled;
551 int64_t total_byte_count;
553 int buffered_mode;
555 int buffer_level;
556 int bits_off_target;
558 int rolling_target_bits;
559 int rolling_actual_bits;
561 int long_rolling_target_bits;
562 int long_rolling_actual_bits;
564 int64_t total_actual_bits;
565 int total_target_vs_actual; // debug stats
567 int worst_quality;
568 int active_worst_quality;
569 int best_quality;
570 int active_best_quality;
572 int cq_target_quality;
574 #if CONFIG_SUPERBLOCKS
575 int sb_count;
576 int sb_ymode_count [VP9_I32X32_MODES];
577 #endif
578 int ymode_count[VP9_YMODES]; /* intra MB type cts this frame */
579 int bmode_count[VP9_NKF_BINTRAMODES];
580 int i8x8_mode_count[VP9_I8X8_MODES];
581 int sub_mv_ref_count[SUBMVREF_COUNT][VP9_SUBMVREFS];
582 int mbsplit_count[VP9_NUMMBSPLITS];
583 int y_uv_mode_count[VP9_YMODES][VP9_UV_MODES];
584 #if CONFIG_COMP_INTERINTRA_PRED
585 int interintra_count[2];
586 int interintra_select_count[2];
587 #endif
589 nmv_context_counts NMVcount;
591 unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
592 vp9_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
593 unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
594 unsigned int hybrid_coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
595 vp9_prob frame_hybrid_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
596 unsigned int frame_hybrid_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
598 unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
599 vp9_prob frame_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
600 unsigned int frame_branch_ct_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
601 unsigned int hybrid_coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
602 vp9_prob frame_hybrid_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
603 unsigned int frame_hybrid_branch_ct_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
605 unsigned int coef_counts_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
606 vp9_prob frame_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
607 unsigned int frame_branch_ct_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
608 unsigned int hybrid_coef_counts_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */
609 vp9_prob frame_hybrid_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
610 unsigned int frame_hybrid_branch_ct_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2];
612 int gfu_boost;
613 int last_boost;
614 int kf_boost;
615 int kf_zeromotion_pct;
617 int target_bandwidth;
618 struct vpx_codec_pkt_list *output_pkt_list;
620 #if 0
621 // Experimental code for lagged and one pass
622 ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
623 int one_pass_frame_index;
624 #endif
625 MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
626 int mbgraph_n_frames; // number of frames filled in the above
627 int static_mb_pct; // % forced skip mbs by segmentation
628 int seg0_progress, seg0_idx, seg0_cnt;
629 int ref_pred_count[3][2];
631 int decimation_factor;
632 int decimation_count;
634 // for real time encoding
635 int avg_encode_time; // microsecond
636 int avg_pick_mode_time; // microsecond
637 int Speed;
638 unsigned int cpu_freq; // Mhz
639 int compressor_speed;
641 int interquantizer;
642 int goldfreq;
643 int auto_worst_q;
644 int cpu_used;
645 int horiz_scale;
646 int vert_scale;
647 int pass;
649 vp9_prob last_skip_false_probs[3][MBSKIP_CONTEXTS];
650 int last_skip_probs_q[3];
652 int recent_ref_frame_usage[MAX_REF_FRAMES];
653 int count_mb_ref_frame_usage[MAX_REF_FRAMES];
654 int ref_frame_flags;
656 unsigned char ref_pred_probs_update[PREDICTION_PROBS];
658 SPEED_FEATURES sf;
659 int error_bins[1024];
661 // Data used for real time conferencing mode to help determine if it would be good to update the gf
662 int inter_zz_count;
663 int gf_bad_count;
664 int gf_update_recommended;
665 int skip_true_count[3];
666 int skip_false_count[3];
668 unsigned char *segmentation_map;
670 // segment threashold for encode breakout
671 int segment_encode_breakout[MAX_MB_SEGMENTS];
673 unsigned char *active_map;
674 unsigned int active_map_enabled;
676 TOKENLIST *tplist;
678 fractional_mv_step_fp *find_fractional_mv_step;
679 vp9_full_search_fn_t full_search_sad;
680 vp9_refining_search_fn_t refining_search_sad;
681 vp9_diamond_search_fn_t diamond_search_sad;
682 vp9_variance_fn_ptr_t fn_ptr[BLOCK_MAX_SB_SEGMENTS];
683 uint64_t time_receive_data;
684 uint64_t time_compress_data;
685 uint64_t time_pick_lpf;
686 uint64_t time_encode_mb_row;
688 int base_skip_false_prob[QINDEX_RANGE][3];
690 struct twopass_rc {
691 unsigned int section_intra_rating;
692 unsigned int next_iiratio;
693 unsigned int this_iiratio;
694 FIRSTPASS_STATS *total_stats;
695 FIRSTPASS_STATS *this_frame_stats;
696 FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
697 FIRSTPASS_STATS *total_left_stats;
698 int first_pass_done;
699 int64_t bits_left;
700 int64_t clip_bits_total;
701 double avg_iiratio;
702 double modified_error_total;
703 double modified_error_used;
704 double modified_error_left;
705 double kf_intra_err_min;
706 double gf_intra_err_min;
707 int frames_to_key;
708 int maxq_max_limit;
709 int maxq_min_limit;
710 int static_scene_max_gf_interval;
711 int kf_bits;
712 // Remaining error from uncoded frames in a gf group. Two pass use only
713 int64_t gf_group_error_left;
715 // Projected total bits available for a key frame group of frames
716 int64_t kf_group_bits;
718 // Error score of frames still to be coded in kf group
719 int64_t kf_group_error_left;
721 // Projected Bits available for a group of frames including 1 GF or ARF
722 int64_t gf_group_bits;
723 // Bits for the golden frame or ARF - 2 pass only
724 int gf_bits;
725 int alt_extra_bits;
727 int sr_update_lag;
728 double est_max_qcorrection_factor;
729 } twopass;
731 #if CONFIG_RUNTIME_CPU_DETECT
732 VP9_ENCODER_RTCD rtcd;
733 #endif
734 #if VP9_TEMPORAL_ALT_REF
735 YV12_BUFFER_CONFIG alt_ref_buffer;
736 YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
737 int fixed_divide[512];
738 #endif
740 #if CONFIG_INTERNAL_STATS
741 int count;
742 double total_y;
743 double total_u;
744 double total_v;
745 double total;
746 double total_sq_error;
747 double totalp_y;
748 double totalp_u;
749 double totalp_v;
750 double totalp;
751 double total_sq_error2;
752 int bytes;
753 double summed_quality;
754 double summed_weights;
755 unsigned int tot_recode_hits;
758 double total_ssimg_y;
759 double total_ssimg_u;
760 double total_ssimg_v;
761 double total_ssimg_all;
763 int b_calculate_ssimg;
764 #endif
765 int b_calculate_psnr;
767 // Per MB activity measurement
768 unsigned int activity_avg;
769 unsigned int *mb_activity_map;
770 int *mb_norm_activity_map;
772 // Record of which MBs still refer to last golden frame either
773 // directly or through 0,0
774 unsigned char *gf_active_flags;
775 int gf_active_count;
777 int output_partition;
779 // Store last frame's MV info for next frame MV prediction
780 int_mv *lfmv;
781 int *lf_ref_frame_sign_bias;
782 int *lf_ref_frame;
784 /* force next frame to intra when kf_auto says so */
785 int force_next_frame_intra;
787 int droppable;
789 // TODO Do we still need this??
790 int update_context;
792 int dummy_packing; /* flag to indicate if packing is dummy */
794 #if CONFIG_PRED_FILTER
795 int pred_filter_on_count;
796 int pred_filter_off_count;
797 #endif
798 unsigned int switchable_interp_count[VP9_SWITCHABLE_FILTERS + 1]
799 [VP9_SWITCHABLE_FILTERS];
800 #if CONFIG_NEW_MVREF
801 unsigned int best_ref_index_counts[MAX_REF_FRAMES][MAX_MV_REFS];
802 #endif
804 } VP9_COMP;
806 void vp9_encode_frame(VP9_COMP *cpi);
808 void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
809 unsigned long *size);
811 void vp9_activity_masking(VP9_COMP *cpi, MACROBLOCK *x);
813 void vp9_set_speed_features(VP9_COMP *cpi);
815 extern int vp9_calc_ss_err(YV12_BUFFER_CONFIG *source,
816 YV12_BUFFER_CONFIG *dest);
818 extern void vp9_alloc_compressor_data(VP9_COMP *cpi);
820 #if CONFIG_DEBUG
821 #define CHECK_MEM_ERROR(lval,expr) do {\
822 lval = (expr); \
823 if(!lval) \
824 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
825 "Failed to allocate "#lval" at %s:%d", \
826 __FILE__,__LINE__);\
827 } while(0)
828 #else
829 #define CHECK_MEM_ERROR(lval,expr) do {\
830 lval = (expr); \
831 if(!lval) \
832 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,\
833 "Failed to allocate "#lval);\
834 } while(0)
835 #endif
836 #endif // __INC_ONYX_INT_H