* 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 },
};
// 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},
};
// 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},
};
// 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},
{ 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;
+ }
+}
+
#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.
#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);
}