📄 switched_filters.c
字号:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <float.h>
// #define NDEBUG
#include <assert.h>
#include <memory.h>
#include "global.h"
#include "memalloc.h"
#include "malloc.h"
#include "defines.h"
#include "mbuffer.h"
#include "image.h"
#include "adaptive_filter.h"
#include "switched_filters.h"
#ifdef SWITCHED_FILTERS
static double AccErrorP[NUM_SIFO][16]; // [Filter][Sppos]
static double SequenceAccErrorP[NUM_SIFO][16]; // [Filter][Sppos]
static int SamplesSubPelOffset[16]; // [Sppos]
static int SamplesFrameOffsetP[MAX_REFERENCE_PICTURES]; // [Frame]
static double AccFrameOffsetP[MAX_REFERENCE_PICTURES][16][NUM_SIFO];// [Frame][Sppos][Filter]
// Prediction error used in frame filter selection
static double AccErrorB[NUM_SIFO][NUM_SIFO][16][16]; // [FilterF][FilterB][SpposF][SpposB]
static int SamplesB[NUM_SIFO][NUM_SIFO][16][16]; // [FilterF][FilterB][SpposF][SpposB]
static int BestCombFilterB[16]; // [Sppos]
// Prediction error used in Sequence filter selection
static double SequenceAccErrorB[NUM_SIFO][NUM_SIFO][16][16]; // [FilterF][FilterB][SpposF][SpposB]
static int SequenceBestCombFilterB[16]; // [Sppos]
// Frame offsets
static int FrameOffsetF[MAX_REFERENCE_PICTURES]; // [Frame]
static int FrameOffsetB[MAX_REFERENCE_PICTURES]; // [Frame]
static double AccFrameOffsetF[MAX_REFERENCE_PICTURES]; // [Frame]
static double AccFrameOffsetB[MAX_REFERENCE_PICTURES]; // [Frame]
static int SamplesFrameOffsetF[MAX_REFERENCE_PICTURES]; // [Frame]
static int SamplesFrameOffsetB[MAX_REFERENCE_PICTURES]; // [Frame]
// SubPel offsets
static int SubPelOffsetF[16]; // [Sppos]
static int SubPelOffsetB[16]; // [Sppos]
static double AccSubPelOffsetF[16]; // [Sppos]
static double AccSubPelOffsetB[16]; // [Sppos]
static int SamplesSubPelOffsetF[16]; // [Sppos]
static int SamplesSubPelOffsetB[16]; // [Sppos]
static double SIFO_FILTER[NUM_SIFO][15][SQR_FILTER];
extern pic_parameter_set_rbsp_t *PicParSet[MAXPPS];
extern void GenerateFullPelRepresentation(pel_t ** Fourthpel, pel_t * Fullpel, int xsize, int ysize);
extern void frame_picture (Picture *frame, int method);
extern double STANDARD_2D_FILTER[15][SQR_FILTER];
//
//
//
double SYMMETRIC_1[15][SQR_FILTER] = {
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
-1.0/128.0, -2.0/128.0, 97.0/128.0, 42.0/128.0, -11.0/128.0, 3.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // a_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
3.0/128.0, -16.0/128.0, 77.0/128.0, 77.0/128.0, -16.0/128.0, 3.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // b_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
3.0/128.0, -11.0/128.0, 42.0/128.0, 97.0/128.0, -2.0/128.0, -1.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // c_pos
{
0.0/128.0, 0.0/128.0, -1.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -2.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 97.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 42.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -11.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 3.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // d_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -7.0/128.0, 4.0/128.0, -2.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, 4.0/128.0, 66.0/128.0, 36.0/128.0, 1.0/128.0, 0.0/128.0,
0.0/128.0, -2.0/128.0, 36.0/128.0, 7.0/128.0, -6.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, 1.0/128.0, -6.0/128.0, 2.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // e_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -4.0/128.0, -1.0/128.0, -1.0/128.0, -4.0/128.0, 0.0/128.0,
0.0/128.0, -2.0/128.0, 56.0/128.0, 56.0/128.0, -2.0/128.0, 0.0/128.0,
0.0/128.0, -7.0/128.0, 25.0/128.0, 25.0/128.0, -7.0/128.0, 0.0/128.0,
0.0/128.0, 1.0/128.0, -4.0/128.0, -4.0/128.0, 1.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // f_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, -2.0/128.0, 4.0/128.0, -7.0/128.0, 0.0/128.0,
0.0/128.0, 1.0/128.0, 36.0/128.0, 66.0/128.0, 4.0/128.0, 0.0/128.0,
0.0/128.0, -6.0/128.0, 7.0/128.0, 36.0/128.0, -2.0/128.0, 0.0/128.0,
0.0/128.0, 2.0/128.0, -6.0/128.0, 1.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // g_pos
{
0.0/128.0, 0.0/128.0, 3.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -16.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 77.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 77.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -16.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 3.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // h_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -4.0/128.0, -2.0/128.0, -7.0/128.0, 1.0/128.0, 0.0/128.0,
0.0/128.0, -1.0/128.0, 56.0/128.0, 25.0/128.0, -4.0/128.0, 0.0/128.0,
0.0/128.0, -1.0/128.0, 56.0/128.0, 25.0/128.0, -4.0/128.0, 0.0/128.0,
0.0/128.0, -4.0/128.0, -2.0/128.0, -7.0/128.0, 1.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // i_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -6.0/128.0, -6.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -6.0/128.0, 44.0/128.0, 44.0/128.0, -6.0/128.0, 0.0/128.0,
0.0/128.0, -6.0/128.0, 44.0/128.0, 44.0/128.0, -6.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -6.0/128.0, -6.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // j_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 1.0/128.0, -7.0/128.0, -2.0/128.0, -4.0/128.0, 0.0/128.0,
0.0/128.0, -4.0/128.0, 25.0/128.0, 56.0/128.0, -1.0/128.0, 0.0/128.0,
0.0/128.0, -4.0/128.0, 25.0/128.0, 56.0/128.0, -1.0/128.0, 0.0/128.0,
0.0/128.0, 1.0/128.0, -7.0/128.0, -2.0/128.0, -4.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // k_pos
{
0.0/128.0, 0.0/128.0, 3.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -11.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 42.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 97.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -2.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -1.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // l_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, 1.0/128.0, -6.0/128.0, 2.0/128.0, 0.0/128.0,
0.0/128.0, -2.0/128.0, 36.0/128.0, 7.0/128.0, -6.0/128.0, 0.0/128.0,
0.0/128.0, 4.0/128.0, 66.0/128.0, 36.0/128.0, 1.0/128.0, 0.0/128.0,
0.0/128.0, -7.0/128.0, 4.0/128.0, -2.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // m_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 1.0/128.0, -4.0/128.0, -4.0/128.0, 1.0/128.0, 0.0/128.0,
0.0/128.0, -7.0/128.0, 25.0/128.0, 25.0/128.0, -7.0/128.0, 0.0/128.0,
0.0/128.0, -2.0/128.0, 56.0/128.0, 56.0/128.0, -2.0/128.0, 0.0/128.0,
0.0/128.0, -4.0/128.0, -1.0/128.0, -1.0/128.0, -4.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // n_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 2.0/128.0, -6.0/128.0, 1.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, -6.0/128.0, 7.0/128.0, 36.0/128.0, -2.0/128.0, 0.0/128.0,
0.0/128.0, 1.0/128.0, 36.0/128.0, 66.0/128.0, 4.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, -2.0/128.0, 4.0/128.0, -7.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
} // o_pos
};
//
//
//
double SYMMETRIC_2[15][SQR_FILTER] = {
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
4.0/128.0, -14.0/128.0, 108.0/128.0, 38.0/128.0, -12.0/128.0, 4.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // a_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
6.0/128.0, -23.0/128.0, 81.0/128.0, 81.0/128.0, -23.0/128.0, 6.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // b_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
4.0/128.0, -12.0/128.0, 38.0/128.0, 108.0/128.0, -14.0/128.0, 4.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // c_pos
{
0.0/128.0, 0.0/128.0, 4.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -14.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 108.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 38.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -12.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 4.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // d_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -6.0/128.0, 2.0/128.0, -4.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, 2.0/128.0, 71.0/128.0, 38.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -4.0/128.0, 38.0/128.0, 7.0/128.0, -7.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, 0.0/128.0, -7.0/128.0, 4.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // e_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, -2.0/128.0, -2.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, 58.0/128.0, 58.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, -9.0/128.0, 26.0/128.0, 26.0/128.0, -9.0/128.0, 0.0/128.0,
0.0/128.0, 2.0/128.0, -5.0/128.0, -5.0/128.0, 2.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // f_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, -4.0/128.0, 2.0/128.0, -6.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 38.0/128.0, 71.0/128.0, 2.0/128.0, 0.0/128.0,
0.0/128.0, -7.0/128.0, 7.0/128.0, 38.0/128.0, -4.0/128.0, 0.0/128.0,
0.0/128.0, 4.0/128.0, -7.0/128.0, 0.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // g_pos
{
0.0/128.0, 0.0/128.0, 6.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -23.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 81.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 81.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -23.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 6.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // h_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, -3.0/128.0, -9.0/128.0, 2.0/128.0, 0.0/128.0,
0.0/128.0, -2.0/128.0, 58.0/128.0, 26.0/128.0, -5.0/128.0, 0.0/128.0,
0.0/128.0, -2.0/128.0, 58.0/128.0, 26.0/128.0, -5.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, -3.0/128.0, -9.0/128.0, 2.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // i_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 1.0/128.0, -7.0/128.0, -7.0/128.0, 1.0/128.0, 0.0/128.0,
0.0/128.0, -7.0/128.0, 45.0/128.0, 45.0/128.0, -7.0/128.0, 0.0/128.0,
0.0/128.0, -7.0/128.0, 45.0/128.0, 45.0/128.0, -7.0/128.0, 0.0/128.0,
0.0/128.0, 1.0/128.0, -7.0/128.0, -7.0/128.0, 1.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // j_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 2.0/128.0, -9.0/128.0, -3.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, -5.0/128.0, 26.0/128.0, 58.0/128.0, -2.0/128.0, 0.0/128.0,
0.0/128.0, -5.0/128.0, 26.0/128.0, 58.0/128.0, -2.0/128.0, 0.0/128.0,
0.0/128.0, 2.0/128.0, -9.0/128.0, -3.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // k_pos
{
0.0/128.0, 0.0/128.0, 4.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -12.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 38.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 108.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, -14.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 4.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // l_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, 0.0/128.0, -7.0/128.0, 4.0/128.0, 0.0/128.0,
0.0/128.0, -4.0/128.0, 38.0/128.0, 7.0/128.0, -7.0/128.0, 0.0/128.0,
0.0/128.0, 2.0/128.0, 71.0/128.0, 38.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, -6.0/128.0, 2.0/128.0, -4.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // m_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 2.0/128.0, -5.0/128.0, -5.0/128.0, 2.0/128.0, 0.0/128.0,
0.0/128.0, -9.0/128.0, 26.0/128.0, 26.0/128.0, -9.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, 58.0/128.0, 58.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, -2.0/128.0, -2.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
}, // n_pos
{
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0,
0.0/128.0, 4.0/128.0, -7.0/128.0, 0.0/128.0, -3.0/128.0, 0.0/128.0,
0.0/128.0, -7.0/128.0, 7.0/128.0, 38.0/128.0, -4.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 38.0/128.0, 71.0/128.0, 2.0/128.0, 0.0/128.0,
0.0/128.0, -3.0/128.0, -4.0/128.0, 2.0/128.0, -6.0/128.0, 0.0/128.0,
0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0, 0.0/128.0
} // o_pos
};
//
//
//
static int Clip3Fun(int low, int high, int val)
{
return ((val < low)? low: (val > high)? high: val);
}
//
// Finds a decision vector different in one position and with smallest SAD
//
static double get_min_d(double err[NUM_SIFO][NUM_SIFO][16][16],
int old_d[16], int new_d[16], double currSAD)
{
int spp, flt, sppF, sppB;
double minSAD = currSAD;
int tmp_d[16];
double tmpSAD;
for(spp = 1; spp < 16; ++spp)
{
// Copy a fresh old_d into tmp_d
memcpy(tmp_d, old_d, sizeof(int) * 16);
// Try the remaining (NUM_SIFO - 1) filters on the position spp
for(flt = 0; flt < NUM_SIFO - 1; ++flt)
{
tmp_d[spp] = (tmp_d[spp] + 1) % NUM_SIFO;
tmpSAD = 0;
for(sppF = 1; sppF < 16; ++sppF)
for(sppB = 1; sppB < 16; ++sppB)
tmpSAD += err[tmp_d[sppF]][tmp_d[sppB]][sppF][sppB];
if(tmpSAD < minSAD)
{
minSAD = tmpSAD;
memcpy(new_d, tmp_d, sizeof(int) * 16);
}
}
}
return minSAD;
}
//
// Compute filter combination for frame or sequence
//
static void ComputeFilterCombination_B_gd(double err[NUM_SIFO][NUM_SIFO][16][16], int out[16])
{
int min_d[16] = {0};
double oldSAD = 0.0;
double minSAD;
int sppF, sppB;
int tmp_d[16] = {0};
// Compute error for min_d = 0^n
for(sppF = 1; sppF < 16; ++sppF)
for(sppB = 1; sppB < 16; ++sppB)
oldSAD += err[0][0][sppF][sppB];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -