Merge "Merge lossless experiment" into experimental
This commit is contained in:
commit
441f24de3d
1
configure
vendored
1
configure
vendored
@ -238,7 +238,6 @@ HAVE_LIST="
|
||||
"
|
||||
EXPERIMENT_LIST="
|
||||
csm
|
||||
lossless
|
||||
new_mvref
|
||||
implicit_segmentation
|
||||
newbintramodes
|
||||
|
@ -139,9 +139,7 @@ typedef enum {
|
||||
|
||||
#define VP9_MVREFS (1 + SPLITMV - NEARESTMV)
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
#define WHT_UPSCALE_FACTOR 2
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
B_DC_PRED, /* average of above and left pixels */
|
||||
@ -367,9 +365,7 @@ typedef struct macroblockd {
|
||||
unsigned int frames_since_golden;
|
||||
unsigned int frames_till_alt_ref_frame;
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
int lossless;
|
||||
#endif
|
||||
/* Inverse transform function pointers. */
|
||||
void (*inv_txm4x4_1)(int16_t *input, int16_t *output, int pitch);
|
||||
void (*inv_txm4x4)(int16_t *input, int16_t *output, int pitch);
|
||||
@ -492,10 +488,8 @@ static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, const BLOCKD *b) {
|
||||
int ib = (int)(b - xd->block);
|
||||
if (ib >= 16)
|
||||
return tx_type;
|
||||
#if CONFIG_LOSSLESS
|
||||
if (xd->lossless)
|
||||
return DCT_DCT;
|
||||
#endif
|
||||
// TODO(rbultje, debargha): Explore ADST usage for superblocks
|
||||
if (xd->mode_info_context->mbmi.sb_type)
|
||||
return tx_type;
|
||||
|
@ -298,7 +298,6 @@ void vp9_ihtllm_c(const int16_t *input, int16_t *output, int pitch,
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
void vp9_short_inv_walsh4x4_x8_c(int16_t *input, int16_t *output, int pitch) {
|
||||
int i;
|
||||
int a1, b1, c1, d1;
|
||||
@ -378,7 +377,6 @@ void vp9_dc_only_inv_walsh_add_c(int input_dc, uint8_t *pred_ptr,
|
||||
pred_ptr += pitch;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void idct4_1d(int16_t *input, int16_t *output) {
|
||||
int16_t step[4];
|
||||
|
@ -308,14 +308,12 @@ specialize vp9_ihtllm
|
||||
prototype void vp9_dc_only_idct_add "int input_dc, uint8_t *pred_ptr, uint8_t *dst_ptr, int pitch, int stride"
|
||||
specialize vp9_dc_only_idct_add
|
||||
|
||||
if [ "$CONFIG_LOSSLESS" = "yes" ]; then
|
||||
prototype void vp9_short_inv_walsh4x4_1_x8 "int16_t *input, int16_t *output, int pitch"
|
||||
specialize vp9_short_inv_walsh4x4_1_x8
|
||||
prototype void vp9_short_inv_walsh4x4_x8 "int16_t *input, int16_t *output, int pitch"
|
||||
specialize vp9_short_inv_walsh4x4_x8
|
||||
prototype void vp9_dc_only_inv_walsh_add "int input_dc, uint8_t *pred_ptr, uint8_t *dst_ptr, int pitch, int stride"
|
||||
specialize vp9_dc_only_inv_walsh_add
|
||||
fi
|
||||
|
||||
prototype unsigned int vp9_sad32x3 "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, int max_sad"
|
||||
specialize vp9_sad32x3
|
||||
|
@ -128,7 +128,6 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) {
|
||||
xd->dc_only_itxm_add = vp9_dc_only_idct_add_c;
|
||||
xd->itxm_add_y_block = vp9_dequant_idct_add_y_block;
|
||||
xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block;
|
||||
#if CONFIG_LOSSLESS
|
||||
if (xd->lossless) {
|
||||
assert(QIndex == 0);
|
||||
xd->inv_txm4x4_1 = vp9_short_inv_walsh4x4_1_x8;
|
||||
@ -138,7 +137,6 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) {
|
||||
xd->itxm_add_y_block = vp9_dequant_idct_add_y_block_lossless_c;
|
||||
xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block_lossless_c;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 16; i < 24; i++) {
|
||||
xd->block[i].dequant = pc->UVdequant[QIndex];
|
||||
@ -1418,14 +1416,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
|
||||
|
||||
pc->sb64_coded = vp9_read_literal(&header_bc, 8);
|
||||
pc->sb32_coded = vp9_read_literal(&header_bc, 8);
|
||||
#if CONFIG_LOSSLESS
|
||||
xd->lossless = vp9_read_bit(&header_bc);
|
||||
if (xd->lossless) {
|
||||
pc->txfm_mode = ONLY_4X4;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
/* Read the loop filter level and type */
|
||||
pc->txfm_mode = vp9_read_literal(&header_bc, 2);
|
||||
if (pc->txfm_mode == 3)
|
||||
|
@ -145,7 +145,6 @@ void vp9_dequant_dc_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
|
||||
add_residual(diff_ptr, pred, pitch, dest, stride, 4, 4);
|
||||
}
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
void vp9_dequant_idct_add_lossless_c(int16_t *input, const int16_t *dq,
|
||||
uint8_t *pred, uint8_t *dest,
|
||||
int pitch, int stride) {
|
||||
@ -183,7 +182,6 @@ void vp9_dequant_dc_idct_add_lossless_c(int16_t *input, const int16_t *dq,
|
||||
|
||||
add_residual(diff_ptr, pred, pitch, dest, stride, 4, 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
void vp9_dequant_idct_add_8x8_c(int16_t *input, const int16_t *dq,
|
||||
uint8_t *pred, uint8_t *dest, int pitch,
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define VP9_DECODER_VP9_DEQUANTIZE_H_
|
||||
#include "vp9/common/vp9_blockd.h"
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
|
||||
extern void vp9_dequant_idct_add_lossless_c(int16_t *input, const int16_t *dq,
|
||||
unsigned char *pred,
|
||||
unsigned char *output,
|
||||
@ -40,7 +40,6 @@ extern void vp9_dequant_idct_add_uv_block_lossless_c(int16_t *q, const int16_t *
|
||||
unsigned char *dst_v,
|
||||
int stride,
|
||||
uint16_t *eobs);
|
||||
#endif
|
||||
|
||||
void vp9_ht_dequant_idct_add_c(TX_TYPE tx_type, int16_t *input, const int16_t *dq,
|
||||
unsigned char *pred, unsigned char *dest,
|
||||
|
@ -10,9 +10,7 @@
|
||||
|
||||
#include "vp9_rtcd.h"
|
||||
#include "vp9/common/vp9_blockd.h"
|
||||
#if CONFIG_LOSSLESS
|
||||
#include "vp9/decoder/vp9_dequantize.h"
|
||||
#endif
|
||||
|
||||
void vp9_dequant_idct_add_y_block_4x4_inplace_c(int16_t *q,
|
||||
const int16_t *dq,
|
||||
@ -214,7 +212,7 @@ void vp9_dequant_idct_add_uv_block_8x8_inplace_c(int16_t *q, const int16_t *dq,
|
||||
xd->eobs[20]);
|
||||
}
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
|
||||
void vp9_dequant_idct_add_y_block_lossless_c(int16_t *q, const int16_t *dq,
|
||||
uint8_t *pre,
|
||||
uint8_t *dst,
|
||||
@ -284,5 +282,4 @@ void vp9_dequant_idct_add_uv_block_lossless_c(int16_t *q, const int16_t *dq,
|
||||
dstv += 4 * stride - 8;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1671,14 +1671,11 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
|
||||
vp9_write_literal(&header_bc, pc->sb64_coded, 8);
|
||||
pc->sb32_coded = get_binary_prob(cpi->sb32_count[0], cpi->sb32_count[1]);
|
||||
vp9_write_literal(&header_bc, pc->sb32_coded, 8);
|
||||
#if CONFIG_LOSSLESS
|
||||
|
||||
vp9_write_bit(&header_bc, cpi->mb.e_mbd.lossless);
|
||||
if (cpi->mb.e_mbd.lossless) {
|
||||
pc->txfm_mode = ONLY_4X4;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
if (pc->txfm_mode == TX_MODE_SELECT) {
|
||||
pc->prob_tx[0] = get_prob(cpi->txfm_count_32x32p[TX_4X4] +
|
||||
cpi->txfm_count_16x16p[TX_4X4] +
|
||||
|
@ -896,7 +896,6 @@ void vp9_short_fdct8x8_c(int16_t *input, int16_t *output, int pitch) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
void vp9_short_walsh4x4_x8_c(short *input, short *output, int pitch) {
|
||||
int i;
|
||||
int a1, b1, c1, d1;
|
||||
@ -941,7 +940,6 @@ void vp9_short_walsh8x4_x8_c(short *input, short *output, int pitch) {
|
||||
vp9_short_walsh4x4_x8_c(input, output, pitch);
|
||||
vp9_short_walsh4x4_x8_c(input + 4, output + 16, pitch);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TEST_INT_16x16_DCT 1
|
||||
#if !TEST_INT_16x16_DCT
|
||||
|
@ -1225,7 +1225,7 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
|
||||
if (cm->full_pixel)
|
||||
xd->fullpixel_mask = 0xfffffff8;
|
||||
}
|
||||
#if CONFIG_LOSSLESS
|
||||
|
||||
static void switch_lossless_mode(VP9_COMP *cpi, int lossless) {
|
||||
if (lossless) {
|
||||
cpi->mb.fwd_txm8x4 = vp9_short_walsh8x4_x8;
|
||||
@ -1243,7 +1243,7 @@ static void switch_lossless_mode(VP9_COMP *cpi, int lossless) {
|
||||
cpi->mb.e_mbd.inv_txm4x4 = vp9_short_idct4x4llm;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void encode_frame_internal(VP9_COMP *cpi) {
|
||||
int mb_row;
|
||||
@ -1301,14 +1301,14 @@ static void encode_frame_internal(VP9_COMP *cpi) {
|
||||
vp9_zero(cpi->mb_mv_ref_count);
|
||||
#endif
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
|
||||
// force lossless mode when Q0 is selected
|
||||
cpi->mb.e_mbd.lossless = (cm->base_qindex == 0 &&
|
||||
cm->y1dc_delta_q == 0 &&
|
||||
cm->uvdc_delta_q == 0 &&
|
||||
cm->uvac_delta_q == 0);
|
||||
switch_lossless_mode(cpi, cpi->mb.e_mbd.lossless);
|
||||
#endif
|
||||
|
||||
vp9_frame_init_quantizer(cpi);
|
||||
|
||||
vp9_initialize_rd_consts(cpi, cm->base_qindex + cm->y1dc_delta_q);
|
||||
@ -1561,13 +1561,12 @@ void vp9_encode_frame(VP9_COMP *cpi) {
|
||||
pred_type = HYBRID_PREDICTION;
|
||||
|
||||
/* transform size (4x4, 8x8, 16x16 or select-per-mb) selection */
|
||||
#if CONFIG_LOSSLESS
|
||||
|
||||
cpi->mb.e_mbd.lossless = 0;
|
||||
if (cpi->oxcf.lossless) {
|
||||
txfm_type = ONLY_4X4;
|
||||
cpi->mb.e_mbd.lossless = 1;
|
||||
} else
|
||||
#endif
|
||||
/* FIXME (rbultje)
|
||||
* this is a hack (no really), basically to work around the complete
|
||||
* nonsense coefficient cost prediction for keyframes. The probabilities
|
||||
|
@ -753,12 +753,12 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
|
||||
sf->quarter_pixel_search = 1;
|
||||
sf->half_pixel_search = 1;
|
||||
sf->iterative_sub_pixel = 1;
|
||||
sf->optimize_coefficients = 1;
|
||||
#if CONFIG_LOSSLESS
|
||||
sf->no_skip_block4x4_search = 1;
|
||||
if (cpi->oxcf.lossless)
|
||||
sf->optimize_coefficients = 0;
|
||||
#endif
|
||||
sf->no_skip_block4x4_search = 1;
|
||||
else
|
||||
sf->optimize_coefficients = 1;
|
||||
|
||||
sf->first_step = 0;
|
||||
sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
|
||||
sf->static_segmentation = 1;
|
||||
@ -845,13 +845,10 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
|
||||
cpi->mb.fwd_txm8x8 = vp9_short_fdct8x8;
|
||||
cpi->mb.fwd_txm8x4 = vp9_short_fdct8x4;
|
||||
cpi->mb.fwd_txm4x4 = vp9_short_fdct4x4;
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
if (cpi->oxcf.lossless || cpi->mb.e_mbd.lossless) {
|
||||
cpi->mb.fwd_txm8x4 = vp9_short_walsh8x4_x8;
|
||||
cpi->mb.fwd_txm4x4 = vp9_short_walsh4x4_x8;
|
||||
}
|
||||
#endif
|
||||
|
||||
cpi->mb.quantize_b_4x4 = vp9_regular_quantize_b_4x4;
|
||||
cpi->mb.quantize_b_4x4_pair = vp9_regular_quantize_b_4x4_pair;
|
||||
@ -1216,16 +1213,14 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
|
||||
cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q];
|
||||
cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level];
|
||||
|
||||
cpi->mb.e_mbd.inv_txm4x4_1 = vp9_short_idct4x4llm_1;
|
||||
cpi->mb.e_mbd.inv_txm4x4 = vp9_short_idct4x4llm;
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
cpi->oxcf.lossless = oxcf->lossless;
|
||||
if (cpi->oxcf.lossless) {
|
||||
cpi->mb.e_mbd.inv_txm4x4_1 = vp9_short_inv_walsh4x4_1_x8;
|
||||
cpi->mb.e_mbd.inv_txm4x4 = vp9_short_inv_walsh4x4_x8;
|
||||
} else {
|
||||
cpi->mb.e_mbd.inv_txm4x4_1 = vp9_short_idct4x4llm_1;
|
||||
cpi->mb.e_mbd.inv_txm4x4 = vp9_short_idct4x4llm;
|
||||
}
|
||||
#endif
|
||||
|
||||
cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
|
||||
|
||||
@ -2461,15 +2456,9 @@ static void update_reference_frames(VP9_COMP * const cpi) {
|
||||
}
|
||||
|
||||
static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
|
||||
if (cm->no_lpf) {
|
||||
if (cm->no_lpf || cpi->mb.e_mbd.lossless) {
|
||||
cm->filter_level = 0;
|
||||
}
|
||||
#if CONFIG_LOSSLESS
|
||||
else if (cpi->mb.e_mbd.lossless) {
|
||||
cm->filter_level = 0;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
} else {
|
||||
struct vpx_usec_timer timer;
|
||||
|
||||
vp9_clear_system_state();
|
||||
@ -2621,11 +2610,12 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
|
||||
// For 2 Pass Only used where GF/ARF prediction quality
|
||||
// is above a threshold
|
||||
cpi->zbin_mode_boost = 0;
|
||||
cpi->zbin_mode_boost_enabled = TRUE;
|
||||
#if CONFIG_LOSSLESS
|
||||
|
||||
if (cpi->oxcf.lossless)
|
||||
cpi->zbin_mode_boost_enabled = FALSE;
|
||||
#endif
|
||||
else
|
||||
cpi->zbin_mode_boost_enabled = TRUE;
|
||||
|
||||
if (cpi->gfu_boost <= 400) {
|
||||
cpi->zbin_mode_boost_enabled = FALSE;
|
||||
}
|
||||
|
@ -35,9 +35,7 @@ struct vp8_extracfg {
|
||||
vp8e_tuning tuning;
|
||||
unsigned int cq_level; /* constrained quality level */
|
||||
unsigned int rc_max_intra_bitrate_pct;
|
||||
#if CONFIG_LOSSLESS
|
||||
unsigned int lossless;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct extraconfig_map {
|
||||
@ -64,9 +62,7 @@ static const struct extraconfig_map extracfg_map[] = {
|
||||
0, /* tuning*/
|
||||
10, /* cq_level */
|
||||
0, /* rc_max_intra_bitrate_pct */
|
||||
#if CONFIG_LOSSLESS
|
||||
0, /* lossless */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -138,13 +134,11 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
|
||||
|
||||
RANGE_CHECK_HI(cfg, rc_max_quantizer, 63);
|
||||
RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer);
|
||||
#if CONFIG_LOSSLESS
|
||||
RANGE_CHECK_BOOL(vp8_cfg, lossless);
|
||||
if (vp8_cfg->lossless) {
|
||||
RANGE_CHECK_HI(cfg, rc_max_quantizer, 0);
|
||||
RANGE_CHECK_HI(cfg, rc_min_quantizer, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
RANGE_CHECK_HI(cfg, g_threads, 64);
|
||||
RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS);
|
||||
@ -314,9 +308,7 @@ static vpx_codec_err_t set_vp8e_config(VP9_CONFIG *oxcf,
|
||||
oxcf->tile_columns = vp8_cfg.tile_columns;
|
||||
oxcf->tile_rows = vp8_cfg.tile_rows;
|
||||
|
||||
#if CONFIG_LOSSLESS
|
||||
oxcf->lossless = vp8_cfg.lossless;
|
||||
#endif
|
||||
|
||||
oxcf->error_resilient_mode = cfg.g_error_resilient;
|
||||
oxcf->frame_parallel_decoding_mode = cfg.g_frame_parallel_decoding;
|
||||
@ -428,9 +420,7 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx,
|
||||
MAP(VP8E_SET_TUNING, xcfg.tuning);
|
||||
MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level);
|
||||
MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct);
|
||||
#if CONFIG_LOSSLESS
|
||||
MAP(VP9E_SET_LOSSLESS, xcfg.lossless);
|
||||
#endif
|
||||
}
|
||||
|
||||
res = validate_config(ctx, &ctx->cfg, &xcfg);
|
||||
@ -1020,9 +1010,7 @@ static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = {
|
||||
{VP8E_SET_TUNING, set_param},
|
||||
{VP8E_SET_CQ_LEVEL, set_param},
|
||||
{VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param},
|
||||
#if CONFIG_LOSSLESS
|
||||
{VP9E_SET_LOSSLESS, set_param},
|
||||
#endif
|
||||
{ -1, NULL},
|
||||
};
|
||||
|
||||
|
9
vpxenc.c
9
vpxenc.c
@ -1106,9 +1106,7 @@ static const arg_def_t cq_level = ARG_DEF(NULL, "cq-level", 1,
|
||||
"Constrained Quality Level");
|
||||
static const arg_def_t max_intra_rate_pct = ARG_DEF(NULL, "max-intra-rate", 1,
|
||||
"Max I-frame bitrate (pct)");
|
||||
#if CONFIG_LOSSLESS
|
||||
static const arg_def_t lossless = ARG_DEF(NULL, "lossless", 1, "Lossless mode");
|
||||
#endif
|
||||
|
||||
#if CONFIG_VP8_ENCODER
|
||||
static const arg_def_t *vp8_args[] = {
|
||||
@ -1131,10 +1129,7 @@ static const int vp8_arg_ctrl_map[] = {
|
||||
static const arg_def_t *vp9_args[] = {
|
||||
&cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh,
|
||||
&tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type,
|
||||
&tune_ssim, &cq_level, &max_intra_rate_pct,
|
||||
#if CONFIG_LOSSLESS
|
||||
&lossless,
|
||||
#endif
|
||||
&tune_ssim, &cq_level, &max_intra_rate_pct, &lossless,
|
||||
NULL
|
||||
};
|
||||
static const int vp9_arg_ctrl_map[] = {
|
||||
@ -1143,9 +1138,7 @@ static const int vp9_arg_ctrl_map[] = {
|
||||
VP9E_SET_TILE_COLUMNS, VP9E_SET_TILE_ROWS,
|
||||
VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE,
|
||||
VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT,
|
||||
#if CONFIG_LOSSLESS
|
||||
VP9E_SET_LOSSLESS,
|
||||
#endif
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user