add the missing cost for I4/I16 mode selection

was missing from the RD-computation of intra-4x4 score.
Doesn't change anything significantly, it's just More Correct.

Change-Id: I25c5b53a810d97e6fb7f98c549fd23bbe55e1bf4
This commit is contained in:
Pascal Massimino 2011-08-18 20:48:06 -07:00
parent 3cf2030653
commit cd12b4b0ac
2 changed files with 21 additions and 20 deletions

View File

@ -17,7 +17,7 @@
extern "C" { extern "C" {
#endif #endif
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Boolean-cost cost table // Boolean-cost cost table
const uint16_t VP8EntropyCost[256] = { const uint16_t VP8EntropyCost[256] = {
@ -49,7 +49,7 @@ const uint16_t VP8EntropyCost[256] = {
10, 9, 7, 6, 4, 3 10, 9, 7, 6, 4, 3
}; };
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Level cost tables // Level cost tables
// For each given level, the following table given the pattern of contexts // For each given level, the following table given the pattern of contexts
@ -351,7 +351,7 @@ static int VariableLevelCost(int level, const uint8_t probas[NUM_PROBAS]) {
return cost; return cost;
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Pre-calc level costs once for all // Pre-calc level costs once for all
void VP8CalculateLevelCosts(VP8Proba* const proba) { void VP8CalculateLevelCosts(VP8Proba* const proba) {
@ -374,12 +374,13 @@ void VP8CalculateLevelCosts(VP8Proba* const proba) {
} }
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Mode cost tables. // Mode cost tables.
// These are the fixed probabilities (in the coding trees) turned into bit-cost // These are the fixed probabilities (in the coding trees) turned into bit-cost
// by calling VP8BitCost(). // by calling VP8BitCost().
const uint16_t VP8FixedCostsUV[4] = { 302, 984, 439, 642 }; const uint16_t VP8FixedCostsUV[4] = { 302, 984, 439, 642 };
// note: these values include the fixed VP8BitCost(1, 145) mode selection cost.
const uint16_t VP8FixedCostsI16[4] = { 663, 919, 872, 919 }; const uint16_t VP8FixedCostsI16[4] = { 663, 919, 872, 919 };
const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES] = { const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES] = {
{ { 251, 1362, 1934, 2085, 2314, 2230, 1839, 1988, 2437, 2348 }, { { 251, 1362, 1934, 2085, 2314, 2230, 1839, 1988, 2437, 2348 },
@ -484,7 +485,7 @@ const uint16_t VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES] = {
{ 516, 1378, 1569, 1110, 1798, 1798, 1198, 2199, 1543, 712 } }, { 516, 1378, 1569, 1110, 1798, 1798, 1198, 2199, 1543, 712 } },
}; };
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)
} // extern "C" } // extern "C"

View File

@ -33,7 +33,7 @@
extern "C" { extern "C" {
#endif #endif
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
static inline int clip(int v, int m, int M) { static inline int clip(int v, int m, int M) {
return v < m ? m : v > M ? M : v; return v < m ? m : v > M ? M : v;
@ -132,7 +132,7 @@ static const uint8_t kFreqSharpening[16] = {
90, 90, 90, 90 90, 90, 90, 90
}; };
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Initialize quantization parameters in VP8Matrix // Initialize quantization parameters in VP8Matrix
// Returns the average quantizer // Returns the average quantizer
@ -192,7 +192,7 @@ static void SetupMatrices(VP8Encoder* enc) {
} }
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Initialize filtering parameters // Initialize filtering parameters
// Very small filter-strength values have close to no visual effect. So we can // Very small filter-strength values have close to no visual effect. So we can
@ -214,7 +214,7 @@ static void SetupFilterStrength(VP8Encoder* const enc) {
enc->filter_hdr_.sharpness_ = enc->config_->filter_sharpness; enc->filter_hdr_.sharpness_ = enc->config_->filter_sharpness;
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Note: if you change the values below, remember that the max range // Note: if you change the values below, remember that the max range
// allowed by the syntax for DQ_UV is [-16,16]. // allowed by the syntax for DQ_UV is [-16,16].
@ -286,7 +286,7 @@ void VP8SetSegmentParams(VP8Encoder* const enc, float quality) {
SetupFilterStrength(enc); // initialize segments' filtering, eventually SetupFilterStrength(enc); // initialize segments' filtering, eventually
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Form the predictions in cache // Form the predictions in cache
// Must be ordered using {DC_PRED, TM_PRED, V_PRED, H_PRED} as index // Must be ordered using {DC_PRED, TM_PRED, V_PRED, H_PRED} as index
@ -316,7 +316,7 @@ void VP8MakeIntra4Preds(const VP8EncIterator* const it) {
VP8EncPredLuma4(it->yuv_p_, it->i4_top_); VP8EncPredLuma4(it->yuv_p_, it->i4_top_);
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Quantize // Quantize
// Layout: // Layout:
@ -341,7 +341,7 @@ const int VP8Scan[16 + 4 + 4] = {
8 + 0 * BPS, 12 + 0 * BPS, 8 + 4 * BPS, 12 + 4 * BPS // V 8 + 0 * BPS, 12 + 0 * BPS, 8 + 4 * BPS, 12 + 4 * BPS // V
}; };
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Distortion measurement // Distortion measurement
static const uint16_t kWeightY[16] = { static const uint16_t kWeightY[16] = {
@ -384,7 +384,7 @@ static void AddScore(VP8ModeScore* const dst, const VP8ModeScore* const src) {
dst->score += src->score; dst->score += src->score;
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Performs trellis-optimized quantization. // Performs trellis-optimized quantization.
// Trellis // Trellis
@ -571,7 +571,7 @@ static int TrellisQuantizeBlock(const VP8EncIterator* const it,
#undef NODE #undef NODE
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Performs: difference, transform, quantize, back-transform, add // Performs: difference, transform, quantize, back-transform, add
// all at once. Output is the reconstructed block in *yuv_out, and the // all at once. Output is the reconstructed block in *yuv_out, and the
// quantized levels in *levels. // quantized levels in *levels.
@ -685,7 +685,7 @@ static int ReconstructUV(VP8EncIterator* const it, VP8ModeScore* const rd,
return (nz << 16); return (nz << 16);
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// RD-opt decision. Reconstruct each modes, evalue distortion and bit-cost. // RD-opt decision. Reconstruct each modes, evalue distortion and bit-cost.
// Pick the mode is lower RD-cost = Rate + lamba * Distortion. // Pick the mode is lower RD-cost = Rate + lamba * Distortion.
@ -738,7 +738,7 @@ static void PickBestIntra16(VP8EncIterator* const it, VP8ModeScore* const rd) {
VP8SetIntra16Mode(it, rd->mode_i16); VP8SetIntra16Mode(it, rd->mode_i16);
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// return the cost array corresponding to the surrounding prediction modes. // return the cost array corresponding to the surrounding prediction modes.
static const uint16_t* GetCostModeI4(VP8EncIterator* const it, static const uint16_t* GetCostModeI4(VP8EncIterator* const it,
@ -760,7 +760,7 @@ static int PickBestIntra4(VP8EncIterator* const it, VP8ModeScore* const rd) {
VP8ModeScore rd_best; VP8ModeScore rd_best;
InitScore(&rd_best); InitScore(&rd_best);
rd_best.score = 0; rd_best.score = 211; // '211' is the value of VP8BitCost(0, 145)
VP8IteratorStartI4(it); VP8IteratorStartI4(it);
do { do {
VP8ModeScore rd_i4; VP8ModeScore rd_i4;
@ -817,7 +817,7 @@ static int PickBestIntra4(VP8EncIterator* const it, VP8ModeScore* const rd) {
return 1; // select intra4x4 over intra16x16 return 1; // select intra4x4 over intra16x16
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
static void PickBestUV(VP8EncIterator* const it, VP8ModeScore* const rd) { static void PickBestUV(VP8EncIterator* const it, VP8ModeScore* const rd) {
VP8Encoder* const enc = it->enc_; VP8Encoder* const enc = it->enc_;
@ -855,7 +855,7 @@ static void PickBestUV(VP8EncIterator* const it, VP8ModeScore* const rd) {
AddScore(rd, &rd_best); AddScore(rd, &rd_best);
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Final reconstruction and quantization. // Final reconstruction and quantization.
static void SimpleQuantize(VP8EncIterator* const it, VP8ModeScore* const rd) { static void SimpleQuantize(VP8EncIterator* const it, VP8ModeScore* const rd) {
@ -882,7 +882,7 @@ static void SimpleQuantize(VP8EncIterator* const it, VP8ModeScore* const rd) {
rd->nz = nz; rd->nz = nz;
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Entry point // Entry point
int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, int rd_opt) { int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, int rd_opt) {