Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cVideoBZ.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cVideoBZ_H
7 #define _INC_cVideoBZ_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cVideoCodec.h"
13 
14 #ifdef USE_BZIP2
15 #include "cAVSink.h"
16 #include "../Math/cBitArray.h"
17 #include "../Image/cSurface.h"
18 #include "../Geometry/cRectI.h"
22 
23 namespace GrayLib
24 {
26  {
31 
32  public:
33  static const int k_BLOCK_SIZE = 32; // size of a block in pixels.
34  static const FOURCC k_Form = MAKEFOURCC('G', 'V', 'B', 'Z');
35 
39 
40  protected:
42  virtual ~cVideoBZ();
43 
44 #pragma pack(push,2)
46  {
49  BYTE col; // x
50  BYTE row; // y
51  };
52 #pragma pack(pop)
53 
55  static HRESULT GRAYCALL CoordWrite(cStreamOutput& out, const BLOCK_COORD& coord);
57 
58  bool isReady() const noexcept
59  {
60  return m_Blocks.cx && m_Blocks.cy;
61  }
62  int get_BlocksTotal() const noexcept
63  {
64  return m_Blocks.cx * m_Blocks.cy;
65  }
66  void GetBlockRect(const BLOCK_COORD& coord, cRectI& rect) const noexcept
67  {
69  rect.left = coord.col * k_BLOCK_SIZE;
70  rect.top = coord.row * k_BLOCK_SIZE;
71  rect.right = (coord.col >= m_Blocks.cx - 1) ? m_Info.get_Width() : (rect.left + k_BLOCK_SIZE);
72  rect.bottom = (coord.row >= m_Blocks.cy - 1) ? m_Info.get_Height() : (rect.top + k_BLOCK_SIZE);
73  }
74 
76  };
77 
79  {
83 
84  public:
86 
87  // Temporary buffers while compressing.
90 
91  protected:
92  bool SetBlockDirty(int x, int y);
94  // void GetBlockTmp(int row, int col);
95 
96  public:
97  cVideoBZComp(void);
98  virtual ~cVideoBZComp(void);
99 
100  // IVideoCompress
101  virtual HRESULT CompStart(const cSurfaceInfo& rInfo, OUT cSurfaceBitmapInfo* pbiOut) override;
102  virtual HRESULT CompFrame(const cSurfaceBase& frame, OUT const void*& rpCompRet, OUT size_t& rnSizeRet, OUT bool& rbIsKey) override;
103  };
104 
106  {
108  public:
110  virtual ~cVideoBZDecomp(void);
111 
112  // IVideoDecompress
113  virtual HRESULT DecompStart(const cSurfaceBitmapInfo* pbiInp, cSurfaceInfo* pFrameInfo) override;
114  virtual HRESULT DecompFrame(const void* pCompData, size_t nSizeComp, cSurfaceBase& frame) override;
115  };
116 
118  {
120 
121  protected:
122  struct cBlock
123  {
126  };
127 
132 
133  public:
135 
136  // cAVSink in cAVRateController
137  virtual HRESULT OnHeaderStream(const cAVHeaderStream& head, const void* pForm, size_t nSizeForm) override;
138  virtual HRESULT OnFrame(const cAVHeaderFrame& head, const void* pData, size_t nSizeData) override;
139 
140  // cAVRateController
141  virtual HRESULT BuildCompFrame(TIMESYS_t tWhenLast, const void*& rpCompRet, size_t& rnSizeRet) override;
142 
143  protected:
145  };
146 }
147 
148 #endif
149 #endif
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define CATTR_PACKED
Definition: GrayCore.h:87
#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
PIXELS_t get_Width() const noexcept
Definition: cSurfaceInfo.h:151
PIXELS_t get_Height() const noexcept
Definition: cSurfaceInfo.h:156
Definition: cSurface.h:21
Definition: cVideoBZ.h:79
cStreamQueue m_CompFrame
holder for the last compressed frame. key or diff. persisted for CompFrame( rpCompRet )
Definition: cVideoBZ.h:89
bool SetBlockDirty(int x, int y)
cSurface m_FrameLast
The last full frame m_Info. (diff against this)
Definition: cVideoBZ.h:85
int UpdateBlockDirtyBits(const cSurfaceBase &frame)
virtual HRESULT CompStart(const cSurfaceInfo &rInfo, OUT cSurfaceBitmapInfo *pbiOut) override
virtual HRESULT CompFrame(const cSurfaceBase &frame, OUT const void *&rpCompRet, OUT size_t &rnSizeRet, OUT bool &rbIsKey) override
cBitArrayStatic m_BlocksDirty
which blocks changed? (any pixels in them) 2d array of m_Blocks
Definition: cVideoBZ.h:88
virtual ~cVideoBZComp(void)
Definition: cVideoBZ.h:106
virtual HRESULT DecompFrame(const void *pCompData, size_t nSizeComp, cSurfaceBase &frame) override
virtual HRESULT DecompStart(const cSurfaceBitmapInfo *pbiInp, cSurfaceInfo *pFrameInfo) override
virtual ~cVideoBZDecomp(void)
Definition: cVideoBZ.h:118
cTimeSys m_tUpdateOldest
When was this last FULLY built/current.
Definition: cVideoBZ.h:131
cArrayStruct< cBlock > m_aBlocks
the blocks making up the current frame.
Definition: cVideoBZ.h:128
cStreamQueue m_CompFrame
holder for the last compressed frame. key or diff. persisted for BuildCompFrame( rpCompRet )
Definition: cVideoBZ.h:130
virtual HRESULT BuildCompFrame(TIMESYS_t tWhenLast, const void *&rpCompRet, size_t &rnSizeRet) override
virtual HRESULT OnHeaderStream(const cAVHeaderStream &head, const void *pForm, size_t nSizeForm) override
cSurface m_FrameLast
Last Full uncompressed frame.
Definition: cVideoBZ.h:129
virtual HRESULT OnFrame(const cAVHeaderFrame &head, const void *pData, size_t nSizeData) override
Definition: cVideoBZ.h:26
static HRESULT GRAYCALL CoordRead(cStreamInput &stmIn, BLOCK_COORD &coord)
void UpdateBlockParams()
int get_BlocksTotal() const noexcept
Definition: cVideoBZ.h:62
cWinSize m_Blocks
Count of blocks = m_FrameSize / k_BLOCK_SIZE.
Definition: cVideoBZ.h:36
UINT m_nFrameNum
Definition: cVideoBZ.h:37
cSurfaceInfo m_Info
i was init to use this format + size. CompStart() or DecompStart()
Definition: cVideoBZ.h:38
virtual ~cVideoBZ()
bool isReady() const noexcept
Definition: cVideoBZ.h:58
void GetBlockRect(const BLOCK_COORD &coord, cRectI &rect) const noexcept
Definition: cVideoBZ.h:66
static HRESULT GRAYCALL CoordWrite(cStreamOutput &out, const BLOCK_COORD &coord)
UNITTEST_FRIEND(cVideoBZ)
Definition: WinTypes.h:128
Definition: cArray.h:932
Definition: cStream.h:306
Definition: cStream.h:126
Definition: cStreamQueue.h:19
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: cVideoBZ.h:123
cTimeSys m_tUpdated
only used by cVideoBZRateController
Definition: cVideoBZ.h:125
Definition: cVideoBZ.h:46
BYTE col
Definition: cVideoBZ.h:49
BYTE row
Definition: cVideoBZ.h:50