summaryrefslogtreecommitdiffstats
path: root/libvpx/vp9/common/vp9_blockd.h
diff options
context:
space:
mode:
authorhkuang <hkuang@google.com>2013-11-07 15:50:31 -0800
committerhkuang <hkuang@google.com>2013-11-08 11:40:06 -0800
commit5ae7ac49f08a179e4f054d99fcfc9dce78d26e58 (patch)
tree0d891d2cbbac4c3da6fd15a25bf8797b29b31994 /libvpx/vp9/common/vp9_blockd.h
parente6eeaaa14ccef4c0938fcce21c54979204041a30 (diff)
downloadandroid_external_libvpx-5ae7ac49f08a179e4f054d99fcfc9dce78d26e58.tar.gz
android_external_libvpx-5ae7ac49f08a179e4f054d99fcfc9dce78d26e58.tar.bz2
android_external_libvpx-5ae7ac49f08a179e4f054d99fcfc9dce78d26e58.zip
Roll latest libvpx into Android.
The lastest libvpx just added multithread tile decoding support. Checkout is from master: abdefeaa89a0908327518e5ca75c935c66b2e1aa Bug:11576718 Change-Id: Icbe5430633e179b8dc6d419e280ad7ebd3cad4a0
Diffstat (limited to 'libvpx/vp9/common/vp9_blockd.h')
-rw-r--r--libvpx/vp9/common/vp9_blockd.h147
1 files changed, 36 insertions, 111 deletions
diff --git a/libvpx/vp9/common/vp9_blockd.h b/libvpx/vp9/common/vp9_blockd.h
index c8d677f..d0d4852 100644
--- a/libvpx/vp9/common/vp9_blockd.h
+++ b/libvpx/vp9/common/vp9_blockd.h
@@ -20,6 +20,7 @@
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_common_data.h"
#include "vp9/common/vp9_enums.h"
+#include "vp9/common/vp9_filter.h"
#include "vp9/common/vp9_mv.h"
#include "vp9/common/vp9_scale.h"
#include "vp9/common/vp9_seg_common.h"
@@ -52,18 +53,10 @@ static INLINE int combine_entropy_contexts(ENTROPY_CONTEXT a,
typedef enum {
KEY_FRAME = 0,
INTER_FRAME = 1,
- NUM_FRAME_TYPES,
+ FRAME_TYPES,
} FRAME_TYPE;
typedef enum {
- EIGHTTAP = 0,
- EIGHTTAP_SMOOTH = 1,
- EIGHTTAP_SHARP = 2,
- BILINEAR = 3,
- SWITCHABLE = 4 /* should be the last one */
-} INTERPOLATIONFILTERTYPE;
-
-typedef enum {
DC_PRED, // Average of above and left pixels
V_PRED, // Vertical
H_PRED, // Horizontal
@@ -81,10 +74,6 @@ typedef enum {
MB_MODE_COUNT
} MB_PREDICTION_MODE;
-static INLINE int is_intra_mode(MB_PREDICTION_MODE mode) {
- return mode <= TM_PRED;
-}
-
static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) {
return mode >= NEARESTMV && mode <= NEWMV;
}
@@ -101,10 +90,10 @@ static INLINE int inter_mode_offset(MB_PREDICTION_MODE mode) {
modes for the Y blocks to the left and above us; for interframes, there
is a single probability table. */
-union b_mode_info {
+typedef struct {
MB_PREDICTION_MODE as_mode;
int_mv as_mv[2]; // first, second inter predictor motion vectors
-};
+} b_mode_info;
typedef enum {
NONE = -1,
@@ -137,7 +126,7 @@ typedef struct {
TX_SIZE tx_size;
int_mv mv[2]; // for each reference frame used
int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
- int_mv best_mv, best_second_mv;
+ int_mv best_mv[2];
uint8_t mode_context[MAX_REF_FRAMES];
@@ -147,14 +136,14 @@ typedef struct {
// Flags used for prediction status of various bit-stream signals
unsigned char seg_id_predicted;
- INTERPOLATIONFILTERTYPE interp_filter;
+ INTERPOLATION_TYPE interp_filter;
BLOCK_SIZE sb_type;
} MB_MODE_INFO;
typedef struct {
MB_MODE_INFO mbmi;
- union b_mode_info bmi[4];
+ b_mode_info bmi[4];
} MODE_INFO;
static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) {
@@ -203,22 +192,15 @@ typedef struct macroblockd {
struct scale_factors scale_factor[2];
MODE_INFO *last_mi;
- MODE_INFO *this_mi;
int mode_info_stride;
- MODE_INFO *mic_stream_ptr;
-
// A NULL indicates that the 8x8 is not part of the image
MODE_INFO **mi_8x8;
MODE_INFO **prev_mi_8x8;
+ MODE_INFO *mi_stream;
int up_available;
int left_available;
- int right_available;
-
- // partition contexts
- PARTITION_CONTEXT *above_seg_context;
- PARTITION_CONTEXT *left_seg_context;
/* Distance of MB away from frame edges */
int mb_to_left_edge;
@@ -228,14 +210,10 @@ typedef struct macroblockd {
int lossless;
/* Inverse transform function pointers. */
- void (*inv_txm4x4_1_add)(int16_t *input, uint8_t *dest, int stride);
- void (*inv_txm4x4_add)(int16_t *input, uint8_t *dest, int stride);
- void (*itxm_add)(int16_t *input, uint8_t *dest, int stride, int eob);
+ void (*itxm_add)(const int16_t *input, uint8_t *dest, int stride, int eob);
struct subpix_fn_table subpix;
- int allow_high_precision_mv;
-
int corrupted;
unsigned char sb_index; // index of 32x32 block inside the 64x64 block
@@ -245,71 +223,15 @@ typedef struct macroblockd {
int q_index;
-} MACROBLOCKD;
+ /* Y,U,V,(A) */
+ ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
+ ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16];
-static INLINE unsigned char *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE subsize) {
- switch (subsize) {
- case BLOCK_64X64:
- case BLOCK_64X32:
- case BLOCK_32X64:
- case BLOCK_32X32:
- return &xd->sb_index;
- case BLOCK_32X16:
- case BLOCK_16X32:
- case BLOCK_16X16:
- return &xd->mb_index;
- case BLOCK_16X8:
- case BLOCK_8X16:
- case BLOCK_8X8:
- return &xd->b_index;
- case BLOCK_8X4:
- case BLOCK_4X8:
- case BLOCK_4X4:
- return &xd->ab_index;
- default:
- assert(0);
- return NULL;
- }
-}
-
-static INLINE void update_partition_context(MACROBLOCKD *xd, BLOCK_SIZE sb_type,
- BLOCK_SIZE sb_size) {
- const int bsl = b_width_log2(sb_size), bs = (1 << bsl) / 2;
- const int bwl = b_width_log2(sb_type);
- const int bhl = b_height_log2(sb_type);
- const int boffset = b_width_log2(BLOCK_64X64) - bsl;
- const char pcval0 = ~(0xe << boffset);
- const char pcval1 = ~(0xf << boffset);
- const char pcvalue[2] = {pcval0, pcval1};
-
- assert(MAX(bwl, bhl) <= bsl);
-
- // update the partition context at the end notes. set partition bits
- // of block sizes larger than the current one to be one, and partition
- // bits of smaller block sizes to be zero.
- vpx_memset(xd->above_seg_context, pcvalue[bwl == bsl], bs);
- vpx_memset(xd->left_seg_context, pcvalue[bhl == bsl], bs);
-}
-
-static INLINE int partition_plane_context(MACROBLOCKD *xd, BLOCK_SIZE sb_type) {
- int bsl = mi_width_log2(sb_type), bs = 1 << bsl;
- int above = 0, left = 0, i;
- int boffset = mi_width_log2(BLOCK_64X64) - bsl;
-
- assert(mi_width_log2(sb_type) == mi_height_log2(sb_type));
- assert(bsl >= 0);
- assert(boffset >= 0);
-
- for (i = 0; i < bs; i++)
- above |= (xd->above_seg_context[i] & (1 << boffset));
- for (i = 0; i < bs; i++)
- left |= (xd->left_seg_context[i] & (1 << boffset));
+ PARTITION_CONTEXT *above_seg_context;
+ PARTITION_CONTEXT left_seg_context[8];
+} MACROBLOCKD;
- above = (above > 0);
- left = (left > 0);
- return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
-}
static BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, PARTITION_TYPE partition) {
const BLOCK_SIZE subsize = subsize_lookup[partition][bsize];
@@ -321,7 +243,7 @@ extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT];
static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type,
const MACROBLOCKD *xd, int ib) {
- const MODE_INFO *const mi = xd->this_mi;
+ const MODE_INFO *const mi = xd->mi_8x8[0];
const MB_MODE_INFO *const mbmi = &mi->mbmi;
if (plane_type != PLANE_TYPE_Y_WITH_DC ||
@@ -336,13 +258,13 @@ static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type,
static INLINE TX_TYPE get_tx_type_8x8(PLANE_TYPE plane_type,
const MACROBLOCKD *xd) {
return plane_type == PLANE_TYPE_Y_WITH_DC ?
- mode2txfm_map[xd->this_mi->mbmi.mode] : DCT_DCT;
+ mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] : DCT_DCT;
}
static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type,
const MACROBLOCKD *xd) {
return plane_type == PLANE_TYPE_Y_WITH_DC ?
- mode2txfm_map[xd->this_mi->mbmi.mode] : DCT_DCT;
+ mode2txfm_map[xd->mi_8x8[0]->mbmi.mode] : DCT_DCT;
}
static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) {
@@ -391,7 +313,7 @@ static INLINE void foreach_transformed_block_in_plane(
const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane,
foreach_transformed_block_visitor visit, void *arg) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
- const MB_MODE_INFO* mbmi = &xd->this_mi->mbmi;
+ const MB_MODE_INFO* mbmi = &xd->mi_8x8[0]->mbmi;
// block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
// 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
// transform size varies per plane, look it up in a common way.
@@ -495,7 +417,7 @@ static void txfrm_block_to_raster_xy(BLOCK_SIZE plane_bsize,
*y = (raster_mb >> tx_cols_log2) << tx_size;
}
-static void extend_for_intra(MACROBLOCKD* const xd, BLOCK_SIZE plane_bsize,
+static void extend_for_intra(MACROBLOCKD *xd, BLOCK_SIZE plane_bsize,
int plane, int block, TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
uint8_t *const buf = pd->dst.buf;
@@ -520,19 +442,22 @@ static void extend_for_intra(MACROBLOCKD* const xd, BLOCK_SIZE plane_bsize,
}
if (xd->mb_to_bottom_edge < 0) {
- const int bh = 4 << b_height_log2(plane_bsize);
- const int umv_border_start = bh + (xd->mb_to_bottom_edge >>
- (3 + pd->subsampling_y));
- int i;
- const uint8_t c = buf[(umv_border_start - 1) * stride + x];
- uint8_t *d = &buf[umv_border_start * stride + x];
-
- if (y + bh > umv_border_start)
- for (i = 0; i < bh; ++i, d += stride)
- *d = c;
+ if (xd->left_available || x >= 0) {
+ const int bh = 4 << b_height_log2(plane_bsize);
+ const int umv_border_start =
+ bh + (xd->mb_to_bottom_edge >> (3 + pd->subsampling_y));
+
+ if (y + bh > umv_border_start) {
+ const uint8_t c = buf[(umv_border_start - 1) * stride + x];
+ uint8_t *d = &buf[umv_border_start * stride + x];
+ int i;
+ for (i = 0; i < bh; ++i, d += stride)
+ *d = c;
+ }
+ }
}
}
-static void set_contexts_on_border(MACROBLOCKD *xd,
+static void set_contexts_on_border(const MACROBLOCKD *xd,
struct macroblockd_plane *pd,
BLOCK_SIZE plane_bsize,
int tx_size_in_blocks, int has_eob,
@@ -570,7 +495,7 @@ static void set_contexts_on_border(MACROBLOCKD *xd,
L[pt] = 0;
}
-static void set_contexts(MACROBLOCKD *xd, struct macroblockd_plane *pd,
+static void set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
int has_eob, int aoff, int loff) {
ENTROPY_CONTEXT *const A = pd->above_context + aoff;
@@ -586,7 +511,7 @@ static void set_contexts(MACROBLOCKD *xd, struct macroblockd_plane *pd,
}
}
-static int get_tx_eob(struct segmentation *seg, int segment_id,
+static int get_tx_eob(const struct segmentation *seg, int segment_id,
TX_SIZE tx_size) {
const int eob_max = 16 << (tx_size << 1);
return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;