Merge changes from topic 'fix_ec_adapt' into nextgenv2

* changes:
  Reverse order of CLPF and dering
  Refactor: read_tx_size_probs()
  Fix compiling issues with --enable-ec-adapt
  Fixes compilation error on Windows/Visual Studio
This commit is contained in:
Yaowu Xu 2016-10-31 22:18:52 +00:00 коммит произвёл Gerrit Code Review
Родитель a98d80fdaa 5d56f4d69a
Коммит 292bd65510
4 изменённых файлов: 84 добавлений и 54 удалений

Просмотреть файл

@ -1964,6 +1964,7 @@ int main(int argc, const char **argv_) {
{ stream->config.cfg.g_input_bit_depth = input.bit_depth; });
}
#if CONFIG_AOM_HIGHBITDEPTH
FOREACH_STREAM({
if (input.fmt != AOM_IMG_FMT_I420 && input.fmt != AOM_IMG_FMT_I42016) {
/* Automatically upgrade if input is non-4:2:0 but a 4:2:0 profile
@ -1980,7 +1981,6 @@ int main(int argc, const char **argv_) {
default: break;
}
}
#if CONFIG_AOM_HIGHBITDEPTH
/* Automatically set the codec bit depth to match the input bit depth.
* Upgrade the profile if required. */
if (stream->config.cfg.g_input_bit_depth >
@ -2003,7 +2003,6 @@ int main(int argc, const char **argv_) {
if (stream->config.cfg.g_profile > 1) {
stream->config.use_16bit_internal = 1;
}
#endif
if (profile_updated) {
fprintf(stderr,
"Warning: automatically upgrading to profile %d to "
@ -2011,6 +2010,31 @@ int main(int argc, const char **argv_) {
stream->config.cfg.g_profile);
}
});
#else
FOREACH_STREAM({
if (input.fmt != AOM_IMG_FMT_I420 && input.fmt != AOM_IMG_FMT_I42016) {
/* Automatically upgrade if input is non-4:2:0 but a 4:2:0 profile
was selected. */
switch (stream->config.cfg.g_profile) {
case 0:
stream->config.cfg.g_profile = 1;
profile_updated = 1;
break;
case 2:
stream->config.cfg.g_profile = 3;
profile_updated = 1;
break;
default: break;
}
}
if (profile_updated) {
fprintf(stderr,
"Warning: automatically upgrading to profile %d to "
"match input format.\n",
stream->config.cfg.g_profile);
}
});
#endif
FOREACH_STREAM(set_stream_dimensions(stream, input.width, input.height));
FOREACH_STREAM(validate_stream_config(stream, &global));

Просмотреть файл

@ -115,6 +115,14 @@ static TX_MODE read_tx_mode(struct aom_read_bit_buffer *rb) {
return aom_rb_read_bit(rb) ? TX_MODE_SELECT : aom_rb_read_literal(rb, 2);
}
static void read_tx_size_probs(FRAME_CONTEXT *fc, aom_reader *r) {
int i, j, k;
for (i = 0; i < MAX_TX_DEPTH; ++i)
for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
for (k = 0; k < i + 1; ++k)
av1_diff_update_prob(r, &fc->tx_size_probs[i][j][k], ACCT_STR);
}
#if !CONFIG_EC_ADAPT
static void read_switchable_interp_probs(FRAME_CONTEXT *fc, aom_reader *r) {
int i, j;
@ -1800,6 +1808,18 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
dec_update_partition_context(xd, mi_row, mi_col, subsize, num_8x8_wh);
#endif // CONFIG_EXT_PARTITION_TYPES
#if CONFIG_DERING
if (bsize == BLOCK_64X64) {
if (cm->dering_level != 0 && !sb_all_skip(cm, mi_row, mi_col)) {
cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]->mbmi.dering_gain =
aom_read_literal(r, DERING_REFINEMENT_BITS, ACCT_STR);
} else {
cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]->mbmi.dering_gain =
0;
}
}
#endif
#if CONFIG_CLPF
if (bsize == BLOCK_64X64 && cm->clpf_strength_y &&
cm->clpf_size != CLPF_NOSIZE) {
@ -1836,18 +1856,6 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
}
}
#endif
#if CONFIG_DERING
if (bsize == BLOCK_64X64) {
if (cm->dering_level != 0 && !sb_all_skip(cm, mi_row, mi_col)) {
cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]->mbmi.dering_gain =
aom_read_literal(r, DERING_REFINEMENT_BITS, ACCT_STR);
} else {
cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]->mbmi.dering_gain =
0;
}
}
#endif
}
#if !CONFIG_ANS
@ -3523,12 +3531,12 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
#endif // CONFIG_EXT_PARTITION
setup_loopfilter(cm, rb);
#if CONFIG_CLPF
setup_clpf(pbi, rb);
#endif
#if CONFIG_DERING
setup_dering(cm, rb);
#endif
#if CONFIG_CLPF
setup_clpf(pbi, rb);
#endif
#if CONFIG_LOOP_RESTORATION
decode_restoration_mode(cm, rb);
#endif // CONFIG_LOOP_RESTORATION
@ -3721,12 +3729,7 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
decode_restoration(cm, &r);
#endif
if (cm->tx_mode == TX_MODE_SELECT) {
for (i = 0; i < MAX_TX_DEPTH; ++i)
for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
for (k = 0; k < i + 1; ++k)
av1_diff_update_prob(&r, &fc->tx_size_probs[i][j][k], ACCT_STR);
}
if (cm->tx_mode == TX_MODE_SELECT) read_tx_size_probs(fc, &r);
read_coef_probs(fc, cm->tx_mode, &r);
@ -4174,6 +4177,12 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
}
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_DERING
if (cm->dering_level && !cm->skip_loop_filter) {
av1_dering_frame(&pbi->cur_buf->buf, cm, &pbi->mb, cm->dering_level);
}
#endif // CONFIG_DERING
#if CONFIG_CLPF
if (!cm->skip_loop_filter) {
const YV12_BUFFER_CONFIG *const frame = &pbi->cur_buf->buf;
@ -4195,11 +4204,6 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
}
if (cm->clpf_blocks) aom_free(cm->clpf_blocks);
#endif
#if CONFIG_DERING
if (cm->dering_level && !cm->skip_loop_filter) {
av1_dering_frame(&pbi->cur_buf->buf, cm, &pbi->mb, cm->dering_level);
}
#endif // CONFIG_DERING
if (!xd->corrupted) {
if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {

Просмотреть файл

@ -314,7 +314,7 @@ static void encode_unsigned_max(struct aom_write_bit_buffer *wb, int data,
aom_wb_write_literal(wb, data, get_unsigned_bits(max));
}
#if !CONFIG_EC_ADAPT
#if !CONFIG_EC_ADAPT || !CONFIG_DAALA_EC
static void prob_diff_update(const aom_tree_index *tree,
aom_prob probs[/*n - 1*/],
const unsigned int counts[/*n - 1*/], int n,
@ -628,7 +628,6 @@ static void update_ext_tx_probs(AV1_COMMON *cm, aom_writer *w) {
#else
#if !CONFIG_EC_ADAPT
static void update_ext_tx_probs(AV1_COMMON *cm, aom_writer *w) {
const int savings_thresh = av1_cost_one(GROUP_DIFF_UPDATE_PROB) -
av1_cost_zero(GROUP_DIFF_UPDATE_PROB);
@ -2093,6 +2092,16 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
#endif // CONFIG_EXT_PARTITION_TYPES
#if CONFIG_DERING
if (bsize == BLOCK_64X64 && cm->dering_level != 0 &&
!sb_all_skip(cm, mi_row, mi_col)) {
aom_write_literal(
w,
cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]->mbmi.dering_gain,
DERING_REFINEMENT_BITS);
}
#endif
#if CONFIG_CLPF
if (bsize == BLOCK_64X64 && cm->clpf_blocks && cm->clpf_strength_y &&
cm->clpf_size != CLPF_NOSIZE) {
@ -2123,16 +2132,6 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
aom_write_literal(w, cm->clpf_blocks[br], 1);
}
#endif
#if CONFIG_DERING
if (bsize == BLOCK_64X64 && cm->dering_level != 0 &&
!sb_all_skip(cm, mi_row, mi_col)) {
aom_write_literal(
w,
cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]->mbmi.dering_gain,
DERING_REFINEMENT_BITS);
}
#endif
}
static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
@ -2917,6 +2916,7 @@ static void write_txfm_mode(TX_MODE mode, struct aom_write_bit_buffer *wb) {
if (mode != TX_MODE_SELECT) aom_wb_write_literal(wb, mode, 2);
}
#if !CONFIG_EC_ADAPT
static void update_txfm_probs(AV1_COMMON *cm, aom_writer *w,
FRAME_COUNTS *counts) {
#if CONFIG_TILE_GROUPS
@ -2932,6 +2932,7 @@ static void update_txfm_probs(AV1_COMMON *cm, aom_writer *w,
counts->tx_size[i][j], i + 2, probwt, w);
}
}
#endif
static void write_interp_filter(InterpFilter filter,
struct aom_write_bit_buffer *wb) {
@ -3569,12 +3570,12 @@ static void write_uncompressed_header(AV1_COMP *cpi,
#endif // CONFIG_EXT_PARTITION
encode_loopfilter(cm, wb);
#if CONFIG_CLPF
encode_clpf(cm, wb);
#endif
#if CONFIG_DERING
encode_dering(cm->dering_level, wb);
#endif // CONFIG_DERING
#if CONFIG_CLPF
encode_clpf(cm, wb);
#endif
#if CONFIG_LOOP_RESTORATION
encode_restoration_mode(cm, wb);
#endif // CONFIG_LOOP_RESTORATION
@ -3706,9 +3707,9 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
#if CONFIG_LOOP_RESTORATION
encode_restoration(cm, header_bc);
#endif // CONFIG_LOOP_RESTORATION
#if !CONFIG_EC_ADAPT
update_txfm_probs(cm, header_bc, counts);
#endif
update_coef_probs(cpi, header_bc);
#if CONFIG_VAR_TX

Просмотреть файл

@ -3324,6 +3324,16 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
av1_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0);
#endif
}
#if CONFIG_DERING
if (is_lossless_requested(&cpi->oxcf)) {
cm->dering_level = 0;
} else {
cm->dering_level =
av1_dering_search(cm->frame_to_show, cpi->Source, cm, xd);
av1_dering_frame(cm->frame_to_show, cm, xd, cm->dering_level);
}
#endif // CONFIG_DERING
#if CONFIG_CLPF
cm->clpf_strength_y = cm->clpf_strength_u = cm->clpf_strength_v = 0;
cm->clpf_size = CLPF_64X64;
@ -3372,15 +3382,6 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
}
}
#endif
#if CONFIG_DERING
if (is_lossless_requested(&cpi->oxcf)) {
cm->dering_level = 0;
} else {
cm->dering_level =
av1_dering_search(cm->frame_to_show, cpi->Source, cm, xd);
av1_dering_frame(cm->frame_to_show, cm, xd, cm->dering_level);
}
#endif // CONFIG_DERING
#if CONFIG_LOOP_RESTORATION
if (cm->rst_info.restoration_type != RESTORE_NONE) {
av1_loop_restoration_init(&cm->rst_internal, &cm->rst_info,