diff options
Diffstat (limited to 'libvpx/vp9/common')
-rw-r--r-- | libvpx/vp9/common/vp9_alloccommon.c | 86 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_alloccommon.h | 17 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_blockd.c | 2 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_blockd.h | 42 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_entropy.h | 2 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_entropymode.c | 7 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_entropymv.c | 51 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_enums.h | 23 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_loopfilter.c | 85 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_mvref_common.c | 56 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_onyxc_int.h | 72 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_postproc.h | 1 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_ppflags.h | 2 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_pred_common.c | 2 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_pred_common.h | 4 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_reconinter.c | 21 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_reconintra.c | 4 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_rtcd_defs.pl | 8 | ||||
-rw-r--r-- | libvpx/vp9/common/vp9_scale.c | 4 | ||||
-rw-r--r-- | libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c | 5 |
20 files changed, 276 insertions, 218 deletions
diff --git a/libvpx/vp9/common/vp9_alloccommon.c b/libvpx/vp9/common/vp9_alloccommon.c index 08ab27a..f44ada1 100644 --- a/libvpx/vp9/common/vp9_alloccommon.c +++ b/libvpx/vp9/common/vp9_alloccommon.c @@ -17,22 +17,21 @@ #include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_systemdependent.h" -void vp9_update_mode_info_border(VP9_COMMON *cm, MODE_INFO *mi) { - const int stride = cm->mode_info_stride; +static void clear_mi_border(const VP9_COMMON *cm, MODE_INFO *mi) { int i; - // Clear down top border row - vpx_memset(mi, 0, sizeof(MODE_INFO) * stride); + // Top border row + vpx_memset(mi, 0, sizeof(*mi) * cm->mi_stride); - // Clear left border column - for (i = 1; i < cm->mi_rows + 1; i++) - vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO)); + // Left border column + for (i = 1; i < cm->mi_rows + 1; ++i) + vpx_memset(&mi[i * cm->mi_stride], 0, sizeof(*mi)); } static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) { cm->mi_cols = aligned_width >> MI_SIZE_LOG2; cm->mi_rows = aligned_height >> MI_SIZE_LOG2; - cm->mode_info_stride = cm->mi_cols + MI_BLOCK_SIZE; + cm->mi_stride = cm->mi_cols + MI_BLOCK_SIZE; cm->mb_cols = (cm->mi_cols + 1) >> 1; cm->mb_rows = (cm->mi_rows + 1) >> 1; @@ -40,19 +39,17 @@ static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) { } static void setup_mi(VP9_COMMON *cm) { - cm->mi = cm->mip + cm->mode_info_stride + 1; - cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; - cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1; - cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1; + cm->mi = cm->mip + cm->mi_stride + 1; + cm->prev_mi = cm->prev_mip + cm->mi_stride + 1; + cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1; + cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mi_stride + 1; - vpx_memset(cm->mip, 0, - cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(*cm->mip)); + vpx_memset(cm->mip, 0, cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip)); - vpx_memset(cm->mi_grid_base, 0, - cm->mode_info_stride * (cm->mi_rows + 1) * - sizeof(*cm->mi_grid_base)); + vpx_memset(cm->mi_grid_base, 0, cm->mi_stride * (cm->mi_rows + 1) * + sizeof(*cm->mi_grid_base)); - vp9_update_mode_info_border(cm, cm->prev_mip); + clear_mi_border(cm, cm->prev_mip); } static int alloc_mi(VP9_COMMON *cm, int mi_size) { @@ -108,6 +105,12 @@ void vp9_free_frame_buffers(VP9_COMMON *cm) { vpx_free(cm->last_frame_seg_map); cm->last_frame_seg_map = NULL; + + vpx_free(cm->above_context); + cm->above_context = NULL; + + vpx_free(cm->above_seg_context); + cm->above_seg_context = NULL; } int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { @@ -123,7 +126,7 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { set_mb_mi(cm, aligned_width, aligned_height); free_mi(cm); - if (alloc_mi(cm, cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE))) + if (alloc_mi(cm, cm->mi_stride * (cm->mi_rows + MI_BLOCK_SIZE))) goto fail; setup_mi(cm); @@ -134,6 +137,21 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { if (!cm->last_frame_seg_map) goto fail; + vpx_free(cm->above_context); + cm->above_context = + (ENTROPY_CONTEXT *)vpx_calloc(2 * mi_cols_aligned_to_sb(cm->mi_cols) * + MAX_MB_PLANE, + sizeof(*cm->above_context)); + if (!cm->above_context) + goto fail; + + vpx_free(cm->above_seg_context); + cm->above_seg_context = + (PARTITION_CONTEXT *)vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols), + sizeof(*cm->above_seg_context)); + if (!cm->above_seg_context) + goto fail; + return 0; fail: @@ -142,12 +160,11 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { } int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { - int i; - const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); const int ss_x = cm->subsampling_x; const int ss_y = cm->subsampling_y; + int i; vp9_free_frame_buffers(cm); @@ -172,7 +189,7 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { set_mb_mi(cm, aligned_width, aligned_height); - if (alloc_mi(cm, cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE))) + if (alloc_mi(cm, cm->mi_stride * (cm->mi_rows + MI_BLOCK_SIZE))) goto fail; setup_mi(cm); @@ -182,6 +199,19 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { if (!cm->last_frame_seg_map) goto fail; + cm->above_context = + (ENTROPY_CONTEXT *)vpx_calloc(2 * mi_cols_aligned_to_sb(cm->mi_cols) * + MAX_MB_PLANE, + sizeof(*cm->above_context)); + if (!cm->above_context) + goto fail; + + cm->above_seg_context = + (PARTITION_CONTEXT *)vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols), + sizeof(*cm->above_seg_context)); + if (!cm->above_seg_context) + goto fail; + return 0; fail: @@ -194,10 +224,6 @@ void vp9_remove_common(VP9_COMMON *cm) { vp9_free_internal_frame_buffers(&cm->int_frame_buffers); } -void vp9_initialize_common() { - vp9_init_neighbors(); -} - void vp9_update_frame_size(VP9_COMMON *cm) { const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, MI_SIZE_LOG2); const int aligned_height = ALIGN_POWER_OF_TWO(cm->height, MI_SIZE_LOG2); @@ -220,8 +246,8 @@ void vp9_swap_mi_and_prev_mi(VP9_COMMON *cm) { cm->mi_grid_base = temp2; // Update the upper left visible macroblock ptrs. - cm->mi = cm->mip + cm->mode_info_stride + 1; - cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; - cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1; - cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1; + cm->mi = cm->mip + cm->mi_stride + 1; + cm->prev_mi = cm->prev_mip + cm->mi_stride + 1; + cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1; + cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mi_stride + 1; } diff --git a/libvpx/vp9/common/vp9_alloccommon.h b/libvpx/vp9/common/vp9_alloccommon.h index fca6935..06636a9 100644 --- a/libvpx/vp9/common/vp9_alloccommon.h +++ b/libvpx/vp9/common/vp9_alloccommon.h @@ -12,26 +12,23 @@ #ifndef VP9_COMMON_VP9_ALLOCCOMMON_H_ #define VP9_COMMON_VP9_ALLOCCOMMON_H_ -#include "vp9/common/vp9_onyxc_int.h" - #ifdef __cplusplus extern "C" { #endif -void vp9_initialize_common(); +struct VP9Common; -void vp9_update_mode_info_border(VP9_COMMON *cm, MODE_INFO *mi); +void vp9_remove_common(struct VP9Common *cm); -void vp9_remove_common(VP9_COMMON *cm); +int vp9_resize_frame_buffers(struct VP9Common *cm, int width, int height); -int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height); -int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height); -void vp9_free_frame_buffers(VP9_COMMON *cm); +int vp9_alloc_frame_buffers(struct VP9Common *cm, int width, int height); +void vp9_free_frame_buffers(struct VP9Common *cm); -void vp9_update_frame_size(VP9_COMMON *cm); +void vp9_update_frame_size(struct VP9Common *cm); -void vp9_swap_mi_and_prev_mi(VP9_COMMON *cm); +void vp9_swap_mi_and_prev_mi(struct VP9Common *cm); #ifdef __cplusplus } // extern "C" diff --git a/libvpx/vp9/common/vp9_blockd.c b/libvpx/vp9/common/vp9_blockd.c index e1d1318..fedfb18 100644 --- a/libvpx/vp9/common/vp9_blockd.c +++ b/libvpx/vp9/common/vp9_blockd.c @@ -40,7 +40,7 @@ void vp9_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->mi_8x8[0]->mbmi; + const MB_MODE_INFO* mbmi = &xd->mi[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. diff --git a/libvpx/vp9/common/vp9_blockd.h b/libvpx/vp9/common/vp9_blockd.h index ca5a0c2..55320a6 100644 --- a/libvpx/vp9/common/vp9_blockd.h +++ b/libvpx/vp9/common/vp9_blockd.h @@ -120,23 +120,23 @@ static INLINE int mi_width_log2(BLOCK_SIZE sb_type) { // This structure now relates to 8x8 block regions. typedef struct { - MB_PREDICTION_MODE mode, uv_mode; - MV_REFERENCE_FRAME ref_frame[2]; + // Common for both INTER and INTRA blocks + BLOCK_SIZE sb_type; + MB_PREDICTION_MODE mode; TX_SIZE tx_size; - int_mv mv[2]; // for each reference frame used - int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; - - uint8_t mode_context[MAX_REF_FRAMES]; - - unsigned char skip; // 0=need to decode coeffs, 1=no coefficients - unsigned char segment_id; // Segment id for this block. + uint8_t skip; + uint8_t segment_id; + uint8_t seg_id_predicted; // valid only when temporal_update is enabled - // Flags used for prediction status of various bit-stream signals - unsigned char seg_id_predicted; + // Only for INTRA blocks + MB_PREDICTION_MODE uv_mode; + // Only for INTER blocks + MV_REFERENCE_FRAME ref_frame[2]; + int_mv mv[2]; + int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; + uint8_t mode_context[MAX_REF_FRAMES]; INTERP_FILTER interp_filter; - - BLOCK_SIZE sb_type; } MB_MODE_INFO; typedef struct { @@ -204,11 +204,10 @@ typedef struct RefBuffer { typedef struct macroblockd { struct macroblockd_plane plane[MAX_MB_PLANE]; - int mode_info_stride; + int mi_stride; // A NULL indicates that the 8x8 is not part of the image - MODE_INFO **mi_8x8; - MODE_INFO **prev_mi_8x8; + MODE_INFO **mi; int up_available; int left_available; @@ -232,11 +231,10 @@ typedef struct macroblockd { /* Inverse transform function pointers. */ void (*itxm_add)(const int16_t *input, uint8_t *dest, int stride, int eob); - const InterpKernel *interp_kernel; - int corrupted; - /* Y,U,V,(A) */ + DECLARE_ALIGNED(16, int16_t, dqcoeff[MAX_MB_PLANE][64 * 64]); + ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; @@ -244,8 +242,6 @@ typedef struct macroblockd { PARTITION_CONTEXT left_seg_context[8]; } MACROBLOCKD; - - static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, PARTITION_TYPE partition) { const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; @@ -257,7 +253,7 @@ extern const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES]; static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, const MACROBLOCKD *xd) { - const MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; + const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; if (plane_type != PLANE_TYPE_Y || is_inter_block(mbmi)) return DCT_DCT; @@ -266,7 +262,7 @@ static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, const MACROBLOCKD *xd, int ib) { - const MODE_INFO *const mi = xd->mi_8x8[0]; + const MODE_INFO *const mi = xd->mi[0]; if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(&mi->mbmi)) return DCT_DCT; diff --git a/libvpx/vp9/common/vp9_entropy.h b/libvpx/vp9/common/vp9_entropy.h index 15bf8eb..6788eb6 100644 --- a/libvpx/vp9/common/vp9_entropy.h +++ b/libvpx/vp9/common/vp9_entropy.h @@ -175,7 +175,7 @@ static INLINE int get_entropy_context(TX_SIZE tx_size, const ENTROPY_CONTEXT *a, static const INLINE scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size, PLANE_TYPE type, int block_idx) { - const MODE_INFO *const mi = xd->mi_8x8[0]; + const MODE_INFO *const mi = xd->mi[0]; if (is_inter_block(&mi->mbmi) || type != PLANE_TYPE_Y || xd->lossless) { return &vp9_default_scan_orders[tx_size]; diff --git a/libvpx/vp9/common/vp9_entropymode.c b/libvpx/vp9/common/vp9_entropymode.c index f2c81bc..5b00b00 100644 --- a/libvpx/vp9/common/vp9_entropymode.c +++ b/libvpx/vp9/common/vp9_entropymode.c @@ -465,11 +465,10 @@ void vp9_setup_past_independence(VP9_COMMON *cm) { } if (frame_is_intra_only(cm)) - vpx_memset(cm->prev_mip, 0, - cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); + vpx_memset(cm->prev_mip, 0, cm->mi_stride * (cm->mi_rows + 1) * + sizeof(*cm->prev_mip)); - vpx_memset(cm->mip, 0, - cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); + vpx_memset(cm->mip, 0, cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip)); vp9_zero(cm->ref_frame_sign_bias); diff --git a/libvpx/vp9/common/vp9_entropymv.c b/libvpx/vp9/common/vp9_entropymv.c index 197b7c0..5bb0482 100644 --- a/libvpx/vp9/common/vp9_entropymv.c +++ b/libvpx/vp9/common/vp9_entropymv.c @@ -8,14 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_entropymv.h" #define MV_COUNT_SAT 20 #define MV_MAX_UPDATE_FACTOR 128 -/* Integer pel reference mv threshold for use of high-precision 1/8 mv */ +// Integer pel reference mv threshold for use of high-precision 1/8 mv #define COMPANDED_MVREF_THRESH 8 const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)] = { @@ -49,32 +48,30 @@ const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(MV_FP_SIZE)] = { static const nmv_context default_nmv_context = { {32, 64, 96}, - { // NOLINT - { /* vert component */ // NOLINT - 128, /* sign */ - {224, 144, 192, 168, 192, 176, 192, 198, 198, 245}, /* class */ - {216}, /* class0 */ - {136, 140, 148, 160, 176, 192, 224, 234, 234, 240}, /* bits */ - {{128, 128, 64}, {96, 112, 64}}, /* class0_fp */ - {64, 96, 64}, /* fp */ - 160, /* class0_hp bit */ - 128, /* hp */ + { + { // Vertical component + 128, // sign + {224, 144, 192, 168, 192, 176, 192, 198, 198, 245}, // class + {216}, // class0 + {136, 140, 148, 160, 176, 192, 224, 234, 234, 240}, // bits + {{128, 128, 64}, {96, 112, 64}}, // class0_fp + {64, 96, 64}, // fp + 160, // class0_hp bit + 128, // hp }, - { /* hor component */ // NOLINT - 128, /* sign */ - {216, 128, 176, 160, 176, 176, 192, 198, 198, 208}, /* class */ - {208}, /* class0 */ - {136, 140, 148, 160, 176, 192, 224, 234, 234, 240}, /* bits */ - {{128, 128, 64}, {96, 112, 64}}, /* class0_fp */ - {64, 96, 64}, /* fp */ - 160, /* class0_hp bit */ - 128, /* hp */ + { // Horizontal component + 128, // sign + {216, 128, 176, 160, 176, 176, 192, 198, 198, 208}, // class + {208}, // class0 + {136, 140, 148, 160, 176, 192, 224, 234, 234, 240}, // bits + {{128, 128, 64}, {96, 112, 64}}, // class0_fp + {64, 96, 64}, // fp + 160, // class0_hp bit + 128, // hp } }, }; -#define mv_class_base(c) ((c) ? (CLASS0_SIZE << (c + 2)) : 0) - static const uint8_t log_in_base_2[] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, @@ -121,9 +118,13 @@ static const uint8_t log_in_base_2[] = { 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10 }; +static INLINE int mv_class_base(MV_CLASS_TYPE c) { + return c ? CLASS0_SIZE << (c + 2) : 0; +} + MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset) { - const MV_CLASS_TYPE c = (z >= CLASS0_SIZE * 4096) ? MV_CLASS_10 : - (MV_CLASS_TYPE)log_in_base_2[z >> 3]; + const MV_CLASS_TYPE c = (z >= CLASS0_SIZE * 4096) ? + MV_CLASS_10 : (MV_CLASS_TYPE)log_in_base_2[z >> 3]; if (offset) *offset = z - mv_class_base(c); return c; diff --git a/libvpx/vp9/common/vp9_enums.h b/libvpx/vp9/common/vp9_enums.h index e96e769..068284f 100644 --- a/libvpx/vp9/common/vp9_enums.h +++ b/libvpx/vp9/common/vp9_enums.h @@ -25,6 +25,23 @@ extern "C" { #define MI_MASK (MI_BLOCK_SIZE - 1) +// Bitstream profiles indicated by 2 bits in the uncompressed header. +// 00: Profile 0. 4:2:0 only. +// 10: Profile 1. adds 4:4:4, 4:2:2, alpha. +// 01: Profile 2. Supports 10-bit and 12-bit color only. +// 11: Undefined profile. +typedef enum BITSTREAM_PROFILE { + PROFILE_0, + PROFILE_1, + PROFILE_2, + MAX_PROFILES +} BITSTREAM_PROFILE; + +typedef enum BIT_DEPTH { + BITS_8, + BITS_10, + BITS_12 +} BIT_DEPTH; typedef enum BLOCK_SIZE { BLOCK_4X4, @@ -94,6 +111,12 @@ typedef enum { SRGB = 7 // RGB } COLOR_SPACE; +typedef enum { + VP9_LAST_FLAG = 1 << 0, + VP9_GOLD_FLAG = 1 << 1, + VP9_ALT_FLAG = 1 << 2, +} VP9_REFFRAME; + #ifdef __cplusplus } // extern "C" #endif diff --git a/libvpx/vp9/common/vp9_loopfilter.c b/libvpx/vp9/common/vp9_loopfilter.c index af8afed..3ac5a05 100644 --- a/libvpx/vp9/common/vp9_loopfilter.c +++ b/libvpx/vp9/common/vp9_loopfilter.c @@ -228,6 +228,12 @@ static void update_sharpness(loop_filter_info_n *lfi, int sharpness_lvl) { } } +static uint8_t get_filter_level(const loop_filter_info_n *lfi_n, + const MB_MODE_INFO *mbmi) { + return lfi_n->lvl[mbmi->segment_id][mbmi->ref_frame[0]] + [mode_lf_lut[mbmi->mode]]; +} + void vp9_loop_filter_init(VP9_COMMON *cm) { loop_filter_info_n *lfi = &cm->lf_info; struct loopfilter *lf = &cm->lf; @@ -493,27 +499,25 @@ static void build_masks(const loop_filter_info_n *const lfi_n, const MODE_INFO *mi, const int shift_y, const int shift_uv, LOOP_FILTER_MASK *lfm) { - const BLOCK_SIZE block_size = mi->mbmi.sb_type; - const TX_SIZE tx_size_y = mi->mbmi.tx_size; - const TX_SIZE tx_size_uv = get_uv_tx_size(&mi->mbmi); - const int skip = mi->mbmi.skip; - const int seg = mi->mbmi.segment_id; - const int ref = mi->mbmi.ref_frame[0]; - const int filter_level = lfi_n->lvl[seg][ref][mode_lf_lut[mi->mbmi.mode]]; - uint64_t *left_y = &lfm->left_y[tx_size_y]; - uint64_t *above_y = &lfm->above_y[tx_size_y]; - uint64_t *int_4x4_y = &lfm->int_4x4_y; - uint16_t *left_uv = &lfm->left_uv[tx_size_uv]; - uint16_t *above_uv = &lfm->above_uv[tx_size_uv]; - uint16_t *int_4x4_uv = &lfm->int_4x4_uv; + const MB_MODE_INFO *mbmi = &mi->mbmi; + const BLOCK_SIZE block_size = mbmi->sb_type; + const TX_SIZE tx_size_y = mbmi->tx_size; + const TX_SIZE tx_size_uv = get_uv_tx_size(mbmi); + const int filter_level = get_filter_level(lfi_n, mbmi); + uint64_t *const left_y = &lfm->left_y[tx_size_y]; + uint64_t *const above_y = &lfm->above_y[tx_size_y]; + uint64_t *const int_4x4_y = &lfm->int_4x4_y; + uint16_t *const left_uv = &lfm->left_uv[tx_size_uv]; + uint16_t *const above_uv = &lfm->above_uv[tx_size_uv]; + uint16_t *const int_4x4_uv = &lfm->int_4x4_uv; int i; - int w = num_8x8_blocks_wide_lookup[block_size]; - int h = num_8x8_blocks_high_lookup[block_size]; // If filter level is 0 we don't loop filter. if (!filter_level) { return; } else { + const int w = num_8x8_blocks_wide_lookup[block_size]; + const int h = num_8x8_blocks_high_lookup[block_size]; int index = shift_y; for (i = 0; i < h; i++) { vpx_memset(&lfm->lfl_y[index], filter_level, w); @@ -540,7 +544,7 @@ static void build_masks(const loop_filter_info_n *const lfi_n, // If the block has no coefficients and is not intra we skip applying // the loop filter on block edges. - if (skip && ref > INTRA_FRAME) + if (mbmi->skip && is_inter_block(mbmi)) return; // Here we are adding a mask for the transform size. The transform @@ -561,12 +565,11 @@ static void build_masks(const loop_filter_info_n *const lfi_n, // boundaries. These differ from the 4x4 boundaries on the outside edge of // an 8x8 in that the internal ones can be skipped and don't depend on // the prediction block size. - if (tx_size_y == TX_4X4) { + if (tx_size_y == TX_4X4) *int_4x4_y |= (size_mask[block_size] & 0xffffffffffffffff) << shift_y; - } - if (tx_size_uv == TX_4X4) { + + if (tx_size_uv == TX_4X4) *int_4x4_uv |= (size_mask_uv[block_size] & 0xffff) << shift_uv; - } } // This function does the same thing as the one above with the exception that @@ -575,22 +578,20 @@ static void build_masks(const loop_filter_info_n *const lfi_n, static void build_y_mask(const loop_filter_info_n *const lfi_n, const MODE_INFO *mi, const int shift_y, LOOP_FILTER_MASK *lfm) { - const BLOCK_SIZE block_size = mi->mbmi.sb_type; - const TX_SIZE tx_size_y = mi->mbmi.tx_size; - const int skip = mi->mbmi.skip; - const int seg = mi->mbmi.segment_id; - const int ref = mi->mbmi.ref_frame[0]; - const int filter_level = lfi_n->lvl[seg][ref][mode_lf_lut[mi->mbmi.mode]]; - uint64_t *left_y = &lfm->left_y[tx_size_y]; - uint64_t *above_y = &lfm->above_y[tx_size_y]; - uint64_t *int_4x4_y = &lfm->int_4x4_y; + const MB_MODE_INFO *mbmi = &mi->mbmi; + const BLOCK_SIZE block_size = mbmi->sb_type; + const TX_SIZE tx_size_y = mbmi->tx_size; + const int filter_level = get_filter_level(lfi_n, mbmi); + uint64_t *const left_y = &lfm->left_y[tx_size_y]; + uint64_t *const above_y = &lfm->above_y[tx_size_y]; + uint64_t *const int_4x4_y = &lfm->int_4x4_y; int i; - int w = num_8x8_blocks_wide_lookup[block_size]; - int h = num_8x8_blocks_high_lookup[block_size]; if (!filter_level) { return; } else { + const int w = num_8x8_blocks_wide_lookup[block_size]; + const int h = num_8x8_blocks_high_lookup[block_size]; int index = shift_y; for (i = 0; i < h; i++) { vpx_memset(&lfm->lfl_y[index], filter_level, w); @@ -601,7 +602,7 @@ static void build_y_mask(const loop_filter_info_n *const lfi_n, *above_y |= above_prediction_mask[block_size] << shift_y; *left_y |= left_prediction_mask[block_size] << shift_y; - if (skip && ref > INTRA_FRAME) + if (mbmi->skip && is_inter_block(mbmi)) return; *above_y |= (size_mask[block_size] & @@ -610,9 +611,8 @@ static void build_y_mask(const loop_filter_info_n *const lfi_n, *left_y |= (size_mask[block_size] & left_64x64_txform_mask[tx_size_y]) << shift_y; - if (tx_size_y == TX_4X4) { + if (tx_size_y == TX_4X4) *int_4x4_y |= (size_mask[block_size] & 0xffffffffffffffff) << shift_y; - } } // This function sets up the bit masks for the entire 64x64 region represented @@ -868,13 +868,6 @@ void vp9_setup_mask(VP9_COMMON *const cm, const int mi_row, const int mi_col, assert(!(lfm->int_4x4_uv & lfm->above_uv[TX_16X16])); } -static uint8_t build_lfi(const loop_filter_info_n *lfi_n, - const MB_MODE_INFO *mbmi) { - const int seg = mbmi->segment_id; - const int ref = mbmi->ref_frame[0]; - return lfi_n->lvl[seg][ref][mode_lf_lut[mbmi->mode]]; -} - static void filter_selectively_vert(uint8_t *s, int pitch, unsigned int mask_16x16, unsigned int mask_8x8, @@ -916,7 +909,7 @@ static void filter_block_plane_non420(VP9_COMMON *cm, const int ss_y = plane->subsampling_y; const int row_step = 1 << ss_x; const int col_step = 1 << ss_y; - const int row_step_stride = cm->mode_info_stride * row_step; + const int row_step_stride = cm->mi_stride * row_step; struct buf_2d *const dst = &plane->dst; uint8_t* const dst0 = dst->buf; unsigned int mask_16x16[MI_BLOCK_SIZE] = {0}; @@ -953,7 +946,7 @@ static void filter_block_plane_non420(VP9_COMMON *cm, // Filter level can vary per MI if (!(lfl[(r << 3) + (c >> ss_x)] = - build_lfi(&cm->lf_info, &mi[0].mbmi))) + get_filter_level(&cm->lf_info, &mi[0].mbmi))) continue; // Build masks based on the transform size of each block @@ -1208,7 +1201,7 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, xd->plane[1].subsampling_x == 1); for (mi_row = start; mi_row < stop; mi_row += MI_BLOCK_SIZE) { - MODE_INFO **mi_8x8 = cm->mi_grid_visible + mi_row * cm->mode_info_stride; + MODE_INFO **mi_8x8 = cm->mi_grid_visible + mi_row * cm->mi_stride; for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MI_BLOCK_SIZE) { int plane; @@ -1217,8 +1210,8 @@ void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, // TODO(JBB): Make setup_mask work for non 420. if (use_420) - vp9_setup_mask(cm, mi_row, mi_col, mi_8x8 + mi_col, - cm->mode_info_stride, &lfm); + vp9_setup_mask(cm, mi_row, mi_col, mi_8x8 + mi_col, cm->mi_stride, + &lfm); for (plane = 0; plane < num_planes; ++plane) { if (use_420) diff --git a/libvpx/vp9/common/vp9_mvref_common.c b/libvpx/vp9/common/vp9_mvref_common.c index 9f2c2df..1aab362 100644 --- a/libvpx/vp9/common/vp9_mvref_common.c +++ b/libvpx/vp9/common/vp9_mvref_common.c @@ -148,28 +148,30 @@ static INLINE int_mv scale_mv(const MB_MODE_INFO *mbmi, int ref, // This macro is used to add a motion vector mv_ref list if it isn't // already in the list. If it's the second motion vector it will also // skip all additional processing and jump to done! -#define ADD_MV_REF_LIST(MV) \ +#define ADD_MV_REF_LIST(mv) \ do { \ if (refmv_count) { \ - if ((MV).as_int != mv_ref_list[0].as_int) { \ - mv_ref_list[refmv_count] = (MV); \ + if ((mv).as_int != mv_ref_list[0].as_int) { \ + mv_ref_list[refmv_count] = (mv); \ goto Done; \ } \ } else { \ - mv_ref_list[refmv_count++] = (MV); \ + mv_ref_list[refmv_count++] = (mv); \ } \ } while (0) // If either reference frame is different, not INTRA, and they // are different from each other scale and add the mv to our list. -#define IF_DIFF_REF_FRAME_ADD_MV(CANDIDATE) \ +#define IF_DIFF_REF_FRAME_ADD_MV(mbmi) \ do { \ - if ((CANDIDATE)->ref_frame[0] != ref_frame) \ - ADD_MV_REF_LIST(scale_mv((CANDIDATE), 0, ref_frame, ref_sign_bias)); \ - if ((CANDIDATE)->ref_frame[1] != ref_frame && \ - has_second_ref(CANDIDATE) && \ - (CANDIDATE)->mv[1].as_int != (CANDIDATE)->mv[0].as_int) \ - ADD_MV_REF_LIST(scale_mv((CANDIDATE), 1, ref_frame, ref_sign_bias)); \ + if (is_inter_block(mbmi)) { \ + if ((mbmi)->ref_frame[0] != ref_frame) \ + ADD_MV_REF_LIST(scale_mv((mbmi), 0, ref_frame, ref_sign_bias)); \ + if (has_second_ref(mbmi) && \ + (mbmi)->ref_frame[1] != ref_frame && \ + (mbmi)->mv[1].as_int != (mbmi)->mv[0].as_int) \ + ADD_MV_REF_LIST(scale_mv((mbmi), 1, ref_frame, ref_sign_bias)); \ + } \ } while (0) @@ -193,11 +195,14 @@ static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, int block, int mi_row, int mi_col) { const int *ref_sign_bias = cm->ref_frame_sign_bias; int i, refmv_count = 0; - const MODE_INFO *prev_mi = cm->coding_use_prev_mi && cm->prev_mi ? - xd->prev_mi_8x8[0] : NULL; + const MODE_INFO *prev_mi = cm->prev_mi + ? cm->prev_mi_grid_visible[mi_row * xd->mi_stride + mi_col] + : NULL; + const MB_MODE_INFO *const prev_mbmi = prev_mi ? &prev_mi->mbmi : NULL; + + const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type]; - const MB_MODE_INFO *const prev_mbmi = cm->coding_use_prev_mi && prev_mi ? - &prev_mi->mbmi : NULL; + int different_ref_found = 0; int context_counter = 0; @@ -210,8 +215,8 @@ static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, for (i = 0; i < 2; ++i) { const POSITION *const mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { - const MODE_INFO *const candidate_mi = xd->mi_8x8[mv_ref->col + mv_ref->row - * xd->mode_info_stride]; + const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row * + xd->mi_stride]; const MB_MODE_INFO *const candidate = &candidate_mi->mbmi; // Keep counts for entropy encoding. context_counter += mode_2_counter[candidate->mode]; @@ -230,9 +235,8 @@ static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, for (; i < MVREF_NEIGHBOURS; ++i) { const POSITION *const mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { - const MB_MODE_INFO *const candidate = &xd->mi_8x8[mv_ref->col + - mv_ref->row - * xd->mode_info_stride]->mbmi; + const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row * + xd->mi_stride]->mbmi; different_ref_found = 1; if (candidate->ref_frame[0] == ref_frame) @@ -257,19 +261,17 @@ static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, for (i = 0; i < MVREF_NEIGHBOURS; ++i) { const POSITION *mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { - const MB_MODE_INFO *const candidate = &xd->mi_8x8[mv_ref->col + - mv_ref->row - * xd->mode_info_stride]->mbmi; + const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row + * xd->mi_stride]->mbmi; // If the candidate is INTRA we don't want to consider its mv. - if (is_inter_block(candidate)) - IF_DIFF_REF_FRAME_ADD_MV(candidate); + IF_DIFF_REF_FRAME_ADD_MV(candidate); } } } // Since we still don't have a candidate we'll try the last frame. - if (prev_mbmi && is_inter_block(prev_mbmi)) + if (prev_mbmi) IF_DIFF_REF_FRAME_ADD_MV(prev_mbmi); Done: @@ -318,7 +320,7 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, int block, int ref, int mi_row, int mi_col, int_mv *nearest, int_mv *near) { int_mv mv_list[MAX_MV_REF_CANDIDATES]; - MODE_INFO *const mi = xd->mi_8x8[0]; + MODE_INFO *const mi = xd->mi[0]; b_mode_info *bmi = mi->bmi; int n; diff --git a/libvpx/vp9/common/vp9_onyxc_int.h b/libvpx/vp9/common/vp9_onyxc_int.h index 52889f7..fe9cc9e 100644 --- a/libvpx/vp9/common/vp9_onyxc_int.h +++ b/libvpx/vp9/common/vp9_onyxc_int.h @@ -126,7 +126,7 @@ typedef struct VP9Common { int MBs; int mb_rows, mi_rows; int mb_cols, mi_cols; - int mode_info_stride; + int mi_stride; /* profile settings */ TX_MODE tx_mode; @@ -179,7 +179,10 @@ typedef struct VP9Common { FRAME_COUNTS counts; unsigned int current_video_frame; - int version; + BITSTREAM_PROFILE profile; + + // BITS_8 in versions 0 and 1, BITS_10 or BITS_12 in version 2 + BIT_DEPTH bit_depth; #if CONFIG_VP9_POSTPROC struct postproc_state postproc_state; @@ -202,6 +205,9 @@ typedef struct VP9Common { // Handles memory for the codec. InternalFrameBufferList int_frame_buffers; + + PARTITION_CONTEXT *above_seg_context; + ENTROPY_CONTEXT *above_context; } VP9_COMMON; static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) { @@ -234,24 +240,33 @@ static INLINE int mi_cols_aligned_to_sb(int n_mis) { return ALIGN_POWER_OF_TWO(n_mis, MI_BLOCK_SIZE_LOG2); } +static INLINE void init_macroblockd(VP9_COMMON *cm, MACROBLOCKD *xd) { + int i; + + for (i = 0; i < MAX_MB_PLANE; ++i) { + xd->plane[i].dqcoeff = xd->dqcoeff[i]; + xd->above_context[i] = cm->above_context + + i * sizeof(*cm->above_context) * 2 * mi_cols_aligned_to_sb(cm->mi_cols); + } + + xd->above_seg_context = cm->above_seg_context; + xd->mi_stride = cm->mi_stride; +} + static INLINE const vp9_prob* get_partition_probs(const VP9_COMMON *cm, int ctx) { return cm->frame_type == KEY_FRAME ? vp9_kf_partition_probs[ctx] : cm->fc.partition_prob[ctx]; } -static INLINE void set_skip_context( - MACROBLOCKD *xd, - ENTROPY_CONTEXT *above_context[MAX_MB_PLANE], - ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16], - int mi_row, int mi_col) { +static INLINE void set_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col) { const int above_idx = mi_col * 2; const int left_idx = (mi_row * 2) & 15; int i; - for (i = 0; i < MAX_MB_PLANE; i++) { + for (i = 0; i < MAX_MB_PLANE; ++i) { struct macroblockd_plane *const pd = &xd->plane[i]; - pd->above_context = above_context[i] + (above_idx >> pd->subsampling_x); - pd->left_context = left_context[i] + (left_idx >> pd->subsampling_y); + pd->above_context = &xd->above_context[i][above_idx >> pd->subsampling_x]; + pd->left_context = &xd->left_context[i][left_idx >> pd->subsampling_y]; } } @@ -269,27 +284,27 @@ static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile, xd->left_available = (mi_col > tile->mi_col_start); } -static INLINE void set_prev_mi(VP9_COMMON *cm) { - const int use_prev_in_find_mv_refs = cm->width == cm->last_width && - cm->height == cm->last_height && - !cm->intra_only && - cm->last_show_frame; +static INLINE MODE_INFO *get_prev_mi(VP9_COMMON *cm) { + const int use_prev_mi = cm->coding_use_prev_mi && + cm->width == cm->last_width && + cm->height == cm->last_height && + !cm->intra_only && + cm->last_show_frame; // Special case: set prev_mi to NULL when the previous mode info // context cannot be used. - cm->prev_mi = use_prev_in_find_mv_refs ? - cm->prev_mip + cm->mode_info_stride + 1 : NULL; + return use_prev_mi ? &cm->prev_mip[cm->mi_stride + 1] : NULL; } static INLINE int frame_is_intra_only(const VP9_COMMON *const cm) { return cm->frame_type == KEY_FRAME || cm->intra_only; } -static INLINE void update_partition_context( - PARTITION_CONTEXT *above_seg_context, - PARTITION_CONTEXT left_seg_context[8], - int mi_row, int mi_col, BLOCK_SIZE subsize, BLOCK_SIZE bsize) { - PARTITION_CONTEXT *const above_ctx = above_seg_context + mi_col; - PARTITION_CONTEXT *const left_ctx = left_seg_context + (mi_row & MI_MASK); +static INLINE void update_partition_context(MACROBLOCKD *xd, + int mi_row, int mi_col, + BLOCK_SIZE subsize, + BLOCK_SIZE bsize) { + PARTITION_CONTEXT *const above_ctx = xd->above_seg_context + mi_col; + PARTITION_CONTEXT *const left_ctx = xd->left_seg_context + (mi_row & MI_MASK); // num_4x4_blocks_wide_lookup[bsize] / 2 const int bs = num_8x8_blocks_wide_lookup[bsize]; @@ -301,12 +316,11 @@ static INLINE void update_partition_context( vpx_memset(left_ctx, partition_context_lookup[subsize].left, bs); } -static INLINE int partition_plane_context( - const PARTITION_CONTEXT *above_seg_context, - const PARTITION_CONTEXT left_seg_context[8], - int mi_row, int mi_col, BLOCK_SIZE bsize) { - const PARTITION_CONTEXT *above_ctx = above_seg_context + mi_col; - const PARTITION_CONTEXT *left_ctx = left_seg_context + (mi_row & MI_MASK); +static INLINE int partition_plane_context(const MACROBLOCKD *xd, + int mi_row, int mi_col, + BLOCK_SIZE bsize) { + const PARTITION_CONTEXT *above_ctx = xd->above_seg_context + mi_col; + const PARTITION_CONTEXT *left_ctx = xd->left_seg_context + (mi_row & MI_MASK); const int bsl = mi_width_log2(bsize); const int bs = 1 << bsl; diff --git a/libvpx/vp9/common/vp9_postproc.h b/libvpx/vp9/common/vp9_postproc.h index b07d5d0..ebebc1a 100644 --- a/libvpx/vp9/common/vp9_postproc.h +++ b/libvpx/vp9/common/vp9_postproc.h @@ -13,6 +13,7 @@ #define VP9_COMMON_VP9_POSTPROC_H_ #include "vpx_ports/mem.h" +#include "vpx_scale/yv12config.h" #include "vp9/common/vp9_ppflags.h" #ifdef __cplusplus diff --git a/libvpx/vp9/common/vp9_ppflags.h b/libvpx/vp9/common/vp9_ppflags.h index 8168935..e8b04d2 100644 --- a/libvpx/vp9/common/vp9_ppflags.h +++ b/libvpx/vp9/common/vp9_ppflags.h @@ -33,10 +33,12 @@ typedef struct { int post_proc_flag; int deblocking_level; int noise_level; +#if CONFIG_POSTPROC_VISUALIZER int display_ref_frame_flag; int display_mb_modes_flag; int display_b_modes_flag; int display_mv_flag; +#endif // CONFIG_POSTPROC_VISUALIZER } vp9_ppflags_t; #ifdef __cplusplus diff --git a/libvpx/vp9/common/vp9_pred_common.c b/libvpx/vp9/common/vp9_pred_common.c index 197bcb6..bc9d6ef 100644 --- a/libvpx/vp9/common/vp9_pred_common.c +++ b/libvpx/vp9/common/vp9_pred_common.c @@ -348,7 +348,7 @@ int vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) { // left of the entries corresponding to real blocks. // The prediction flags in these dummy entries are initialized to 0. int vp9_get_tx_size_context(const MACROBLOCKD *xd) { - const int max_tx_size = max_txsize_lookup[xd->mi_8x8[0]->mbmi.sb_type]; + const int max_tx_size = max_txsize_lookup[xd->mi[0]->mbmi.sb_type]; const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd)); const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd)); const int has_above = above_mbmi != NULL; diff --git a/libvpx/vp9/common/vp9_pred_common.h b/libvpx/vp9/common/vp9_pred_common.h index 6c7a0d3..1a7ba86 100644 --- a/libvpx/vp9/common/vp9_pred_common.h +++ b/libvpx/vp9/common/vp9_pred_common.h @@ -19,11 +19,11 @@ extern "C" { #endif static INLINE const MODE_INFO *get_above_mi(const MACROBLOCKD *const xd) { - return xd->up_available ? xd->mi_8x8[-xd->mode_info_stride] : NULL; + return xd->up_available ? xd->mi[-xd->mi_stride] : NULL; } static INLINE const MODE_INFO *get_left_mi(const MACROBLOCKD *const xd) { - return xd->left_available ? xd->mi_8x8[-1] : NULL; + return xd->left_available ? xd->mi[-1] : NULL; } int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids, diff --git a/libvpx/vp9/common/vp9_reconinter.c b/libvpx/vp9/common/vp9_reconinter.c index 005f370..e722d6a 100644 --- a/libvpx/vp9/common/vp9_reconinter.c +++ b/libvpx/vp9/common/vp9_reconinter.c @@ -144,8 +144,9 @@ static void build_inter_predictors(MACROBLOCKD *xd, int plane, int block, int x, int y, int w, int h, int mi_x, int mi_y) { struct macroblockd_plane *const pd = &xd->plane[plane]; - const MODE_INFO *mi = xd->mi_8x8[0]; + const MODE_INFO *mi = xd->mi[0]; const int is_compound = has_second_ref(&mi->mbmi); + const InterpKernel *kernel = vp9_get_interp_kernel(mi->mbmi.interp_filter); int ref; for (ref = 0; ref < 1 + is_compound; ++ref) { @@ -193,8 +194,7 @@ static void build_inter_predictors(MACROBLOCKD *xd, int plane, int block, + (scaled_mv.col >> SUBPEL_BITS); inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride, - subpel_x, subpel_y, sf, w, h, ref, xd->interp_kernel, - xs, ys); + subpel_x, subpel_y, sf, w, h, ref, kernel, xs, ys); } } @@ -212,7 +212,7 @@ static void build_inter_predictors_for_planes(MACROBLOCKD *xd, BLOCK_SIZE bsize, const int bw = 4 * num_4x4_w; const int bh = 4 * num_4x4_h; - if (xd->mi_8x8[0]->mbmi.sb_type < BLOCK_8X8) { + if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8) { int i = 0, x, y; assert(bsize == BLOCK_8X8); for (y = 0; y < num_4x4_h; ++y) @@ -248,8 +248,9 @@ static void dec_build_inter_predictors(MACROBLOCKD *xd, int plane, int block, int x, int y, int w, int h, int mi_x, int mi_y) { struct macroblockd_plane *const pd = &xd->plane[plane]; - const MODE_INFO *mi = xd->mi_8x8[0]; + const MODE_INFO *mi = xd->mi[0]; const int is_compound = has_second_ref(&mi->mbmi); + const InterpKernel *kernel = vp9_get_interp_kernel(mi->mbmi.interp_filter); int ref; for (ref = 0; ref < 1 + is_compound; ++ref) { @@ -308,10 +309,8 @@ static void dec_build_inter_predictors(MACROBLOCKD *xd, int plane, int block, y0_16 = sf->scale_value_y(y0_16, sf); // Map the top left corner of the block into the reference frame. - // NOTE: This must be done in this way instead of - // sf->scale_value_x(x_start + x, sf). - x0 = sf->scale_value_x(x_start, sf) + sf->scale_value_x(x, sf); - y0 = sf->scale_value_y(y_start, sf) + sf->scale_value_y(y, sf); + x0 = sf->scale_value_x(x_start + x, sf); + y0 = sf->scale_value_y(y_start + y, sf); // Scale the MV and incorporate the sub-pixel offset of the block // in the reference frame. @@ -379,7 +378,7 @@ static void dec_build_inter_predictors(MACROBLOCKD *xd, int plane, int block, } inter_predictor(buf_ptr, buf_stride, dst, dst_buf->stride, subpel_x, - subpel_y, sf, w, h, ref, xd->interp_kernel, xs, ys); + subpel_y, sf, w, h, ref, kernel, xs, ys); } } @@ -396,7 +395,7 @@ void vp9_dec_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col, const int bw = 4 * num_4x4_w; const int bh = 4 * num_4x4_h; - if (xd->mi_8x8[0]->mbmi.sb_type < BLOCK_8X8) { + if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8) { int i = 0, x, y; assert(bsize == BLOCK_8X8); for (y = 0; y < num_4x4_h; ++y) diff --git a/libvpx/vp9/common/vp9_reconintra.c b/libvpx/vp9/common/vp9_reconintra.c index 915c1c1..44951b5 100644 --- a/libvpx/vp9/common/vp9_reconintra.c +++ b/libvpx/vp9/common/vp9_reconintra.c @@ -347,6 +347,8 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref, x0 = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x)) + x; y0 = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y)) + y; + vpx_memset(left_col, 129, 64); + // left if (left_available) { if (xd->mb_to_bottom_edge < 0) { @@ -366,8 +368,6 @@ static void build_intra_predictors(const MACROBLOCKD *xd, const uint8_t *ref, for (i = 0; i < bs; ++i) left_col[i] = ref[i * ref_stride - 1]; } - } else { - vpx_memset(left_col, 129, bs); } // TODO(hkuang) do not extend 2*bs pixels for all modes. diff --git a/libvpx/vp9/common/vp9_rtcd_defs.pl b/libvpx/vp9/common/vp9_rtcd_defs.pl index e4cd9d4..b455592 100644 --- a/libvpx/vp9/common/vp9_rtcd_defs.pl +++ b/libvpx/vp9/common/vp9_rtcd_defs.pl @@ -380,6 +380,10 @@ specialize qw/vp9_variance64x64/, "$sse2_x86inc", "$avx2_x86inc"; add_proto qw/unsigned int vp9_variance16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance16x16 mmx/, "$sse2_x86inc", "$avx2_x86inc"; +add_proto qw/void vp9_get_sse_sum_16x16/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse, int *sum"; +specialize qw/vp9_get_sse_sum_16x16 sse2/; +$vp9_get_sse_sum_16x16_sse2=vp9_get16x16var_sse2; + add_proto qw/unsigned int vp9_variance16x8/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"; specialize qw/vp9_variance16x8 mmx/, "$sse2_x86inc"; @@ -636,7 +640,7 @@ add_proto qw/void vp9_sad4x4x8/, "const uint8_t *src_ptr, int src_stride, const specialize qw/vp9_sad4x4x8 sse4/; add_proto qw/void vp9_sad64x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; -specialize qw/vp9_sad64x64x4d sse2/; +specialize qw/vp9_sad64x64x4d sse2 avx2/; add_proto qw/void vp9_sad32x64x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad32x64x4d sse2/; @@ -651,7 +655,7 @@ add_proto qw/void vp9_sad16x32x4d/, "const uint8_t *src_ptr, int src_stride, co specialize qw/vp9_sad16x32x4d sse2/; add_proto qw/void vp9_sad32x32x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; -specialize qw/vp9_sad32x32x4d sse2/; +specialize qw/vp9_sad32x32x4d sse2 avx2/; add_proto qw/void vp9_sad16x16x4d/, "const uint8_t *src_ptr, int src_stride, const uint8_t* const ref_ptr[], int ref_stride, unsigned int *sad_array"; specialize qw/vp9_sad16x16x4d sse2/; diff --git a/libvpx/vp9/common/vp9_scale.c b/libvpx/vp9/common/vp9_scale.c index e0f1e34..d3405fc 100644 --- a/libvpx/vp9/common/vp9_scale.c +++ b/libvpx/vp9/common/vp9_scale.c @@ -13,11 +13,11 @@ #include "vp9/common/vp9_scale.h" static INLINE int scaled_x(int val, const struct scale_factors *sf) { - return val * sf->x_scale_fp >> REF_SCALE_SHIFT; + return (int)((int64_t)val * sf->x_scale_fp >> REF_SCALE_SHIFT); } static INLINE int scaled_y(int val, const struct scale_factors *sf) { - return val * sf->y_scale_fp >> REF_SCALE_SHIFT; + return (int)((int64_t)val * sf->y_scale_fp >> REF_SCALE_SHIFT); } static int unscaled_value(int val, const struct scale_factors *sf) { diff --git a/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c b/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c index 7e9cc84..b84db97 100644 --- a/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c +++ b/libvpx/vp9/common/x86/vp9_subpixel_8t_intrin_avx2.c @@ -33,10 +33,11 @@ DECLARE_ALIGNED(32, static const uint8_t, filt4_global_avx2[32]) = { }; #if defined(__clang__) -# if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ <= 3) +# if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ <= 3) || \ + (defined(__APPLE__) && __clang_major__ == 5 && __clang_minor__ == 0) # define MM256_BROADCASTSI128_SI256(x) \ _mm_broadcastsi128_si256((__m128i const *)&(x)) -# else // clang > 3.3 +# else // clang > 3.3, and not 5.0 on macosx. # define MM256_BROADCASTSI128_SI256(x) _mm256_broadcastsi128_si256(x) # endif // clang <= 3.3 #elif defined(__GNUC__) |