| Index: third_party/libwebp/enc/analysis_enc.c
|
| diff --git a/third_party/libwebp/enc/analysis.c b/third_party/libwebp/enc/analysis_enc.c
|
| similarity index 92%
|
| rename from third_party/libwebp/enc/analysis.c
|
| rename to third_party/libwebp/enc/analysis_enc.c
|
| index 136c331289092af1e301ff12bbec133577ef201d..dce159b316f1c2d44c6aa42cfb76d364f948252f 100644
|
| --- a/third_party/libwebp/enc/analysis.c
|
| +++ b/third_party/libwebp/enc/analysis_enc.c
|
| @@ -15,8 +15,8 @@
|
| #include <string.h>
|
| #include <assert.h>
|
|
|
| -#include "./vp8enci.h"
|
| -#include "./cost.h"
|
| +#include "./vp8i_enc.h"
|
| +#include "./cost_enc.h"
|
| #include "../utils/utils.h"
|
|
|
| #define MAX_ITERS_K_MEANS 6
|
| @@ -262,6 +262,29 @@ static int MBAnalyzeBestIntra16Mode(VP8EncIterator* const it) {
|
| return best_alpha;
|
| }
|
|
|
| +static int FastMBAnalyze(VP8EncIterator* const it) {
|
| + // Empirical cut-off value, should be around 16 (~=block size). We use the
|
| + // [8-17] range and favor intra4 at high quality, intra16 for low quality.
|
| + const int q = (int)it->enc_->config_->quality;
|
| + const uint32_t kThreshold = 8 + (17 - 8) * q / 100;
|
| + int k;
|
| + uint32_t dc[16], m, m2;
|
| + for (k = 0; k < 16; k += 4) {
|
| + VP8Mean16x4(it->yuv_in_ + Y_OFF_ENC + k * BPS, &dc[k]);
|
| + }
|
| + for (m = 0, m2 = 0, k = 0; k < 16; ++k) {
|
| + m += dc[k];
|
| + m2 += dc[k] * dc[k];
|
| + }
|
| + if (kThreshold * m2 < m * m) {
|
| + VP8SetIntra16Mode(it, 0); // DC16
|
| + } else {
|
| + const uint8_t modes[16] = { 0 }; // DC4
|
| + VP8SetIntra4Mode(it, modes);
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| static int MBAnalyzeBestIntra4Mode(VP8EncIterator* const it,
|
| int best_alpha) {
|
| uint8_t modes[16];
|
| @@ -344,13 +367,17 @@ static void MBAnalyze(VP8EncIterator* const it,
|
| VP8SetSkip(it, 0); // not skipped
|
| VP8SetSegment(it, 0); // default segment, spec-wise.
|
|
|
| - best_alpha = MBAnalyzeBestIntra16Mode(it);
|
| - if (enc->method_ >= 5) {
|
| - // We go and make a fast decision for intra4/intra16.
|
| - // It's usually not a good and definitive pick, but helps seeding the stats
|
| - // about level bit-cost.
|
| - // TODO(skal): improve criterion.
|
| - best_alpha = MBAnalyzeBestIntra4Mode(it, best_alpha);
|
| + if (enc->method_ <= 1) {
|
| + best_alpha = FastMBAnalyze(it);
|
| + } else {
|
| + best_alpha = MBAnalyzeBestIntra16Mode(it);
|
| + if (enc->method_ >= 5) {
|
| + // We go and make a fast decision for intra4/intra16.
|
| + // It's usually not a good and definitive pick, but helps seeding the
|
| + // stats about level bit-cost.
|
| + // TODO(skal): improve criterion.
|
| + best_alpha = MBAnalyzeBestIntra4Mode(it, best_alpha);
|
| + }
|
| }
|
| best_uv_alpha = MBAnalyzeBestUVMode(it);
|
|
|
| @@ -453,7 +480,7 @@ int VP8EncAnalyze(VP8Encoder* const enc) {
|
| const int do_segments =
|
| enc->config_->emulate_jpeg_size || // We need the complexity evaluation.
|
| (enc->segment_hdr_.num_segments_ > 1) ||
|
| - (enc->method_ == 0); // for method 0, we need preds_[] to be filled.
|
| + (enc->method_ <= 1); // for method 0 - 1, we need preds_[] to be filled.
|
| if (do_segments) {
|
| const int last_row = enc->mb_h_;
|
| // We give a little more than a half work to the main thread.
|
|
|