Esempio 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;
}
Esempio n. 2
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;
}