FFmpeg——AVFrame中 的 data

 

AVFrame中 的 data 的定义如下:

typedef struct AVFrame {
#define AV_NUM_DATA_POINTERS 8
    /**
     * pointer to the picture/channel planes.
     * This might be different from the first allocated byte
     *
     * Some decoders access areas outside 0,0 - width,height, please
     * see avcodec_align_dimensions2(). Some filters and swscale can read
     * up to 16 bytes beyond the planes, if these filters are to be used,
     * then 16 extra bytes must be allocated.
     *
     * NOTE: Except for hwaccel formats, pointers not needed by the format
     * MUST be set to NULL.
     */
    uint8_t *data[AV_NUM_DATA_POINTERS];

    // ...
} AVFrame;

 

对于planar模式的YUV:
  • data[0]指向Y分量的开始位置
  • data[1]指向U分量的开始位置
  • data[2]指向V分量的开始位置
 
对于packed模式YUV:
  • data[0]指向数据的开始位置
  • data[1]和data[2]都为NULL
 
对于图像文件来说,如果是plannar模式的图像格式,其存储必然是先存完一张图像所有的所有Y、紧接着再存一张图像的所有U、紧接着存一张图像的所有V。
这刚好和data数组的三个指针的对应的。
 
所以无论是planar还是packed模式,我们直接使用data[0]即可,不用分开读写。

        
 

转载于:https://www.cnblogs.com/zoneofmine/p/10838943.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值