📄 switched_filters.c
字号:
{
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
};
//
//
//
void readSIFOHeader()
{
Slice *currSlice = img->currentSlice;
int dP_nr = assignSE2partition[currSlice->dp_mode][SE_HEADER];
DataPartition *partition = &(currSlice->partArr[dP_nr]);
Bitstream *currStream = partition->bitstream;
int sub_pos, frame, nonzero;
if(img->type != I_SLICE)
{
img->filterParam = u_1("SH: encodig pass", currStream);
if(img->filterParam == 0)
{
for(sub_pos = 1; sub_pos < 16; sub_pos++)
{
img->filterSequence[sub_pos] = u_1("SH: filterSequence", currStream);
if(img->filterSequence[sub_pos] == 1)
{
if(u_1("SH: filterSequence", currStream))
img->filterSequence[sub_pos] = 2;
}
}
}
else
{
for(sub_pos = 1; sub_pos < 16; ++sub_pos)
{
img->filterFrame[sub_pos] = u_1("SH: filterFrame", currStream);
if(img->filterFrame[sub_pos] == 1)
{
if(u_1("SH: filterFrame", currStream))
img->filterFrame[sub_pos] = 2;
}
}
nonzero = u_1("SH: nonzero offset", currStream);
if(nonzero)
{
for(frame = 0; frame < listXsize[LIST_0]; ++frame)
{
if(frame == 0)
{
for(sub_pos = 0; sub_pos < 16; ++sub_pos)
img->subpelOffset_list0[sub_pos] = se_v("SH: subpelOffset_list0", currStream);
}
else
{
img->imgOffset_list0[frame] = se_v("SH: imgOffset_list0", currStream);
}
}
}
else
{
for(frame = 0; frame < listXsize[LIST_0]; ++frame)
{
if(frame == 0)
{
for(sub_pos = 0; sub_pos < 16; ++sub_pos)
img->subpelOffset_list0[sub_pos] = 0;
}
else
{
img->imgOffset_list0[frame] = 0;
}
}
}
if (img->type==B_SLICE)
{
nonzero = u_1("SH: nonzero offset", currStream);
if(nonzero)
{
for(frame = 0; frame < listXsize[LIST_1]; frame++)
{
if(frame == 0)
{
for(sub_pos = 0; sub_pos < 16; ++sub_pos)
img->subpelOffset_list1[sub_pos] = se_v("SH: subpelOffset_list1", currStream);
}
else
{
img->imgOffset_list1[frame] = se_v("SH: imgOffset_list1", currStream);
}
}
}
else
{
for(frame = 0; frame < listXsize[LIST_1]; ++frame)
{
if(frame == 0)
{
for(sub_pos = 0; sub_pos < 16; ++sub_pos)
img->subpelOffset_list1[sub_pos] = 0;
}
else
{
img->imgOffset_list1[frame] = 0;
}
}
}
}
}
}
}
//
//
//
int getblock2DFilt_quarter_pel(int ref_idx, StorablePicture **list, int x_pos, int y_pos,
int mvx, int mvy, int img_width, int img_height,
int block[BLOCK_SIZE][BLOCK_SIZE])
{
int i,j, ii, jj;
int x4, y4, sub_pos, pos_x, pos_y, x_sub, y_sub;
int temp;
int offset;
double is;
double *FILTER = NULL;
int FILTER_SIZE = 6;
int FILTER_OFFSET = (FILTER_SIZE) / 2 - 1;
if(img->filterParam == 0)
{
for(i = 0; i < BLOCK_SIZE; ++i) //y
for(j = 0; j < BLOCK_SIZE; ++j) //x
{
x4 = (j + x_pos) * 4 + mvx;
y4 = (i + y_pos) * 4 + mvy;
x_sub = (x4 < 0)? (4 - abs(x4) % 4) % 4: x4 % 4;
y_sub = (y4 < 0)? (4 - abs(y4) % 4) % 4: y4 % 4;
sub_pos = x_sub + 4 * y_sub;
if(sub_pos != 0)
{
if(img->filterSequence[sub_pos] == 0)
FILTER = STANDARD_2D_FILTER[sub_pos-1];
else if (img->filterSequence[sub_pos] == 1)
FILTER = SYMMETRIC_1[sub_pos-1];
else if (img->filterSequence[sub_pos] == 2)
FILTER = SYMMETRIC_2[sub_pos-1];
else
error("img->filterSequence should be less than 3", -1);
is = 0.0;
for(ii = 0; ii < FILTER_SIZE; ++ii)
for(jj = 0; jj < FILTER_SIZE; ++jj)
{
pos_y = Clip3(0, img_height-1, y4 / 4 - FILTER_OFFSET + ii);
if((y4 < 0) && (pos_y > 0))
pos_y -= 1;
pos_x = Clip3(0, img_width -1, x4 / 4 - FILTER_OFFSET + jj);
if((x4 < 0) && (pos_x > 0))
pos_x -=1;
is += (FILTER[FILTER_SIZE * ii + jj] * list[ref_idx]->imgY[pos_y][pos_x]);
}
block[j][i] = Clip3(0, 255, (int)(is + 0.5));
}
else
{
block[j][i] = list[ref_idx]->imgY[Clip3(0, img_height - 1, y4 / 4)][Clip3(0, img_width - 1, x4 / 4)];
}
}
}
else
{
for(i = 0; i < BLOCK_SIZE; ++i) //y
for(j = 0; j < BLOCK_SIZE; ++j) //x
{
x4 = (j + x_pos) * 4 + mvx;
y4 = (i + y_pos) * 4 + mvy;
x_sub = (x4 < 0)? (4 - abs(x4) % 4) % 4: x4 % 4;
y_sub = (y4 < 0)? (4 - abs(y4) % 4) % 4: y4 % 4;
sub_pos = x_sub + 4 * y_sub; // pos 1..15 in a 4x4 block
if(ref_idx == 0)
{
if(listX[LIST_0] == list)
offset = img->subpelOffset_list0[sub_pos];
else
offset = img->subpelOffset_list1[sub_pos];
}
else
{
if(list == listX[LIST_0])
{
if(listX[LIST_0][ref_idx] == listX[LIST_1][0])
offset = img->subpelOffset_list1[sub_pos];
else
offset = img->imgOffset_list0[ref_idx];
}
else
{
if (listX[LIST_1][ref_idx] == listX[LIST_0][0])
offset = img->subpelOffset_list0[sub_pos];
else
offset = img->imgOffset_list1[ref_idx];
}
}
if(sub_pos != 0)
{
if(img->filterFrame[sub_pos] == 0)
FILTER = STANDARD_2D_FILTER[sub_pos-1];
else if(img->filterFrame[sub_pos] == 1)
FILTER = SYMMETRIC_1[sub_pos-1];
else if (img->filterFrame[sub_pos] == 2)
FILTER = SYMMETRIC_2[sub_pos-1];
else
error("img->filterSequence should be less than 3", -1);
is = 0.0;
for(ii = 0; ii < FILTER_SIZE; ++ii)
for(jj = 0; jj < FILTER_SIZE; ++jj)
{
pos_y = Clip3(0, img_height - 1, y4 / 4 - FILTER_OFFSET + ii);
if((y4 < 0) && (pos_y > 0))
pos_y -= 1;
pos_x = Clip3(0, img_width - 1, x4 / 4 - FILTER_OFFSET + jj);
if((x4 < 0) && (pos_x > 0))
pos_x -= 1;
is += (FILTER[FILTER_SIZE * ii + jj] * list[ref_idx]->imgY[pos_y][pos_x]);
}
temp = Clip3(0, 255,(int)(is+0.5));
}
else
{
temp = list[ref_idx]->imgY[Clip3(0, img_height - 1, y4 / 4)][Clip3(0, img_width - 1, x4 / 4)];
}
temp = (int)(temp + offset);
block[j][i] = Clip3(0, 255, temp);
}
}
return sub_pos;
}
//
//
//
int getblock2DFilt(int ref_idx, StorablePicture **list, int x_pos, int y_pos,
int mvx, int mvy, int img_width, int img_height, int block[BLOCK_SIZE][BLOCK_SIZE])
{
// if(img->mv_res)
// error("does not support one_eighth_pel\n", 1);
// else
return getblock2DFilt_quarter_pel(ref_idx, list, x_pos, y_pos, mvx, mvy, img_width,img_height, block);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -