Commit 8587878c authored by Hui Su's avatar Hui Su

Add flag to indicate if intrabc is used

Change-Id: If8a4f3d256e619c9efdb66b1d8b8da5b8fc980ab
parent 8e232aad
......@@ -278,6 +278,9 @@ typedef struct AV1Common {
#endif
int allow_screen_content_tools;
#if CONFIG_INTRABC
int allow_intrabc;
#endif // CONFIG_INTRABC
int allow_interintra_compound;
int allow_masked_compound;
......
......@@ -75,7 +75,7 @@ static INLINE int av1_allow_intrabc(BLOCK_SIZE bsize,
// TODO(huisu@google.com): intrabc is disabled for BLOCK_4X16 and
// BLOCK_16X4 because of onflict between cfl.
return bsize != BLOCK_4X16 && bsize != BLOCK_16X4 &&
cm->allow_screen_content_tools;
cm->allow_screen_content_tools && cm->allow_intrabc;
}
#endif // CONFIG_INTRABC
......
......@@ -2843,6 +2843,10 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
int frame_size_override_flag = aom_rb_read_literal(rb, 1);
#endif
#if CONFIG_INTRABC
cm->allow_intrabc = 0;
#endif // CONFIG_INTRABC
if (cm->frame_type == KEY_FRAME) {
cm->current_video_frame = 0;
#if !CONFIG_OBU
......@@ -2870,6 +2874,9 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
cm->ans_window_size_log2 = aom_rb_read_literal(rb, 4) + 8;
#endif // CONFIG_ANS && ANS_MAX_SYMBOLS
cm->allow_screen_content_tools = aom_rb_read_bit(rb);
#if CONFIG_INTRABC
if (cm->allow_screen_content_tools) cm->allow_intrabc = aom_rb_read_bit(rb);
#endif // CONFIG_INTRABC
#if CONFIG_AMVR
if (cm->allow_screen_content_tools) {
if (aom_rb_read_bit(rb)) {
......@@ -2885,7 +2892,13 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
cm->use_prev_frame_mvs = 0;
#endif
} else {
if (cm->intra_only) cm->allow_screen_content_tools = aom_rb_read_bit(rb);
if (cm->intra_only) {
cm->allow_screen_content_tools = aom_rb_read_bit(rb);
#if CONFIG_INTRABC
if (cm->allow_screen_content_tools)
cm->allow_intrabc = aom_rb_read_bit(rb);
#endif // CONFIG_INTRABC
}
#if CONFIG_TEMPMV_SIGNALING
if (cm->intra_only || cm->error_resilient_mode) cm->use_prev_frame_mvs = 0;
#endif
......
......@@ -3870,6 +3870,9 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
aom_wb_write_literal(wb, cpi->common.ans_window_size_log2 - 8, 4);
#endif // CONFIG_ANS && ANS_MAX_SYMBOLS
aom_wb_write_bit(wb, cm->allow_screen_content_tools);
#if CONFIG_INTRABC
if (cm->allow_screen_content_tools) aom_wb_write_bit(wb, cm->allow_intrabc);
#endif // CONFIG_INTRABC
#if CONFIG_AMVR
if (cm->allow_screen_content_tools) {
if (cm->seq_force_integer_mv == 2) {
......@@ -3881,7 +3884,13 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
}
#endif
} else {
if (cm->intra_only) aom_wb_write_bit(wb, cm->allow_screen_content_tools);
if (cm->intra_only) {
aom_wb_write_bit(wb, cm->allow_screen_content_tools);
#if CONFIG_INTRABC
if (cm->allow_screen_content_tools)
aom_wb_write_bit(wb, cm->allow_intrabc);
#endif // CONFIG_INTRABC
}
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
if (!cm->error_resilient_mode) {
if (cm->intra_only) {
......
......@@ -3628,11 +3628,19 @@ void av1_encode_tile(AV1_COMP *cpi, ThreadData *td, int tile_row,
av1_crc_calculator_init(&td->mb.tx_rd_record.crc_calculator, 24, 0x5D6DCB);
#if CONFIG_INTRABC
td->intrabc_used_this_tile = 0;
#endif // CONFIG_INTRABC
for (mi_row = tile_info->mi_row_start; mi_row < tile_info->mi_row_end;
mi_row += cm->mib_size) {
encode_rd_sb_row(cpi, td, this_tile, mi_row, &tok);
}
#if CONFIG_INTRABC
cpi->intrabc_used |= td->intrabc_used_this_tile;
#endif // CONFIG_INTRABC
cpi->tok_count[tile_row][tile_col] =
(unsigned int)(tok - cpi->tile_tok[tile_row][tile_col]);
assert(cpi->tok_count[tile_row][tile_col] <=
......@@ -3919,6 +3927,13 @@ static void encode_frame_internal(AV1_COMP *cpi) {
cpi->source->y_height);
}
#if CONFIG_INTRABC
// Allow intrabc when screen content tools are enabled.
cm->allow_intrabc = cm->allow_screen_content_tools;
// Reset the flag.
cpi->intrabc_used = 0;
#endif // CONFIG_INTRABC
#if CONFIG_HASH_ME
if (cpi->oxcf.pass != 1 && cpi->common.allow_screen_content_tools) {
// add to hash table
......@@ -4224,6 +4239,11 @@ static void encode_frame_internal(AV1_COMP *cpi) {
cpi->time_encode_sb_row += aom_usec_timer_elapsed(&emr_timer);
}
#if CONFIG_INTRABC
// If intrabc is allowed but never selected, reset the allow_intrabc flag.
if (cm->allow_intrabc && !cpi->intrabc_used) cm->allow_intrabc = 0;
#endif // CONFIG_INTRABC
#if 0
// Keep record of the total distortion this time around for future use
cpi->last_frame_distortion = cpi->frame_distortion;
......@@ -4850,6 +4870,10 @@ static void encode_superblock(const AV1_COMP *const cpi, TileDataEnc *tile_data,
#endif // CONFIG_DIST_8X8
if (!dry_run) {
#if CONFIG_INTRABC
if (av1_allow_intrabc(bsize, cm))
if (is_intrabc_block(mbmi)) td->intrabc_used_this_tile = 1;
#endif // CONFIG_INTRABC
TX_SIZE tx_size =
is_inter && !mbmi->skip ? mbmi->min_tx_size : mbmi->tx_size;
if (cm->tx_mode == TX_MODE_SELECT && !xd->lossless[mbmi->segment_id] &&
......
......@@ -341,8 +341,10 @@ typedef struct ThreadData {
int32_t *mask_buf;
uint8_t *above_pred_buf;
uint8_t *left_pred_buf;
PALETTE_BUFFER *palette_buffer;
#if CONFIG_INTRABC
int intrabc_used_this_tile;
#endif // CONFIG_INTRABC
} ThreadData;
struct EncWorkerData;
......@@ -606,6 +608,10 @@ typedef struct AV1_COMP {
#if CONFIG_BGSPRITE
int bgsprite_allowed;
#endif // CONFIG_BGSPRITE
#if CONFIG_INTRABC
// A flag to indicate if intrabc is ever used in current frame.
int intrabc_used;
#endif // CONFIG_INTRABC
} AV1_COMP;
void av1_initialize_enc(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment