LOOPFILTER_LEVEL: add flexibility for EXT_DELTA_Q
When experiment LOOPFILTER_LEVEL is on, there're four base filter levels
for each frame. This patch enables one to use one delta or four deltas
to update corresponding filter levels for each superblock in
EXT_DELTA_Q.
1 bit per frame is sent through bitstream to select one or four deltas.
Now, we hard code to use one delta.
Change-Id: I9c61a035064fa81878b0575ad21664e2b22a6a45
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 37bfdfb..0662273 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -541,8 +541,14 @@
(void)cm;
#if CONFIG_LOOPFILTER_LEVEL
- aom_write_symbol(w, AOMMIN(abs, DELTA_LF_SMALL), ec_ctx->delta_lf_cdf[lf_id],
- DELTA_LF_PROBS + 1);
+ if (cm->delta_lf_multi) {
+ assert(lf_id >= 0 && lf_id < FRAME_LF_COUNT);
+ aom_write_symbol(w, AOMMIN(abs, DELTA_LF_SMALL),
+ ec_ctx->delta_lf_multi_cdf[lf_id], DELTA_LF_PROBS + 1);
+ } else {
+ aom_write_symbol(w, AOMMIN(abs, DELTA_LF_SMALL), ec_ctx->delta_lf_cdf,
+ DELTA_LF_PROBS + 1);
+ }
#else
aom_write_symbol(w, AOMMIN(abs, DELTA_LF_SMALL), ec_ctx->delta_lf_cdf,
DELTA_LF_PROBS + 1);
@@ -1724,12 +1730,20 @@
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_present_flag) {
- for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
+ if (cm->delta_lf_multi) {
+ for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
+ int reduced_delta_lflevel =
+ (mbmi->curr_delta_lf[lf_id] - xd->prev_delta_lf[lf_id]) /
+ cm->delta_lf_res;
+ write_delta_lflevel(cm, xd, lf_id, reduced_delta_lflevel, w);
+ xd->prev_delta_lf[lf_id] = mbmi->curr_delta_lf[lf_id];
+ }
+ } else {
int reduced_delta_lflevel =
- (mbmi->curr_delta_lf[lf_id] - xd->prev_delta_lf[lf_id]) /
+ (mbmi->current_delta_lf_from_base - xd->prev_delta_lf_from_base) /
cm->delta_lf_res;
- write_delta_lflevel(cm, xd, lf_id, reduced_delta_lflevel, w);
- xd->prev_delta_lf[lf_id] = mbmi->curr_delta_lf[lf_id];
+ write_delta_lflevel(cm, xd, -1, reduced_delta_lflevel, w);
+ xd->prev_delta_lf_from_base = mbmi->current_delta_lf_from_base;
}
}
#else
@@ -2119,12 +2133,20 @@
#if CONFIG_EXT_DELTA_Q
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_present_flag) {
- for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
+ if (cm->delta_lf_multi) {
+ for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
+ int reduced_delta_lflevel =
+ (mbmi->curr_delta_lf[lf_id] - xd->prev_delta_lf[lf_id]) /
+ cm->delta_lf_res;
+ write_delta_lflevel(cm, xd, lf_id, reduced_delta_lflevel, w);
+ xd->prev_delta_lf[lf_id] = mbmi->curr_delta_lf[lf_id];
+ }
+ } else {
int reduced_delta_lflevel =
- (mbmi->curr_delta_lf[lf_id] - xd->prev_delta_lf[lf_id]) /
+ (mbmi->current_delta_lf_from_base - xd->prev_delta_lf_from_base) /
cm->delta_lf_res;
- write_delta_lflevel(cm, xd, lf_id, reduced_delta_lflevel, w);
- xd->prev_delta_lf[lf_id] = mbmi->curr_delta_lf[lf_id];
+ write_delta_lflevel(cm, xd, -1, reduced_delta_lflevel, w);
+ xd->prev_delta_lf_from_base = mbmi->current_delta_lf_from_base;
}
}
#else
@@ -4757,11 +4779,12 @@
aom_wb_write_bit(wb, cm->delta_lf_present_flag);
if (cm->delta_lf_present_flag) {
aom_wb_write_literal(wb, OD_ILOG_NZ(cm->delta_lf_res) - 1, 2);
+ xd->prev_delta_lf_from_base = 0;
#if CONFIG_LOOPFILTER_LEVEL
+ aom_wb_write_bit(wb, cm->delta_lf_multi);
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id)
xd->prev_delta_lf[lf_id] = 0;
#endif // CONFIG_LOOPFILTER_LEVEL
- xd->prev_delta_lf_from_base = 0;
}
#endif // CONFIG_EXT_DELTA_Q
}