void VP8IteratorReset(VP8EncIterator* const it) { VP8Encoder* const enc = it->enc_; VP8IteratorSetRow(it, 0); VP8IteratorSetCountDown(it, enc->mb_w_ * enc->mb_h_); // default InitTop(it); memset(it->bit_count_, 0, sizeof(it->bit_count_)); it->do_trellis_ = 0; }
int VP8IteratorNext(VP8EncIterator* const it) { it->preds_ += 4; it->mb_ += 1; it->nz_ += 1; it->y_top_ += 16; it->uv_top_ += 16; it->x_ += 1; if (it->x_ == it->enc_->mb_w_) { VP8IteratorSetRow(it, ++it->y_); } return (0 < --it->count_down_); }
// initialize the job struct with some TODOs static void InitSegmentJob(VP8Encoder* const enc, SegmentJob* const job, int start_row, int end_row) { WebPGetWorkerInterface()->Init(&job->worker); job->worker.data1 = job; job->worker.data2 = &job->it; job->worker.hook = (WebPWorkerHook)DoSegmentsJob; VP8IteratorInit(enc, &job->it); VP8IteratorSetRow(&job->it, start_row); VP8IteratorSetCountDown(&job->it, (end_row - start_row) * enc->mb_w_); memset(job->alphas, 0, sizeof(job->alphas)); job->alpha = 0; job->uv_alpha = 0; // only one of both jobs can record the progress, since we don't // expect the user's hook to be multi-thread safe job->delta_progress = (start_row == 0) ? 20 : 0; }