decodemv.c 40.9 KB
Newer Older
Jingning Han's avatar
Jingning Han committed
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jingning Han's avatar
Jingning Han committed
3
 *
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Jingning Han's avatar
Jingning Han committed
10 11 12 13
 */

#include <assert.h>

Yaowu Xu's avatar
Yaowu Xu committed
14 15 16 17 18 19 20 21
#include "av1/common/common.h"
#include "av1/common/entropy.h"
#include "av1/common/entropymode.h"
#include "av1/common/entropymv.h"
#include "av1/common/mvref_common.h"
#include "av1/common/pred_common.h"
#include "av1/common/reconinter.h"
#include "av1/common/seg_common.h"
Jingning Han's avatar
Jingning Han committed
22

Yaowu Xu's avatar
Yaowu Xu committed
23
#include "av1/decoder/decodeframe.h"
Jingning Han's avatar
Jingning Han committed
24
#include "av1/decoder/decodemv.h"
Jingning Han's avatar
Jingning Han committed
25

Adrian Grange's avatar
Adrian Grange committed
26
#include "aom_dsp/aom_dsp_common.h"
27

Michael Bebenita's avatar
Michael Bebenita committed
28 29
#define ACCT_STR __func__

30
#if CONFIG_DAALA_EC
31
static PREDICTION_MODE read_intra_mode(aom_reader *r, const aom_cdf_prob *cdf) {
32 33 34
  return (PREDICTION_MODE)
      av1_intra_mode_inv[aom_read_symbol(r, cdf, INTRA_MODES, ACCT_STR)];
}
35
#else
Adrian Grange's avatar
Adrian Grange committed
36
static PREDICTION_MODE read_intra_mode(aom_reader *r, const aom_prob *p) {
Michael Bebenita's avatar
Michael Bebenita committed
37
  return (PREDICTION_MODE)aom_read_tree(r, av1_intra_mode_tree, p, ACCT_STR);
Jingning Han's avatar
Jingning Han committed
38
}
39
#endif
Jingning Han's avatar
Jingning Han committed
40

41
static PREDICTION_MODE read_intra_mode_y(AV1_COMMON *cm, MACROBLOCKD *xd,
Adrian Grange's avatar
Adrian Grange committed
42
                                         aom_reader *r, int size_group) {
Jingning Han's avatar
Jingning Han committed
43
  const PREDICTION_MODE y_mode =
44
#if CONFIG_DAALA_EC
45
      read_intra_mode(r, cm->fc->y_mode_cdf[size_group]);
46
#else
Jingning Han's avatar
Jingning Han committed
47
      read_intra_mode(r, cm->fc->y_mode_prob[size_group]);
48
#endif
Jingning Han's avatar
Jingning Han committed
49
  FRAME_COUNTS *counts = xd->counts;
clang-format's avatar
clang-format committed
50
  if (counts) ++counts->y_mode[size_group][y_mode];
Jingning Han's avatar
Jingning Han committed
51 52 53
  return y_mode;
}

54
static PREDICTION_MODE read_intra_mode_uv(AV1_COMMON *cm, MACROBLOCKD *xd,
Adrian Grange's avatar
Adrian Grange committed
55
                                          aom_reader *r,
Jingning Han's avatar
Jingning Han committed
56
                                          PREDICTION_MODE y_mode) {
clang-format's avatar
clang-format committed
57
  const PREDICTION_MODE uv_mode =
58 59 60
#if CONFIG_DAALA_EC
      read_intra_mode(r, cm->fc->uv_mode_cdf[y_mode]);
#else
clang-format's avatar
clang-format committed
61
      read_intra_mode(r, cm->fc->uv_mode_prob[y_mode]);
62
#endif
Jingning Han's avatar
Jingning Han committed
63
  FRAME_COUNTS *counts = xd->counts;
clang-format's avatar
clang-format committed
64
  if (counts) ++counts->uv_mode[y_mode][uv_mode];
Jingning Han's avatar
Jingning Han committed
65 66 67
  return uv_mode;
}

68
static PREDICTION_MODE read_inter_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
69
                                       aom_reader *r, int16_t ctx) {
70 71
#if CONFIG_REF_MV
  FRAME_COUNTS *counts = xd->counts;
72
  int16_t mode_ctx = ctx & NEWMV_CTX_MASK;
73 74
  aom_prob mode_prob = cm->fc->newmv_prob[mode_ctx];

Michael Bebenita's avatar
Michael Bebenita committed
75
  if (aom_read(r, mode_prob, ACCT_STR) == 0) {
clang-format's avatar
clang-format committed
76
    if (counts) ++counts->newmv_mode[mode_ctx][0];
77 78
    return NEWMV;
  }
clang-format's avatar
clang-format committed
79
  if (counts) ++counts->newmv_mode[mode_ctx][1];
80

clang-format's avatar
clang-format committed
81
  if (ctx & (1 << ALL_ZERO_FLAG_OFFSET)) return ZEROMV;
82

83
  mode_ctx = (ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
84 85

  mode_prob = cm->fc->zeromv_prob[mode_ctx];
Michael Bebenita's avatar
Michael Bebenita committed
86
  if (aom_read(r, mode_prob, ACCT_STR) == 0) {
clang-format's avatar
clang-format committed
87
    if (counts) ++counts->zeromv_mode[mode_ctx][0];
88 89
    return ZEROMV;
  }
clang-format's avatar
clang-format committed
90
  if (counts) ++counts->zeromv_mode[mode_ctx][1];
91

92
  mode_ctx = (ctx >> REFMV_OFFSET) & REFMV_CTX_MASK;
93

clang-format's avatar
clang-format committed
94 95 96
  if (ctx & (1 << SKIP_NEARESTMV_OFFSET)) mode_ctx = 6;
  if (ctx & (1 << SKIP_NEARMV_OFFSET)) mode_ctx = 7;
  if (ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) mode_ctx = 8;
97

98
  mode_prob = cm->fc->refmv_prob[mode_ctx];
Jingning Han's avatar
Jingning Han committed
99
  if (aom_read(r, mode_prob, ACCT_STR) == 0) {
clang-format's avatar
clang-format committed
100
    if (counts) ++counts->refmv_mode[mode_ctx][0];
101 102
    return NEARESTMV;
  } else {
clang-format's avatar
clang-format committed
103
    if (counts) ++counts->refmv_mode[mode_ctx][1];
104 105 106 107 108
    return NEARMV;
  }

  // Invalid prediction mode.
  assert(0);
109 110 111 112
#else
#if CONFIG_DAALA_EC
  const int mode = av1_inter_mode_inv[aom_read_symbol(
      r, cm->fc->inter_mode_cdf[ctx], INTER_MODES, ACCT_STR)];
113
#else
Michael Bebenita's avatar
Michael Bebenita committed
114 115
  const int mode = aom_read_tree(r, av1_inter_mode_tree,
                                 cm->fc->inter_mode_probs[ctx], ACCT_STR);
116
#endif
Jingning Han's avatar
Jingning Han committed
117
  FRAME_COUNTS *counts = xd->counts;
clang-format's avatar
clang-format committed
118
  if (counts) ++counts->inter_mode[ctx][mode];
Jingning Han's avatar
Jingning Han committed
119 120

  return NEARESTMV + mode;
121
#endif
Jingning Han's avatar
Jingning Han committed
122 123
}

124
#if CONFIG_REF_MV
clang-format's avatar
clang-format committed
125 126
static void read_drl_idx(const AV1_COMMON *cm, MACROBLOCKD *xd,
                         MB_MODE_INFO *mbmi, aom_reader *r) {
127 128 129
  uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
  mbmi->ref_mv_idx = 0;

130 131 132 133 134 135
  if (mbmi->mode == NEWMV) {
    int idx;
    for (idx = 0; idx < 2; ++idx) {
      if (xd->ref_mv_count[ref_frame_type] > idx + 1) {
        uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx);
        aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
Jingning Han's avatar
Jingning Han committed
136
        if (!aom_read(r, drl_prob, ACCT_STR)) {
137
          mbmi->ref_mv_idx = idx;
clang-format's avatar
clang-format committed
138
          if (xd->counts) ++xd->counts->drl_mode[drl_ctx][0];
139 140 141
          return;
        }
        mbmi->ref_mv_idx = idx + 1;
clang-format's avatar
clang-format committed
142
        if (xd->counts) ++xd->counts->drl_mode[drl_ctx][1];
143 144 145 146
      }
    }
  }

147 148 149 150 151 152 153 154 155
  if (mbmi->mode == NEARMV) {
    int idx;
    // Offset the NEARESTMV mode.
    // TODO(jingning): Unify the two syntax decoding loops after the NEARESTMV
    // mode is factored in.
    for (idx = 1; idx < 3; ++idx) {
      if (xd->ref_mv_count[ref_frame_type] > idx + 1) {
        uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx);
        aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
Jingning Han's avatar
Jingning Han committed
156
        if (!aom_read(r, drl_prob, ACCT_STR)) {
157
          mbmi->ref_mv_idx = idx - 1;
clang-format's avatar
clang-format committed
158
          if (xd->counts) ++xd->counts->drl_mode[drl_ctx][0];
159 160
          return;
        }
161
        mbmi->ref_mv_idx = idx;
clang-format's avatar
clang-format committed
162
        if (xd->counts) ++xd->counts->drl_mode[drl_ctx][1];
163 164 165 166 167 168
      }
    }
  }
}
#endif

169 170 171 172 173 174 175
#if CONFIG_MOTION_VAR
static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
                                    MB_MODE_INFO *mbmi, aom_reader *r) {
  if (is_motion_variation_allowed(mbmi)) {
    int motion_mode;
    FRAME_COUNTS *counts = xd->counts;

Michael Bebenita's avatar
Michael Bebenita committed
176 177 178
    motion_mode =
        aom_read_tree(r, av1_motion_mode_tree,
                      cm->fc->motion_mode_prob[mbmi->sb_type], ACCT_STR);
179 180 181 182 183 184 185 186
    if (counts) ++counts->motion_mode[mbmi->sb_type][motion_mode];
    return (MOTION_MODE)(SIMPLE_TRANSLATION + motion_mode);
  } else {
    return SIMPLE_TRANSLATION;
  }
}
#endif  // CONFIG_MOTION_VAR

Adrian Grange's avatar
Adrian Grange committed
187
static int read_segment_id(aom_reader *r,
clang-format's avatar
clang-format committed
188
                           const struct segmentation_probs *segp) {
189
#if CONFIG_DAALA_EC
Michael Bebenita's avatar
Michael Bebenita committed
190
  return aom_read_symbol(r, segp->tree_cdf, MAX_SEGMENTS, ACCT_STR);
191
#else
Michael Bebenita's avatar
Michael Bebenita committed
192
  return aom_read_tree(r, av1_segment_tree, segp->tree_probs, ACCT_STR);
193
#endif
Jingning Han's avatar
Jingning Han committed
194 195
}

196
static TX_SIZE read_selected_tx_size(AV1_COMMON *cm, MACROBLOCKD *xd,
Adrian Grange's avatar
Adrian Grange committed
197
                                     TX_SIZE max_tx_size, aom_reader *r) {
Jingning Han's avatar
Jingning Han committed
198 199
  FRAME_COUNTS *counts = xd->counts;
  const int ctx = get_tx_size_context(xd);
Adrian Grange's avatar
Adrian Grange committed
200
  const aom_prob *tx_probs = get_tx_probs(max_tx_size, ctx, &cm->fc->tx_probs);
Michael Bebenita's avatar
Michael Bebenita committed
201
  TX_SIZE tx_size = aom_read(r, tx_probs[0], ACCT_STR) ? TX_8X8 : TX_4X4;
Jingning Han's avatar
Jingning Han committed
202
  if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) {
Michael Bebenita's avatar
Michael Bebenita committed
203
    tx_size += aom_read(r, tx_probs[1], ACCT_STR);
Jingning Han's avatar
Jingning Han committed
204
    if (tx_size != TX_8X8 && max_tx_size >= TX_32X32)
Michael Bebenita's avatar
Michael Bebenita committed
205
      tx_size += aom_read(r, tx_probs[2], ACCT_STR);
Jingning Han's avatar
Jingning Han committed
206 207
  }

clang-format's avatar
clang-format committed
208
  if (counts) ++get_tx_counts(max_tx_size, ctx, &counts->tx)[tx_size];
209
  return tx_size;
Jingning Han's avatar
Jingning Han committed
210 211
}

212
static TX_SIZE read_tx_size(AV1_COMMON *cm, MACROBLOCKD *xd, int allow_select,
Adrian Grange's avatar
Adrian Grange committed
213
                            aom_reader *r) {
Jingning Han's avatar
Jingning Han committed
214 215 216
  TX_MODE tx_mode = cm->tx_mode;
  BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
  const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
clang-format's avatar
clang-format committed
217
  if (xd->lossless[xd->mi[0]->mbmi.segment_id]) return TX_4X4;
Jingning Han's avatar
Jingning Han committed
218 219 220
  if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8)
    return read_selected_tx_size(cm, xd, max_tx_size, r);
  else
Adrian Grange's avatar
Adrian Grange committed
221
    return AOMMIN(max_tx_size, tx_mode_to_biggest_tx_size[tx_mode]);
Jingning Han's avatar
Jingning Han committed
222 223
}

224
static int dec_get_segment_id(const AV1_COMMON *cm, const uint8_t *segment_ids,
Jingning Han's avatar
Jingning Han committed
225 226 227 228 229
                              int mi_offset, int x_mis, int y_mis) {
  int x, y, segment_id = INT_MAX;

  for (y = 0; y < y_mis; y++)
    for (x = 0; x < x_mis; x++)
230
      segment_id =
Adrian Grange's avatar
Adrian Grange committed
231
          AOMMIN(segment_id, segment_ids[mi_offset + y * cm->mi_cols + x]);
Jingning Han's avatar
Jingning Han committed
232 233 234 235 236

  assert(segment_id >= 0 && segment_id < MAX_SEGMENTS);
  return segment_id;
}

237
static void set_segment_id(AV1_COMMON *cm, int mi_offset, int x_mis, int y_mis,
clang-format's avatar
clang-format committed
238
                           int segment_id) {
Jingning Han's avatar
Jingning Han committed
239 240 241 242 243 244 245 246 247
  int x, y;

  assert(segment_id >= 0 && segment_id < MAX_SEGMENTS);

  for (y = 0; y < y_mis; y++)
    for (x = 0; x < x_mis; x++)
      cm->current_frame_seg_map[mi_offset + y * cm->mi_cols + x] = segment_id;
}

248
static int read_intra_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
249
                                 int mi_offset, int x_mis, int y_mis,
Adrian Grange's avatar
Adrian Grange committed
250
                                 aom_reader *r) {
Jingning Han's avatar
Jingning Han committed
251
  struct segmentation *const seg = &cm->seg;
252 253 254 255 256 257
#if CONFIG_MISC_FIXES
  FRAME_COUNTS *counts = xd->counts;
  struct segmentation_probs *const segp = &cm->fc->seg;
#else
  struct segmentation_probs *const segp = &cm->segp;
#endif
Jingning Han's avatar
Jingning Han committed
258 259
  int segment_id;

260
#if !CONFIG_MISC_FIXES
clang-format's avatar
clang-format committed
261
  (void)xd;
262 263
#endif

clang-format's avatar
clang-format committed
264
  if (!seg->enabled) return 0;  // Default for disabled segmentation
Jingning Han's avatar
Jingning Han committed
265

266
  assert(seg->update_map && !seg->temporal_update);
Jingning Han's avatar
Jingning Han committed
267

268 269
  segment_id = read_segment_id(r, segp);
#if CONFIG_MISC_FIXES
clang-format's avatar
clang-format committed
270
  if (counts) ++counts->seg.tree_total[segment_id];
271
#endif
Jingning Han's avatar
Jingning Han committed
272 273 274 275
  set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
  return segment_id;
}

276
static void copy_segment_id(const AV1_COMMON *cm,
clang-format's avatar
clang-format committed
277 278 279
                            const uint8_t *last_segment_ids,
                            uint8_t *current_segment_ids, int mi_offset,
                            int x_mis, int y_mis) {
280 281 282 283
  int x, y;

  for (y = 0; y < y_mis; y++)
    for (x = 0; x < x_mis; x++)
clang-format's avatar
clang-format committed
284 285 286
      current_segment_ids[mi_offset + y * cm->mi_cols + x] =
          last_segment_ids ? last_segment_ids[mi_offset + y * cm->mi_cols + x]
                           : 0;
287 288
}

289
static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
Adrian Grange's avatar
Adrian Grange committed
290
                                 int mi_row, int mi_col, aom_reader *r) {
Jingning Han's avatar
Jingning Han committed
291
  struct segmentation *const seg = &cm->seg;
292 293 294 295 296 297
#if CONFIG_MISC_FIXES
  FRAME_COUNTS *counts = xd->counts;
  struct segmentation_probs *const segp = &cm->fc->seg;
#else
  struct segmentation_probs *const segp = &cm->segp;
#endif
Jingning Han's avatar
Jingning Han committed
298 299 300 301 302 303 304
  MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
  int predicted_segment_id, segment_id;
  const int mi_offset = mi_row * cm->mi_cols + mi_col;
  const int bw = xd->plane[0].n4_w >> 1;
  const int bh = xd->plane[0].n4_h >> 1;

  // TODO(slavarnway): move x_mis, y_mis into xd ?????
Adrian Grange's avatar
Adrian Grange committed
305 306
  const int x_mis = AOMMIN(cm->mi_cols - mi_col, bw);
  const int y_mis = AOMMIN(cm->mi_rows - mi_row, bh);
Jingning Han's avatar
Jingning Han committed
307

clang-format's avatar
clang-format committed
308
  if (!seg->enabled) return 0;  // Default for disabled segmentation
Jingning Han's avatar
Jingning Han committed
309

clang-format's avatar
clang-format committed
310 311 312 313
  predicted_segment_id = cm->last_frame_seg_map
                             ? dec_get_segment_id(cm, cm->last_frame_seg_map,
                                                  mi_offset, x_mis, y_mis)
                             : 0;
Jingning Han's avatar
Jingning Han committed
314 315 316 317 318 319 320 321

  if (!seg->update_map) {
    copy_segment_id(cm, cm->last_frame_seg_map, cm->current_frame_seg_map,
                    mi_offset, x_mis, y_mis);
    return predicted_segment_id;
  }

  if (seg->temporal_update) {
322
    const int ctx = av1_get_pred_context_seg_id(xd);
Adrian Grange's avatar
Adrian Grange committed
323
    const aom_prob pred_prob = segp->pred_probs[ctx];
Michael Bebenita's avatar
Michael Bebenita committed
324
    mbmi->seg_id_predicted = aom_read(r, pred_prob, ACCT_STR);
325
#if CONFIG_MISC_FIXES
clang-format's avatar
clang-format committed
326
    if (counts) ++counts->seg.pred[ctx][mbmi->seg_id_predicted];
327 328 329 330 331 332
#endif
    if (mbmi->seg_id_predicted) {
      segment_id = predicted_segment_id;
    } else {
      segment_id = read_segment_id(r, segp);
#if CONFIG_MISC_FIXES
clang-format's avatar
clang-format committed
333
      if (counts) ++counts->seg.tree_mispred[segment_id];
334 335
#endif
    }
Jingning Han's avatar
Jingning Han committed
336
  } else {
337 338
    segment_id = read_segment_id(r, segp);
#if CONFIG_MISC_FIXES
clang-format's avatar
clang-format committed
339
    if (counts) ++counts->seg.tree_total[segment_id];
340
#endif
Jingning Han's avatar
Jingning Han committed
341 342 343 344 345
  }
  set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
  return segment_id;
}

346
static int read_skip(AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
Adrian Grange's avatar
Adrian Grange committed
347
                     aom_reader *r) {
Jingning Han's avatar
Jingning Han committed
348 349 350
  if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
    return 1;
  } else {
351
    const int ctx = av1_get_skip_context(xd);
Michael Bebenita's avatar
Michael Bebenita committed
352
    const int skip = aom_read(r, cm->fc->skip_probs[ctx], ACCT_STR);
Jingning Han's avatar
Jingning Han committed
353
    FRAME_COUNTS *counts = xd->counts;
clang-format's avatar
clang-format committed
354
    if (counts) ++counts->skip[ctx][skip];
Jingning Han's avatar
Jingning Han committed
355 356 357 358
    return skip;
  }
}

359
#if CONFIG_EXT_INTRA || CONFIG_PALETTE
hui su's avatar
hui su committed
360 361 362
static INLINE int read_uniform(aom_reader *r, int n) {
  const int l = get_unsigned_bits(n);
  const int m = (1 << l) - n;
Michael Bebenita's avatar
Michael Bebenita committed
363
  const int v = aom_read_literal(r, l - 1, ACCT_STR);
hui su's avatar
hui su committed
364 365

  assert(l != 0);
366
  return (v < m) ? v : ((v << 1) - m + aom_read_literal(r, 1, ACCT_STR));
hui su's avatar
hui su committed
367
}
368
#endif  // CONFIG_EXT_INTRA || CONFIG_PALETTE
hui su's avatar
hui su committed
369

370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
#if CONFIG_PALETTE
static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
                                   aom_reader *r) {
  MODE_INFO *const mi = xd->mi[0];
  MB_MODE_INFO *const mbmi = &mi->mbmi;
  const MODE_INFO *const above_mi = xd->above_mi;
  const MODE_INFO *const left_mi = xd->left_mi;
  const BLOCK_SIZE bsize = mbmi->sb_type;
  int i, n, palette_ctx = 0;
  PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;

  if (mbmi->mode == DC_PRED) {
    if (above_mi)
      palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0);
    if (left_mi)
      palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
    if (aom_read(
387 388
            r, av1_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx],
            ACCT_STR)) {
389 390
      pmi->palette_size[0] =
          aom_read_tree(r, av1_palette_size_tree,
391 392
                        av1_default_palette_y_size_prob[bsize - BLOCK_8X8],
                        ACCT_STR) +
393 394 395
          2;
      n = pmi->palette_size[0];
      for (i = 0; i < n; ++i)
396
        pmi->palette_colors[i] = aom_read_literal(r, cm->bit_depth, ACCT_STR);
397 398 399 400 401
      xd->plane[0].color_index_map[0] = read_uniform(r, n);
      assert(xd->plane[0].color_index_map[0] < n);
    }
  }
  if (mbmi->uv_mode == DC_PRED) {
402 403
    if (aom_read(r, av1_default_palette_uv_mode_prob[pmi->palette_size[0] > 0],
                 ACCT_STR)) {
404 405
      pmi->palette_size[1] =
          aom_read_tree(r, av1_palette_size_tree,
406 407
                        av1_default_palette_uv_size_prob[bsize - BLOCK_8X8],
                        ACCT_STR) +
408 409 410 411
          2;
      n = pmi->palette_size[1];
      for (i = 0; i < n; ++i) {
        pmi->palette_colors[PALETTE_MAX_SIZE + i] =
412
            aom_read_literal(r, cm->bit_depth, ACCT_STR);
413
        pmi->palette_colors[2 * PALETTE_MAX_SIZE + i] =
414
            aom_read_literal(r, cm->bit_depth, ACCT_STR);
415 416 417 418 419 420 421 422 423
      }
      xd->plane[1].color_index_map[0] = read_uniform(r, n);
      assert(xd->plane[1].color_index_map[0] < n);
    }
  }
}
#endif  // CONFIG_PALETTE

#if CONFIG_EXT_INTRA
hui su's avatar
hui su committed
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
static void read_intra_angle_info(MB_MODE_INFO *const mbmi, aom_reader *r) {
  mbmi->intra_angle_delta[0] = 0;
  mbmi->intra_angle_delta[1] = 0;
  if (mbmi->sb_type < BLOCK_8X8) return;

  if (is_directional_mode(mbmi->mode)) {
    const TX_SIZE max_tx_size = max_txsize_lookup[mbmi->sb_type];
    const int max_angle_delta = av1_max_angle_delta_y[max_tx_size][mbmi->mode];
    mbmi->intra_angle_delta[0] =
        read_uniform(r, 2 * max_angle_delta + 1) - max_angle_delta;
  }

  if (is_directional_mode(mbmi->uv_mode)) {
    mbmi->intra_angle_delta[1] =
        read_uniform(r, 2 * MAX_ANGLE_DELTA_UV + 1) - MAX_ANGLE_DELTA_UV;
  }
}
#endif  // CONFIG_EXT_INTRA

443
static void read_intra_frame_mode_info(AV1_COMMON *const cm,
clang-format's avatar
clang-format committed
444
                                       MACROBLOCKD *const xd, int mi_row,
Adrian Grange's avatar
Adrian Grange committed
445
                                       int mi_col, aom_reader *r) {
Jingning Han's avatar
Jingning Han committed
446 447 448
  MODE_INFO *const mi = xd->mi[0];
  MB_MODE_INFO *const mbmi = &mi->mbmi;
  const MODE_INFO *above_mi = xd->above_mi;
clang-format's avatar
clang-format committed
449
  const MODE_INFO *left_mi = xd->left_mi;
Jingning Han's avatar
Jingning Han committed
450 451 452 453 454 455 456
  const BLOCK_SIZE bsize = mbmi->sb_type;
  int i;
  const int mi_offset = mi_row * cm->mi_cols + mi_col;
  const int bw = xd->plane[0].n4_w >> 1;
  const int bh = xd->plane[0].n4_h >> 1;

  // TODO(slavarnway): move x_mis, y_mis into xd ?????
Adrian Grange's avatar
Adrian Grange committed
457 458
  const int x_mis = AOMMIN(cm->mi_cols - mi_col, bw);
  const int y_mis = AOMMIN(cm->mi_rows - mi_row, bh);
Jingning Han's avatar
Jingning Han committed
459

460
  mbmi->segment_id = read_intra_segment_id(cm, xd, mi_offset, x_mis, y_mis, r);
Jingning Han's avatar
Jingning Han committed
461 462 463 464 465 466 467 468 469
  mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
  mbmi->tx_size = read_tx_size(cm, xd, 1, r);
  mbmi->ref_frame[0] = INTRA_FRAME;
  mbmi->ref_frame[1] = NONE;

  switch (bsize) {
    case BLOCK_4X4:
      for (i = 0; i < 4; ++i)
        mi->bmi[i].as_mode =
470
#if CONFIG_DAALA_EC
471
            read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, i));
472
#else
473
            read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, i));
474
#endif
Jingning Han's avatar
Jingning Han committed
475 476 477 478
      mbmi->mode = mi->bmi[3].as_mode;
      break;
    case BLOCK_4X8:
      mi->bmi[0].as_mode = mi->bmi[2].as_mode =
479
#if CONFIG_DAALA_EC
480
          read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
481
#else
482
          read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
483
#endif
Jingning Han's avatar
Jingning Han committed
484
      mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode =
485
#if CONFIG_DAALA_EC
486
          read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 1));
487
#else
488
          read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 1));
489
#endif
Jingning Han's avatar
Jingning Han committed
490 491 492
      break;
    case BLOCK_8X4:
      mi->bmi[0].as_mode = mi->bmi[1].as_mode =
493
#if CONFIG_DAALA_EC
494
          read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
495
#else
496
          read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
497
#endif
Jingning Han's avatar
Jingning Han committed
498
      mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode =
499
#if CONFIG_DAALA_EC
500
          read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 2));
501
#else
502
          read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 2));
503
#endif
Jingning Han's avatar
Jingning Han committed
504 505
      break;
    default:
clang-format's avatar
clang-format committed
506
      mbmi->mode =
507
#if CONFIG_DAALA_EC
508
          read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
509
#else
clang-format's avatar
clang-format committed
510
          read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
511
#endif
Jingning Han's avatar
Jingning Han committed
512 513
  }

514
  mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
hui su's avatar
hui su committed
515 516 517
#if CONFIG_EXT_INTRA
  read_intra_angle_info(mbmi, r);
#endif  // CONFIG_EXT_INTRA
518

519 520 521 522 523 524 525
#if CONFIG_PALETTE
  mbmi->palette_mode_info.palette_size[0] = 0;
  mbmi->palette_mode_info.palette_size[1] = 0;
  if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
    read_palette_mode_info(cm, xd, r);
#endif  // CONFIG_PALETTE

clang-format's avatar
clang-format committed
526
  if (mbmi->tx_size < TX_32X32 && cm->base_qindex > 0 && !mbmi->skip &&
527 528 529
      !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
    FRAME_COUNTS *counts = xd->counts;
    TX_TYPE tx_type_nom = intra_mode_to_tx_type_context[mbmi->mode];
530 531 532 533 534
#if CONFIG_DAALA_EC
    mbmi->tx_type = av1_ext_tx_inv[aom_read_symbol(
        r, cm->fc->intra_ext_tx_cdf[mbmi->tx_size][tx_type_nom], TX_TYPES,
        ACCT_STR)];
#else
Michael Bebenita's avatar
Michael Bebenita committed
535 536 537
    mbmi->tx_type = aom_read_tree(
        r, av1_ext_tx_tree,
        cm->fc->intra_ext_tx_prob[mbmi->tx_size][tx_type_nom], ACCT_STR);
538
#endif
539 540 541 542 543
    if (counts)
      ++counts->intra_ext_tx[mbmi->tx_size][tx_type_nom][mbmi->tx_type];
  } else {
    mbmi->tx_type = DCT_DCT;
  }
Jingning Han's avatar
Jingning Han committed
544 545
}

Adrian Grange's avatar
Adrian Grange committed
546
static int read_mv_component(aom_reader *r, const nmv_component *mvcomp,
clang-format's avatar
clang-format committed
547
                             int usehp) {
Jingning Han's avatar
Jingning Han committed
548
  int mag, d, fr, hp;
Michael Bebenita's avatar
Michael Bebenita committed
549 550
  const int sign = aom_read(r, mvcomp->sign, ACCT_STR);
  const int mv_class =
551 552 553
#if CONFIG_DAALA_EC
      aom_read_symbol(r, mvcomp->class_cdf, MV_CLASSES, ACCT_STR);
#else
Michael Bebenita's avatar
Michael Bebenita committed
554
      aom_read_tree(r, av1_mv_class_tree, mvcomp->classes, ACCT_STR);
555
#endif
Jingning Han's avatar
Jingning Han committed
556 557 558 559
  const int class0 = mv_class == MV_CLASS_0;

  // Integer part
  if (class0) {
560
    d = aom_read(r, mvcomp->class0[0], ACCT_STR);
Jingning Han's avatar
Jingning Han committed
561 562 563 564 565 566
    mag = 0;
  } else {
    int i;
    const int n = mv_class + CLASS0_BITS - 1;  // number of bits

    d = 0;
Michael Bebenita's avatar
Michael Bebenita committed
567
    for (i = 0; i < n; ++i) d |= aom_read(r, mvcomp->bits[i], ACCT_STR) << i;
Jingning Han's avatar
Jingning Han committed
568 569 570 571
    mag = CLASS0_SIZE << (mv_class + 2);
  }

  // Fractional part
572
  fr = aom_read_tree(r, av1_mv_fp_tree,
Michael Bebenita's avatar
Michael Bebenita committed
573
                     class0 ? mvcomp->class0_fp[d] : mvcomp->fp, ACCT_STR);
Jingning Han's avatar
Jingning Han committed
574 575

  // High precision part (if hp is not used, the default value of the hp is 1)
Michael Bebenita's avatar
Michael Bebenita committed
576 577
  hp = usehp ? aom_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp, ACCT_STR)
             : 1;
Jingning Han's avatar
Jingning Han committed
578 579 580 581 582 583

  // Result
  mag += ((d << 3) | (fr << 1) | hp) + 1;
  return sign ? -mag : mag;
}

Adrian Grange's avatar
Adrian Grange committed
584
static INLINE void read_mv(aom_reader *r, MV *mv, const MV *ref,
clang-format's avatar
clang-format committed
585 586
                           const nmv_context *ctx, nmv_context_counts *counts,
                           int allow_hp) {
Jingning Han's avatar
Jingning Han committed
587
  const MV_JOINT_TYPE joint_type =
588 589 590
#if CONFIG_DAALA_EC
      (MV_JOINT_TYPE)aom_read_symbol(r, ctx->joint_cdf, MV_JOINTS, ACCT_STR);
#else
Michael Bebenita's avatar
Michael Bebenita committed
591
      (MV_JOINT_TYPE)aom_read_tree(r, av1_mv_joint_tree, ctx->joints, ACCT_STR);
592
#endif
593
  const int use_hp = allow_hp && av1_use_mv_hp(ref);
clang-format's avatar
clang-format committed
594
  MV diff = { 0, 0 };
Jingning Han's avatar
Jingning Han committed
595 596 597 598 599 600 601

  if (mv_joint_vertical(joint_type))
    diff.row = read_mv_component(r, &ctx->comps[0], use_hp);

  if (mv_joint_horizontal(joint_type))
    diff.col = read_mv_component(r, &ctx->comps[1], use_hp);

602
  av1_inc_mv(&diff, counts, use_hp);
Jingning Han's avatar
Jingning Han committed
603 604 605 606 607

  mv->row = ref->row + diff.row;
  mv->col = ref->col + diff.col;
}

608
static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm,
Jingning Han's avatar
Jingning Han committed
609
                                                const MACROBLOCKD *xd,
Adrian Grange's avatar
Adrian Grange committed
610
                                                aom_reader *r) {
Jingning Han's avatar
Jingning Han committed
611
  if (cm->reference_mode == REFERENCE_MODE_SELECT) {
612
    const int ctx = av1_get_reference_mode_context(cm, xd);
Jingning Han's avatar
Jingning Han committed
613
    const REFERENCE_MODE mode =
Michael Bebenita's avatar
Michael Bebenita committed
614
        (REFERENCE_MODE)aom_read(r, cm->fc->comp_inter_prob[ctx], ACCT_STR);
Jingning Han's avatar
Jingning Han committed
615
    FRAME_COUNTS *counts = xd->counts;
clang-format's avatar
clang-format committed
616
    if (counts) ++counts->comp_inter[ctx][mode];
Jingning Han's avatar
Jingning Han committed
617 618 619 620 621 622 623
    return mode;  // SINGLE_REFERENCE or COMPOUND_REFERENCE
  } else {
    return cm->reference_mode;
  }
}

// Read the referncence frame
624
static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
Adrian Grange's avatar
Adrian Grange committed
625
                            aom_reader *r, int segment_id,
clang-format's avatar
clang-format committed
626
                            MV_REFERENCE_FRAME ref_frame[2]) {
Jingning Han's avatar
Jingning Han committed
627 628 629 630 631 632 633 634 635 636 637
  FRAME_CONTEXT *const fc = cm->fc;
  FRAME_COUNTS *counts = xd->counts;

  if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
    ref_frame[0] = (MV_REFERENCE_FRAME)get_segdata(&cm->seg, segment_id,
                                                   SEG_LVL_REF_FRAME);
    ref_frame[1] = NONE;
  } else {
    const REFERENCE_MODE mode = read_block_reference_mode(cm, xd, r);
    // FIXME(rbultje) I'm pretty sure this breaks segmentation ref frame coding
    if (mode == COMPOUND_REFERENCE) {
638 639
#if CONFIG_EXT_REFS
      const int idx = cm->ref_frame_sign_bias[cm->comp_bwd_ref[0]];
640
      // Read forward references.
641
      const int ctx_fwd = av1_get_pred_context_comp_fwdref_p(cm, xd);
Michael Bebenita's avatar
Michael Bebenita committed
642 643
      const int bit_fwd =
          aom_read(r, fc->comp_fwdref_prob[ctx_fwd][0], ACCT_STR);
644 645 646
      if (counts) ++counts->comp_fwdref[ctx_fwd][0][bit_fwd];
      if (!bit_fwd) {
        const int ctx_fwd1 = av1_get_pred_context_comp_fwdref_p1(cm, xd);
Michael Bebenita's avatar
Michael Bebenita committed
647 648
        const int bit_fwd1 =
            aom_read(r, fc->comp_fwdref_prob[ctx_fwd1][1], ACCT_STR);
649 650 651 652
        if (counts) ++counts->comp_fwdref[ctx_fwd1][1][bit_fwd1];
        ref_frame[!idx] = cm->comp_fwd_ref[bit_fwd1 ? 0 : 1];
      } else {
        const int ctx_fwd2 = av1_get_pred_context_comp_fwdref_p2(cm, xd);
Michael Bebenita's avatar
Michael Bebenita committed
653 654
        const int bit_fwd2 =
            aom_read(r, fc->comp_fwdref_prob[ctx_fwd2][2], ACCT_STR);
655 656 657
        if (counts) ++counts->comp_fwdref[ctx_fwd2][2][bit_fwd2];
        ref_frame[!idx] = cm->comp_fwd_ref[bit_fwd2 ? 3 : 2];
      }
658 659 660
      // Read backward references.
      {
        const int ctx_bwd = av1_get_pred_context_comp_bwdref_p(cm, xd);
Michael Bebenita's avatar
Michael Bebenita committed
661 662
        const int bit_bwd =
            aom_read(r, fc->comp_bwdref_prob[ctx_bwd][0], ACCT_STR);
663 664 665
        if (counts) ++counts->comp_bwdref[ctx_bwd][0][bit_bwd];
        ref_frame[idx] = cm->comp_bwd_ref[bit_bwd];
      }
666
#else
Jingning Han's avatar
Jingning Han committed
667
      const int idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
668
      const int ctx = av1_get_pred_context_comp_ref_p(cm, xd);
Michael Bebenita's avatar
Michael Bebenita committed
669
      const int bit = aom_read(r, fc->comp_ref_prob[ctx], ACCT_STR);
clang-format's avatar
clang-format committed
670
      if (counts) ++counts->comp_ref[ctx][bit];
Jingning Han's avatar
Jingning Han committed
671 672
      ref_frame[idx] = cm->comp_fixed_ref;
      ref_frame[!idx] = cm->comp_var_ref[bit];
673
#endif  // CONFIG_EXT_REFS
Jingning Han's avatar
Jingning Han committed
674
    } else if (mode == SINGLE_REFERENCE) {
675 676
#if CONFIG_EXT_REFS
      const int ctx0 = av1_get_pred_context_single_ref_p1(xd);
Michael Bebenita's avatar
Michael Bebenita committed
677
      const int bit0 = aom_read(r, fc->single_ref_prob[ctx0][0], ACCT_STR);
678 679 680
      if (counts) ++counts->single_ref[ctx0][0][bit0];
      if (bit0) {
        const int ctx1 = av1_get_pred_context_single_ref_p2(xd);
Michael Bebenita's avatar
Michael Bebenita committed
681
        const int bit1 = aom_read(r, fc->single_ref_prob[ctx1][1], ACCT_STR);
682 683 684 685
        if (counts) ++counts->single_ref[ctx1][1][bit1];
        ref_frame[0] = bit1 ? ALTREF_FRAME : BWDREF_FRAME;
      } else {
        const int ctx2 = av1_get_pred_context_single_ref_p3(xd);
Michael Bebenita's avatar
Michael Bebenita committed
686
        const int bit2 = aom_read(r, fc->single_ref_prob[ctx2][2], ACCT_STR);
687
        if (counts) ++counts->single_ref[ctx2][2][bit2];
688
        if (!bit2) {
689
          const int ctx3 = av1_get_pred_context_single_ref_p4(xd);
Michael Bebenita's avatar
Michael Bebenita committed
690
          const int bit3 = aom_read(r, fc->single_ref_prob[ctx3][3], ACCT_STR);
691 692
          if (counts) ++counts->single_ref[ctx3][3][bit3];
          ref_frame[0] = bit3 ? LAST2_FRAME : LAST_FRAME;
693 694
        } else {
          const int ctx4 = av1_get_pred_context_single_ref_p5(xd);
Michael Bebenita's avatar
Michael Bebenita committed
695
          const int bit4 = aom_read(r, fc->single_ref_prob[ctx4][4], ACCT_STR);
696 697
          if (counts) ++counts->single_ref[ctx4][4][bit4];
          ref_frame[0] = bit4 ? GOLDEN_FRAME : LAST3_FRAME;
698 699 700
        }
      }
#else
701
      const int ctx0 = av1_get_pred_context_single_ref_p1(xd);
Michael Bebenita's avatar
Michael Bebenita committed
702
      const int bit0 = aom_read(r, fc->single_ref_prob[ctx0][0], ACCT_STR);
clang-format's avatar
clang-format committed
703
      if (counts) ++counts->single_ref[ctx0][0][bit0];
Jingning Han's avatar
Jingning Han committed
704
      if (bit0) {
705
        const int ctx1 = av1_get_pred_context_single_ref_p2(xd);
Michael Bebenita's avatar
Michael Bebenita committed
706
        const int bit1 = aom_read(r, fc->single_ref_prob[ctx1][1], ACCT_STR);
clang-format's avatar
clang-format committed
707
        if (counts) ++counts->single_ref[ctx1][1][bit1];
Jingning Han's avatar
Jingning Han committed
708 709 710 711
        ref_frame[0] = bit1 ? ALTREF_FRAME : GOLDEN_FRAME;
      } else {
        ref_frame[0] = LAST_FRAME;
      }
712
#endif  // CONFIG_EXT_REFS
Jingning Han's avatar
Jingning Han committed
713 714 715 716 717 718 719 720

      ref_frame[1] = NONE;
    } else {
      assert(0 && "Invalid prediction mode.");
    }
  }
}

James Zern's avatar
James Zern committed
721 722 723
static INLINE InterpFilter read_switchable_interp_filter(AV1_COMMON *const cm,
                                                         MACROBLOCKD *const xd,
                                                         aom_reader *r) {
724 725 726 727 728 729
  if (cm->interp_filter == SWITCHABLE) {
#if CONFIG_EXT_INTERP
    if (is_interp_needed(xd))
#endif
    {
      const int ctx = av1_get_pred_context_switchable_interp(xd);
730 731
#if CONFIG_DAALA_EC
      const InterpFilter type =
732
          (InterpFilter)av1_switchable_interp_inv[aom_read_symbol(
Michael Bebenita's avatar
Michael Bebenita committed
733 734
              r, cm->fc->switchable_interp_cdf[ctx], SWITCHABLE_FILTERS,
              ACCT_STR)];
735
#else
736
      const InterpFilter type = (InterpFilter)aom_read_tree(
Michael Bebenita's avatar
Michael Bebenita committed
737 738
          r, av1_switchable_interp_tree, cm->fc->switchable_interp_prob[ctx],
          ACCT_STR);
739
#endif
740 741 742 743 744 745 746 747
      FRAME_COUNTS *counts = xd->counts;
      if (counts) ++counts->switchable_interp[ctx][type];
      return type;
    }
    return EIGHTTAP;
  } else {
    return cm->interp_filter;
  }
Jingning Han's avatar
Jingning Han committed
748 749
}

750
static void read_intra_block_mode_info(AV1_COMMON *const cm,
Jingning Han's avatar
Jingning Han committed
751
                                       MACROBLOCKD *const xd, MODE_INFO *mi,
Adrian Grange's avatar
Adrian Grange committed
752
                                       aom_reader *r) {
Jingning Han's avatar
Jingning Han committed
753 754 755 756 757 758 759 760 761 762 763 764 765 766
  MB_MODE_INFO *const mbmi = &mi->mbmi;
  const BLOCK_SIZE bsize = mi->mbmi.sb_type;
  int i;

  mbmi->ref_frame[0] = INTRA_FRAME;
  mbmi->ref_frame[1] = NONE;

  switch (bsize) {
    case BLOCK_4X4:
      for (i = 0; i < 4; ++i)
        mi->bmi[i].as_mode = read_intra_mode_y(cm, xd, r, 0);
      mbmi->mode = mi->bmi[3].as_mode;
      break;
    case BLOCK_4X8:
clang-format's avatar
clang-format committed
767
      mi->bmi[0].as_mode = mi->bmi[2].as_mode = read_intra_mode_y(cm, xd, r, 0);
Jingning Han's avatar
Jingning Han committed
768 769 770 771
      mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode =
          read_intra_mode_y(cm, xd, r, 0);
      break;
    case BLOCK_8X4:
clang-format's avatar
clang-format committed
772
      mi->bmi[0].as_mode = mi->bmi[1].as_mode = read_intra_mode_y(cm, xd, r, 0);
Jingning Han's avatar
Jingning Han committed
773 774 775 776 777 778 779 780
      mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode =
          read_intra_mode_y(cm, xd, r, 0);
      break;
    default:
      mbmi->mode = read_intra_mode_y(cm, xd, r, size_group_lookup[bsize]);
  }

  mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
781 782 783 784 785 786 787
#if CONFIG_PALETTE
  mbmi->palette_mode_info.palette_size[0] = 0;
  mbmi->palette_mode_info.palette_size[1] = 0;
  if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
    read_palette_mode_info(cm, xd, r);
#endif  // CONFIG_PALETTE

hui su's avatar
hui su committed
788 789 790
#if CONFIG_EXT_INTRA
  read_intra_angle_info(mbmi, r);
#endif  // CONFIG_EXT_INTRA
Jingning Han's avatar
Jingning Han committed
791 792 793
}

static INLINE int is_mv_valid(const MV *mv) {