现在的位置: 首页 > 综合 > 正文

在ADSP-BF561上使用x264(9):mc_chroma

2013年12月12日 ⁄ 综合 ⁄ 共 1133字 ⁄ 字号 评论关闭

这个函数定义为:

static void mc_chroma( uint8_t *dst, int i_dst_stride,

                       uint8_t *src, int i_src_stride,

                       int mvx, int mvy,

                       int i_width, int i_height )

{

    uint8_t *srcp;

    int x, y;

 

    const int d8x = mvx&0x07;

    const int d8y = mvy&0x07;

 

    const int cA = (8-d8x)*(8-d8y);

    const int cB = d8x    *(8-d8y);

    const int cC = (8-d8x)*d8y;

    const int cD = d8x    *d8y;

 

    src  += (mvy >> 3) * i_src_stride + (mvx >> 3);

    srcp = &src[i_src_stride];

 

    for ( y = 0; y < i_height; y++ )

    {

        for ( x = 0; x < i_width; x++ )

        {

            dst[x] = ( cA*src[x]  + cB*src[x+1] +

                       cC*srcp[x] + cD*srcp[x+1] + 32 ) >> 6;

        }

        dst  += i_dst_stride;

 

        src   = srcp;

        srcp += i_src_stride;

    }

}

观察编译器自动生成的代码,可以发现编译器已经很好地处理了这个二重循环。在 8x8 的情况下,这个函数需要 1700 cycle

仔细看循环中间的代码:

            dst[x] = ( cA*src[x]  + cB*src[x+1] +

                        cC*srcp[x] + cD*srcp[x+1] + 32 ) >> 6;

显然,这个地方可以 561 提供的双 MAC 运算来进行快速计算。为此我们将此函数改写为汇编,这样可以将其所需要的 cycle 数降低到 950 8x8 ),呵呵,专用指令的效率还是惊人的!

运行:

encoded 301 frames, 2.71 fps, 1136.47 kb/s

总共使用了 64957M cycle ,效率提高了 4%

 

 

 

近日,我家6岁的小姑娘参加了第六届POP全国少儿英语风采大赛,拉票进行中(2011-6-15前)。

请帮忙点击新东方网站的链接:

http://popdasai.xdf.cn/toupiao.php?do=space&uid=4237

投她一票,谢谢!

抱歉!评论已关闭.