circularbufferposition.cpp
来自「C++封装的视频采集代码」· C++ 代码 · 共 46 行
CPP
46 行
#include "CircularBufferPosition.h"namespace oxsemi{ namespace circular_buffer { CircularBufferPosition::CircularBufferPosition( unsigned long maxOffset, unsigned long offset, unsigned long loopCount) : maxOffset_(maxOffset), offset_(offset), loopCount_(loopCount) { } CircularBufferPosition CircularBufferPosition::DecodeFromBuffer(const unsigned char* buffer) { unsigned long maxOffset = *reinterpret_cast<const unsigned long*>(buffer); buffer += sizeof(unsigned long); unsigned long offset = *reinterpret_cast<const unsigned long*>(buffer); buffer += sizeof(unsigned long); unsigned long loopCount = *reinterpret_cast<const unsigned long*>(buffer); return CircularBufferPosition(maxOffset, offset, loopCount); } void CircularBufferPosition::EncodeToBuffer(unsigned char* buffer) const { *reinterpret_cast<unsigned long*>(buffer) = maxOffset_; buffer += sizeof(unsigned long); *reinterpret_cast<unsigned long*>(buffer) = offset_; buffer += sizeof(unsigned long); *reinterpret_cast<unsigned long*>(buffer) = loopCount_; } void CircularBufferPosition::Zeroise(unsigned long maxOffset) { maxOffset_ = maxOffset; offset_ = 0; loopCount_ = 0; } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?