summaryrefslogtreecommitdiff
path: root/media/libaom/src/av1/common/pred_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'media/libaom/src/av1/common/pred_common.h')
-rw-r--r--media/libaom/src/av1/common/pred_common.h74
1 files changed, 44 insertions, 30 deletions
diff --git a/media/libaom/src/av1/common/pred_common.h b/media/libaom/src/av1/common/pred_common.h
index 6dba2322d..d1dab97e7 100644
--- a/media/libaom/src/av1/common/pred_common.h
+++ b/media/libaom/src/av1/common/pred_common.h
@@ -12,29 +12,31 @@
#ifndef AOM_AV1_COMMON_PRED_COMMON_H_
#define AOM_AV1_COMMON_PRED_COMMON_H_
+#include "av1/common/av1_common_int.h"
#include "av1/common/blockd.h"
#include "av1/common/mvref_common.h"
-#include "av1/common/onyxc_int.h"
#include "aom_dsp/aom_dsp_common.h"
#ifdef __cplusplus
extern "C" {
#endif
-static INLINE int get_segment_id(const AV1_COMMON *const cm,
+static INLINE int get_segment_id(const CommonModeInfoParams *const mi_params,
const uint8_t *segment_ids, BLOCK_SIZE bsize,
int mi_row, int mi_col) {
- const int mi_offset = mi_row * cm->mi_cols + mi_col;
+ const int mi_offset = mi_row * mi_params->mi_cols + mi_col;
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
- const int xmis = AOMMIN(cm->mi_cols - mi_col, bw);
- const int ymis = AOMMIN(cm->mi_rows - mi_row, bh);
- int x, y, segment_id = MAX_SEGMENTS;
-
- for (y = 0; y < ymis; ++y)
- for (x = 0; x < xmis; ++x)
- segment_id =
- AOMMIN(segment_id, segment_ids[mi_offset + y * cm->mi_cols + x]);
+ const int xmis = AOMMIN(mi_params->mi_cols - mi_col, bw);
+ const int ymis = AOMMIN(mi_params->mi_rows - mi_row, bh);
+ int segment_id = MAX_SEGMENTS;
+
+ for (int y = 0; y < ymis; ++y) {
+ for (int x = 0; x < xmis; ++x) {
+ segment_id = AOMMIN(segment_id,
+ segment_ids[mi_offset + y * mi_params->mi_cols + x]);
+ }
+ }
assert(segment_id >= 0 && segment_id < MAX_SEGMENTS);
return segment_id;
@@ -42,26 +44,33 @@ static INLINE int get_segment_id(const AV1_COMMON *const cm,
static INLINE int av1_get_spatial_seg_pred(const AV1_COMMON *const cm,
const MACROBLOCKD *const xd,
- int mi_row, int mi_col,
int *cdf_index) {
int prev_ul = -1; // top left segment_id
int prev_l = -1; // left segment_id
int prev_u = -1; // top segment_id
+ const int mi_row = xd->mi_row;
+ const int mi_col = xd->mi_col;
+ const CommonModeInfoParams *const mi_params = &cm->mi_params;
+ const uint8_t *seg_map = cm->cur_frame->seg_map;
if ((xd->up_available) && (xd->left_available)) {
- prev_ul = get_segment_id(cm, cm->current_frame_seg_map, BLOCK_4X4,
- mi_row - 1, mi_col - 1);
+ prev_ul =
+ get_segment_id(mi_params, seg_map, BLOCK_4X4, mi_row - 1, mi_col - 1);
}
if (xd->up_available) {
- prev_u = get_segment_id(cm, cm->current_frame_seg_map, BLOCK_4X4,
- mi_row - 1, mi_col - 0);
+ prev_u =
+ get_segment_id(mi_params, seg_map, BLOCK_4X4, mi_row - 1, mi_col - 0);
}
if (xd->left_available) {
- prev_l = get_segment_id(cm, cm->current_frame_seg_map, BLOCK_4X4,
- mi_row - 0, mi_col - 1);
+ prev_l =
+ get_segment_id(mi_params, seg_map, BLOCK_4X4, mi_row - 0, mi_col - 1);
}
+ // This property follows from the fact that get_segment_id() returns a
+ // nonnegative value. This allows us to test for all edge cases with a simple
+ // prev_ul < 0 check.
+ assert(IMPLIES(prev_ul >= 0, prev_u >= 0 && prev_l >= 0));
// Pick CDF index based on number of matching/out-of-bounds segment IDs.
- if (prev_ul < 0 || prev_u < 0 || prev_l < 0) /* Edge case */
+ if (prev_ul < 0) /* Edge cases */
*cdf_index = 0;
else if ((prev_ul == prev_u) && (prev_ul == prev_l))
*cdf_index = 2;
@@ -90,18 +99,18 @@ static INLINE int av1_get_pred_context_seg_id(const MACROBLOCKD *xd) {
static INLINE int get_comp_index_context(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
MB_MODE_INFO *mbmi = xd->mi[0];
- int bck_idx = cm->frame_refs[mbmi->ref_frame[0] - LAST_FRAME].idx;
- int fwd_idx = cm->frame_refs[mbmi->ref_frame[1] - LAST_FRAME].idx;
+ const RefCntBuffer *const bck_buf = get_ref_frame_buf(cm, mbmi->ref_frame[0]);
+ const RefCntBuffer *const fwd_buf = get_ref_frame_buf(cm, mbmi->ref_frame[1]);
int bck_frame_index = 0, fwd_frame_index = 0;
- int cur_frame_index = cm->cur_frame->cur_frame_offset;
+ int cur_frame_index = cm->cur_frame->order_hint;
- if (bck_idx >= 0)
- bck_frame_index = cm->buffer_pool->frame_bufs[bck_idx].cur_frame_offset;
+ if (bck_buf != NULL) bck_frame_index = bck_buf->order_hint;
+ if (fwd_buf != NULL) fwd_frame_index = fwd_buf->order_hint;
- if (fwd_idx >= 0)
- fwd_frame_index = cm->buffer_pool->frame_bufs[fwd_idx].cur_frame_offset;
- int fwd = abs(get_relative_dist(cm, fwd_frame_index, cur_frame_index));
- int bck = abs(get_relative_dist(cm, cur_frame_index, bck_frame_index));
+ int fwd = abs(get_relative_dist(&cm->seq_params.order_hint_info,
+ fwd_frame_index, cur_frame_index));
+ int bck = abs(get_relative_dist(&cm->seq_params.order_hint_info,
+ cur_frame_index, bck_frame_index));
const MB_MODE_INFO *const above_mi = xd->above_mbmi;
const MB_MODE_INFO *const left_mi = xd->left_mbmi;
@@ -109,14 +118,14 @@ static INLINE int get_comp_index_context(const AV1_COMMON *cm,
int above_ctx = 0, left_ctx = 0;
const int offset = (fwd == bck);
- if (above_mi) {
+ if (above_mi != NULL) {
if (has_second_ref(above_mi))
above_ctx = above_mi->compound_idx;
else if (above_mi->ref_frame[0] == ALTREF_FRAME)
above_ctx = 1;
}
- if (left_mi) {
+ if (left_mi != NULL) {
if (has_second_ref(left_mi))
left_ctx = left_mi->compound_idx;
else if (left_mi->ref_frame[0] == ALTREF_FRAME)
@@ -178,6 +187,7 @@ int av1_get_palette_cache(const MACROBLOCKD *const xd, int plane,
uint16_t *cache);
static INLINE int av1_get_palette_bsize_ctx(BLOCK_SIZE bsize) {
+ assert(bsize < BLOCK_SIZES_ALL);
return num_pels_log2_lookup[bsize] - num_pels_log2_lookup[BLOCK_8X8];
}
@@ -198,6 +208,10 @@ static INLINE aom_cdf_prob *av1_get_reference_mode_cdf(const MACROBLOCKD *xd) {
return xd->tile_ctx->comp_inter_cdf[av1_get_reference_mode_context(xd)];
}
+static INLINE aom_cdf_prob *av1_get_skip_cdf(const MACROBLOCKD *xd) {
+ return xd->tile_ctx->skip_cdfs[av1_get_skip_context(xd)];
+}
+
int av1_get_comp_reference_type_context(const MACROBLOCKD *xd);
// == Uni-directional contexts ==