Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cVideoFS.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cVideoFS_H
7 #define _INC_cVideoFS_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cVideoCodec.h"
13 #include "cAVSink.h"
14 #include "../Math/cBitArray.h"
15 #include "../Image/cSurfaceBase.h"
16 #include "../Geometry/cRectI.h"
22 
23 namespace GrayLib
24 {
26  {
32 
33  public:
34  static const int k_BLOCK_DEF = 32;
35  static const FOURCC k_Form = MAKEFOURCC('F', 'S', 'V', '1'); // FSV1
36 
39 
41  UINT m_nFrameNum;
43 
44  protected:
45  cVideoFS(int nBlockX = k_BLOCK_DEF, int nBlockY = k_BLOCK_DEF);
46  ~cVideoFS();
47 
48  void UpdateBlockParams();
49  BYTE* BuildCompFrameHeader(BYTE* pComp) const;
50 
51  bool isReady() const noexcept
52  {
53  return m_Blocks.cx && m_Blocks.cy;
54  }
55  int get_BlocksTotal() const noexcept
56  {
57  return m_Blocks.cx*m_Blocks.cy;
58  }
59 
60  void GetBlockRect(int col, int row, cRectI& rect) const noexcept
61  {
63  rect.left = col * m_BlockSize.cx;
64  rect.top = row * m_BlockSize.cy;
65  rect.right = (col >= m_Blocks.cx - 1) ? m_FrameSize.cx : (rect.left + m_BlockSize.cx);
66  rect.bottom = (row >= m_Blocks.cy - 1) ? m_FrameSize.cy : (rect.top + m_BlockSize.cy);
67  }
68 
70  };
71 
73  {
76 
77  protected:
79 
80  // Temporary buffers while compressing.
83 
84  protected:
85  void SetBlockDirty(int x, int y);
86  void UpdateBlockDirtyBits(const cSurfaceBase& frame);
87  size_t AddImageBlock(BYTE* pComp, INT_PTR nCompSizeMax, int row, int col);
88 
89  public:
90  cVideoFSComp(int nBlockX = k_BLOCK_DEF, int nBlockY = k_BLOCK_DEF);
91  cVideoFSComp(const cVideoFSComp& copythis);
92  virtual ~cVideoFSComp();
93 
94  // IVideoCompress
95  virtual HRESULT CompStart(const cSurfaceInfo& rInfo, cSurfaceBitmapInfo* pbiOut) override;
96  virtual HRESULT CompFrame(const cSurfaceBase& frame, OUT const void*& rpCompRet, OUT size_t& rnSizeRet, OUT bool& rbIsKey) override;
97  };
98 
100  {
104  public:
105  virtual HRESULT DecompStart(const cSurfaceBitmapInfo* pbiInp, cSurfaceInfo* pFrameInfo) override;
106  virtual HRESULT DecompFrame(const void* pCompData, size_t nSizeComp, cSurfaceBase& frame) override;
107  };
108 
110  {
114 
115  protected:
116  struct CBlock
117  {
122  };
123 
126 
127  protected:
128  void UpdateBlockParams();
129 
130  public:
132  {
133  }
135  {
136  }
137 
138  // cAVSink in cAVRateController
139  virtual HRESULT OnHeaderStream(const cAVHeaderStream& head, const void* pForm, size_t nSizeForm) override;
140  virtual HRESULT OnFrame(const cAVHeaderFrame& head, const void* pData, size_t nSizeData) override;
141 
142  // cAVRateController
143  virtual HRESULT BuildCompFrame(TIMESYS_t tWhenLast, const void*& rpCompRet, size_t& rnSizeRet) override;
144  };
145 };
146 #endif
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
UINT32 FOURCC
32 bit code. Also defined in _MMSYSTEM_H
Definition: cFourCC.h:19
#define MAKEFOURCC(ch0, ch1, ch2, ch3)
Definition: cFourCC.h:24
Definition: cAVSink.h:80
Definition: cAVSink.h:60
Definition: cAVSink.h:231
Definition: cBitArray.h:28
Definition: cRectI.h:22
Definition: cSurfaceBase.h:26
Definition: cSurfaceInfo.h:308
Definition: cSurfaceInfo.h:109
Definition: cVideoFS.h:73
cHeapBlock m_CompFrame
holder for the last compressed frame. key or diff. persisted for CompFrame( rpCompRet )
Definition: cVideoFS.h:82
cNewPtr< cColor888 > m_FrameLast
The last full frame m_FrameSize. (diff against this)
Definition: cVideoFS.h:78
cBitArrayStatic m_BlocksDirty
are any of the pixels in the block changed? 2d array of m_Blocks
Definition: cVideoFS.h:81
Definition: cVideoFS.h:100
Definition: cVideoFS.h:110
virtual ~cVideoFSRateController()
Definition: cVideoFS.h:134
cVideoFSRateController()
Definition: cVideoFS.h:131
cArrayStruct< CBlock > m_aBlocks
the blocks making up the current frame.
Definition: cVideoFS.h:124
cHeapBlock m_CompFrame
holder for the last compressed frame. key or diff. persisted for BuildCompFrame( rpCompRet )
Definition: cVideoFS.h:125
Definition: cVideoFS.h:26
cWinSize m_Blocks
Count of blocks = m_FrameSize / m_BlockSize.
Definition: cVideoFS.h:40
void GetBlockRect(int col, int row, cRectI &rect) const noexcept
Definition: cVideoFS.h:60
int get_BlocksTotal() const noexcept
Definition: cVideoFS.h:55
UNITTEST_FRIEND(cVideoFS)
cWinSize m_BlockSize
Preconfigured size of the dirty block in pixels. (arbitrary 16..256, multiple of 16)
Definition: cVideoFS.h:37
cArrayVal< cColor888 > m_BlockTmp
space to hold a block for (de)compression. m_BlockSize
Definition: cVideoFS.h:42
bool isReady() const noexcept
Definition: cVideoFS.h:51
UINT m_nFrameNum
frame number in video stream so far.
Definition: cVideoFS.h:41
cWinSize m_FrameSize
total size in pixels in Frame.
Definition: cVideoFS.h:38
Definition: WinTypes.h:128
Definition: cArray.h:932
Definition: cArray.h:914
Definition: cHeap.h:156
Definition: cNewPtr.h:18
Definition: cTimeSys.h:93
Definition: cMesh.h:22
interface const RECTQ_t & rect
Definition: cQuadtree.h:44
UINT32 TIMESYS_t
TIMESYS_t = The normal system tick timer. milli-seconds since start of system/app ?
Definition: cTimeSys.h:27
Definition: cVideoCodec.h:25
Definition: cVideoCodec.h:45
Definition: cVideoFS.h:117
cTimeSys m_tUpdated
When was this last built/current.
Definition: cVideoFS.h:120
cHeapBlock m_Compressed
store a compressed key frame block.
Definition: cVideoFS.h:121