// Copyright 2011 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // Cost tables for level and modes // // Author: Skal ([email protected]) #include "src/enc/cost_enc.h" //------------------------------------------------------------------------------ // Level cost tables // For each given level, the following table gives the pattern of contexts to // use for coding it (in [][0]) as well as the bit value to use for each // context (in [][1]). const uint16_t VP8LevelCodes[MAX_VARIABLE_LEVEL][2] = …; static int VariableLevelCost(int level, const uint8_t probas[NUM_PROBAS]) { … } //------------------------------------------------------------------------------ // Pre-calc level costs once for all void VP8CalculateLevelCosts(VP8EncProba* const proba) { … } //------------------------------------------------------------------------------ // Mode cost tables. // These are the fixed probabilities (in the coding trees) turned into bit-cost // by calling VP8BitCost(). const uint16_t VP8FixedCostsUV[4] = …; // note: these values include the fixed VP8BitCost(1, 145) mode selection cost. const uint16_t VP8FixedCostsI16[4] = …; const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES] = …; //------------------------------------------------------------------------------ // helper functions for residuals struct VP8Residual. void VP8InitResidual(int first, int coeff_type, VP8Encoder* const enc, VP8Residual* const res) { … } //------------------------------------------------------------------------------ // Mode costs int VP8GetCostLuma4(VP8EncIterator* const it, const int16_t levels[16]) { … } int VP8GetCostLuma16(VP8EncIterator* const it, const VP8ModeScore* const rd) { … } int VP8GetCostUV(VP8EncIterator* const it, const VP8ModeScore* const rd) { … } //------------------------------------------------------------------------------ // Recording of token probabilities. // We keep the table-free variant around for reference, in case. #define USE_LEVEL_CODE_TABLE // Simulate block coding, but only record statistics. // Note: no need to record the fixed probas. int VP8RecordCoeffs(int ctx, const VP8Residual* const res) { … } //------------------------------------------------------------------------------