x264中read_frame_yuv函数欣赏

       编码300帧的视频,发现read_frame_yuv函数被调用300次. 函数read_frame_yuv的功能是从yuv文件中读取一帧的数据,具体函数定义如下:

int read_frame_yuv( x264_picture_t *p_pic, hnd_t handle, int i_frame )
{
    yuv_input_t *h = handle;

    if( i_frame != h->next_frame )
        if( fseek( h->fh, (uint64_t)i_frame * h->width * h->height * 3 / 2, SEEK_SET ) )  yuv420
            return -1;

    if( fread( p_pic->img.plane[0], 1, h->width * h->height, h->fh ) <= 0  // Y分量
            || fread( p_pic->img.plane[1], 1, h->width * h->height / 4, h->fh ) <= 0  // U分量
            || fread( p_pic->img.plane[2], 1, h->width * h->height / 4, h->fh ) <= 0 )  // V分量
        return -1;

    h->next_frame = i_frame + 1;

    return 0;
}


     对于每一帧而言,p_pic->img.plane[0][i]表示Y分量,p_pic->img.plane[1][i]表示U分量,p_pic->img.plane[2][i]表示V分量. 所以,通过调用read_frame_yuv函数后,yuv视频文件的像素值就读到程序中了.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值