Exemplo n.º 1
0
// Paragraph 9.9
void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec) {
  VP8Proba* const proba = &dec->proba_;
  int t, b, c, p;
  for (t = 0; t < NUM_TYPES; ++t) {
    for (b = 0; b < NUM_BANDS; ++b) {
      for (c = 0; c < NUM_CTX; ++c) {
        for (p = 0; p < NUM_PROBAS; ++p) {
          const int v = VP8GetBit(br, CoeffsUpdateProba[t][b][c][p]) ?
                        VP8GetValue(br, 8) : CoeffsProba0[t][b][c][p];
          proba->bands_[t][b].probas_[c][p] = v;
        }
      }
    }
  }
  dec->use_skip_proba_ = VP8Get(br);
  if (dec->use_skip_proba_) {
    dec->skip_p_ = VP8GetValue(br, 8);
  }
}
Exemplo n.º 2
0
// Paragraph 9.9
void VP8ParseProba(VP8BitReader* const br, VP8Decoder* const dec) {
  VP8Proba* const proba = &dec->proba_;
  int t, b, c, p;
  for (t = 0; t < NUM_TYPES; ++t) {
    for (b = 0; b < NUM_BANDS; ++b) {
      for (c = 0; c < NUM_CTX; ++c) {
        for (p = 0; p < NUM_PROBAS; ++p) {
          if (VP8GetBit(br, CoeffsUpdateProba[t][b][c][p])) {
            proba->coeffs_[t][b][c][p] = VP8GetValue(br, 8);
          }
        }
      }
    }
  }
  dec->use_skip_proba_ = VP8Get(br);
  if (dec->use_skip_proba_) {
    dec->skip_p_ = VP8GetValue(br, 8);
  }
#ifndef ONLY_KEYFRAME_CODE
  if (!dec->frm_hdr_.key_frame_) {
    int i;
    dec->intra_p_ = VP8GetValue(br, 8);
    dec->last_p_ = VP8GetValue(br, 8);
    dec->golden_p_ = VP8GetValue(br, 8);
    if (VP8Get(br)) {   // update y-mode
      for (i = 0; i < 4; ++i) {
        proba->ymode_[i] = VP8GetValue(br, 8);
      }
    }
    if (VP8Get(br)) {   // update uv-mode
      for (i = 0; i < 3; ++i) {
        proba->uvmode_[i] = VP8GetValue(br, 8);
      }
    }
    // update MV
    for (i = 0; i < 2; ++i) {
      int k;
      for (k = 0; k < NUM_MV_PROBAS; ++k) {
        if (VP8GetBit(br, MVUpdateProba[i][k])) {
          const int v = VP8GetValue(br, 7);
          proba->mv_[i][k] = v ? v << 1 : 1;
        }
      }
    }
  }
#endif
}
Exemplo n.º 3
0
void VP8ParseQuant(VP8Decoder* const dec) {
  VP8BitReader* const br = &dec->br_;
  const int base_q0 = VP8GetValue(br, 7);
  const int dqy1_dc = VP8Get(br) ? VP8GetSignedValue(br, 4) : 0;
  const int dqy2_dc = VP8Get(br) ? VP8GetSignedValue(br, 4) : 0;
  const int dqy2_ac = VP8Get(br) ? VP8GetSignedValue(br, 4) : 0;
  const int dquv_dc = VP8Get(br) ? VP8GetSignedValue(br, 4) : 0;
  const int dquv_ac = VP8Get(br) ? VP8GetSignedValue(br, 4) : 0;

  const VP8SegmentHeader* const hdr = &dec->segment_hdr_;
  int i;

  for (i = 0; i < NUM_MB_SEGMENTS; ++i) {
    int q;
    if (hdr->use_segment_) {
      q = hdr->quantizer_[i];
      if (!hdr->absolute_delta_) {
        q += base_q0;
      }
    } else {
      if (i > 0) {
        dec->dqm_[i] = dec->dqm_[0];
        continue;
      } else {
        q = base_q0;
      }
    }
    {
      VP8QuantMatrix* const m = &dec->dqm_[i];
      m->y1_mat_[0] = kDcTable[clip(q + dqy1_dc, 127)];
      m->y1_mat_[1] = kAcTable[clip(q + 0,       127)];

      m->y2_mat_[0] = kDcTable[clip(q + dqy2_dc, 127)] * 2;
      // For all x in [0..284], x*155/100 is bitwise equal to (x*101581) >> 16.
      // The smallest precision for that is '(x*6349) >> 12' but 16 is a good
      // word size.
      m->y2_mat_[1] = (kAcTable[clip(q + dqy2_ac, 127)] * 101581) >> 16;
      if (m->y2_mat_[1] < 8) m->y2_mat_[1] = 8;

      m->uv_mat_[0] = kDcTable[clip(q + dquv_dc, 117)];
      m->uv_mat_[1] = kAcTable[clip(q + dquv_ac, 127)];

      m->uv_quant_ = q + dquv_ac;   // for dithering strength evaluation
    }
  }
}
Exemplo n.º 4
0
int32_t VP8GetSignedValue(VP8BitReader* const br, int bits) {
  const int value = VP8GetValue(br, bits);
  return VP8Get(br) ? -value : value;
}