Encoder/Decoder mismatch fix: need a separate copy of eob_counts. The bug was introduced here: https://chromium-review.googlesource.com/#/c/399975/4/av1/encoder/bitstream.c In that patch, I had removed 2nd declaration of a variable of the same name. But it turns out that the two variables actually had a different type (even though the name was same). Now, we keep both variables, but rename one of them -- that fixes the mismatch. While we are at it, made both variables local as well. The fix can be verified as follows: ../../libvpx/configure --enable-experimental --enable-supertx --enable-var-tx --enable-entropy --enable-internal-stats && make clean && make -j16 aomenc -o soccer_cif_1000_av1_b8.webm ../soccer_cif.y4m --codec=av1 --limit=50 --skip=0 -p 2 --pass=1 --fpf=soccer_cif_av1.fpf --good --cpu-used=0 --target-bitrate=1000 --lag-in-frames=25 --min-q=0 --max-q=63 --auto-alt-ref=1 --kf-max-dist=150 --kf-min-dist=0 --drop-frame=0 --static-thresh=0 --bias-pct=50 --minsection-pct=0 --maxsection-pct=2000 --arnr-maxframes=7 --arnr-strength=5 --sharpness=0 --undershoot-pct=100 --overshoot-pct=100 --frame-parallel=0 --tile-columns=0 --profile=0 --test-decode=warn aomenc -o soccer_cif_1000_av1_b8.webm ../soccer_cif.y4m --codec=av1 --limit=50 --skip=0 -p 2 --pass=2 --fpf=soccer_cif_av1.fpf --good --cpu-used=0 --target-bitrate=1000 --lag-in-frames=25 --min-q=0 --max-q=63 --auto-alt-ref=1 --kf-max-dist=150 --kf-min-dist=0 --drop-frame=0 --static-thresh=0 --bias-pct=50 --minsection-pct=0 --maxsection-pct=2000 --arnr-maxframes=7 --arnr-strength=5 --sharpness=0 --undershoot-pct=100 --overshoot-pct=100 --frame-parallel=0 --tile-columns=0 --profile=0 --test-decode=warn -v --psnr Change-Id: Ibd72dbe1f620e6de231513220ee4e190606613ae
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index a4bd8d9..743d10b 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -2478,8 +2478,6 @@ #if CONFIG_ENTROPY AV1_COMMON *cm = &cpi->common; SUBFRAME_STATS *subframe_stats = &cpi->subframe_stats; - unsigned int eob_counts_copy[TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS] - [COEFF_CONTEXTS]; int i; av1_coeff_probs_model dummy_frame_coef_probs[PLANE_TYPES]; @@ -2504,8 +2502,10 @@ #if CONFIG_ENTROPY if (cm->do_subframe_update && cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) { + unsigned int this_eob_counts_copy[PLANE_TYPES][REF_TYPES][COEF_BANDS] + [COEFF_CONTEXTS]; av1_coeff_count coef_counts_copy[PLANE_TYPES]; - av1_copy(eob_counts_copy, cpi->common.counts.eob_branch[tx_size]); + av1_copy(this_eob_counts_copy, cpi->common.counts.eob_branch[tx_size]); av1_copy(coef_counts_copy, cpi->td.rd_counts.coef_counts[tx_size]); build_tree_distribution(cpi, tx_size, frame_branch_ct, frame_coef_probs); @@ -2517,7 +2517,7 @@ build_tree_distribution(cpi, tx_size, cpi->branch_ct_buf[i][tx_size], dummy_frame_coef_probs); } - av1_copy(cpi->common.counts.eob_branch[tx_size], eob_counts_copy); + av1_copy(cpi->common.counts.eob_branch[tx_size], this_eob_counts_copy); av1_copy(cpi->td.rd_counts.coef_counts[tx_size], coef_counts_copy); update_coef_probs_subframe(w, cpi, tx_size, cpi->branch_ct_buf, @@ -2545,6 +2545,8 @@ av1_copy(subframe_stats->coef_probs_buf[0], cm->fc->coef_probs); if (cm->do_subframe_update && cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) { + unsigned int eob_counts_copy[TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS] + [COEFF_CONTEXTS]; av1_copy(eob_counts_copy, cm->counts.eob_branch); for (i = 1; i <= cpi->common.coef_probs_update_idx; ++i) { for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)