Commit 9ec09700 authored by Dmitry Kovalev's avatar Dmitry Kovalev

Adding vp9_get_filter_kernel() function.

Moving INTERPOLATIONFILTERTYPE enum and subpix_fn_table struct to
vp9_filter.h. Adding convenient typedef for subpel kernels.

Function vp9_setup_interp_filters() besides setting xd->subpix.filter_x &
xd->subpix.filter_y has a side effect of also setting scale factors. This
is not required inside decode_modes_b() because scale factors have been
already set by set_ref() calls. That's why replacing
vp9_setup_interp_filters() call with newly created vp9_get_filter_kernel()
call. The behavior of vp9_setup_interp_filters() is unchanged (it
is used from the encoder).

Change-Id: I3f36d3f7cd8d15195a6e2fafd1777cdaf9ecb847
parent 934c4e66
......@@ -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"
......@@ -55,14 +56,6 @@ typedef enum {
NUM_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
......
......@@ -21,9 +21,4 @@ typedef void (*convolve_fn_t)(const uint8_t *src, ptrdiff_t src_stride,
const int16_t *filter_y, int y_step_q4,
int w, int h);
struct subpix_fn_table {
const int16_t (*filter_x)[8];
const int16_t (*filter_y)[8];
};
#endif // VP9_COMMON_VP9_CONVOLVE_H_
......@@ -8,12 +8,14 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <assert.h>
#include "vpx_ports/mem.h"
#include "vp9/common/vp9_filter.h"
DECLARE_ALIGNED(256, const int16_t,
vp9_bilinear_filters[SUBPEL_SHIFTS][SUBPEL_TAPS]) = {
DECLARE_ALIGNED(256, const subpel_kernel,
vp9_bilinear_filters[SUBPEL_SHIFTS]) = {
{ 0, 0, 0, 128, 0, 0, 0, 0 },
{ 0, 0, 0, 120, 8, 0, 0, 0 },
{ 0, 0, 0, 112, 16, 0, 0, 0 },
......@@ -33,8 +35,8 @@ DECLARE_ALIGNED(256, const int16_t,
};
// Lagrangian interpolation filter
DECLARE_ALIGNED(256, const int16_t,
vp9_sub_pel_filters_8[SUBPEL_SHIFTS][SUBPEL_TAPS]) = {
DECLARE_ALIGNED(256, const subpel_kernel,
vp9_sub_pel_filters_8[SUBPEL_SHIFTS]) = {
{ 0, 0, 0, 128, 0, 0, 0, 0},
{ 0, 1, -5, 126, 8, -3, 1, 0},
{ -1, 3, -10, 122, 18, -6, 2, 0},
......@@ -54,8 +56,8 @@ DECLARE_ALIGNED(256, const int16_t,
};
// DCT based filter
DECLARE_ALIGNED(256, const int16_t,
vp9_sub_pel_filters_8s[SUBPEL_SHIFTS][SUBPEL_TAPS]) = {
DECLARE_ALIGNED(256, const subpel_kernel,
vp9_sub_pel_filters_8s[SUBPEL_SHIFTS]) = {
{0, 0, 0, 128, 0, 0, 0, 0},
{-1, 3, -7, 127, 8, -3, 1, 0},
{-2, 5, -13, 125, 17, -6, 3, -1},
......@@ -75,8 +77,8 @@ DECLARE_ALIGNED(256, const int16_t,
};
// freqmultiplier = 0.5
DECLARE_ALIGNED(256, const int16_t,
vp9_sub_pel_filters_8lp[SUBPEL_SHIFTS][SUBPEL_TAPS]) = {
DECLARE_ALIGNED(256, const subpel_kernel,
vp9_sub_pel_filters_8lp[SUBPEL_SHIFTS]) = {
{ 0, 0, 0, 128, 0, 0, 0, 0},
{-3, -1, 32, 64, 38, 1, -3, 0},
{-2, -2, 29, 63, 41, 2, -3, 0},
......@@ -94,3 +96,20 @@ DECLARE_ALIGNED(256, const int16_t,
{ 0, -3, 2, 41, 63, 29, -2, -2},
{ 0, -3, 1, 38, 64, 32, -1, -3}
};
const subpel_kernel *vp9_get_filter_kernel(INTERPOLATIONFILTERTYPE type) {
switch (type) {
case EIGHTTAP:
return vp9_sub_pel_filters_8;
case EIGHTTAP_SMOOTH:
return vp9_sub_pel_filters_8lp;
case EIGHTTAP_SHARP:
return vp9_sub_pel_filters_8s;
case BILINEAR:
return vp9_bilinear_filters;
default:
assert(!"Invalid filter type.");
return NULL;
}
}
......@@ -19,11 +19,28 @@
#define SUBPEL_SHIFTS (1 << SUBPEL_BITS)
#define SUBPEL_TAPS 8
extern const int16_t vp9_bilinear_filters[SUBPEL_SHIFTS][SUBPEL_TAPS];
extern const int16_t vp9_sub_pel_filters_6[SUBPEL_SHIFTS][SUBPEL_TAPS];
extern const int16_t vp9_sub_pel_filters_8[SUBPEL_SHIFTS][SUBPEL_TAPS];
extern const int16_t vp9_sub_pel_filters_8s[SUBPEL_SHIFTS][SUBPEL_TAPS];
extern const int16_t vp9_sub_pel_filters_8lp[SUBPEL_SHIFTS][SUBPEL_TAPS];
typedef enum {
EIGHTTAP = 0,
EIGHTTAP_SMOOTH = 1,
EIGHTTAP_SHARP = 2,
BILINEAR = 3,
SWITCHABLE = 4 /* should be the last one */
} INTERPOLATIONFILTERTYPE;
typedef const int16_t subpel_kernel[SUBPEL_TAPS];
struct subpix_fn_table {
const subpel_kernel *filter_x;
const subpel_kernel *filter_y;
};
const subpel_kernel *vp9_get_filter_kernel(INTERPOLATIONFILTERTYPE type);
extern const subpel_kernel vp9_bilinear_filters[SUBPEL_SHIFTS];
extern const subpel_kernel vp9_sub_pel_filters_6[SUBPEL_SHIFTS];
extern const subpel_kernel vp9_sub_pel_filters_8[SUBPEL_SHIFTS];
extern const subpel_kernel vp9_sub_pel_filters_8s[SUBPEL_SHIFTS];
extern const subpel_kernel vp9_sub_pel_filters_8lp[SUBPEL_SHIFTS];
// The VP9_BILINEAR_FILTERS_2TAP macro returns a pointer to the bilinear
// filter kernel as a 2 tap filter.
......
......@@ -20,34 +20,23 @@
#include "vp9/common/vp9_reconinter.h"
#include "vp9/common/vp9_reconintra.h"
void vp9_setup_interp_filters(MACROBLOCKD *xd,
INTERPOLATIONFILTERTYPE mcomp_filter_type,
VP9_COMMON *cm) {
if (xd->mi_8x8 && xd->this_mi) {
MB_MODE_INFO * mbmi = &xd->this_mi->mbmi;
MB_MODE_INFO *const mbmi = &xd->this_mi->mbmi;
set_scale_factors(xd, mbmi->ref_frame[0] - 1, mbmi->ref_frame[1] - 1,
cm->active_ref_scale);
set_scale_factors(xd, mbmi->ref_frame[0] - LAST_FRAME,
mbmi->ref_frame[1] - LAST_FRAME,
cm->active_ref_scale);
} else {
set_scale_factors(xd, -1, -1, cm->active_ref_scale);
}
switch (mcomp_filter_type) {
case EIGHTTAP:
case SWITCHABLE:
xd->subpix.filter_x = xd->subpix.filter_y = vp9_sub_pel_filters_8;
break;
case EIGHTTAP_SMOOTH:
xd->subpix.filter_x = xd->subpix.filter_y = vp9_sub_pel_filters_8lp;
break;
case EIGHTTAP_SHARP:
xd->subpix.filter_x = xd->subpix.filter_y = vp9_sub_pel_filters_8s;
break;
case BILINEAR:
xd->subpix.filter_x = xd->subpix.filter_y = vp9_bilinear_filters;
break;
}
xd->subpix.filter_x = xd->subpix.filter_y =
vp9_get_filter_kernel(mcomp_filter_type == SWITCHABLE ?
EIGHTTAP : mcomp_filter_type);
assert(((intptr_t)xd->subpix.filter_x & 0xff) == 0);
}
......
......@@ -224,7 +224,6 @@ static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) {
static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
const int less8x8 = bsize < BLOCK_8X8;
MB_MODE_INFO *mbmi;
......@@ -261,7 +260,8 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
if (has_second_ref(mbmi))
set_ref(pbi, 1, mi_row, mi_col);
vp9_setup_interp_filters(xd, mbmi->interp_filter, cm);
xd->subpix.filter_x = xd->subpix.filter_y =
vp9_get_filter_kernel(mbmi->interp_filter);
vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
if (decode_blocks)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment