mi_col + mi_pos->col < tile->mi_col_start ||
mi_row + mi_pos->row >= mi_rows ||
mi_col + mi_pos->col >= tile->mi_col_end);
+#endif // CONFIG_EXT_TILE
+}
+
+static INLINE void lower_mv_precision(MV *mv, int allow_hp) {
+ const int use_hp = allow_hp && vp10_use_mv_hp(mv);
+ if (!use_hp) {
+ if (mv->row & 1)
+ mv->row += (mv->row > 0 ? -1 : 1);
+ if (mv->col & 1)
+ mv->col += (mv->col > 0 ? -1 : 1);
+ }
}
- if (ref_mv_stack[ref_idx].weight > REF_CAT_LEVEL &&
- ref_mv_stack[ref_idx + 1].weight > REF_CAT_LEVEL) {
+#if CONFIG_REF_MV
+static INLINE int vp10_nmv_ctx(const uint8_t ref_mv_count,
+ const CANDIDATE_MV *ref_mv_stack) {
+#if CONFIG_EXT_INTER
+ return 0;
+#endif
+ if (ref_mv_stack[0].weight > REF_CAT_LEVEL &&
+ ref_mv_count > 0) {
+ if (abs(ref_mv_stack[0].this_mv.as_mv.row -
+ ref_mv_stack[0].pred_mv.as_mv.row) <= 4 &&
+ abs(ref_mv_stack[0].this_mv.as_mv.col -
+ ref_mv_stack[0].pred_mv.as_mv.col) <= 4)
+ return 2;
+ else
+ return 1;
+ }
+ return 0;
+}
+
+static INLINE int8_t vp10_ref_frame_type(const MV_REFERENCE_FRAME *const rf) {
+ if (rf[1] > INTRA_FRAME)
+ return rf[0] + ALTREF_FRAME;
+
+ return rf[0];
+}
+
+static INLINE void vp10_set_ref_frame(MV_REFERENCE_FRAME *rf,
+ int8_t ref_frame_type) {
+ if (ref_frame_type > ALTREF_FRAME) {
+ rf[0] = ref_frame_type - ALTREF_FRAME;
+ rf[1] = ALTREF_FRAME;
+ } else {
+ rf[0] = ref_frame_type;
+ rf[1] = NONE;
+ assert(ref_frame_type > INTRA_FRAME && ref_frame_type < MAX_REF_FRAMES);
+ }
+}
+
+static INLINE int16_t vp10_mode_context_analyzer(
+ const int16_t *const mode_context, const MV_REFERENCE_FRAME *const rf,
+ BLOCK_SIZE bsize, int block) {
+ int16_t mode_ctx = 0;
+ if (block >= 0) {
+ mode_ctx = mode_context[rf[0]] & 0x00ff;
+
+ if (block > 0 && bsize < BLOCK_8X8 && bsize > BLOCK_4X4)
+ mode_ctx |= (1 << SKIP_NEARESTMV_SUB8X8_OFFSET);
+
+ return mode_ctx;
+ }
+
+ if (rf[1] > INTRA_FRAME)
+ return mode_context[rf[0]] & (mode_context[rf[1]] | 0x00ff);
+ else if (rf[0] != ALTREF_FRAME)
+ return mode_context[rf[0]] & ~(mode_context[ALTREF_FRAME] & 0xfe00);
+ else
+ return mode_context[rf[0]];
+}
+
+static INLINE uint8_t vp10_drl_ctx(const CANDIDATE_MV *ref_mv_stack,
+ int ref_idx) {
- if (ref_mv_stack[ref_idx].weight > REF_CAT_LEVEL &&
++ if (ref_mv_stack[ref_idx].weight >= REF_CAT_LEVEL &&
++ ref_mv_stack[ref_idx + 1].weight >= REF_CAT_LEVEL) {
+ if (ref_mv_stack[ref_idx].weight == ref_mv_stack[ref_idx + 1].weight)
+ return 0;
+ else
+ return 1;
+ }
+
- assert(0);
++ if (ref_mv_stack[ref_idx].weight >= REF_CAT_LEVEL &&
+ ref_mv_stack[ref_idx + 1].weight < REF_CAT_LEVEL)
+ return 2;
+
+ if (ref_mv_stack[ref_idx].weight < REF_CAT_LEVEL &&
+ ref_mv_stack[ref_idx + 1].weight < REF_CAT_LEVEL) {
+ if (ref_mv_stack[ref_idx].weight == ref_mv_stack[ref_idx + 1].weight)
+ return 3;
+ else
+ return 4;
+ }
+
+ return 0;
+}
+#endif
+
typedef void (*find_mv_refs_sync)(void *const data, int mi_row);
void vp10_find_mv_refs(const VP10_COMMON *cm, const MACROBLOCKD *xd,
- MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
- int_mv *mv_ref_list, int mi_row, int mi_col,
- find_mv_refs_sync sync, void *const data,
- uint8_t *mode_context);
+ MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
+#if CONFIG_REF_MV
+ uint8_t *ref_mv_count,
+ CANDIDATE_MV *ref_mv_stack,
+#if CONFIG_EXT_INTER
+ int16_t *compound_mode_context,
+#endif // CONFIG_EXT_INTER
+#endif
+ int_mv *mv_ref_list, int mi_row, int mi_col,
+ find_mv_refs_sync sync, void *const data,
+ int16_t *mode_context);
// check a list of motion vectors by sad score using a number rows of pixels
// above and a number cols of pixels in the left to select the one with best
vpx_clear_system_state();
- recon_err = vp9_highbd_get_y_sse(cpi->Source, get_frame_new_buffer(cm));
+ #if CONFIG_VP9_HIGHBITDEPTH
+ if (cm->use_highbitdepth) {
- recon_err = vp9_get_y_sse(cpi->Source, get_frame_new_buffer(cm));
++ recon_err = vpx_highbd_get_y_sse(cpi->Source, get_frame_new_buffer(cm));
+ } else {
- recon_err = vp9_get_y_sse(cpi->Source, get_frame_new_buffer(cm));
++ recon_err = vpx_get_y_sse(cpi->Source, get_frame_new_buffer(cm));
+ }
+ #else
+ recon_err = vpx_get_y_sse(cpi->Source, get_frame_new_buffer(cm));
+ #endif // CONFIG_VP9_HIGHBITDEPTH
+
+
+ if (cpi->twopass.total_left_stats.coded_error != 0.0) {
+ double dc_quant_devisor;
+ #if CONFIG_VP9_HIGHBITDEPTH
+ switch (cm->bit_depth) {
+ case VPX_BITS_8:
+ dc_quant_devisor = 4.0;
+ break;
+ case VPX_BITS_10:
+ dc_quant_devisor = 16.0;
+ break;
+ case VPX_BITS_12:
+ dc_quant_devisor = 64.0;
+ break;
+ default:
+ assert(0 && "bit_depth must be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12");
+ break;
+ }
+ #else
+ dc_quant_devisor = 4.0;
+ #endif
- if (cpi->twopass.total_left_stats.coded_error != 0.0)
fprintf(f, "%10u %dx%d %10d %10d %d %d %10d %10d %10d %10d"
"%10"PRId64" %10"PRId64" %5d %5d %10"PRId64" "
"%10"PRId64" %10"PRId64" %10d "