From eb9a4b97c5a7dcac61b824e1fe0b6e01626745a7 Mon Sep 17 00:00:00 2001 From: hui su Date: Mon, 25 Jul 2016 17:08:10 -0700 Subject: [PATCH] Reset segment id if we decide not to update segment map This avoids potential encoder and decoder mismatch. Change-Id: I5282d3e168afc6193033ad3fce8fbc35618ab2f5 (cherry picked from commit 386e4ba2f0c5e95bf2ad6042cae46a9ba07a5141) --- src/enc/frame.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/enc/frame.c b/src/enc/frame.c index 5b7a40b9..75f38a17 100644 --- a/src/enc/frame.c +++ b/src/enc/frame.c @@ -185,6 +185,13 @@ static int GetProba(int a, int b) { : (255 * a + total / 2) / total; // rounded proba } +static void ResetSegments(VP8Encoder* const enc) { + int n; + for (n = 0; n < enc->mb_w_ * enc->mb_h_; ++n) { + enc->mb_info_[n].segment_ = 0; + } +} + static void SetSegmentProbas(VP8Encoder* const enc) { int p[NUM_MB_SEGMENTS] = { 0 }; int n; @@ -206,6 +213,7 @@ static void SetSegmentProbas(VP8Encoder* const enc) { enc->segment_hdr_.update_map_ = (probas[0] != 255) || (probas[1] != 255) || (probas[2] != 255); + if (!enc->segment_hdr_.update_map_) ResetSegments(enc); enc->segment_hdr_.size_ = p[0] * (VP8BitCost(0, probas[0]) + VP8BitCost(0, probas[1])) + p[1] * (VP8BitCost(0, probas[0]) + VP8BitCost(1, probas[1])) +