Exemplo n.º 1
0
int VP8EncAnalyze(VP8Encoder* const enc) {
  int ok = 1;
  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->alpha_ = 0;
  enc->uv_alpha_ = 0;
  if (do_segments) {
    int alphas[MAX_ALPHA + 1] = { 0 };
    VP8EncIterator it;

    VP8IteratorInit(enc, &it);
    do {
      VP8IteratorImport(&it);
      MBAnalyze(&it, alphas, &enc->alpha_, &enc->uv_alpha_);
      ok = VP8IteratorProgress(&it, 20);
      // Let's pretend we have perfect lossless reconstruction.
    } while (ok && VP8IteratorNext(&it, it.yuv_in_));
    enc->alpha_ /= enc->mb_w_ * enc->mb_h_;
    enc->uv_alpha_ /= enc->mb_w_ * enc->mb_h_;
    if (ok) AssignSegments(enc, alphas);
  } else {   // Use only one default segment.
    ResetAllMBInfo(enc);
  }
  return ok;
}
Exemplo n.º 2
0
void VP8CodeIntraModes(VP8Encoder* const enc) {
  VP8BitWriter* const bw = &enc->bw_;
  VP8EncIterator it;
  VP8IteratorInit(enc, &it);
  do {
    const VP8MBInfo* const mb = it.mb_;
    const uint8_t* preds = it.preds_;
    if (enc->segment_hdr_.update_map_) {
      PutSegment(bw, mb->segment_, enc->proba_.segments_);
    }
    if (enc->proba_.use_skip_proba_) {
      VP8PutBit(bw, mb->skip_, enc->proba_.skip_proba_);
    }
    if (VP8PutBit(bw, (mb->type_ != 0), 145)) {  // i16x16
      PutI16Mode(bw, preds[0]);
    } else {
      const int preds_w = enc->preds_w_;
      const uint8_t* top_pred = preds - preds_w;
      int x, y;
      for (y = 0; y < 4; ++y) {
        int left = preds[-1];
        for (x = 0; x < 4; ++x) {
          const uint8_t* const probas = kBModesProba[top_pred[x]][left];
          left = PutI4Mode(bw, preds[x], probas);
        }
        top_pred = preds;
        preds += preds_w;
      }
    }
    PutUVMode(bw, mb->uv_mode_);
  } while (VP8IteratorNext(&it));
}
Exemplo n.º 3
0
int VP8EncAnalyze(VP8Encoder* const enc) {
  int ok = 1;
  const int do_segments =
      enc->config_->emulate_jpeg_size ||   
      (enc->segment_hdr_.num_segments_ > 1) ||
      (enc->method_ == 0);  
  enc->alpha_ = 0;
  enc->uv_alpha_ = 0;
  if (do_segments) {
    int alphas[MAX_ALPHA + 1] = { 0 };
    VP8EncIterator it;

    VP8IteratorInit(enc, &it);
    do {
      VP8IteratorImport(&it);
      MBAnalyze(&it, alphas, &enc->alpha_, &enc->uv_alpha_);
      ok = VP8IteratorProgress(&it, 20);
      
    } while (ok && VP8IteratorNext(&it, it.yuv_in_));
    enc->alpha_ /= enc->mb_w_ * enc->mb_h_;
    enc->uv_alpha_ /= enc->mb_w_ * enc->mb_h_;
    if (ok) AssignSegments(enc, alphas);
  } else {   
    ResetAllMBInfo(enc);
  }
  return ok;
}
Exemplo n.º 4
0
int VP8EncAnalyze(VP8Encoder* const enc) {
    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 };
        VP8EncIterator it;

        VP8IteratorInit(enc, &it);
        enc->uv_alpha_ = 0;
        do {
            VP8IteratorImport(&it);
            MBAnalyze(&it, alphas, &enc->uv_alpha_);
            ok = VP8IteratorProgress(&it, 20);
            // Let's pretend we have perfect lossless reconstruction.
        } while (ok && VP8IteratorNext(&it, it.yuv_in_));
        enc->uv_alpha_ /= enc->mb_w_ * enc->mb_h_;
        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;
}
Exemplo n.º 5
0
// main work call
static int DoSegmentsJob(SegmentJob* const job, VP8EncIterator* const it) {
  int ok = 1;
  if (!VP8IteratorIsDone(it)) {
    uint8_t tmp[32 + ALIGN_CST];
    uint8_t* const scratch = (uint8_t*)DO_ALIGN(tmp);
    do {
      // Let's pretend we have perfect lossless reconstruction.
      VP8IteratorImport(it, scratch);
      MBAnalyze(it, job->alphas, &job->alpha, &job->uv_alpha);
      ok = VP8IteratorProgress(it, job->delta_progress);
    } while (ok && VP8IteratorNext(it));
  }
  return ok;
}
Exemplo n.º 6
0
int VP8EncAnalyze(VP8Encoder* const enc) {
  int ok = 1;
  int alphas[256] = { 0 };
  VP8EncIterator it;

  VP8IteratorInit(enc, &it);
  enc->uv_alpha_ = 0;
  do {
    VP8IteratorImport(&it);
    MBAnalyze(&it, alphas, &enc->uv_alpha_);
    ok = VP8IteratorProgress(&it, 20);
    // Let's pretend we have perfect lossless reconstruction.
  } while (ok && VP8IteratorNext(&it, it.yuv_in_));
  enc->uv_alpha_ /= enc->mb_w_ * enc->mb_h_;
  if (ok) AssignSegments(enc, alphas);

  return ok;
}