// O S H S O
// S S S S S
// H S H S H
// S S S S S
// O S H S O
// O代表整像素; H代表1/2像素; S代表1/4像素;
// Y轴向下, X轴向右
// (y=0,x=1)需要O和H计算S像素
// (y=0,x=2)仅需要O
static uint8_t *get_ref( uint8_t *dst, int *i_dst_stride,
uint8_t *src[4], int i_src_stride,
int mvx, int mvy,
int i_width, int i_height )
{
int qpel_idx = ((mvy&3)<<2) + (mvx&3); // mvx, mvy前2比特表示在"1/4像素座标轴上的座标"; 其他表示在整个frame的行和列数
int offset = (mvy>>2)*i_src_stride + (mvx>>2);
uint8_t *src1 = src[hpel_ref0[qpel_idx]] + offset + ((mvy&3) == 3) * i_src_stride;
if( qpel_idx & 5 ) /* qpel interpolation needed */
{
uint8_t *src2 = src[hpel_ref1[qpel_idx]] + offset + ((mvx&3) == 3);
pixel_avg( dst, *i_dst_stride, src1, i_src_stride,
src2, i_src_stride, i_width, i_height ); // 1/4像素插值
return dst;
}
else
{
*i_dst_stride = i_src_stride;
return src1;
}
}
x264源码分析 -- get_ref
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.