diff --git a/src/enc/cost.c b/src/enc/cost.c index 0f7ee722..656d1ea9 100644 --- a/src/enc/cost.c +++ b/src/enc/cost.c @@ -17,7 +17,7 @@ extern "C" { #endif -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Boolean-cost cost table const uint16_t VP8EntropyCost[256] = { @@ -49,7 +49,7 @@ const uint16_t VP8EntropyCost[256] = { 10, 9, 7, 6, 4, 3 }; -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Level cost tables // 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; } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Pre-calc level costs once for all void VP8CalculateLevelCosts(VP8Proba* const proba) { @@ -374,12 +374,13 @@ void VP8CalculateLevelCosts(VP8Proba* 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] = { 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 VP8FixedCostsI4[NUM_BMODES][NUM_BMODES][NUM_BMODES] = { { { 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 } }, }; -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" diff --git a/src/enc/quant.c b/src/enc/quant.c index 31ec8144..b0dd463d 100644 --- a/src/enc/quant.c +++ b/src/enc/quant.c @@ -33,7 +33,7 @@ extern "C" { #endif -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ static inline int clip(int v, int m, int M) { return v < m ? m : v > M ? M : v; @@ -132,7 +132,7 @@ static const uint8_t kFreqSharpening[16] = { 90, 90, 90, 90 }; -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Initialize quantization parameters in VP8Matrix // Returns the average quantizer @@ -192,7 +192,7 @@ static void SetupMatrices(VP8Encoder* enc) { } } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Initialize filtering parameters // 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; } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Note: if you change the values below, remember that the max range // 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 } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Form the predictions in cache // 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_); } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Quantize // Layout: @@ -341,7 +341,7 @@ const int VP8Scan[16 + 4 + 4] = { 8 + 0 * BPS, 12 + 0 * BPS, 8 + 4 * BPS, 12 + 4 * BPS // V }; -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Distortion measurement static const uint16_t kWeightY[16] = { @@ -384,7 +384,7 @@ static void AddScore(VP8ModeScore* const dst, const VP8ModeScore* const src) { dst->score += src->score; } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Performs trellis-optimized quantization. // Trellis @@ -571,7 +571,7 @@ static int TrellisQuantizeBlock(const VP8EncIterator* const it, #undef NODE -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Performs: difference, transform, quantize, back-transform, add // all at once. Output is the reconstructed block in *yuv_out, and the // quantized levels in *levels. @@ -685,7 +685,7 @@ static int ReconstructUV(VP8EncIterator* const it, VP8ModeScore* const rd, return (nz << 16); } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // RD-opt decision. Reconstruct each modes, evalue distortion and bit-cost. // 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); } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // return the cost array corresponding to the surrounding prediction modes. static const uint16_t* GetCostModeI4(VP8EncIterator* const it, @@ -760,7 +760,7 @@ static int PickBestIntra4(VP8EncIterator* const it, VP8ModeScore* const rd) { VP8ModeScore rd_best; InitScore(&rd_best); - rd_best.score = 0; + rd_best.score = 211; // '211' is the value of VP8BitCost(0, 145) VP8IteratorStartI4(it); do { VP8ModeScore rd_i4; @@ -817,7 +817,7 @@ static int PickBestIntra4(VP8EncIterator* const it, VP8ModeScore* const rd) { return 1; // select intra4x4 over intra16x16 } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ static void PickBestUV(VP8EncIterator* const it, VP8ModeScore* const rd) { VP8Encoder* const enc = it->enc_; @@ -855,7 +855,7 @@ static void PickBestUV(VP8EncIterator* const it, VP8ModeScore* const rd) { AddScore(rd, &rd_best); } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Final reconstruction and quantization. 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; } -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ // Entry point int VP8Decimate(VP8EncIterator* const it, VP8ModeScore* const rd, int rd_opt) {