Merge "analysis_enc.c: fix a dead store warning" into main

This commit is contained in:
James Zern 2022-10-17 17:34:34 +00:00 committed by Gerrit Code Review
commit ac252b6118

View File

@ -391,12 +391,14 @@ static int DoSegmentsJob(void* arg1, void* arg2) {
return ok; return ok;
} }
#ifdef WEBP_USE_THREAD
static void MergeJobs(const SegmentJob* const src, SegmentJob* const dst) { static void MergeJobs(const SegmentJob* const src, SegmentJob* const dst) {
int i; int i;
for (i = 0; i <= MAX_ALPHA; ++i) dst->alphas[i] += src->alphas[i]; for (i = 0; i <= MAX_ALPHA; ++i) dst->alphas[i] += src->alphas[i];
dst->alpha += src->alpha; dst->alpha += src->alpha;
dst->uv_alpha += src->uv_alpha; dst->uv_alpha += src->uv_alpha;
} }
#endif
// initialize the job struct with some tasks to perform // initialize the job struct with some tasks to perform
static void InitSegmentJob(VP8Encoder* const enc, SegmentJob* const job, static void InitSegmentJob(VP8Encoder* const enc, SegmentJob* const job,
@ -425,10 +427,10 @@ int VP8EncAnalyze(VP8Encoder* const enc) {
(enc->method_ <= 1); // for method 0 - 1, we need preds_[] to be filled. (enc->method_ <= 1); // for method 0 - 1, we need preds_[] to be filled.
if (do_segments) { if (do_segments) {
const int last_row = enc->mb_h_; const int last_row = enc->mb_h_;
// We give a little more than a half work to the main thread.
const int split_row = (9 * last_row + 15) >> 4;
const int total_mb = last_row * enc->mb_w_; const int total_mb = last_row * enc->mb_w_;
#ifdef WEBP_USE_THREAD #ifdef WEBP_USE_THREAD
// We give a little more than a half work to the main thread.
const int split_row = (9 * last_row + 15) >> 4;
const int kMinSplitRow = 2; // minimal rows needed for mt to be worth it const int kMinSplitRow = 2; // minimal rows needed for mt to be worth it
const int do_mt = (enc->thread_level_ > 0) && (split_row >= kMinSplitRow); const int do_mt = (enc->thread_level_ > 0) && (split_row >= kMinSplitRow);
#else #else
@ -438,6 +440,7 @@ int VP8EncAnalyze(VP8Encoder* const enc) {
WebPGetWorkerInterface(); WebPGetWorkerInterface();
SegmentJob main_job; SegmentJob main_job;
if (do_mt) { if (do_mt) {
#ifdef WEBP_USE_THREAD
SegmentJob side_job; SegmentJob side_job;
// Note the use of '&' instead of '&&' because we must call the functions // Note the use of '&' instead of '&&' because we must call the functions
// no matter what. // no matter what.
@ -455,6 +458,7 @@ int VP8EncAnalyze(VP8Encoder* const enc) {
} }
worker_interface->End(&side_job.worker); worker_interface->End(&side_job.worker);
if (ok) MergeJobs(&side_job, &main_job); // merge results together if (ok) MergeJobs(&side_job, &main_job); // merge results together
#endif // WEBP_USE_THREAD
} else { } else {
// Even for single-thread case, we use the generic Worker tools. // Even for single-thread case, we use the generic Worker tools.
InitSegmentJob(enc, &main_job, 0, last_row); InitSegmentJob(enc, &main_job, 0, last_row);