Only recompute level_cost_[] when needed

Add a dirty_ flag to keep track of updated probabilities and the need to
recompute the level costs.
This only makes a difference for "-m 2" method which was sub-optimal.
But it's overall cleaner to have this flag.

Change-Id: I21c71201e1d07a923d97a3adf2fbbd7d67d35433
This commit is contained in:
Pascal Massimino
2012-01-25 07:45:34 -08:00
parent 974aaff360
commit 1336fa719d
5 changed files with 19 additions and 8 deletions

View File

@ -354,6 +354,9 @@ static int VariableLevelCost(int level, const uint8_t probas[NUM_PROBAS]) {
void VP8CalculateLevelCosts(VP8Proba* const proba) {
int ctype, band, ctx;
if (!proba->dirty_) return; // nothing to do.
for (ctype = 0; ctype < NUM_TYPES; ++ctype) {
for (band = 0; band < NUM_BANDS; ++band) {
for(ctx = 0; ctx < NUM_CTX; ++ctx) {
@ -370,6 +373,7 @@ void VP8CalculateLevelCosts(VP8Proba* const proba) {
}
}
}
proba->dirty_ = 0;
}
//------------------------------------------------------------------------------