📄 me_distortion.c
字号:
src_line = src_tmp + x;
for (y4 = 0; y4 < BLOCK_SIZE; y4++ )
{
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
ref_line += img_padded_size_x_m4x4;
src_line += src_size_x;
}
if ((mcost += HadamardSAD4x4 (diff)) > min_mcost) return mcost;
}
src_tmp += src_size_mul;
}
}
else
{ // 8x8 TRANSFORM
src_size_x = (blocksize_x - BLOCK_SIZE_8x8);
src_size_mul = blocksize_x * BLOCK_SIZE_8x8;
for (y = cand_y; y < cand_y + (blocksize_y<<2); y += (BLOCK_SIZE_8x8_SP) )
{
for (x=0; x<blocksize_x; x += BLOCK_SIZE_8x8 )
{
d = diff;
ref_line = get_line[ref_access_method] (ref_pic_sub.luma, y, cand_x + (x<<2));
src_line = src_tmp + x;
for (y4 = 0; y4 < BLOCK_SIZE_8x8; y4++ )
{
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
*d++ = *src_line++ - *ref_line++ ;
ref_line += img_padded_size_x_m8x8;
src_line += src_size_x;
}
if ((mcost += HadamardSAD8x8 (diff)) > min_mcost) return mcost;
}
src_tmp += src_size_mul;
}
}
return mcost;
}
/*!
************************************************************************
* \brief
* SAD computation of weighted samples _with_ Hadamard Transform
************************************************************************
*/
int computeSATDWP(imgpel* src_pic,
int blocksize_y,
int blocksize_x,
int min_mcost,
int cand_x,
int cand_y)
{
int mcost = 0;
int y, x, y4, *d;
int weighted_pel;
int src_size_x, src_size_mul;
imgpel *src_tmp = src_pic;
if ( !test8x8transform )
{ // 4x4 TRANSFORM
src_size_x = (blocksize_x - BLOCK_SIZE);
src_size_mul = blocksize_x * BLOCK_SIZE;
for (y = cand_y; y < cand_y + (blocksize_y<<2); y += (BLOCK_SIZE_SP))
{
for (x=0; x<blocksize_x; x += BLOCK_SIZE)
{
d = diff;
ref_line = get_line[ref_access_method] (ref_pic_sub.luma, y, cand_x + (x<<2));
src_line = src_tmp + x;
for (y4 = 0; y4 < BLOCK_SIZE; y4++ )
{
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
ref_line += img_padded_size_x_m4x4;
src_line += src_size_x;
}
if ((mcost += HadamardSAD4x4 (diff)) > min_mcost) return mcost;
}
src_tmp += src_size_mul;
}
}
else
{ // 8x8 TRANSFORM
src_size_x = (blocksize_x - BLOCK_SIZE_8x8);
src_size_mul = blocksize_x * BLOCK_SIZE_8x8;
for (y = cand_y; y < cand_y + (blocksize_y<<2); y += (BLOCK_SIZE_8x8_SP) )
{
for (x=0; x<blocksize_x; x += BLOCK_SIZE_8x8 )
{
d = diff;
ref_line = get_line[ref_access_method] (ref_pic_sub.luma, y, cand_x + (x<<2));
src_line = src_tmp + x;
for (y4 = 0; y4 < BLOCK_SIZE_8x8; y4++ )
{
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
weighted_pel = iClip1( img->max_imgpel_value, ((weight_luma * *ref_line++ + wp_luma_round) >> luma_log_weight_denom) + offset_luma);
*d++ = *src_line++ - weighted_pel;
ref_line += img_padded_size_x_m8x8;
src_line += src_size_x;
}
if ((mcost += HadamardSAD8x8 (diff)) > min_mcost) return mcost;
}
src_tmp += src_size_mul;
}
}
return mcost;
}
/*!
************************************************************************
* \brief
* BiPred (w/o weights) SATD computation
************************************************************************
*/
int computeBiPredSATD1(imgpel* src_pic,
int blocksize_y,
int blocksize_x,
int min_mcost,
int cand_x1, int cand_y1,
int cand_x2, int cand_y2)
{
int mcost = 0;
int y, x, y4, *d;
int src_size_x, src_size_mul;
imgpel *src_tmp = src_pic;
if ( !test8x8transform )
{ // 4x4 TRANSFORM
src_size_x = (blocksize_x - BLOCK_SIZE);
src_size_mul = blocksize_x * BLOCK_SIZE;
for (y=0; y<(blocksize_y<<2); y += (BLOCK_SIZE_SP))
{
for (x=0; x<blocksize_x; x += BLOCK_SIZE)
{
d = diff;
src_line = src_tmp + x;
ref2_line = get_line[bipred2_access_method] (ref_pic2_sub.luma, cand_y2 + y, cand_x2 + (x<<2));
ref1_line = get_line[bipred1_access_method] (ref_pic1_sub.luma, cand_y1 + y, cand_x1 + (x<<2));
for (y4 = 0; y4 < BLOCK_SIZE; y4++ )
{
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
ref1_line += img_padded_size_x_m4x4;
ref2_line += img_padded_size_x_m4x4;
src_line += src_size_x;
}
if ((mcost += HadamardSAD4x4 (diff)) > min_mcost) return mcost;
}
src_tmp += src_size_mul;
}
}
else
{ // 8x8 TRANSFORM
src_size_x = (blocksize_x - BLOCK_SIZE_8x8);
src_size_mul = blocksize_x * BLOCK_SIZE_8x8;
for (y=0; y<blocksize_y; y += BLOCK_SIZE_8x8 )
{
int y_pos2 = cand_y2 + (y<<2);
int y_pos1 = cand_y1 + (y<<2);
for (x=0; x<blocksize_x; x += BLOCK_SIZE_8x8 )
{
d = diff;
src_line = src_tmp + x;
ref2_line = get_line[bipred2_access_method] (ref_pic2_sub.luma, y_pos2, cand_x2 + (x<<2));
ref1_line = get_line[bipred1_access_method] (ref_pic1_sub.luma, y_pos1, cand_x1 + (x<<2));
for (y4 = 0; y4 < BLOCK_SIZE_8x8; y4++ )
{
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
*d++ = (*src_line++) - ((*ref1_line++ + *ref2_line++ + 1)>>1);
ref1_line += img_padded_size_x_m8x8;
ref2_line += img_padded_size_x_m8x8;
src_line += src_size_x;
}
if ((mcost += HadamardSAD8x8 (diff)) > min_mcost) return mcost;
}
src_tmp += src_size_mul;
}
}
return mcost;
}
/*!
************************************************************************
* \brief
* BiPred (w/ weights) SATD computation
************************************************************************
*/
int computeBiPredSATD2(imgpel* src_pic,
int blocksize_y,
int blocksize_x,
int min_mcost,
int cand_x1, int cand_y1,
int cand_x2, int cand_y2)
{
int mcost = 0;
int y, x, y4, *d;
int weighted_pel, pixel1, pixel2;
int denom = luma_log_weight_denom + 1;
int lround = 2 * wp_luma_round;
int src_size_x, src_size_mul;
imgpel *src_tmp = src_pic;
if ( !test8x8transform )
{ // 4x4 TRANSFORM
src_size_x = (blocksize_x - BLOCK_SIZE);
src_size_mul = blocksize_x * BLOCK_SIZE;
for (y=0; y<(blocksize_y<<2); y += BLOCK_SIZE_SP)
{
for (x=0; x<blocksize_x; x += BLOCK_SIZE)
{
d = diff;
src_line = src_tmp + x;
ref2_line = get_line[bipred2_access_method] (ref_pic2_sub.luma, cand_y2 + y, cand_x2 + (x<<2));
ref1_line = get_line[bipred1_access_method] (ref_pic1_sub.luma, cand_y1 + y, cand_x1 + (x<<2));
for (y4 = 0; y4 < BLOCK_SIZE; y4++ )
{
// 0
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 1
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 2
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 3
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
ref1_line += img_padded_size_x_m4x4;
ref2_line += img_padded_size_x_m4x4;
src_line += src_size_x;
}
if ((mcost += HadamardSAD4x4 (diff)) > min_mcost) return mcost;
}
src_tmp += src_size_mul;
}
}
else
{ // 8x8 TRANSFORM
src_size_x = (blocksize_x - BLOCK_SIZE_8x8);
src_size_mul = blocksize_x * BLOCK_SIZE_8x8;
for (y=0; y<blocksize_y; y += BLOCK_SIZE_8x8 )
{
int y_pos2 = cand_y2 + (y<<2);
int y_pos1 = cand_y1 + (y<<2);
for (x=0; x<blocksize_x; x += BLOCK_SIZE_8x8 )
{
d = diff;
src_line = src_tmp + x;
ref2_line = get_line[bipred2_access_method] (ref_pic2_sub.luma, y_pos2, cand_x2 + (x<<2));
ref1_line = get_line[bipred1_access_method] (ref_pic1_sub.luma, y_pos1, cand_x1 + (x<<2));
for (y4 = 0; y4 < BLOCK_SIZE_8x8; y4++ )
{
// 0
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 1
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 2
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 3
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 4
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 5
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 6
pixel1 = weight1 * (*ref1_line++);
pixel2 = weight2 * (*ref2_line++);
weighted_pel = iClip1( img->max_imgpel_value, ((pixel1 + pixel2 + lround) >> denom) + offsetBi);
*d++ = (*src_line++) - weighted_pel;
// 7
pixel1 = weight1 * (*ref1_line++);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -