x265-1.7版本-common/framedata.h注释

注:问号以及未注释部分 会在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.
*****************************************************************************/

#ifndef X265_FRAMEDATA_H
#define X265_FRAMEDATA_H

#include "common.h"
#include "slice.h"
#include "cudata.h"

namespace x265 {
// private namespace

class PicYuv;
class JobProvider;

/* Per-frame data that is used during encodes and referenced while the picture
 * is available for reference. A FrameData instance is attached to a Frame as it
 * comes out of the lookahead. Frames which are not being encoded do not have a
 * FrameData instance. These instances are re-used once the encoded frame has
 * no active references. They hold the Slice instance and the 'official' CTU
 * data structures. They are maintained in a free-list pool along together with
 * a reconstructed image PicYuv in order to conserve memory. */
class FrameData
{
public:

    Slice*         m_slice; //slice数据,在本类中会实例化
    SAOParam*      m_saoParam;
    x265_param*    m_param;  //配置参数

    FrameData*     m_freeListNext;
    PicYuv*        m_reconPic;     //重构帧数据首地址 (只是指针,指向 frame->m_reconPic)
    bool           m_bHasReferences; // 表示是否有帧参考它(如果后向帧不再参考它设为false) 如果是X265_TYPE_B(不可参考B帧) 设置为false 否则为true 在新来帧计算RPS时会用到(对已经确定RPS的帧,其状态是不可靠的) /* used during DPB/RPS updates */
    int            m_frameEncoderID; //当前任务的job id  /* the ID of the FrameEncoder encoding this frame */
    JobProvider*   m_jobProvider;   //当前帧所在的线程位置

    CUDataMemPool  m_cuMemPool;  //存储一帧CTU的全部空间
    CUData*        m_picCTU;     //存储当前帧的全部CTU (空间为一帧CTU个数,在本类中会实例化)

    /* Rate control data used during encode and by references */
    struct RCStatCU
    {
        uint32_t totalBits;     /* total bits to encode this CTU */
        uint32_t vbvCost;       /* sum of lowres costs for 16x16 sub-blocks */
        uint32_t intraVbvCost;  /* sum of lowres intra costs for 16x16 sub-blocks */
        uint64_t avgCost[4];    /* stores the avg cost of CU's in frame for each depth */
        uint32_t count[4];      /* count and avgCost only used by Analysis at RD0..4 */
        double   baseQp;        /* Qp of Cu set from RateControl/Vbv (only used by frame encoder) */
    };
    
    struct RCStatRow//只在FrameData类中应用
    {
        uint32_t numEncodedCUs; /* ctuAddr of last encoded CTU in row */
        uint32_t encodedBits;   /* sum of 'totalBits' of encoded CTUs */
        uint32_t satdForVbv;    //在Lookahead::getEstimatedPictureCost函数中存储每个CTU行对应所有8x8块的cost累加值 /* sum of lowres (estimated) costs for entire row */
        uint32_t intraSatdForVbv;//在Lookahead::getEstimatedPictureCost函数中存储每个CTU行对应所有8x8块的intracost累加值  /* sum of lowres (estimated) intra costs for entire row */
        uint32_t diagSatd;
        uint32_t diagIntraSatd;
        double   diagQp;
        double   diagQpScale;
        double   sumQpRc;
        double   sumQpAq;
    };

    RCStatCU*      m_cuStat; //申请空间为一帧CTU个数???
    RCStatRow*     m_rowStat;//申请空间为一帧CTU行数???

    double         m_avgQpRc;    /* avg QP as decided by rate-control */
    double         m_avgQpAq;    /* avg QP as decided by AQ in addition to rate-control */
    double         m_rateFactor; /* calculated based on the Frame QP */
    /** 函数功能    :初始化
    /*  调用范围    :只在Frame::allocEncodeData函数中被调用
    */
    FrameData();
    /** 函数功能    :申请一帧CTU的存储空间,初始化CTU、初始化统计信息
    /*  调用范围    :只在Frame::allocEncodeData函数中被调用
    * \返回值       :申请空间成功为ture,否则为false
    */
    bool create(x265_param *param, const SPS& sps);
    /** 函数功能    :初始化统计信息为0
    /*  调用范围    :只在FrameData::create和Frame::reinit函数中被调用
    * \返回值       :null
    */
    void reinit(const SPS& sps);
    /** 函数功能    :释放内存
    /*  调用范围    :只在Frame::destroy()和DPB::~DPB()函数中被调用
    */
    void destroy();
    /** 函数功能    :获取在当前帧对应号的CTU   
    * \参数  ctuAddr: CTU在帧中的编号 */
    CUData* getPicCTU(uint32_t ctuAddr) { return &m_picCTU[ctuAddr]; }
};
}

#endif // ifndef X265_FRAMEDATA_H


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值