📄 mc.c
字号:
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
if(chroma_format != 3){
width >>= 1;
xv /= 2;
x /= 2;
r_offset -= x;
p_offset -= x;
}
if(chroma_format == 1){
height >>= 1;
yv /= 2;
y /= 2;
r_offset -= in->width * y;
p_offset -= in->width * y;
}
r = in->u + r_offset;
p = out->u + p_offset;
xh = xv & 1;
yh = yv & 1;
xiv = xv >> 1;
yiv = yv >> 1;
r += yiv * r_step + xiv;
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
r = in->v + r_offset;
p = out->v + p_offset;
r += yiv * r_step + xiv;
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
}
void prediction_sse(FRAME *in, FRAME *out, int type, int xv, int yv, int x, int y, int first, int chroma_format)
{
int r_offset, p_offset;
int r_step, p_step;
int width, height;
int xh, yh;
int xiv, yiv;
unsigned char *r, *p;
static const ASM_MC_CORE table[2][2][2][2] = {
{/* width - 8 */
{ /* horizontal full */
{ /* vertical full */
prediction_w8_ff_2nd_sse,
prediction_w8_ff_1st_mmx,
},
{ /* vertical half */
prediction_w8_fh_2nd_sse,
prediction_w8_fh_1st_sse,
},
},
{ /* horizontal half */
{ /* vertical full */
prediction_w8_hf_2nd_sse,
prediction_w8_hf_1st_sse,
},
{ /* vertical half */
prediction_w8_hh_2nd_mmx,
prediction_w8_hh_1st_mmx,
},
},
},
{/* width - 16 */
{ /* horizontal full */
{ /* vertical full */
prediction_w16_ff_2nd_sse,
prediction_w16_ff_1st_mmx,
},
{ /* vertical half */
prediction_w16_fh_2nd_sse,
prediction_w16_fh_1st_sse,
},
},
{ /* horizontal half */
{ /* vertical full */
prediction_w16_hf_2nd_sse,
prediction_w16_hf_1st_sse,
},
{ /* vertical half */
prediction_w16_hh_2nd_mmx,
prediction_w16_hh_1st_mmx,
},
},
},
};
switch(type){
case PREDICTION_FRAME_TO_FRAME:
r_offset = in->width * y + x;
p_offset = in->width * y + x;
r_step = in->width;
p_step = in->width;
width = 16;
height = 16;
break;
case PREDICTION_FRAME_TO_TOP:
r_offset = in->width * y + x;
p_offset = in->width * y + x;
r_step = in->width;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_FRAME_TO_BOTOM:
r_offset = in->width * (y+1) + x;
p_offset = in->width * (y+1) + x;
r_step = in->width;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_TOP_TO_TOP:
r_offset = in->width * y + x;
p_offset = in->width * y + x;
r_step = in->width * 2;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_TOP_TO_BOTOM:
r_offset = in->width * y + x;
p_offset = in->width * (y+1) + x;
r_step = in->width * 2;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_BOTOM_TO_TOP:
r_offset = in->width * (y+1) + x;
p_offset = in->width * y + x;
r_step = in->width * 2;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_BOTOM_TO_BOTOM:
r_offset = in->width * (y+1) + x;
p_offset = in->width * (y+1) + x;
r_step = in->width * 2;
p_step = in->width * 2;
width = 16;
height = 8;
break;
default:
return;
}
r = in->y + r_offset;
p = out->y + p_offset;
xh = xv & 1;
yh = yv & 1;
xiv = xv >> 1;
yiv = yv >> 1;
r += yiv * r_step + xiv;
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
if(chroma_format != 3){
width >>= 1;
xv /= 2;
x /= 2;
r_offset -= x;
p_offset -= x;
}
if(chroma_format == 1){
height >>= 1;
yv /= 2;
y /= 2;
r_offset -= in->width * y;
p_offset -= in->width * y;
}
r = in->u + r_offset;
p = out->u + p_offset;
xh = xv & 1;
yh = yv & 1;
xiv = xv >> 1;
yiv = yv >> 1;
r += yiv * r_step + xiv;
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
r = in->v + r_offset;
p = out->v + p_offset;
r += yiv * r_step + xiv;
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
}
void prediction_sse2(FRAME *in, FRAME *out, int type, int xv, int yv, int x, int y, int first, int chroma_format)
{
int r_offset, p_offset;
int r_step, p_step;
int width, height;
int xh, yh;
int xiv, yiv;
unsigned char *r, *p;
static const ASM_MC_CORE table[2][2][2][2] = {
{/* width - 8 */
{ /* horizontal full */
{ /* vertical full */
prediction_w8_ff_2nd_sse,
prediction_w8_ff_1st_mmx,
},
{ /* vertical half */
prediction_w8_fh_2nd_sse,
prediction_w8_fh_1st_sse,
},
},
{ /* horizontal half */
{ /* vertical full */
prediction_w8_hf_2nd_sse,
prediction_w8_hf_1st_sse,
},
{ /* vertical half */
prediction_w8_hh_2nd_mmx,
prediction_w8_hh_1st_mmx,
},
},
},
{/* width - 16 */
{ /* horizontal full */
{ /* vertical full */
prediction_w16_ff_2nd_sse2,
prediction_w16_ff_1st_mmx,
},
{ /* vertical half */
prediction_w16_fh_2nd_sse2,
prediction_w16_fh_1st_sse2,
},
},
{ /* horizontal half */
{ /* vertical full */
prediction_w16_hf_2nd_sse2,
prediction_w16_hf_1st_sse2,
},
{ /* vertical half */
prediction_w16_hh_2nd_sse2,
prediction_w16_hh_1st_sse2,
},
},
},
};
switch(type){
case PREDICTION_FRAME_TO_FRAME:
r_offset = in->width * y + x;
p_offset = in->width * y + x;
r_step = in->width;
p_step = in->width;
width = 16;
height = 16;
break;
case PREDICTION_FRAME_TO_TOP:
r_offset = in->width * y + x;
p_offset = in->width * y + x;
r_step = in->width;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_FRAME_TO_BOTOM:
r_offset = in->width * (y+1) + x;
p_offset = in->width * (y+1) + x;
r_step = in->width;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_TOP_TO_TOP:
r_offset = in->width * y + x;
p_offset = in->width * y + x;
r_step = in->width * 2;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_TOP_TO_BOTOM:
r_offset = in->width * y + x;
p_offset = in->width * (y+1) + x;
r_step = in->width * 2;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_BOTOM_TO_TOP:
r_offset = in->width * (y+1) + x;
p_offset = in->width * y + x;
r_step = in->width * 2;
p_step = in->width * 2;
width = 16;
height = 8;
break;
case PREDICTION_BOTOM_TO_BOTOM:
r_offset = in->width * (y+1) + x;
p_offset = in->width * (y+1) + x;
r_step = in->width * 2;
p_step = in->width * 2;
width = 16;
height = 8;
break;
default:
return;
}
r = in->y + r_offset;
p = out->y + p_offset;
xh = xv & 1;
yh = yv & 1;
xiv = xv >> 1;
yiv = yv >> 1;
r += yiv * r_step + xiv;
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
if(chroma_format != 3){
width >>= 1;
xv /= 2;
x /= 2;
r_offset -= x;
p_offset -= x;
}
if(chroma_format == 1){
height >>= 1;
yv /= 2;
y /= 2;
r_offset -= in->width * y;
p_offset -= in->width * y;
}
r = in->u + r_offset;
p = out->u + p_offset;
xh = xv & 1;
yh = yv & 1;
xiv = xv >> 1;
yiv = yv >> 1;
r += yiv * r_step + xiv;
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
r = in->v + r_offset;
p = out->v + p_offset;
r += yiv * r_step + xiv;
table[width>>4][xh][yh][first](r, p, r_step, p_step, height);
}
static void prediction_w16_hh_1st(unsigned char *in, unsigned char *out, int in_step, int out_step, int height)
{
int w;
int x, y;
for(y=0;y<height;y++){
for(x=0;x<16;x++){
w = in[x] + in[x+1] + in[x+in_step] + in[x+in_step+1] + 2;
out[x] = (w >> 2);
}
in += in_step;
out += out_step;
}
}
static void prediction_w16_hh_2nd(unsigned char *in, unsigned char *out, int in_step, int out_step, int height)
{
int w;
int x, y;
for(y=0;y<height;y++){
for(x=0;x<16;x++){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -