Commit f74b4abd authored by Imdad Sardharwalla's avatar Imdad Sardharwalla

Don't read chroma delta_lflevels in mono mode

There are 4 delta_lflevels (FRAME_LF_COUNT=4), corresponding to 2 for the luma
plane and 1 for each of the U and V planes. In monochrome mode we do not need
to use/encode/decode the last two values, and so in this case the for loops all
terminate at FRAME_LF_COUNT - 2 rather than FRAME_LF_COUNT.

BUG=aomedia:1410

Change-Id: Ieb60cce9e39287a385e7f74d9009aac1f0f23e54
parent 238bc287
......@@ -3292,7 +3292,9 @@ static int read_uncompressed_header(AV1Decoder *pbi,
cm->delta_lf_res = 1 << aom_rb_read_literal(rb, 2);
#if CONFIG_LOOPFILTER_LEVEL
cm->delta_lf_multi = aom_rb_read_bit(rb);
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id)
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id)
xd->prev_delta_lf[lf_id] = 0;
#endif // CONFIG_LOOPFILTER_LEVEL
}
......
......@@ -123,7 +123,9 @@ static int read_delta_lflevel(AV1_COMMON *cm, MACROBLOCKD *xd, aom_reader *r,
read_delta_lf_flag) {
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_multi) {
assert(lf_id >= 0 && lf_id < FRAME_LF_COUNT);
assert(lf_id >= 0 &&
lf_id < (av1_num_planes(cm) > 1 ? FRAME_LF_COUNT
: FRAME_LF_COUNT - 2));
abs = aom_read_symbol(r, ec_ctx->delta_lf_multi_cdf[lf_id],
DELTA_LF_PROBS + 1, ACCT_STR);
} else {
......@@ -989,7 +991,9 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
if (cm->delta_lf_present_flag) {
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id) {
const int tmp_lvl =
xd->prev_delta_lf[lf_id] +
read_delta_lflevel(cm, xd, r, lf_id, mbmi, mi_col, mi_row) *
......@@ -2089,7 +2093,9 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
if (cm->delta_lf_present_flag) {
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id) {
const int tmp_lvl =
xd->prev_delta_lf[lf_id] +
read_delta_lflevel(cm, xd, r, lf_id, mbmi, mi_col, mi_row) *
......
......@@ -346,7 +346,8 @@ static void write_delta_lflevel(const AV1_COMMON *cm, const MACROBLOCKD *xd,
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_multi) {
assert(lf_id >= 0 && lf_id < FRAME_LF_COUNT);
assert(lf_id >= 0 && lf_id < (av1_num_planes(cm) > 1 ? FRAME_LF_COUNT
: FRAME_LF_COUNT - 2));
aom_write_symbol(w, AOMMIN(abs, DELTA_LF_SMALL),
ec_ctx->delta_lf_multi_cdf[lf_id], DELTA_LF_PROBS + 1);
} else {
......@@ -1120,7 +1121,9 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_present_flag) {
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
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;
......@@ -1463,7 +1466,9 @@ static void write_mb_modes_kf(AV1_COMP *cpi, MACROBLOCKD *xd,
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_present_flag) {
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
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;
......@@ -2035,7 +2040,9 @@ static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
#if CONFIG_EXT_DELTA_Q
if (cpi->common.delta_lf_present_flag) {
#if CONFIG_LOOPFILTER_LEVEL
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id)
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
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;
......@@ -3789,7 +3796,9 @@ static void write_uncompressed_header_frame(AV1_COMP *cpi,
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)
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id)
xd->prev_delta_lf[lf_id] = 0;
#endif // CONFIG_LOOPFILTER_LEVEL
}
......@@ -4202,7 +4211,9 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
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)
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id)
xd->prev_delta_lf[lf_id] = 0;
#endif // CONFIG_LOOPFILTER_LEVEL
}
......
......@@ -967,7 +967,9 @@ static void update_stats(const AV1_COMMON *const cm, TileDataEnc *tile_data,
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_present_flag) {
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id) {
const int delta_lf =
(mbmi->curr_delta_lf[lf_id] - xd->prev_delta_lf[lf_id]) /
cm->delta_lf_res;
......@@ -1509,7 +1511,10 @@ static void encode_b(const AV1_COMP *const cpi, TileDataEnc *tile_data,
if (bsize == cpi->common.seq_params.sb_size && mbmi->skip == 1 &&
cpi->common.delta_lf_present_flag) {
#if CONFIG_LOOPFILTER_LEVEL
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id)
const int frame_lf_count = av1_num_planes(&cpi->common) > 1
? FRAME_LF_COUNT
: FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id)
mbmi->curr_delta_lf[lf_id] = xd->prev_delta_lf[lf_id];
#endif // CONFIG_LOOPFILTER_LEVEL
mbmi->current_delta_lf_from_base = xd->prev_delta_lf_from_base;
......@@ -3603,9 +3608,12 @@ static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td,
#if CONFIG_EXT_DELTA_Q
if (cm->delta_lf_present_flag) {
#if CONFIG_LOOPFILTER_LEVEL
if (mi_row == tile_info->mi_row_start)
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id)
if (mi_row == tile_info->mi_row_start) {
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id)
xd->prev_delta_lf[lf_id] = 0;
}
#endif // CONFIG_LOOPFILTER_LEVEL
if (mi_row == tile_info->mi_row_start) xd->prev_delta_lf_from_base = 0;
}
......@@ -3701,7 +3709,9 @@ static void encode_rd_sb_row(AV1_COMP *cpi, ThreadData *td,
.mbmi.current_delta_lf_from_base = clamp(
current_delta_lf_from_base, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
#if CONFIG_LOOPFILTER_LEVEL
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
const int frame_lf_count =
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id) {
cm->mi[(mi_row + j) * cm->mi_stride + (mi_col + k)]
.mbmi.curr_delta_lf[lf_id] =
clamp(current_delta_lf_from_base, -MAX_LOOP_FILTER,
......
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