x265-1.7版本-common/frame.cpp注释
2016-01-22 21:56
357 查看
注:问号以及未注释部分 会在x265-1.8版本内更新
/***************************************************************************** * Copyright (C) 2013 x265 project * * Author: Steve Borho <steve@borho.org> * * 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. *****************************************************************************/ #include "common.h" #include "frame.h" #include "picyuv.h" #include "framedata.h" using namespace x265; /** 函数功能 :初始化Frmae /* 调用范围 :只在Encoder::encode函数中被调用 * \返回值 :null **/ Frame::Frame() { m_bChromaExtended = false; m_lowresInit = false; m_reconRowCount.set(0); m_countRefEncoders = 0; m_encData = NULL; m_reconPic = NULL; m_next = NULL; m_prev = NULL; m_param = NULL; memset(&m_lowres, 0, sizeof(m_lowres)); } /** 函数功能 :申请原始帧m_fencPic与1/2下采样帧空间并将其初始化 /* 调用范围 :只在Encoder::encode函数中被调用 * \返回值 :申请空间成功为ture,否则为false */ bool Frame::create(x265_param *param) { m_fencPic = new PicYuv; m_param = param; return m_fencPic->create(param->sourceWidth, param->sourceHeight, param->internalCsp) && m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode); //申请原始帧m_fencPic与1/2下采样帧空间并将其初始化 } /** 函数功能 :申请重构帧内存并初始化为0,申请一帧CTU的存储空间,初始化CTU、初始化统计信息 /* 调用范围 :只在Encoder::encode函数中被调用 * \返回值 :申请空间成功为ture,否则为false */ bool Frame::allocEncodeData(x265_param *param, const SPS& sps) { m_encData = new FrameData;//实例化 m_reconPic = new PicYuv; //实例化 m_encData->m_reconPic = m_reconPic;//获取存储重构帧的指针 bool ok = m_encData->create(param, sps) && m_reconPic->create(param->sourceWidth, param->sourceHeight, param->internalCsp);//申请内存空间 if (ok) { /* initialize right border of m_reconpicYuv as SAO may read beyond the * end of the picture accessing uninitialized pixels */ int maxHeight = sps.numCuInHeight * g_maxCUSize; memset(m_reconPic->m_picOrg[0], 0, sizeof(pixel) * m_reconPic->m_stride * maxHeight); memset(m_reconPic->m_picOrg[1], 0, sizeof(pixel) * m_reconPic->m_strideC * (maxHeight >> m_reconPic->m_vChromaShift)); memset(m_reconPic->m_picOrg[2], 0, sizeof(pixel) * m_reconPic->m_strideC * (maxHeight >> m_reconPic->m_vChromaShift)); } return ok; } /* prepare to re-use a FrameData instance to encode a new picture */ void Frame::reinit(const SPS& sps) { m_bChromaExtended = false; m_reconPic = m_encData->m_reconPic; m_encData->reinit(sps); } /** 函数功能 :释放内存 /* 调用范围 :只在Encoder::encode、Lookahead::destroy()和~DPB()函数中被调用 * \返回值 :null */ void Frame::destroy() { //在Encoder::encode 申请内存失败时才会调用 //在Lookahead::destroy()中: //在~DPB()中: if (m_encData) { m_encData->destroy(); delete m_encData; m_encData = NULL; } if (m_fencPic) { m_fencPic->destroy(); delete m_fencPic; m_fencPic = NULL; } if (m_reconPic) { m_reconPic->destroy(); delete m_reconPic; m_reconPic = NULL; } m_lowres.destroy(); }
相关文章推荐
- c语言头文件
- C++整型字面值
- 内联函数学习
- C语言 printf函数的返回值
- 一维/二维动态数组分配(C语言)
- C++指定小数位输出
- C++基础::<limits>
- C++异常处理
- C++学习笔记3
- c++企业级接口框架(一)
- C++climits中的符号常量
- C++内核格式化
- 【c/c++】map
- C++文件操作典型案例
- 【转】嵌入式C语言调试开关
- C语言中,头文件和源文件的关系(转)
- C++ sort 排序(降序、升序)使用总结
- DDX_Control 与 DDX_Text 区别
- 【VC++】没有与参数列表匹配的 重载函数 AfxMessageBox
- ClustLib——A C++ Data Clustering Framework(二):杂项