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阅读
发布评论