2014-07-02 21:36:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VP9_ENCODER_VP9_RD_H_
|
|
|
|
#define VP9_ENCODER_VP9_RD_H_
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#include "vp9/common/vp9_blockd.h"
|
|
|
|
|
|
|
|
#include "vp9/encoder/vp9_block.h"
|
|
|
|
#include "vp9/encoder/vp9_context_tree.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define RDDIV_BITS 7
|
|
|
|
|
|
|
|
#define RDCOST(RM, DM, R, D) \
|
|
|
|
(((128 + ((int64_t)R) * (RM)) >> 8) + (D << DM))
|
|
|
|
#define QIDX_SKIP_THRESH 115
|
|
|
|
|
|
|
|
#define MV_COST_WEIGHT 108
|
|
|
|
#define MV_COST_WEIGHT_SUB 120
|
|
|
|
|
|
|
|
#define INVALID_MV 0x80008000
|
|
|
|
|
|
|
|
#define MAX_MODES 30
|
|
|
|
#define MAX_REFS 6
|
|
|
|
|
Enable mode search threshold update in non-RD coding mode
Adaptively adjust the mode thresholds after each mode search round
to skip checking less likely selected modes. Local tests indicate
5% - 10% speed-up in speed -5 and -6. Average coding performance
loss is -1.055%.
speed -5
vidyo1 720p 1000 kbps
16533 b/f, 40.851 dB, 12607 ms -> 16556 b/f, 40.796 dB, 11831 ms
nik 720p 1000 kbps
33229 b/f, 39.127 dB, 11468 ms -> 33235 b/f, 39.131 dB, 10919 ms
speed -6
vidyo1 720p 1000 kbps
16549 b/f, 40.268 dB, 10138 ms -> 16538 b/f, 40.212 dB, 8456 ms
nik 720p 1000 kbps
33271 b/f, 38.433 dB, 7886 ms -> 33279 b/f, 38.416 dB, 7843 ms
Change-Id: I2c2963f1ce4ed9c1cf233b5b2c880b682e1c1e8b
2014-10-28 22:50:10 +01:00
|
|
|
#define RD_THRESH_MAX_FACT 64
|
|
|
|
#define RD_THRESH_INC 1
|
|
|
|
|
2014-07-02 21:36:48 +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.
|
|
|
|
typedef enum {
|
|
|
|
THR_NEARESTMV,
|
|
|
|
THR_NEARESTA,
|
|
|
|
THR_NEARESTG,
|
|
|
|
|
|
|
|
THR_DC,
|
|
|
|
|
|
|
|
THR_NEWMV,
|
|
|
|
THR_NEWA,
|
|
|
|
THR_NEWG,
|
|
|
|
|
|
|
|
THR_NEARMV,
|
|
|
|
THR_NEARA,
|
Adaptive mode search scheduling
This commit enables an adaptive mode search order scheduling scheme
in the rate-distortion optimization. It changes the compression
performance by -0.433% and -0.420% for derf and stdhd respectively.
It provides speed improvement for speed 3:
bus CIF 1000 kbps
24590 b/f, 35.513 dB, 7864 ms ->
24696 b/f, 35.491 dB, 7408 ms (6% speed-up)
stockholm 720p 1000 kbps
8983 b/f, 35.078 dB, 65698 ms ->
8962 b/f, 35.054 dB, 60298 ms (8%)
old_town_cross 720p 1000 kbps
11804 b/f, 35.666 dB, 62492 ms ->
11778 b/f, 35.609 dB, 56040 ms (10%)
blue_sky 1080p 1500 kbps
57173 b/f, 36.179 dB, 77879 ms ->
57199 b/f, 36.131 dB, 69821 ms (10%)
pedestrian_area 1080p 2000 kbps
74241 b/f, 41.105 dB, 144031 ms ->
74271 b/f, 41.091 dB, 133614 ms (8%)
Change-Id: Iaad28cbc99399030fc5f9951eb5aa7fa633f320e
2014-09-18 22:37:20 +02:00
|
|
|
THR_NEARG,
|
|
|
|
|
|
|
|
THR_ZEROMV,
|
|
|
|
THR_ZEROG,
|
|
|
|
THR_ZEROA,
|
|
|
|
|
2014-07-02 21:36:48 +02:00
|
|
|
THR_COMP_NEARESTLA,
|
|
|
|
THR_COMP_NEARESTGA,
|
|
|
|
|
|
|
|
THR_TM,
|
|
|
|
|
|
|
|
THR_COMP_NEARLA,
|
|
|
|
THR_COMP_NEWLA,
|
|
|
|
THR_COMP_NEARGA,
|
|
|
|
THR_COMP_NEWGA,
|
|
|
|
|
|
|
|
THR_COMP_ZEROLA,
|
|
|
|
THR_COMP_ZEROGA,
|
|
|
|
|
|
|
|
THR_H_PRED,
|
|
|
|
THR_V_PRED,
|
|
|
|
THR_D135_PRED,
|
|
|
|
THR_D207_PRED,
|
|
|
|
THR_D153_PRED,
|
|
|
|
THR_D63_PRED,
|
|
|
|
THR_D117_PRED,
|
|
|
|
THR_D45_PRED,
|
|
|
|
} THR_MODES;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
THR_LAST,
|
|
|
|
THR_GOLD,
|
|
|
|
THR_ALTR,
|
|
|
|
THR_COMP_LA,
|
|
|
|
THR_COMP_GA,
|
|
|
|
THR_INTRA,
|
|
|
|
} THR_MODES_SUB8X8;
|
|
|
|
|
|
|
|
typedef struct RD_OPT {
|
|
|
|
// Thresh_mult is used to set a threshold for the rd score. A higher value
|
|
|
|
// means that we will accept the best mode so far more often. This number
|
|
|
|
// is used in combination with the current block size, and thresh_freq_fact
|
|
|
|
// to pick a threshold.
|
|
|
|
int thresh_mult[MAX_MODES];
|
|
|
|
int thresh_mult_sub8x8[MAX_REFS];
|
|
|
|
|
|
|
|
int threshes[MAX_SEGMENTS][BLOCK_SIZES][MAX_MODES];
|
Adaptive mode search scheduling
This commit enables an adaptive mode search order scheduling scheme
in the rate-distortion optimization. It changes the compression
performance by -0.433% and -0.420% for derf and stdhd respectively.
It provides speed improvement for speed 3:
bus CIF 1000 kbps
24590 b/f, 35.513 dB, 7864 ms ->
24696 b/f, 35.491 dB, 7408 ms (6% speed-up)
stockholm 720p 1000 kbps
8983 b/f, 35.078 dB, 65698 ms ->
8962 b/f, 35.054 dB, 60298 ms (8%)
old_town_cross 720p 1000 kbps
11804 b/f, 35.666 dB, 62492 ms ->
11778 b/f, 35.609 dB, 56040 ms (10%)
blue_sky 1080p 1500 kbps
57173 b/f, 36.179 dB, 77879 ms ->
57199 b/f, 36.131 dB, 69821 ms (10%)
pedestrian_area 1080p 2000 kbps
74241 b/f, 41.105 dB, 144031 ms ->
74271 b/f, 41.091 dB, 133614 ms (8%)
Change-Id: Iaad28cbc99399030fc5f9951eb5aa7fa633f320e
2014-09-18 22:37:20 +02:00
|
|
|
|
2014-07-02 21:36:48 +02:00
|
|
|
int64_t prediction_type_threshes[MAX_REF_FRAMES][REFERENCE_MODES];
|
|
|
|
|
|
|
|
int64_t filter_threshes[MAX_REF_FRAMES][SWITCHABLE_FILTER_CONTEXTS];
|
|
|
|
|
|
|
|
int RDMULT;
|
|
|
|
int RDDIV;
|
|
|
|
} RD_OPT;
|
|
|
|
|
2014-10-09 21:32:56 +02:00
|
|
|
typedef struct RD_COST {
|
|
|
|
int rate;
|
|
|
|
int64_t dist;
|
|
|
|
int64_t rdcost;
|
|
|
|
} RD_COST;
|
|
|
|
|
2014-10-14 19:26:28 +02:00
|
|
|
// Reset the rate distortion cost values to maximum (invalid) value.
|
|
|
|
void vp9_rd_cost_reset(RD_COST *rd_cost);
|
|
|
|
// Initialize the rate distortion cost values to zero.
|
|
|
|
void vp9_rd_cost_init(RD_COST *rd_cost);
|
|
|
|
|
2014-07-02 21:36:48 +02:00
|
|
|
struct TileInfo;
|
Enable mode search threshold update in non-RD coding mode
Adaptively adjust the mode thresholds after each mode search round
to skip checking less likely selected modes. Local tests indicate
5% - 10% speed-up in speed -5 and -6. Average coding performance
loss is -1.055%.
speed -5
vidyo1 720p 1000 kbps
16533 b/f, 40.851 dB, 12607 ms -> 16556 b/f, 40.796 dB, 11831 ms
nik 720p 1000 kbps
33229 b/f, 39.127 dB, 11468 ms -> 33235 b/f, 39.131 dB, 10919 ms
speed -6
vidyo1 720p 1000 kbps
16549 b/f, 40.268 dB, 10138 ms -> 16538 b/f, 40.212 dB, 8456 ms
nik 720p 1000 kbps
33271 b/f, 38.433 dB, 7886 ms -> 33279 b/f, 38.416 dB, 7843 ms
Change-Id: I2c2963f1ce4ed9c1cf233b5b2c880b682e1c1e8b
2014-10-28 22:50:10 +01:00
|
|
|
struct TileDataEnc;
|
2014-07-02 21:36:48 +02:00
|
|
|
struct VP9_COMP;
|
|
|
|
struct macroblock;
|
|
|
|
|
|
|
|
int vp9_compute_rd_mult(const struct VP9_COMP *cpi, int qindex);
|
|
|
|
|
|
|
|
void vp9_initialize_rd_consts(struct VP9_COMP *cpi);
|
|
|
|
|
2015-03-07 00:17:59 +01:00
|
|
|
void vp9_initialize_me_consts(struct VP9_COMP *cpi, MACROBLOCK *x, int qindex);
|
2014-07-02 21:36:48 +02:00
|
|
|
|
|
|
|
void vp9_model_rd_from_var_lapndz(unsigned int var, unsigned int n,
|
|
|
|
unsigned int qstep, int *rate,
|
|
|
|
int64_t *dist);
|
|
|
|
|
2014-11-21 20:11:06 +01:00
|
|
|
int vp9_get_switchable_rate(const struct VP9_COMP *cpi,
|
|
|
|
const MACROBLOCKD *const xd);
|
2014-07-02 21:36:48 +02:00
|
|
|
|
2014-12-22 22:38:34 +01:00
|
|
|
int vp9_raster_block_offset(BLOCK_SIZE plane_bsize,
|
|
|
|
int raster_block, int stride);
|
|
|
|
|
|
|
|
int16_t* vp9_raster_block_offset_int16(BLOCK_SIZE plane_bsize,
|
|
|
|
int raster_block, int16_t *base);
|
|
|
|
|
2015-02-18 18:40:34 +01:00
|
|
|
YV12_BUFFER_CONFIG *vp9_get_scaled_ref_frame(const struct VP9_COMP *cpi,
|
|
|
|
int ref_frame);
|
2014-07-02 21:36:48 +02:00
|
|
|
|
2015-05-15 05:18:45 +02:00
|
|
|
void vp9_init_me_luts(void);
|
2014-07-02 21:36:48 +02:00
|
|
|
|
|
|
|
void vp9_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size,
|
|
|
|
const struct macroblockd_plane *pd,
|
|
|
|
ENTROPY_CONTEXT t_above[16],
|
|
|
|
ENTROPY_CONTEXT t_left[16]);
|
|
|
|
|
|
|
|
void vp9_set_rd_speed_thresholds(struct VP9_COMP *cpi);
|
|
|
|
|
|
|
|
void vp9_set_rd_speed_thresholds_sub8x8(struct VP9_COMP *cpi);
|
|
|
|
|
2014-10-30 01:37:54 +01:00
|
|
|
void vp9_update_rd_thresh_fact(int (*fact)[MAX_MODES], int rd_thresh,
|
Enable mode search threshold update in non-RD coding mode
Adaptively adjust the mode thresholds after each mode search round
to skip checking less likely selected modes. Local tests indicate
5% - 10% speed-up in speed -5 and -6. Average coding performance
loss is -1.055%.
speed -5
vidyo1 720p 1000 kbps
16533 b/f, 40.851 dB, 12607 ms -> 16556 b/f, 40.796 dB, 11831 ms
nik 720p 1000 kbps
33229 b/f, 39.127 dB, 11468 ms -> 33235 b/f, 39.131 dB, 10919 ms
speed -6
vidyo1 720p 1000 kbps
16549 b/f, 40.268 dB, 10138 ms -> 16538 b/f, 40.212 dB, 8456 ms
nik 720p 1000 kbps
33271 b/f, 38.433 dB, 7886 ms -> 33279 b/f, 38.416 dB, 7843 ms
Change-Id: I2c2963f1ce4ed9c1cf233b5b2c880b682e1c1e8b
2014-10-28 22:50:10 +01:00
|
|
|
int bsize, int best_mode_index);
|
|
|
|
|
2014-07-02 21:36:48 +02:00
|
|
|
static INLINE int rd_less_than_thresh(int64_t best_rd, int thresh,
|
|
|
|
int thresh_fact) {
|
|
|
|
return best_rd < ((int64_t)thresh * thresh_fact >> 5) || thresh == INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp9_mv_pred(struct VP9_COMP *cpi, MACROBLOCK *x,
|
|
|
|
uint8_t *ref_y_buffer, int ref_y_stride,
|
|
|
|
int ref_frame, BLOCK_SIZE block_size);
|
|
|
|
|
|
|
|
void vp9_setup_pred_block(const MACROBLOCKD *xd,
|
|
|
|
struct buf_2d dst[MAX_MB_PLANE],
|
|
|
|
const YV12_BUFFER_CONFIG *src,
|
|
|
|
int mi_row, int mi_col,
|
|
|
|
const struct scale_factors *scale,
|
|
|
|
const struct scale_factors *scale_uv);
|
2014-09-24 15:36:34 +02:00
|
|
|
|
|
|
|
int vp9_get_intra_cost_penalty(int qindex, int qdelta,
|
|
|
|
vpx_bit_depth_t bit_depth);
|
|
|
|
|
2014-07-02 21:36:48 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // VP9_ENCODER_VP9_RD_H_
|