2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-11-30 01:36:10 +01:00
|
|
|
#ifndef VP9_ENCODER_VP9_ONYX_INT_H_
|
|
|
|
#define VP9_ENCODER_VP9_ONYX_INT_H_
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2012-12-23 16:20:10 +01:00
|
|
|
#include "./vpx_config.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_onyx.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/encoder/vp9_treewriter.h"
|
|
|
|
#include "vp9/encoder/vp9_tokenize.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_onyxc_int.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/encoder/vp9_variance.h"
|
|
|
|
#include "vp9/encoder/vp9_encodemb.h"
|
|
|
|
#include "vp9/encoder/vp9_quantize.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_entropy.h"
|
|
|
|
#include "vp9/common/vp9_entropymode.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_ports/mem.h"
|
2010-05-24 17:39:59 +02:00
|
|
|
#include "vpx/internal/vpx_codec_internal.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/encoder/vp9_mcomp.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_findnearmv.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/encoder/vp9_lookahead.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-02-25 13:36:38 +01:00
|
|
|
// Experimental rate control switches
|
2013-03-27 22:58:37 +01:00
|
|
|
#if CONFIG_ONESHOTQ
|
2013-04-03 00:08:50 +02:00
|
|
|
#define ONE_SHOT_Q_ESTIMATE 0
|
|
|
|
#define STRICT_ONE_SHOT_Q 0
|
|
|
|
#define DISABLE_RC_LONG_TERM_MEM 0
|
2013-03-27 22:58:37 +01:00
|
|
|
#endif
|
2013-04-03 00:08:50 +02:00
|
|
|
|
2013-08-21 13:34:14 +02:00
|
|
|
// #define MODE_TEST_HIT_STATS
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
// #define SPEEDSTATS 1
|
2013-04-03 00:08:50 +02:00
|
|
|
#if CONFIG_MULTIPLE_ARF
|
|
|
|
// Set MIN_GF_INTERVAL to 1 for the full decomposition.
|
|
|
|
#define MIN_GF_INTERVAL 2
|
|
|
|
#else
|
2010-05-18 17:58:33 +02:00
|
|
|
#define MIN_GF_INTERVAL 4
|
2013-04-03 00:08:50 +02:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
#define DEFAULT_GF_INTERVAL 7
|
|
|
|
|
|
|
|
#define KEY_FRAME_CONTEXT 5
|
|
|
|
|
2013-06-06 22:44:34 +02:00
|
|
|
#define MAX_MODES 36
|
Dual 16x16 inter prediction.
This patch introduces the concept of dual inter16x16 prediction. A
16x16 inter-predicted macroblock can use 2 references instead of 1,
where both references use the same mvmode (new, near/est, zero). In the
case of newmv, this means that two MVs are coded instead of one. The
frame can be encoded in 3 ways: all MBs single-prediction, all MBs dual
prediction, or per-MB single/dual prediction selection ("hybrid"), in
which case a single bit is coded per-MB to indicate whether the MB uses
single or dual inter prediction.
In the future, we can (maybe?) get further gains by mixing this with
Adrian's 32x32 work, per-segment dual prediction settings, or adding
support for dual splitmv/8x8mv inter prediction.
Gain (on derf-set, CQ mode) is ~2.8% (SSIM) or ~3.6% (glb PSNR). Most
gain is at medium/high bitrates, but there's minor gains at low bitrates
also. Output was confirmed to match between encoder and decoder.
Note for optimization people: this patch introduces a 2nd version of
16x16/8x8 sixtap/bilin functions, which does an avg instead of a
store. They may want to look and make sure this is implemented to
their satisfaction so we can optimize it best in the future.
Change-ID: I59dc84b07cbb3ccf073ac0f756d03d294cb19281
2011-12-06 20:53:02 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
#define MIN_THRESHMULT 32
|
|
|
|
#define MAX_THRESHMULT 512
|
|
|
|
|
2013-03-22 16:47:17 +01:00
|
|
|
#define GF_ZEROMV_ZBIN_BOOST 0
|
|
|
|
#define LF_ZEROMV_ZBIN_BOOST 0
|
|
|
|
#define MV_ZBIN_BOOST 0
|
2013-03-21 19:37:48 +01:00
|
|
|
#define SPLIT_MV_ZBIN_BOOST 0
|
|
|
|
#define INTRA_ZBIN_BOOST 0
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef struct {
|
2012-07-26 22:42:07 +02:00
|
|
|
nmv_context nmvc;
|
|
|
|
int nmvjointcost[MV_JOINTS];
|
|
|
|
int nmvcosts[2][MV_VALS];
|
|
|
|
int nmvcosts_hp[2][MV_VALS];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
vp9_prob segment_pred_probs[PREDICTION_PROBS];
|
2013-06-06 22:44:34 +02:00
|
|
|
vp9_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
|
|
|
|
vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS];
|
|
|
|
vp9_prob single_ref_prob[REF_CONTEXTS][2];
|
|
|
|
vp9_prob comp_ref_prob[REF_CONTEXTS];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char *last_frame_seg_map_copy;
|
2012-04-11 16:44:14 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
// 0 = Intra, Last, GF, ARF
|
|
|
|
signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
|
2013-06-07 07:55:31 +02:00
|
|
|
// 0 = ZERO_MV, MV
|
2012-07-14 00:21:29 +02:00
|
|
|
signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-07-27 02:15:37 +02:00
|
|
|
vp9_coeff_probs_model coef_probs[TX_SIZES][BLOCK_TYPES];
|
32x32 transform for superblocks.
This adds Debargha's DCT/DWT hybrid and a regular 32x32 DCT, and adds
code all over the place to wrap that in the bitstream/encoder/decoder/RD.
Some implementation notes (these probably need careful review):
- token range is extended by 1 bit, since the value range out of this
transform is [-16384,16383].
- the coefficients coming out of the FDCT are manually scaled back by
1 bit, or else they won't fit in int16_t (they are 17 bits). Because
of this, the RD error scoring does not right-shift the MSE score by
two (unlike for 4x4/8x8/16x16).
- to compensate for this loss in precision, the quantizer is halved
also. This is currently a little hacky.
- FDCT and IDCT is double-only right now. Needs a fixed-point impl.
- There are no default probabilities for the 32x32 transform yet; I'm
simply using the 16x16 luma ones. A future commit will add newly
generated probabilities for all transforms.
- No ADST version. I don't think we'll add one for this level; if an
ADST is desired, transform-size selection can scale back to 16x16
or lower, and use an ADST at that level.
Additional notes specific to Debargha's DWT/DCT hybrid:
- coefficient scale is different for the top/left 16x16 (DCT-over-DWT)
block than for the rest (DWT pixel differences) of the block. Therefore,
RD error scoring isn't easily scalable between coefficient and pixel
domain. Thus, unfortunately, we need to compute the RD distortion in
the pixel domain until we figure out how to scale these appropriately.
Change-Id: I00386f20f35d7fabb19aba94c8162f8aee64ef2b
2012-12-07 23:45:05 +01:00
|
|
|
|
2013-08-23 03:40:34 +02:00
|
|
|
vp9_prob y_mode_prob[4][INTRA_MODES - 1];
|
|
|
|
vp9_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
|
2013-06-03 19:39:40 +02:00
|
|
|
vp9_prob partition_prob[2][NUM_PARTITION_CONTEXTS][PARTITION_TYPES - 1];
|
2012-04-17 18:26:19 +02:00
|
|
|
|
2013-08-23 03:40:34 +02:00
|
|
|
vp9_prob switchable_interp_prob[SWITCHABLE_FILTERS + 1]
|
|
|
|
[SWITCHABLE_FILTERS - 1];
|
2012-07-18 22:43:01 +02:00
|
|
|
|
2013-08-23 03:40:34 +02:00
|
|
|
int inter_mode_counts[INTER_MODE_CONTEXTS][INTER_MODES - 1][2];
|
|
|
|
vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-07-11 02:36:06 +02:00
|
|
|
struct tx_probs tx_probs;
|
2013-06-07 22:24:14 +02:00
|
|
|
vp9_prob mbskip_probs[MBSKIP_CONTEXTS];
|
2010-05-18 17:58:33 +02:00
|
|
|
} CODING_CONTEXT;
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef struct {
|
|
|
|
double frame;
|
|
|
|
double intra_error;
|
|
|
|
double coded_error;
|
|
|
|
double sr_coded_error;
|
|
|
|
double ssim_weighted_pred_err;
|
|
|
|
double pcnt_inter;
|
|
|
|
double pcnt_motion;
|
|
|
|
double pcnt_second_ref;
|
|
|
|
double pcnt_neutral;
|
|
|
|
double MVr;
|
|
|
|
double mvr_abs;
|
|
|
|
double MVc;
|
|
|
|
double mvc_abs;
|
|
|
|
double MVrv;
|
|
|
|
double MVcv;
|
|
|
|
double mv_in_out_count;
|
|
|
|
double new_mv_count;
|
|
|
|
double duration;
|
|
|
|
double count;
|
2013-05-31 01:34:59 +02:00
|
|
|
} FIRSTPASS_STATS;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef struct {
|
|
|
|
int frames_so_far;
|
|
|
|
double frame_intra_error;
|
|
|
|
double frame_coded_error;
|
|
|
|
double frame_pcnt_inter;
|
|
|
|
double frame_pcnt_motion;
|
|
|
|
double frame_mvr;
|
|
|
|
double frame_mvr_abs;
|
|
|
|
double frame_mvc;
|
|
|
|
double frame_mvc_abs;
|
2010-05-18 17:58:33 +02:00
|
|
|
} ONEPASS_FRAMESTATS;
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef struct {
|
|
|
|
struct {
|
|
|
|
int err;
|
|
|
|
union {
|
|
|
|
int_mv mv;
|
|
|
|
MB_PREDICTION_MODE mode;
|
|
|
|
} m;
|
|
|
|
} ref[MAX_REF_FRAMES];
|
2011-10-05 12:26:00 +02:00
|
|
|
} MBGRAPH_MB_STATS;
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef struct {
|
|
|
|
MBGRAPH_MB_STATS *mb_stats;
|
2011-10-05 12:26:00 +02:00
|
|
|
} MBGRAPH_FRAME_STATS;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-07-18 17:41:44 +02:00
|
|
|
// This enumerator type needs to be kept aligned with the mode order in
|
|
|
|
// const MODE_DEFINITION vp9_mode_order[MAX_MODES] used in the rd code.
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef enum {
|
|
|
|
THR_NEARESTMV,
|
2013-07-19 15:04:53 +02:00
|
|
|
THR_NEARESTA,
|
|
|
|
THR_NEARESTG,
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-09-05 02:15:05 +02:00
|
|
|
THR_DC,
|
|
|
|
|
|
|
|
THR_NEWMV,
|
2013-07-19 15:04:53 +02:00
|
|
|
THR_NEWA,
|
2013-09-05 02:15:05 +02:00
|
|
|
THR_NEWG,
|
|
|
|
|
|
|
|
THR_NEARMV,
|
2012-07-14 00:21:29 +02:00
|
|
|
THR_NEARA,
|
2013-09-05 02:15:05 +02:00
|
|
|
THR_COMP_NEARESTLA,
|
|
|
|
THR_COMP_NEARESTGA,
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
THR_TM,
|
2012-06-26 01:23:58 +02:00
|
|
|
|
2013-07-19 15:04:53 +02:00
|
|
|
THR_COMP_NEARLA,
|
|
|
|
THR_COMP_NEWLA,
|
|
|
|
THR_NEARG,
|
|
|
|
THR_COMP_NEARGA,
|
|
|
|
THR_COMP_NEWGA,
|
2012-06-26 01:23:58 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
THR_SPLITMV,
|
|
|
|
THR_SPLITG,
|
|
|
|
THR_SPLITA,
|
2013-07-19 15:04:53 +02:00
|
|
|
THR_COMP_SPLITLA,
|
|
|
|
THR_COMP_SPLITGA,
|
2012-06-26 01:23:58 +02:00
|
|
|
|
2013-07-19 15:04:53 +02:00
|
|
|
THR_ZEROMV,
|
|
|
|
THR_ZEROG,
|
|
|
|
THR_ZEROA,
|
2012-07-14 00:21:29 +02:00
|
|
|
THR_COMP_ZEROLA,
|
|
|
|
THR_COMP_ZEROGA,
|
2012-06-26 01:23:58 +02:00
|
|
|
|
2013-07-19 15:04:53 +02:00
|
|
|
THR_B_PRED,
|
|
|
|
THR_H_PRED,
|
|
|
|
THR_V_PRED,
|
|
|
|
THR_D135_PRED,
|
2013-08-24 02:33:48 +02:00
|
|
|
THR_D207_PRED,
|
2013-07-19 15:04:53 +02:00
|
|
|
THR_D153_PRED,
|
|
|
|
THR_D63_PRED,
|
|
|
|
THR_D117_PRED,
|
|
|
|
THR_D45_PRED,
|
2013-05-31 01:34:59 +02:00
|
|
|
} THR_MODES;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef enum {
|
|
|
|
DIAMOND = 0,
|
|
|
|
NSTEP = 1,
|
2013-07-22 23:47:57 +02:00
|
|
|
HEX = 2,
|
|
|
|
BIGDIA = 3,
|
|
|
|
SQUARE = 4
|
2010-05-18 17:58:33 +02:00
|
|
|
} SEARCH_METHODS;
|
|
|
|
|
Tx size selection enhancements
(1) Refines the modeling function and uses that to add some speed
features. Specifically, intead of using a flag use_largest_txfm as
a speed feature, an enum tx_size_search_method is used, of which
two of the types are USE_FULL_RD and USE_LARGESTALL. Two other
new types are added:
USE_LARGESTINTRA (use largest only for intra)
USE_LARGESTINTRA_MODELINTER (use largest for intra, and model for
inter)
(2) Another change is that the framework for deciding transform type
is simplified to use a heuristic count based method rather than
an rd based method using txfm_cache. In practice the new method
is found to work just as well - with derf only -0.01 down.
The new method is more compatible with the new framework where
certain rd costs are based on full rd and certain others are
based on modeled rd or are not computed. In this patch the existing
rd based method is still kept for use in the USE_FULL_RD mode.
In the other modes, the count based method is used.
However the recommendation is to remove it eventually since the
benefit is limited, and will remove a lot of complications in
the code
(3) Finally a bug is fixed with the existing use_largest_txfm speed feature
that causes mismatches when the lossless mode and 4x4 WH transform is
forced.
Results on derf:
USE_FULL_RD: +0.03% (due to change in the tables), 0% encode time reduction
USE_LARGESTINTRA: -0.21%, 15% encode time reduction (this one is a
pretty good compromise)
USE_LARGESTINTRA_MODELINTER: -0.98%, 22% encode time reduction
(currently the benefit of modeling is limited for txfm size selection,
but keeping this enum as a placeholder) .
USE_LARGESTALL: -1.05%, 27% encode-time reduction (same as existing
use_largest_txfm speed feature).
Change-Id: I4d60a5f9ce78fbc90cddf2f97ed91d8bc0d4f936
2013-06-22 01:31:12 +02:00
|
|
|
typedef enum {
|
|
|
|
USE_FULL_RD = 0,
|
|
|
|
USE_LARGESTINTRA,
|
|
|
|
USE_LARGESTINTRA_MODELINTER,
|
|
|
|
USE_LARGESTALL
|
|
|
|
} TX_SIZE_SEARCH_METHOD;
|
|
|
|
|
2013-07-03 23:47:54 +02:00
|
|
|
typedef enum {
|
|
|
|
// Values should be powers of 2 so that they can be selected as bits of
|
|
|
|
// an integer flags field
|
|
|
|
|
|
|
|
// terminate search early based on distortion so far compared to
|
|
|
|
// qp step, distortion in the neighborhood of the frame, etc.
|
|
|
|
FLAG_EARLY_TERMINATE = 1,
|
|
|
|
|
|
|
|
// skips comp inter modes if the best so far is an intra mode
|
|
|
|
FLAG_SKIP_COMP_BESTINTRA = 2,
|
|
|
|
|
|
|
|
// skips comp inter modes if the best single intermode so far does
|
|
|
|
// not have the same reference as one of the two references being
|
|
|
|
// tested
|
|
|
|
FLAG_SKIP_COMP_REFMISMATCH = 4,
|
|
|
|
|
|
|
|
// skips oblique intra modes if the best so far is an inter mode
|
|
|
|
FLAG_SKIP_INTRA_BESTINTER = 8,
|
|
|
|
|
|
|
|
// skips oblique intra modes at angles 27, 63, 117, 153 if the best
|
|
|
|
// intra so far is not one of the neighboring directions
|
|
|
|
FLAG_SKIP_INTRA_DIRMISMATCH = 16,
|
2013-07-31 18:33:58 +02:00
|
|
|
|
|
|
|
// skips intra modes other than DC_PRED if the source variance
|
|
|
|
// is small
|
|
|
|
FLAG_SKIP_INTRA_LOWVAR = 32,
|
2013-07-03 23:47:54 +02:00
|
|
|
} MODE_SEARCH_SKIP_LOGIC;
|
|
|
|
|
2013-08-07 00:53:35 +02:00
|
|
|
typedef enum {
|
|
|
|
SUBPEL_ITERATIVE = 0,
|
2013-08-08 02:01:43 +02:00
|
|
|
SUBPEL_TREE = 1,
|
2013-08-07 00:53:35 +02:00
|
|
|
// Other methods to come
|
|
|
|
} SUBPEL_SEARCH_METHODS;
|
|
|
|
|
2013-08-22 18:23:02 +02:00
|
|
|
#define ALL_INTRA_MODES 0x3FF
|
|
|
|
#define INTRA_DC_ONLY 0x01
|
|
|
|
#define INTRA_DC_TM ((1 << TM_PRED) | (1 << DC_PRED))
|
|
|
|
#define INTRA_DC_TM_H_V (INTRA_DC_TM | (1 << V_PRED) | (1 << H_PRED))
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
typedef struct {
|
|
|
|
int RD;
|
|
|
|
SEARCH_METHODS search_method;
|
|
|
|
int auto_filter;
|
|
|
|
int recode_loop;
|
2013-08-07 00:53:35 +02:00
|
|
|
SUBPEL_SEARCH_METHODS subpel_search_method;
|
|
|
|
int subpel_iters_per_step;
|
2012-07-14 00:21:29 +02:00
|
|
|
int thresh_mult[MAX_MODES];
|
|
|
|
int max_step_search_steps;
|
2013-06-24 16:19:16 +02:00
|
|
|
int reduce_first_step_size;
|
2013-06-26 18:06:25 +02:00
|
|
|
int auto_mv_step_size;
|
2012-07-14 00:21:29 +02:00
|
|
|
int optimize_coefficients;
|
|
|
|
int search_best_filter;
|
2013-02-05 11:13:25 +01:00
|
|
|
int static_segmentation;
|
2013-06-04 16:58:53 +02:00
|
|
|
int comp_inter_joint_search_thresh;
|
2013-07-02 13:34:41 +02:00
|
|
|
int adaptive_rd_thresh;
|
2013-06-26 04:41:56 +02:00
|
|
|
int skip_encode_sb;
|
2013-07-09 01:48:47 +02:00
|
|
|
int skip_encode_frame;
|
2013-06-19 21:16:45 +02:00
|
|
|
int use_lastframe_partitioning;
|
Tx size selection enhancements
(1) Refines the modeling function and uses that to add some speed
features. Specifically, intead of using a flag use_largest_txfm as
a speed feature, an enum tx_size_search_method is used, of which
two of the types are USE_FULL_RD and USE_LARGESTALL. Two other
new types are added:
USE_LARGESTINTRA (use largest only for intra)
USE_LARGESTINTRA_MODELINTER (use largest for intra, and model for
inter)
(2) Another change is that the framework for deciding transform type
is simplified to use a heuristic count based method rather than
an rd based method using txfm_cache. In practice the new method
is found to work just as well - with derf only -0.01 down.
The new method is more compatible with the new framework where
certain rd costs are based on full rd and certain others are
based on modeled rd or are not computed. In this patch the existing
rd based method is still kept for use in the USE_FULL_RD mode.
In the other modes, the count based method is used.
However the recommendation is to remove it eventually since the
benefit is limited, and will remove a lot of complications in
the code
(3) Finally a bug is fixed with the existing use_largest_txfm speed feature
that causes mismatches when the lossless mode and 4x4 WH transform is
forced.
Results on derf:
USE_FULL_RD: +0.03% (due to change in the tables), 0% encode time reduction
USE_LARGESTINTRA: -0.21%, 15% encode time reduction (this one is a
pretty good compromise)
USE_LARGESTINTRA_MODELINTER: -0.98%, 22% encode time reduction
(currently the benefit of modeling is limited for txfm size selection,
but keeping this enum as a placeholder) .
USE_LARGESTALL: -1.05%, 27% encode-time reduction (same as existing
use_largest_txfm speed feature).
Change-Id: I4d60a5f9ce78fbc90cddf2f97ed91d8bc0d4f936
2013-06-22 01:31:12 +02:00
|
|
|
TX_SIZE_SEARCH_METHOD tx_size_search_method;
|
2013-08-08 00:22:51 +02:00
|
|
|
int use_lp32x32fdct;
|
2013-06-20 00:53:47 +02:00
|
|
|
int use_avoid_tested_higherror;
|
|
|
|
int skip_lots_of_modes;
|
|
|
|
int adjust_thresholds_by_speed;
|
2013-06-20 16:17:01 +02:00
|
|
|
int partition_by_variance;
|
2013-06-20 16:46:51 +02:00
|
|
|
int use_one_partition_size_always;
|
2013-06-27 21:07:07 +02:00
|
|
|
int less_rectangular_check;
|
2013-06-27 21:07:07 +02:00
|
|
|
int use_square_partition_only;
|
2013-09-05 02:15:05 +02:00
|
|
|
int mode_skip_start;
|
2013-07-01 17:27:12 +02:00
|
|
|
int reference_masking;
|
2013-08-27 20:05:08 +02:00
|
|
|
BLOCK_SIZE always_this_block_size;
|
2013-07-24 15:07:37 +02:00
|
|
|
int auto_min_max_partition_size;
|
|
|
|
int auto_min_max_partition_interval;
|
|
|
|
int auto_min_max_partition_count;
|
2013-08-27 20:05:08 +02:00
|
|
|
BLOCK_SIZE min_partition_size;
|
|
|
|
BLOCK_SIZE max_partition_size;
|
2013-07-02 03:18:50 +02:00
|
|
|
int adjust_partitioning_from_last_frame;
|
|
|
|
int last_partitioning_redo_frequency;
|
2013-06-30 02:34:51 +02:00
|
|
|
int disable_splitmv;
|
2013-07-03 23:43:23 +02:00
|
|
|
int using_small_partition_info;
|
2013-07-03 23:47:54 +02:00
|
|
|
|
|
|
|
// Implements various heuristics to skip searching modes
|
|
|
|
// The heuristics selected are based on flags
|
|
|
|
// defined in the MODE_SEARCH_SKIP_HEURISTICS enum
|
|
|
|
unsigned int mode_search_skip_flags;
|
Speed feature to skip split partition based on var
Adds a speed feature to disable split partition search based on a
given threshold on the source variance. A tighter threshold derived
from the threshold provided is used to also disable horizontal and
vertical partitions.
Results on derfraw300:
threshold = 16, psnr = -0.057%, speedup ~1% (football)
threshold = 32, psnr = -0.150%, speedup ~4-5% (football)
threshold = 64, psnr = -0.570%, speedup ~10-12% (football)
Results on stdhdraw250:
threshold = 32, psnr = -0.18%, speedup is somewhat more than derf
because of a larger number of smoother blocks at higher resolution.
Based on these results, a threshold of 32 is chosen for speed 1,
and a threshold of 64 is chosen for speeds 2 and above.
Change-Id: If08912fb6c67fd4242d12a0d094783a99f52f6c6
2013-08-03 02:15:38 +02:00
|
|
|
// A source variance threshold below which the split mode is disabled
|
|
|
|
unsigned int disable_split_var_thresh;
|
Cleanup/enhancements of switchable filter search
Cleans up the switchable filter search logic. Also adds a
speed feature - a variance threshold - to disable filter search
if source variance is lower than this value.
Results: derfraw300
threshold = 16, psnr -0.238%, 4-5% speedup (tested on football)
threshold = 32, psnr -0.381%, 8-9% speedup (tested on football)
threshold = 64, psnr -0.611%, 12-13% speedup (tested on football)
threshold = 96, psnr -0.804%, 16-17% speedup (tested on football)
Based on these results, the threshold is chosen as 16 for speed 1,
32 for speed 2, 64 for speed 3 and 96 for speed 4.
Change-Id: Ib630d39192773b1983d3d349b97973768e170c04
2013-08-16 22:51:00 +02:00
|
|
|
// A source variance threshold below which filter search is disabled
|
|
|
|
// Choose a very large value (UINT_MAX) to use 8-tap always
|
|
|
|
unsigned int disable_filter_search_var_thresh;
|
2013-08-22 18:23:02 +02:00
|
|
|
int intra_y_mode_mask;
|
|
|
|
int intra_uv_mode_mask;
|
2013-07-09 01:01:01 +02:00
|
|
|
int use_rd_breakout;
|
2013-07-16 19:12:34 +02:00
|
|
|
int use_uv_intra_rd_estimate;
|
2013-08-07 00:46:26 +02:00
|
|
|
int use_fast_lpf_pick;
|
2013-08-28 00:07:50 +02:00
|
|
|
int use_fast_coef_updates; // 0: 2-loop, 1: 1-loop, 2: 1-loop reduced
|
2010-05-18 17:58:33 +02:00
|
|
|
} SPEED_FEATURES;
|
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
typedef struct VP9_COMP {
|
2013-07-01 20:36:07 +02:00
|
|
|
DECLARE_ALIGNED(16, int16_t, y_quant[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, y_quant_shift[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, y_zbin[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, y_round[QINDEX_RANGE][8]);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-07-01 20:36:07 +02:00
|
|
|
DECLARE_ALIGNED(16, int16_t, uv_quant[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, uv_quant_shift[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, uv_zbin[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, uv_round[QINDEX_RANGE][8]);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-05-16 02:55:08 +02:00
|
|
|
#if CONFIG_ALPHA
|
2013-07-01 20:36:07 +02:00
|
|
|
DECLARE_ALIGNED(16, int16_t, a_quant[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, a_quant_shift[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, a_zbin[QINDEX_RANGE][8]);
|
|
|
|
DECLARE_ALIGNED(16, int16_t, a_round[QINDEX_RANGE][8]);
|
2013-05-16 02:55:08 +02:00
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
MACROBLOCK mb;
|
2012-10-31 01:53:32 +01:00
|
|
|
VP9_COMMON common;
|
2012-10-31 22:40:53 +01:00
|
|
|
VP9_CONFIG oxcf;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
struct lookahead_ctx *lookahead;
|
|
|
|
struct lookahead_entry *source;
|
2013-04-03 00:08:50 +02:00
|
|
|
#if CONFIG_MULTIPLE_ARF
|
|
|
|
struct lookahead_entry *alt_ref_source[NUM_REF_FRAMES];
|
|
|
|
#else
|
2012-07-14 00:21:29 +02:00
|
|
|
struct lookahead_entry *alt_ref_source;
|
2013-04-03 00:08:50 +02:00
|
|
|
#endif
|
2011-04-13 20:00:18 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
YV12_BUFFER_CONFIG *Source;
|
|
|
|
YV12_BUFFER_CONFIG *un_scaled_source;
|
|
|
|
YV12_BUFFER_CONFIG scaled_source;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-07-18 23:09:21 +02:00
|
|
|
unsigned int frames_till_alt_ref_frame;
|
2012-07-14 00:21:29 +02:00
|
|
|
int source_alt_ref_pending; // frame in src_buffers has been identified to be encoded as an alt ref
|
|
|
|
int source_alt_ref_active; // an alt ref frame has been encoded and is usable
|
2010-11-17 00:16:24 +01:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int is_src_frame_alt_ref; // source of frame to encode is an exact copy of an alt ref frame
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int gold_is_last; // golden frame same as last frame ( short circuit gold searches)
|
|
|
|
int alt_is_last; // Alt reference frame same as last ( short circuit altref search)
|
|
|
|
int gold_is_alt; // don't do both alt and gold search ( just do gold).
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-02-20 21:34:31 +01:00
|
|
|
int scaled_ref_idx[3];
|
2013-01-15 22:49:44 +01:00
|
|
|
int lst_fb_idx;
|
|
|
|
int gld_fb_idx;
|
|
|
|
int alt_fb_idx;
|
2013-09-05 17:55:47 +02:00
|
|
|
|
|
|
|
int current_layer;
|
|
|
|
int use_svc;
|
|
|
|
|
2013-04-03 00:08:50 +02:00
|
|
|
#if CONFIG_MULTIPLE_ARF
|
|
|
|
int alt_ref_fb_idx[NUM_REF_FRAMES - 3];
|
|
|
|
#endif
|
2013-01-15 22:49:44 +01:00
|
|
|
int refresh_last_frame;
|
|
|
|
int refresh_golden_frame;
|
|
|
|
int refresh_alt_ref_frame;
|
2012-07-14 00:21:29 +02:00
|
|
|
YV12_BUFFER_CONFIG last_frame_uf;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
TOKENEXTRA *tok;
|
2013-06-12 19:30:06 +02:00
|
|
|
unsigned int tok_count[4][1 << 6];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned int frames_since_key;
|
|
|
|
unsigned int key_frame_frequency;
|
|
|
|
unsigned int this_key_frame_forced;
|
|
|
|
unsigned int next_key_frame_forced;
|
2013-04-03 00:08:50 +02:00
|
|
|
#if CONFIG_MULTIPLE_ARF
|
|
|
|
// Position within a frame coding order (including any additional ARF frames).
|
|
|
|
unsigned int sequence_number;
|
|
|
|
// Next frame in naturally occurring order that has not yet been coded.
|
|
|
|
int next_frame_in_order;
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
// Ambient reconstruction err target for force key frames
|
|
|
|
int ambient_err;
|
2011-01-17 18:23:11 +01:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned int mode_check_freq[MAX_MODES];
|
|
|
|
unsigned int mode_test_hit_counts[MAX_MODES];
|
|
|
|
unsigned int mode_chosen_counts[MAX_MODES];
|
2013-09-05 02:15:05 +02:00
|
|
|
int64_t mode_skip_mask;
|
2013-07-01 17:27:12 +02:00
|
|
|
int ref_frame_mask;
|
|
|
|
int set_ref_frame_mask;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-08-10 02:47:32 +02:00
|
|
|
int rd_threshes[BLOCK_SIZES][MAX_MODES];
|
|
|
|
int rd_thresh_freq_fact[BLOCK_SIZES][MAX_MODES];
|
2013-06-03 13:51:29 +02:00
|
|
|
|
2012-08-10 03:25:29 +02:00
|
|
|
int64_t rd_comp_pred_diff[NB_PREDICTION_TYPES];
|
2013-07-08 23:49:33 +02:00
|
|
|
// FIXME(rbultje) int64_t?
|
2012-07-14 00:21:29 +02:00
|
|
|
int rd_prediction_type_threshes[4][NB_PREDICTION_TYPES];
|
2013-06-06 22:44:34 +02:00
|
|
|
unsigned int intra_inter_count[INTRA_INTER_CONTEXTS][2];
|
|
|
|
unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2];
|
|
|
|
unsigned int single_ref_count[REF_CONTEXTS][2][2];
|
|
|
|
unsigned int comp_ref_count[REF_CONTEXTS][2];
|
|
|
|
|
2013-07-29 22:38:40 +02:00
|
|
|
int64_t rd_tx_select_diff[TX_MODES];
|
2013-07-08 23:49:33 +02:00
|
|
|
// FIXME(rbultje) can this overflow?
|
2013-07-29 22:38:40 +02:00
|
|
|
int rd_tx_select_threshes[4][TX_MODES];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-08-23 03:40:34 +02:00
|
|
|
int64_t rd_filter_diff[SWITCHABLE_FILTERS + 1];
|
|
|
|
int64_t rd_filter_threshes[4][SWITCHABLE_FILTERS + 1];
|
|
|
|
int64_t rd_filter_cache[SWITCHABLE_FILTERS + 1];
|
2013-07-08 23:49:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int RDMULT;
|
|
|
|
int RDDIV;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
CODING_CONTEXT coding_context;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
// Rate targetting variables
|
|
|
|
int this_frame_target;
|
|
|
|
int projected_frame_size;
|
|
|
|
int last_q[2]; // Separate values for Intra/Inter
|
|
|
|
int last_boosted_qindex; // Last boosted GF/KF/ARF q
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
double rate_correction_factor;
|
|
|
|
double key_frame_rate_correction_factor;
|
|
|
|
double gf_rate_correction_factor;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-07-18 23:09:21 +02:00
|
|
|
unsigned int frames_since_golden;
|
2012-07-14 00:21:29 +02:00
|
|
|
int frames_till_gf_update_due; // Count down till next GF
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int gf_overspend_bits; // Total bits overspent becasue of GF boost (cumulative)
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int non_gf_bitrate_adjustment; // Used in the few frames following a GF to recover the extra bits spent in that GF
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int kf_overspend_bits; // Extra bits spent on key frames that need to be recovered on inter frames
|
|
|
|
int kf_bitrate_adjustment; // Current number of bit s to try and recover on each inter frame.
|
|
|
|
int max_gf_interval;
|
|
|
|
int baseline_gf_interval;
|
|
|
|
int active_arnr_frames; // <= cpi->oxcf.arnr_max_frames
|
2013-03-18 17:17:04 +01:00
|
|
|
int active_arnr_strength; // <= cpi->oxcf.arnr_max_strength
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int64_t key_frame_count;
|
|
|
|
int prior_key_frame_distance[KEY_FRAME_CONTEXT];
|
|
|
|
int per_frame_bandwidth; // Current section per frame bandwidth target
|
|
|
|
int av_per_frame_bandwidth; // Average frame size target for clip
|
|
|
|
int min_frame_bandwidth; // Minimum allocation that should be used for any frame
|
|
|
|
int inter_frame_target;
|
2013-07-13 02:12:46 +02:00
|
|
|
double output_framerate;
|
2012-07-14 00:21:29 +02:00
|
|
|
int64_t last_time_stamp_seen;
|
|
|
|
int64_t last_end_time_stamp_seen;
|
|
|
|
int64_t first_time_stamp_ever;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int ni_av_qi;
|
|
|
|
int ni_tot_qi;
|
|
|
|
int ni_frames;
|
|
|
|
int avg_frame_qindex;
|
|
|
|
double tot_q;
|
|
|
|
double avg_q;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int zbin_mode_boost;
|
|
|
|
int zbin_mode_boost_enabled;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int64_t total_byte_count;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int buffered_mode;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int buffer_level;
|
|
|
|
int bits_off_target;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int rolling_target_bits;
|
|
|
|
int rolling_actual_bits;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int long_rolling_target_bits;
|
|
|
|
int long_rolling_actual_bits;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int64_t total_actual_bits;
|
|
|
|
int total_target_vs_actual; // debug stats
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int worst_quality;
|
|
|
|
int active_worst_quality;
|
|
|
|
int best_quality;
|
|
|
|
int active_best_quality;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int cq_target_quality;
|
2011-01-07 17:33:59 +01:00
|
|
|
|
2013-08-23 03:40:34 +02:00
|
|
|
int y_mode_count[4][INTRA_MODES];
|
|
|
|
int y_uv_mode_count[INTRA_MODES][INTRA_MODES];
|
2013-04-23 19:12:18 +02:00
|
|
|
unsigned int partition_count[NUM_PARTITION_CONTEXTS][PARTITION_TYPES];
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2012-07-26 22:42:07 +02:00
|
|
|
nmv_context_counts NMVcount;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-07-27 02:15:37 +02:00
|
|
|
vp9_coeff_count coef_counts[TX_SIZES][BLOCK_TYPES];
|
|
|
|
vp9_coeff_probs_model frame_coef_probs[TX_SIZES][BLOCK_TYPES];
|
|
|
|
vp9_coeff_stats frame_branch_ct[TX_SIZES][BLOCK_TYPES];
|
32x32 transform for superblocks.
This adds Debargha's DCT/DWT hybrid and a regular 32x32 DCT, and adds
code all over the place to wrap that in the bitstream/encoder/decoder/RD.
Some implementation notes (these probably need careful review):
- token range is extended by 1 bit, since the value range out of this
transform is [-16384,16383].
- the coefficients coming out of the FDCT are manually scaled back by
1 bit, or else they won't fit in int16_t (they are 17 bits). Because
of this, the RD error scoring does not right-shift the MSE score by
two (unlike for 4x4/8x8/16x16).
- to compensate for this loss in precision, the quantizer is halved
also. This is currently a little hacky.
- FDCT and IDCT is double-only right now. Needs a fixed-point impl.
- There are no default probabilities for the 32x32 transform yet; I'm
simply using the 16x16 luma ones. A future commit will add newly
generated probabilities for all transforms.
- No ADST version. I don't think we'll add one for this level; if an
ADST is desired, transform-size selection can scale back to 16x16
or lower, and use an ADST at that level.
Additional notes specific to Debargha's DWT/DCT hybrid:
- coefficient scale is different for the top/left 16x16 (DCT-over-DWT)
block than for the rest (DWT pixel differences) of the block. Therefore,
RD error scoring isn't easily scalable between coefficient and pixel
domain. Thus, unfortunately, we need to compute the RD distortion in
the pixel domain until we figure out how to scale these appropriately.
Change-Id: I00386f20f35d7fabb19aba94c8162f8aee64ef2b
2012-12-07 23:45:05 +01:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int gfu_boost;
|
|
|
|
int last_boost;
|
|
|
|
int kf_boost;
|
|
|
|
int kf_zeromotion_pct;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-02-28 02:09:12 +01:00
|
|
|
int64_t target_bandwidth;
|
2012-07-14 00:21:29 +02:00
|
|
|
struct vpx_codec_pkt_list *output_pkt_list;
|
2010-10-14 22:40:12 +02:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
#if 0
|
2012-07-14 00:21:29 +02:00
|
|
|
// Experimental code for lagged and one pass
|
|
|
|
ONEPASS_FRAMESTATS one_pass_frame_stats[MAX_LAG_BUFFERS];
|
|
|
|
int one_pass_frame_index;
|
2010-05-18 17:58:33 +02:00
|
|
|
#endif
|
2012-07-14 00:21:29 +02:00
|
|
|
MBGRAPH_FRAME_STATS mbgraph_stats[MAX_LAG_BUFFERS];
|
|
|
|
int mbgraph_n_frames; // number of frames filled in the above
|
|
|
|
int static_mb_pct; // % forced skip mbs by segmentation
|
|
|
|
int seg0_progress, seg0_idx, seg0_cnt;
|
|
|
|
|
|
|
|
int decimation_factor;
|
|
|
|
int decimation_count;
|
|
|
|
|
|
|
|
// for real time encoding
|
|
|
|
int avg_encode_time; // microsecond
|
|
|
|
int avg_pick_mode_time; // microsecond
|
2013-05-08 23:35:42 +02:00
|
|
|
int speed;
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned int cpu_freq; // Mhz
|
|
|
|
int compressor_speed;
|
|
|
|
|
|
|
|
int interquantizer;
|
|
|
|
int goldfreq;
|
|
|
|
int auto_worst_q;
|
|
|
|
int cpu_used;
|
|
|
|
int pass;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-10-31 22:40:53 +01:00
|
|
|
vp9_prob last_skip_false_probs[3][MBSKIP_CONTEXTS];
|
2012-07-14 00:21:29 +02:00
|
|
|
int last_skip_probs_q[3];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int ref_frame_flags;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
SPEED_FEATURES sf;
|
|
|
|
int error_bins[1024];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-06-26 18:06:25 +02:00
|
|
|
unsigned int max_mv_magnitude;
|
2013-07-12 18:52:24 +02:00
|
|
|
int mv_step_param;
|
2013-06-26 18:06:25 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
// Data used for real time conferencing mode to help determine if it would be good to update the gf
|
|
|
|
int inter_zz_count;
|
|
|
|
int gf_bad_count;
|
|
|
|
int gf_update_recommended;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char *segmentation_map;
|
2011-09-13 12:26:39 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
// segment threashold for encode breakout
|
2013-07-23 13:09:04 +02:00
|
|
|
int segment_encode_breakout[MAX_SEGMENTS];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned char *active_map;
|
|
|
|
unsigned int active_map_enabled;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
fractional_mv_step_fp *find_fractional_mv_step;
|
2013-08-08 02:01:43 +02:00
|
|
|
fractional_mv_step_comp_fp *find_fractional_mv_step_comp;
|
2012-10-31 22:40:53 +01:00
|
|
|
vp9_full_search_fn_t full_search_sad;
|
|
|
|
vp9_refining_search_fn_t refining_search_sad;
|
|
|
|
vp9_diamond_search_fn_t diamond_search_sad;
|
2013-08-10 02:47:32 +02:00
|
|
|
vp9_variance_fn_ptr_t fn_ptr[BLOCK_SIZES];
|
2012-08-11 02:05:46 +02:00
|
|
|
uint64_t time_receive_data;
|
|
|
|
uint64_t time_compress_data;
|
|
|
|
uint64_t time_pick_lpf;
|
2013-07-30 19:16:03 +02:00
|
|
|
uint64_t time_encode_sb_row;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
struct twopass_rc {
|
|
|
|
unsigned int section_intra_rating;
|
|
|
|
unsigned int next_iiratio;
|
|
|
|
unsigned int this_iiratio;
|
2013-05-06 23:07:18 +02:00
|
|
|
FIRSTPASS_STATS total_stats;
|
|
|
|
FIRSTPASS_STATS this_frame_stats;
|
2012-07-14 00:21:29 +02:00
|
|
|
FIRSTPASS_STATS *stats_in, *stats_in_end, *stats_in_start;
|
2013-05-06 23:07:18 +02:00
|
|
|
FIRSTPASS_STATS total_left_stats;
|
2012-07-14 00:21:29 +02:00
|
|
|
int first_pass_done;
|
|
|
|
int64_t bits_left;
|
|
|
|
int64_t clip_bits_total;
|
|
|
|
double avg_iiratio;
|
|
|
|
double modified_error_total;
|
|
|
|
double modified_error_used;
|
|
|
|
double modified_error_left;
|
|
|
|
double kf_intra_err_min;
|
|
|
|
double gf_intra_err_min;
|
|
|
|
int frames_to_key;
|
|
|
|
int maxq_max_limit;
|
|
|
|
int maxq_min_limit;
|
|
|
|
int static_scene_max_gf_interval;
|
|
|
|
int kf_bits;
|
2012-11-05 23:22:59 +01:00
|
|
|
// Remaining error from uncoded frames in a gf group. Two pass use only
|
|
|
|
int64_t gf_group_error_left;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
|
|
|
// Projected total bits available for a key frame group of frames
|
|
|
|
int64_t kf_group_bits;
|
|
|
|
|
|
|
|
// Error score of frames still to be coded in kf group
|
|
|
|
int64_t kf_group_error_left;
|
|
|
|
|
2012-11-05 23:22:59 +01:00
|
|
|
// Projected Bits available for a group of frames including 1 GF or ARF
|
|
|
|
int64_t gf_group_bits;
|
|
|
|
// Bits for the golden frame or ARF - 2 pass only
|
|
|
|
int gf_bits;
|
2012-07-14 00:21:29 +02:00
|
|
|
int alt_extra_bits;
|
|
|
|
|
|
|
|
int sr_update_lag;
|
|
|
|
double est_max_qcorrection_factor;
|
|
|
|
} twopass;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
YV12_BUFFER_CONFIG alt_ref_buffer;
|
|
|
|
YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS];
|
|
|
|
int fixed_divide[512];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-04-29 18:37:59 +02:00
|
|
|
#if CONFIG_INTERNAL_STATS
|
2012-07-14 00:21:29 +02:00
|
|
|
int count;
|
|
|
|
double total_y;
|
|
|
|
double total_u;
|
|
|
|
double total_v;
|
|
|
|
double total;
|
|
|
|
double total_sq_error;
|
|
|
|
double totalp_y;
|
|
|
|
double totalp_u;
|
|
|
|
double totalp_v;
|
|
|
|
double totalp;
|
|
|
|
double total_sq_error2;
|
|
|
|
int bytes;
|
|
|
|
double summed_quality;
|
|
|
|
double summed_weights;
|
2013-04-01 18:10:27 +02:00
|
|
|
double summedp_quality;
|
|
|
|
double summedp_weights;
|
2012-07-14 00:21:29 +02:00
|
|
|
unsigned int tot_recode_hits;
|
|
|
|
|
|
|
|
|
|
|
|
double total_ssimg_y;
|
|
|
|
double total_ssimg_u;
|
|
|
|
double total_ssimg_v;
|
|
|
|
double total_ssimg_all;
|
|
|
|
|
|
|
|
int b_calculate_ssimg;
|
2010-05-18 17:58:33 +02:00
|
|
|
#endif
|
2012-07-14 00:21:29 +02:00
|
|
|
int b_calculate_psnr;
|
2010-08-11 17:02:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
// Per MB activity measurement
|
|
|
|
unsigned int activity_avg;
|
|
|
|
unsigned int *mb_activity_map;
|
|
|
|
int *mb_norm_activity_map;
|
|
|
|
int output_partition;
|
2011-06-13 16:42:27 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
/* force next frame to intra when kf_auto says so */
|
|
|
|
int force_next_frame_intra;
|
2011-08-25 22:54:45 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int droppable;
|
2012-04-07 01:38:34 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int dummy_packing; /* flag to indicate if packing is dummy */
|
2012-05-02 22:53:15 +02:00
|
|
|
|
2013-08-23 03:40:34 +02:00
|
|
|
unsigned int switchable_interp_count[SWITCHABLE_FILTERS + 1]
|
|
|
|
[SWITCHABLE_FILTERS];
|
2012-12-20 23:56:19 +01:00
|
|
|
|
2013-07-27 02:15:37 +02:00
|
|
|
unsigned int txfm_stepdown_count[TX_SIZES];
|
Tx size selection enhancements
(1) Refines the modeling function and uses that to add some speed
features. Specifically, intead of using a flag use_largest_txfm as
a speed feature, an enum tx_size_search_method is used, of which
two of the types are USE_FULL_RD and USE_LARGESTALL. Two other
new types are added:
USE_LARGESTINTRA (use largest only for intra)
USE_LARGESTINTRA_MODELINTER (use largest for intra, and model for
inter)
(2) Another change is that the framework for deciding transform type
is simplified to use a heuristic count based method rather than
an rd based method using txfm_cache. In practice the new method
is found to work just as well - with derf only -0.01 down.
The new method is more compatible with the new framework where
certain rd costs are based on full rd and certain others are
based on modeled rd or are not computed. In this patch the existing
rd based method is still kept for use in the USE_FULL_RD mode.
In the other modes, the count based method is used.
However the recommendation is to remove it eventually since the
benefit is limited, and will remove a lot of complications in
the code
(3) Finally a bug is fixed with the existing use_largest_txfm speed feature
that causes mismatches when the lossless mode and 4x4 WH transform is
forced.
Results on derf:
USE_FULL_RD: +0.03% (due to change in the tables), 0% encode time reduction
USE_LARGESTINTRA: -0.21%, 15% encode time reduction (this one is a
pretty good compromise)
USE_LARGESTINTRA_MODELINTER: -0.98%, 22% encode time reduction
(currently the benefit of modeling is limited for txfm size selection,
but keeping this enum as a placeholder) .
USE_LARGESTALL: -1.05%, 27% encode-time reduction (same as existing
use_largest_txfm speed feature).
Change-Id: I4d60a5f9ce78fbc90cddf2f97ed91d8bc0d4f936
2013-06-22 01:31:12 +02:00
|
|
|
|
2013-02-06 23:22:17 +01:00
|
|
|
int initial_width;
|
|
|
|
int initial_height;
|
2013-04-03 00:08:50 +02:00
|
|
|
|
2013-09-05 17:55:47 +02:00
|
|
|
int number_spatial_layers;
|
|
|
|
|
2013-04-03 00:08:50 +02:00
|
|
|
#if CONFIG_MULTIPLE_ARF
|
|
|
|
// ARF tracking variables.
|
|
|
|
int multi_arf_enabled;
|
|
|
|
unsigned int frame_coding_order_period;
|
|
|
|
unsigned int new_frame_coding_order_period;
|
|
|
|
int frame_coding_order[MAX_LAG_BUFFERS * 2];
|
|
|
|
int arf_buffer_idx[MAX_LAG_BUFFERS * 3 / 2];
|
|
|
|
int arf_weight[MAX_LAG_BUFFERS];
|
|
|
|
int arf_buffered;
|
|
|
|
int this_frame_weight;
|
|
|
|
int max_arf_level;
|
|
|
|
#endif
|
2013-05-16 12:27:12 +02:00
|
|
|
|
|
|
|
#ifdef ENTROPY_STATS
|
2013-08-23 03:40:34 +02:00
|
|
|
int64_t mv_ref_stats[INTER_MODE_CONTEXTS][INTER_MODES - 1][2];
|
2013-05-16 12:27:12 +02:00
|
|
|
#endif
|
2013-08-21 13:34:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef MODE_TEST_HIT_STATS
|
|
|
|
// Debug / test stats
|
|
|
|
int64_t mode_test_hits[BLOCK_SIZES];
|
|
|
|
#endif
|
2012-10-31 01:53:32 +01:00
|
|
|
} VP9_COMP;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-05-21 00:59:39 +02:00
|
|
|
static int get_ref_frame_idx(VP9_COMP *cpi, MV_REFERENCE_FRAME ref_frame) {
|
|
|
|
if (ref_frame == LAST_FRAME) {
|
|
|
|
return cpi->lst_fb_idx;
|
|
|
|
} else if (ref_frame == GOLDEN_FRAME) {
|
|
|
|
return cpi->gld_fb_idx;
|
|
|
|
} else {
|
|
|
|
return cpi->alt_fb_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-05 17:55:47 +02:00
|
|
|
static int get_scale_ref_frame_idx(VP9_COMP *cpi,
|
|
|
|
MV_REFERENCE_FRAME ref_frame) {
|
|
|
|
if (ref_frame == LAST_FRAME) {
|
|
|
|
return 0;
|
|
|
|
} else if (ref_frame == GOLDEN_FRAME) {
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
void vp9_encode_frame(VP9_COMP *cpi);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
|
2012-10-30 22:25:33 +01:00
|
|
|
unsigned long *size);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
void vp9_activity_masking(VP9_COMP *cpi, MACROBLOCK *x);
|
2010-10-11 23:37:27 +02:00
|
|
|
|
2012-10-31 01:53:32 +01:00
|
|
|
void vp9_set_speed_features(VP9_COMP *cpi);
|
2011-07-20 23:21:24 +02:00
|
|
|
|
2012-11-02 19:22:57 +01:00
|
|
|
extern int vp9_calc_ss_err(YV12_BUFFER_CONFIG *source,
|
|
|
|
YV12_BUFFER_CONFIG *dest);
|
|
|
|
|
|
|
|
extern void vp9_alloc_compressor_data(VP9_COMP *cpi);
|
|
|
|
|
2012-12-19 00:31:19 +01:00
|
|
|
#endif // VP9_ENCODER_VP9_ONYX_INT_H_
|