diff --git a/src/enc/cost.c b/src/enc/cost.c index 1eead3fa..14b357ba 100644 --- a/src/enc/cost.c +++ b/src/enc/cost.c @@ -359,7 +359,7 @@ void VP8CalculateLevelCosts(VP8Proba* const proba) { for(ctx = 0; ctx < NUM_CTX; ++ctx) { const uint8_t* const p = proba->coeffs_[ctype][band][ctx]; uint16_t* const table = proba->level_cost_[ctype][band][ctx]; - const int cost_base = VP8BitCost(0, p[0]) + VP8BitCost(1, p[1]); + const int cost_base = VP8BitCost(1, p[1]); int v; table[0] = VP8BitCost(0, p[1]); for (v = 1; v <= MAX_VARIABLE_LEVEL; ++v) { diff --git a/src/enc/frame.c b/src/enc/frame.c index 8a958f2e..f9fbdf2d 100644 --- a/src/enc/frame.c +++ b/src/enc/frame.c @@ -274,12 +274,15 @@ static int GetResidualCost(int ctx, const VP8Residual* const res) { const int b = VP8EncBands[n + 1]; ++n; if (v == 0) { - cost += VP8LevelCost(t, 0); + // short-case for VP8LevelCost(t, 0) (note: VP8LevelFixedCosts[0] == 0): + cost += t[0]; t = res->cost[b][0]; continue; } + cost += VP8BitCost(1, p0); if (2u >= (unsigned int)(v + 1)) { // v = -1 or 1 - cost += VP8LevelCost(t, 1); + // short-case for "VP8LevelCost(t, 1)" (256 is VP8LevelFixedCosts[1]): + cost += 256 + t[1]; p0 = res->prob[b][1][0]; t = res->cost[b][1]; } else {