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

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

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

/***************************************************************************** * Copyright (C) 2013 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_BITCOST_H#define X265_BITCOST_H#include "common.h"#include "threading.h"#include "mv.h"namespace x265 {// private x265 namespace//BitCost主要用于计算MVD-cost MVD = MV-MVP class BitCost //被MotionEstimate继承{public: //初始化 BitCost() : m_cost_mvx(0), m_cost_mvy(0), m_cost(0), m_mvp(0) {} /** 函数功能 :建立当前qp下的MVD占用的cost:λ*bits = 2^(qp/6-2) * s_bitsizes[i] * \参数 qp :当前ME下的qp大小 * \返回 :null * */ void setQP(unsigned int qp); /** 函数功能 :设置当前的MVP,并更新以当前MVP的MVD-cost表格:如当前MV=(3,6)MVP=(1,2),则MVD=(2,4) 期MVcost = m_cost_mvx[mv.x] + m_cost_mvy[mv.y] = m_cost_mvx[3] + m_cost_mvy[6] = m_cost[3-1] + m_cost[6-2] = m_cost[2] + m_cost[4] * \参数 mvp :设置当前ME搜索时选用的MVP,以及计算MVD cost的表格 * \返回 :null * */ void setMVP(const MV& mvp) { m_mvp = mvp; m_cost_mvx = m_cost - mvp.x; m_cost_mvy = m_cost - mvp.y; } // return bit cost of motion vector difference, multiplied by lambda /** 函数功能 :返回当前MV与MVP之间的差(MVD)占用的bits-cost * \参数 mv :当前待计算的MV * \返回 :null * */ inline uint16_t mvcost(const MV& mv) const { return m_cost_mvx[mv.x] + m_cost_mvy[mv.y]; } // return bit cost of motion vector difference, without lambda /** 函数功能 :返回当前MV与MVP之间的差(MVD)占用的bits,没有经过λ加权 * \参数 mv :当前待计算的MV * \返回 :null * */ inline uint32_t bitcost(const MV& mv) const { return (uint32_t)(s_bitsizes[abs(mv.x - m_mvp.x)] + s_bitsizes[abs(mv.y - m_mvp.y)] + 0.5f); } /** 函数功能 :返回当前MV与MVP之间的差(MVD)占用的bits,没有经过λ加权 * \参数 mv :当前待计算的MV * \参数 mvp :当前待计算的MVP * \返回 :null * */ static inline uint32_t bitcost(const MV& mv, const MV& mvp) { return (uint32_t)(s_bitsizes[abs(mv.x - mvp.x)] + s_bitsizes[abs(mv.y - mvp.y)] + 0.5f); } /** 函数功能 : 释放空间内存 * \返回 : null */ static void destroy();protected: uint16_t *m_cost_mvx;//计算当前MVD x坐标占用的bits-cost uint16_t *m_cost_mvy;//计算当前MVD y坐标占用的bits-cost uint16_t *m_cost; //当前qp下的MVD占用的cost:λ*bits = 2^(qp/6-2) * s_bitsizes[i],在setQP()中进行初始化 MV m_mvp; //当前ME搜索时选用的MVP BitCost& operator =(const BitCost&);private: /* default log2_max_mv_length_horizontal and log2_max_mv_length_horizontal * are 15, specified in quarter-pel luma sample units. making the maximum * signaled ful-pel motion distance 4096, max qpel is 32768 */ //最大整像素运动矢量为4096 1/4像素 最大为32768 enum { BC_MAX_MV = (1 << 15) }; enum { BC_MAX_QP = 82 }; static float *s_bitsizes; //申请空间大小为 2*32768+1 MVD估计占用bits表格,例如:当前MV.x = 3 ,则其占用bits 为 s_bitsizes[3] 2*(log2(3+1))+e-1 /* s_bitsizes[0] = e - 2 s_bitsizes[i]= 2*(log2(i+1))+e-1 log2 表示以2为底 s_bitsizes[1] = 2log2(2) + e -1 **/ static uint16_t *s_costs[BC_MAX_QP];//所有的me共有,每个qp只初始化一次 static Lock s_costCalcLock; //多线程锁 /** 函数功能 :建立MVD估计占用bits表格,例如:当前MV.x = 3 ,则其占用bits 为 s_bitsizes[3] 2*(log2(3+1))+e-1 * \返回 :null * */ static void CalculateLogs();};}#endif // ifndef X265_BITCOST_H

 

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

你可能感兴趣的文章
判断数据的JS代码
查看>>
js按键事件说明
查看>>
AJAX 初次体验!推荐刚学看这个满好的!
查看>>
AJAX 设计制作 在公司弄的 非得要做出这个养的 真晕!
查看>>
Linux 查看文件大小
查看>>
Java并发编程:线程池的使用
查看>>
redis单机及其集群的搭建
查看>>
Java多线程学习
查看>>
检查Linux服务器性能
查看>>
Java 8新的时间日期库
查看>>
Chrome开发者工具
查看>>
【LEETCODE】102-Binary Tree Level Order Traversal
查看>>
【LEETCODE】106-Construct Binary Tree from Inorder and Postorder Traversal
查看>>
【LEETCODE】202-Happy Number
查看>>
和机器学习和计算机视觉相关的数学
查看>>
十个值得一试的开源深度学习框架
查看>>
【LEETCODE】240-Search a 2D Matrix II
查看>>
【LEETCODE】53-Maximum Subarray
查看>>
【LEETCODE】215-Kth Largest Element in an Array
查看>>
【LEETCODE】241-Different Ways to Add Parentheses
查看>>