x264源碼分析 -- get_ref

// 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;
    }
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章