mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 05:38:22 +01:00
by-pass Analysis pass in case segments=1
10-15% faster encoding. Almost same output, binary wise. The main difference is that we can't compute uv_alpha susceptibility, means there can be subtle differences with different -sns values. Change-Id: Id1b1a50929bf125b6372212fee1ed75a3bed975f
This commit is contained in:
parent
d2ad4450ce
commit
d9c5fbefa4
@ -344,6 +344,14 @@ static void MBAnalyze(VP8EncIterator* const it,
|
|||||||
it->mb_->alpha_ = best_alpha; // for later remapping.
|
it->mb_->alpha_ = best_alpha; // for later remapping.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DefaultMBInfo(VP8MBInfo* const mb) {
|
||||||
|
mb->type_ = 1; // I16x16
|
||||||
|
mb->uv_mode_ = 0;
|
||||||
|
mb->skip_ = 0; // not skipped
|
||||||
|
mb->segment_ = 0; // default segment
|
||||||
|
mb->alpha_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Main analysis loop:
|
// Main analysis loop:
|
||||||
// Collect all susceptibilities for each macroblock and record their
|
// Collect all susceptibilities for each macroblock and record their
|
||||||
@ -356,6 +364,10 @@ static void MBAnalyze(VP8EncIterator* const it,
|
|||||||
|
|
||||||
int VP8EncAnalyze(VP8Encoder* const enc) {
|
int VP8EncAnalyze(VP8Encoder* const enc) {
|
||||||
int ok = 1;
|
int ok = 1;
|
||||||
|
const int do_segments =
|
||||||
|
(enc->segment_hdr_.num_segments_ > 1) ||
|
||||||
|
(enc->method_ <= 2); // for methods 0,1,2, we need preds_[] to be filled.
|
||||||
|
if (do_segments) {
|
||||||
int alphas[MAX_ALPHA + 1] = { 0 };
|
int alphas[MAX_ALPHA + 1] = { 0 };
|
||||||
VP8EncIterator it;
|
VP8EncIterator it;
|
||||||
|
|
||||||
@ -369,7 +381,17 @@ int VP8EncAnalyze(VP8Encoder* const enc) {
|
|||||||
} while (ok && VP8IteratorNext(&it, it.yuv_in_));
|
} while (ok && VP8IteratorNext(&it, it.yuv_in_));
|
||||||
enc->uv_alpha_ /= enc->mb_w_ * enc->mb_h_;
|
enc->uv_alpha_ /= enc->mb_w_ * enc->mb_h_;
|
||||||
if (ok) AssignSegments(enc, alphas);
|
if (ok) AssignSegments(enc, alphas);
|
||||||
|
} else { // Use only one default segment.
|
||||||
|
int n;
|
||||||
|
for (n = 0; n < enc->mb_w_ * enc->mb_h_; ++n) {
|
||||||
|
DefaultMBInfo(&enc->mb_info_[n]);
|
||||||
|
}
|
||||||
|
// Default susceptibilities.
|
||||||
|
enc->dqm_[0].alpha_ = 0;
|
||||||
|
enc->dqm_[0].beta_ = 0;
|
||||||
|
enc->uv_alpha_ = 0; // we can't compute this one.
|
||||||
|
WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_);
|
||||||
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user