博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
x265-1.7版本-common/picyuv.h注释
阅读量:2189 次
发布时间:2019-05-02

本文共 7450 字,大约阅读时间需要 24 分钟。

注:问号以及未注释部分 会在x265-1.8版本内更新 

/***************************************************************************** * Copyright (C) 2015 x265 project * * Authors: Steve Borho 
* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. * * This program is also available under a commercial proprietary license. * For more information, contact us at license @ x265.com. *****************************************************************************/#ifndef X265_PICYUV_H#define X265_PICYUV_H#include "common.h"#include "md5.h"#include "x265.h"namespace x265 {// private namespaceclass ShortYuv;struct SPS;class PicYuv{public: pixel* m_picBuf[3]; // 申请buf的首地址(分别表示Y、U、V) full allocated buffers, including margins pixel* m_picOrg[3]; // 对应数据的首地址(首地址直接是原始数据,此处只是一个指针,m_picBuf的偏移地址)pointers to plane starts uint32_t m_picWidth; //源图像宽度 uint32_t m_picHeight; //源图像高度 intptr_t m_stride; //亮度步长:(numCuInWidth * g_maxCUSize) + (m_lumaMarginX << 1); numCuInWidth:不够LCU的补全一个LCU intptr_t m_strideC; //色度步长:((numCuInWidth * g_maxCUSize) >> m_hChromaShift) + (m_chromaMarginX * 2); uint32_t m_picCsp; //图像取样格式:420、444:400 uint32_t m_hChromaShift;//根据图像格式,色度宽度需要移位个数 如420格式 就是1 uint32_t m_vChromaShift;//根据图像格式,色度高度需要移位个数 如420格式 就是1 /* these four buffers are owned by the top-level encoder */ //在整个编码器中只申请一次内存,然后将指针赋值到Encoder中,其它的都从Encoder中获取指针 /*如:一幅图像416x240 总过有7x4个LCU m_cuOffsetY[0] = 0 m_cuOffsetY[1] = 64 m_cuOffsetY[2]= 128 m_cuOffsetY[7] = 40960 = 640*64 (640是步长含有扩边值) m_cuOffsetC[0] = 0 m_cuOffsetC[1] = 32 m_cuOffsetC[2]= 64 m_cuOffsetC[7] = 13312 = 416*64 (416是步长含有扩边值) m_buOffsetY[0] = 0 m_buOffsetY[1] = 4 m_buOffsetY[2]= 2560 (按照4x4块计算 zigzag排序 2560 = 640*4) m_buOffsetC[0] = 0 m_buOffsetC[1] = 2 m_buOffsetY[2]= 832 (按照2x2块计算 zigzag排序 832 = 416*2) **/ intptr_t* m_cuOffsetY; //申请空间为一帧LCU个数,按照行列对应亮度LCU的pixel地址 intptr_t* m_cuOffsetC; //申请空间为一帧LCU个数,按照行列对应色度LCU的pixel地址 intptr_t* m_buOffsetY; //申请空间为一个LCU的part个数(默认256个4x4),为当前亮度位置与LCU首地址的偏移地址 (按照zigzag4x4排序) intptr_t* m_buOffsetC; //申请空间为一个LCU的part个数(默认256个4x4),为当前色度位置与LCU首地址的偏移地址 (按照zigzag2x2排序) uint32_t m_lumaMarginX; //宽度左右各扩边值:g_maxCUSize + 32; 64+32 ?????为什么这么扩边 uint32_t m_lumaMarginY; //高度上下各扩边值:g_maxCUSize + 16; 64+16 ?????为什么这么扩边 uint32_t m_chromaMarginX;//色度扩边值为:m_lumaMarginX uint32_t m_chromaMarginY;//色度扩边值为:m_lumaMarginY >> m_vChromaShift /** 函数功能 :初始化PicYuv * \返回值 :null */ PicYuv(); /** 函数功能 : 申请视频帧yuv内存 /* 调用范围 : 只在Frame::create和Frame::allocEncodeData函数中被调用(分别申请原始帧和重构帧内存) * \参数 picWidth : 图像宽度 * \参数 picHeight : 图像高度 * \参数 picCsp : 图像采样格式 * 返回值 : 成功true失败false**/ bool create(uint32_t picWidth, uint32_t picHeight, uint32_t csp); /** 函数功能 : 创建m_cuOffsetY等offset地址信息 /* 调用范围 : 只在Encoder::encode函数中被调用 * \参数 sps : sps信息(含有视频信息) * 返回值 : 成功返回true,失败返回false **/ bool createOffsets(const SPS& sps); /** 函数功能 :释放内存 /* 调用范围 :只在void Frame::destroy()和~DPB()函数中被调用 * \返回值 :null */ void destroy(); void copyFromPicture(const x265_picture&, int padx, int pady); intptr_t getChromaAddrOffset(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } /* get pointer to CTU start address */ pixel* getLumaAddr(uint32_t ctuAddr) { return m_picOrg[0] + m_cuOffsetY[ctuAddr]; } pixel* getCbAddr(uint32_t ctuAddr) { return m_picOrg[1] + m_cuOffsetC[ctuAddr]; } pixel* getCrAddr(uint32_t ctuAddr) { return m_picOrg[2] + m_cuOffsetC[ctuAddr]; } pixel* getChromaAddr(uint32_t chromaId, uint32_t ctuAddr) { return m_picOrg[chromaId] + m_cuOffsetC[ctuAddr]; } pixel* getPlaneAddr(uint32_t plane, uint32_t ctuAddr) { return m_picOrg[plane] + (plane ? m_cuOffsetC[ctuAddr] : m_cuOffsetY[ctuAddr]); } const pixel* getLumaAddr(uint32_t ctuAddr) const { return m_picOrg[0] + m_cuOffsetY[ctuAddr]; } const pixel* getCbAddr(uint32_t ctuAddr) const { return m_picOrg[1] + m_cuOffsetC[ctuAddr]; } const pixel* getCrAddr(uint32_t ctuAddr) const { return m_picOrg[2] + m_cuOffsetC[ctuAddr]; } const pixel* getChromaAddr(uint32_t chromaId, uint32_t ctuAddr) const { return m_picOrg[chromaId] + m_cuOffsetC[ctuAddr]; } const pixel* getPlaneAddr(uint32_t plane, uint32_t ctuAddr) const { return m_picOrg[plane] + (plane ? m_cuOffsetC[ctuAddr] : m_cuOffsetY[ctuAddr]); } /* get pointer to CU start address */ /** 函数功能 :返回当前的LCU下当前zigzag标号对应的亮度pixel地址 * \参数 cuAddr :CTU在帧中的编号 * \参数 absPartIdx :当前CU在LCU中4x4 zizag地址 * \返回值 :返回当前的LCU下当前zigzag标号对应的亮度pixel地址**/ pixel* getLumaAddr(uint32_t ctuAddr, uint32_t absPartIdx) { return m_picOrg[0] + m_cuOffsetY[ctuAddr] + m_buOffsetY[absPartIdx]; } /** 函数功能 :返回当前的LCU下当前zigzag标号对应的色度pixel地址 * \参数 cuAddr :CTU在帧中的编号 * \参数 absPartIdx :当前CU在LCU中4x4 zizag地址 * \返回值 :返回当前的LCU下当前zigzag标号对应的色度pixel地址**/ pixel* getCbAddr(uint32_t ctuAddr, uint32_t absPartIdx) { return m_picOrg[1] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } /** 函数功能 :返回当前的LCU下当前zigzag标号对应的色度pixel地址 * \参数 cuAddr :CTU在帧中的编号 * \参数 absPartIdx :当前CU在LCU中4x4 zizag地址 * \返回值 :返回当前的LCU下当前zigzag标号对应的色度pixel地址**/ pixel* getCrAddr(uint32_t ctuAddr, uint32_t absPartIdx) { return m_picOrg[2] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } pixel* getChromaAddr(uint32_t chromaId, uint32_t ctuAddr, uint32_t absPartIdx) { return m_picOrg[chromaId] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } const pixel* getLumaAddr(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_picOrg[0] + m_cuOffsetY[ctuAddr] + m_buOffsetY[absPartIdx]; } const pixel* getCbAddr(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_picOrg[1] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } const pixel* getCrAddr(uint32_t ctuAddr, uint32_t absPartIdx) const { return m_picOrg[2] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; } const pixel* getChromaAddr(uint32_t chromaId, uint32_t ctuAddr, uint32_t absPartIdx) const { return m_picOrg[chromaId] + m_cuOffsetC[ctuAddr] + m_buOffsetC[absPartIdx]; }};void updateChecksum(const pixel* plane, uint32_t& checksumVal, uint32_t height, uint32_t width, intptr_t stride, int row, uint32_t cuHeight);void updateCRC(const pixel* plane, uint32_t& crcVal, uint32_t height, uint32_t width, intptr_t stride);void crcFinish(uint32_t & crc, uint8_t digest[16]);void checksumFinish(uint32_t checksum, uint8_t digest[16]);void updateMD5Plane(MD5Context& md5, const pixel* plane, uint32_t width, uint32_t height, intptr_t stride);}#endif // ifndef X265_PICYUV_H

转载地址:http://wouub.baihongyu.com/

你可能感兴趣的文章
PCA 的数学原理和可视化效果
查看>>
机器学习中常用评估指标汇总
查看>>
什么是 ROC AUC
查看>>
Bagging 简述
查看>>
详解 Stacking 的 python 实现
查看>>
简述极大似然估计
查看>>
用线性判别分析 LDA 降维
查看>>
用 Doc2Vec 得到文档/段落/句子的向量表达
查看>>
使聊天机器人具有个性
查看>>
使聊天机器人的对话更有营养
查看>>
一个 tflearn 情感分析小例子
查看>>
attention 机制入门
查看>>
手把手用 IntelliJ IDEA 和 SBT 创建 scala 项目
查看>>
GAN 的 keras 实现
查看>>
AI 在 marketing 上的应用
查看>>
Logistic regression 为什么用 sigmoid ?
查看>>
Logistic Regression 为什么用极大似然函数
查看>>
SVM 的核函数选择和调参
查看>>
LightGBM 如何调参
查看>>
用 TensorFlow.js 在浏览器中训练神经网络
查看>>