【H.266/VVC】Common.h阅读

编程入门 行业动态 更新时间:2024-10-28 06:34:42

【H.266/<a href=https://www.elefans.com/category/jswz/34/1748086.html style=VVC】Common.h阅读"/>

【H.266/VVC】Common.h阅读

之前一直做角度,基本就看了个帧内预测函数,然后提取个数据就深度学了,现在专门看VVC感觉跟重头开始一样,心态崩了。马上要找工作了都,害,慢慢来吧。
position 记录的是位置,成员变量就两个,x,y坐标

typedef int PosType;
typedef uint32_t SizeType;
struct Position
{PosType x;//x坐标 int类型PosType y;//y坐标//Position()                                   : x(0),  y(0)  { }//构造函数Position(const PosType _x, const PosType _y) : x(_x), y(_y) { }//操作符重载bool operator!=(const Position &other)  const { return x != other.x || y != other.y; }bool operator==(const Position &other)  const { return x == other.x && y == other.y; }Position offset(const Position pos)                 const { return Position(x + pos.x, y + pos.y); }//返回坐标偏移x y个长度(相加)Position offset(const PosType _x, const PosType _y) const { return Position(x + _x   , y + _y   ); }void     repositionTo(const Position newPos)              { x  = newPos.x; y  = newPos.y; }//复制坐标void     relativeTo  (const Position origin)              { x -= origin.x; y -= origin.y; }//改成相对位置Position operator-( const Position &other )         const { return{ x - other.x, y - other.y }; }//返回相对位置(自己不改)
};

尺寸大小结构体Size

struct Size
{//SizeType =unsigned int 类型变量//typedef unsigned int       uint32_t;//typedef uint32_t SizeType;SizeType width;//宽SizeType height;//高Size()                                              : width(0),      height(0)       { }//构造函数Size(const SizeType _width, const SizeType _height) : width(_width), height(_height) { }//重载操作符 是否相等bool operator!=(const Size &other)      const { return (width != other.width) || (height != other.height); }bool operator==(const Size &other)      const { return (width == other.width) && (height == other.height); }uint32_t area()                             const { return (uint32_t) width * (uint32_t) height; }//计算面积 宽*高
#if REUSE_CU_RESULTS_WITH_MULTIPLE_TUSvoid resizeTo(const Size newSize)             { width = newSize.width; height = newSize.height; }//换成新的尺寸
#endif
};

区域结构

struct Area : public Position, public Size//继承位置和尺寸 面积 成员变量来自继承
{Area()                                                                         : Position(),       Size()       { }//构造函数,尺寸面积Area(const Position &_pos, const Size &_size)                                  : Position(_pos),   Size(_size)  { }Area(const PosType _x, const PosType _y, const SizeType _w, const SizeType _h) : Position(_x, _y), Size(_w, _h) { }
//不是很懂为什么可以直接返回*this 大概是可以把它看成一个坐标类型变量?Position& pos()                           { return *this; }//返回坐标const Position& pos()                     const { return *this; }Size&     size()                          { return *this; }//返回尺寸const Size&     size()                    const { return *this; }const Position& topLeft()                 const { return *this; }//返回左上角坐标Position  topRight()                const { return { (PosType) (x + width - 1), y                          }; }//返回右上角坐标Position  bottomLeft()              const { return { x                        , (PosType) (y + height - 1) }; }//左下Position  bottomRight()             const { return { (PosType) (x + width - 1), (PosType) (y + height - 1) }; }//右下Position  center()                  const { return { (PosType) (x + width / 2), (PosType) (y + height / 2) }; }//中心点
//判断坐标点是否在当前区域中bool contains(const Position &_pos)       const { return (_pos.x >= x) && (_pos.x < (x + width)) && (_pos.y >= y) && (_pos.y < (y + height)); }bool contains(const Area &_area)          const { return contains(_area.pos()) && contains(_area.bottomRight()); }//左上和右下点在就可以//判断两块区域是否相等bool operator!=(const Area &other)        const { return (Size::operator!=(other)) || (Position::operator!=(other)); }bool operator==(const Area &other)        const { return (Size::operator==(other)) && (Position::operator==(other)); }
};

更多推荐

【H.266/VVC】Common.h阅读

本文发布于:2024-03-23 23:56:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1744352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:VVC   Common

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!