From 76405206328bcf22f0a8ed78b4af56cc3a54ae0a Mon Sep 17 00:00:00 2001 From: Rupert Swarbrick Date: Tue, 7 Nov 2017 16:35:55 +0000 Subject: [PATCH] Move loop restoration reset into a helper function This seems a little cleaner than having the loop open coded in four places. Change-Id: I2ce7be2745ba3575f618d9e261ab767d10f551f7 --- av1/common/blockd.c | 9 +++++++++ av1/common/blockd.h | 4 ++++ av1/decoder/decodeframe.c | 5 +---- av1/encoder/bitstream.c | 15 +++------------ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/av1/common/blockd.c b/av1/common/blockd.c index c78831173..a412b959c 100644 --- a/av1/common/blockd.c +++ b/av1/common/blockd.c @@ -160,6 +160,15 @@ void av1_reset_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col, } } +#if CONFIG_LOOP_RESTORATION +void av1_reset_loop_restoration(MACROBLOCKD *xd) { + for (int p = 0; p < MAX_MB_PLANE; ++p) { + set_default_wiener(xd->wiener_info + p); + set_default_sgrproj(xd->sgrproj_info + p); + } +} +#endif // CONFIG_LOOP_RESTORATION + void av1_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y) { int i; diff --git a/av1/common/blockd.h b/av1/common/blockd.h index cb43f5454..fc289dff7 100644 --- a/av1/common/blockd.h +++ b/av1/common/blockd.h @@ -1233,6 +1233,10 @@ static INLINE TX_SIZE av1_get_tx_size(int plane, const MACROBLOCKD *xd) { void av1_reset_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col, BLOCK_SIZE bsize); +#if CONFIG_LOOP_RESTORATION +void av1_reset_loop_restoration(MACROBLOCKD *xd); +#endif // CONFIG_LOOP_RESTORATION + typedef void (*foreach_transformed_block_visitor)(int plane, int block, int blk_row, int blk_col, BLOCK_SIZE plane_bsize, diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 82c266cd1..2f4f5a154 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c @@ -2303,10 +2303,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data, av1_zero_above_context(cm, tile_info.mi_col_start, tile_info.mi_col_end); #endif #if CONFIG_LOOP_RESTORATION - for (int p = 0; p < MAX_MB_PLANE; ++p) { - set_default_wiener(td->xd.wiener_info + p); - set_default_sgrproj(td->xd.sgrproj_info + p); - } + av1_reset_loop_restoration(&td->xd); #endif // CONFIG_LOOP_RESTORATION #if CONFIG_LOOPFILTERING_ACROSS_TILES diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 06fc10f50..22d282d7d 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c @@ -3123,10 +3123,7 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst, #endif mode_bc.allow_update_cdf = !cm->large_scale_tile; #if CONFIG_LOOP_RESTORATION - for (int p = 0; p < MAX_MB_PLANE; ++p) { - set_default_wiener(cpi->td.mb.e_mbd.wiener_info + p); - set_default_sgrproj(cpi->td.mb.e_mbd.sgrproj_info + p); - } + av1_reset_loop_restoration(&cpi->td.mb.e_mbd); #endif // CONFIG_LOOP_RESTORATION aom_start_encode(&mode_bc, buf->data + data_offset); @@ -3310,10 +3307,7 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst, #endif // CONFIG_ANS mode_bc.allow_update_cdf = 1; #if CONFIG_LOOP_RESTORATION - for (int p = 0; p < MAX_MB_PLANE; ++p) { - set_default_wiener(cpi->td.mb.e_mbd.wiener_info + p); - set_default_sgrproj(cpi->td.mb.e_mbd.sgrproj_info + p); - } + av1_reset_loop_restoration(&cpi->td.mb.e_mbd); #endif // CONFIG_LOOP_RESTORATION aom_start_encode(&mode_bc, dst + total_size); @@ -4884,10 +4878,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst, #endif // CONFIG_ANS mode_bc.allow_update_cdf = 1; #if CONFIG_LOOP_RESTORATION - for (int p = 0; p < MAX_MB_PLANE; ++p) { - set_default_wiener(cpi->td.mb.e_mbd.wiener_info + p); - set_default_sgrproj(cpi->td.mb.e_mbd.sgrproj_info + p); - } + av1_reset_loop_restoration(&cpi->td.mb.e_mbd); #endif // CONFIG_LOOP_RESTORATION aom_start_encode(&mode_bc, dst + total_size); -- GitLab