vp9_decodframe.c 35.2 KB
Newer Older

  xd->lossless = pc->base_qindex == 0 &&
                 pc->y_dc_delta_q == 0 &&
                 pc->uv_dc_delta_q == 0 &&
                 pc->uv_ac_delta_q == 0;
  if (xd->lossless) {
    xd->itxm_add          = vp9_idct_add_lossless_c;
    xd->itxm_add_y_block  = vp9_idct_add_y_block_lossless_c;
    xd->itxm_add_uv_block = vp9_idct_add_uv_block_lossless_c;
  } else {
    xd->itxm_add          = vp9_idct_add;
    xd->itxm_add_y_block  = vp9_idct_add_y_block;
    xd->itxm_add_uv_block = vp9_idct_add_uv_block;
  }
    vp9_setup_interp_filters(xd, pc->mcomp_filter_type, pc);
John Koleszar's avatar
John Koleszar committed

  pc->fc = pc->frame_contexts[pc->frame_context_idx];
John Koleszar's avatar
John Koleszar committed

  setup_segmentation(pc, xd, &header_bc);

  setup_txfm_mode(pc, xd->lossless, &header_bc);
  update_frame_context(&pc->fc);
Yaowu Xu's avatar
Yaowu Xu committed

  // Initialize xd pointers. Any reference should do for xd->pre, so use 0.
  setup_pre_planes(xd, &pc->yv12_fb[pc->active_ref_idx[0]], NULL,
                   0, 0, NULL, NULL);
  setup_dst_planes(xd, new_fb, 0, 0);
John Koleszar's avatar
John Koleszar committed
  // Create the segmentation map structure and set to 0
  if (!pc->last_frame_seg_map)
    CHECK_MEM_ERROR(pc->last_frame_seg_map,
                    vpx_calloc((pc->mi_rows * pc->mi_cols), 1));
  vp9_setup_block_dptrs(xd, pc->subsampling_x, pc->subsampling_y);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
  // clear out the coeff buffer
  for (i = 0; i < MAX_MB_PLANE; ++i)
    vp9_zero(xd->plane[i].qcoeff);
  vp9_decode_mode_mvs_init(pbi, &header_bc);
  decode_tiles(pbi, data, first_partition_size, &header_bc, &residual_bc);
John Koleszar's avatar
John Koleszar committed

  pc->last_width = pc->width;
  pc->last_height = pc->height;
  new_fb->corrupted = vp9_reader_has_error(&header_bc) | xd->corrupted;
John Koleszar's avatar
John Koleszar committed

  if (!pbi->decoded_key_frame) {
    if (keyframe && !new_fb->corrupted)
John Koleszar's avatar
John Koleszar committed
      pbi->decoded_key_frame = 1;
    else
      vpx_internal_error(&pc->error, VPX_CODEC_CORRUPT_FRAME,
John Koleszar's avatar
John Koleszar committed
                         "A stream must start with a complete key frame");
  }
  if (!pc->error_resilient_mode && !pc->frame_parallel_decoding_mode) {
    vp9_adapt_coef_probs(pc);
      vp9_adapt_mode_probs(pc);
      vp9_adapt_nmv_probs(pc, xd->allow_high_precision_mv);
John Koleszar's avatar
John Koleszar committed
  }
  if (pc->refresh_frame_context)
    pc->frame_contexts[pc->frame_context_idx] = pc->fc;
  *p_data_end = vp9_reader_find_end(&residual_bc);
John Koleszar's avatar
John Koleszar committed
  return 0;
John Koleszar's avatar
John Koleszar committed
}