openMSX
ZMBVEncoder.hh
Go to the documentation of this file.
1 // Code based on DOSBox-0.65
2 
3 #ifndef ZMBVENCODER_HH
4 #define ZMBVENCODER_HH
5 
6 #include "PixelFormat.hh"
7 #include "MemBuffer.hh"
8 #include <cstdint>
9 #include <zlib.h>
10 
11 namespace openmsx {
12 
13 class FrameSource;
14 template<class P> class PixelOperations;
15 
17 {
18 public:
19  static constexpr const char CODEC_4CC[5] = "ZMBV"; // 4 + zero-terminator
20 
21  ZMBVEncoder(unsigned width, unsigned height, unsigned bpp);
22 
23  void compressFrame(bool keyFrame, FrameSource* frame,
24  void*& buffer, unsigned& written);
25 
26 private:
27  enum Format {
28  ZMBV_FORMAT_16BPP = 6,
29  ZMBV_FORMAT_32BPP = 8
30  };
31 
32  void setupBuffers(unsigned bpp);
33  unsigned neededSize() const;
34  template<class P> void addFullFrame(const PixelFormat& pixelFormat, unsigned& workUsed);
35  template<class P> void addXorFrame (const PixelFormat& pixelFormat, unsigned& workUsed);
36  template<class P> unsigned possibleBlock(int vx, int vy, unsigned offset);
37  template<class P> unsigned compareBlock(int vx, int vy, unsigned offset);
38  template<class P> void addXorBlock(
39  const PixelOperations<P>& pixelOps, int vx, int vy,
40  unsigned offset, unsigned& workUsed);
41  const void* getScaledLine(FrameSource* frame, unsigned y, void* workBuf) const;
42 
46  MemBuffer<uint8_t> output;
47  MemBuffer<unsigned> blockOffsets;
48  unsigned outputSize;
49 
50  z_stream zstream;
51 
52  const unsigned width;
53  const unsigned height;
54  unsigned pitch;
55  unsigned pixelSize;
56  Format format;
57 };
58 
59 } // namespace openmsx
60 
61 #endif
openmsx::ZMBVEncoder::ZMBVEncoder
ZMBVEncoder(unsigned width, unsigned height, unsigned bpp)
Definition: ZMBVEncoder.cc:117
openmsx::PixelOperations
Definition: PixelOperations.hh:143
openmsx::ZMBVEncoder::CODEC_4CC
static constexpr const char CODEC_4CC[5]
Definition: ZMBVEncoder.hh:19
openmsx::PixelFormat
Definition: PixelFormat.hh:9
openmsx::ZMBVEncoder::compressFrame
void compressFrame(bool keyFrame, FrameSource *frame, void *&buffer, unsigned &written)
Definition: ZMBVEncoder.cc:347
openmsx::MemBuffer< uint8_t, SSE2_ALIGNMENT >
MemBuffer.hh
openmsx::ZMBVEncoder
Definition: ZMBVEncoder.hh:17
openmsx::FrameSource
Interface for getting lines from a video frame.
Definition: FrameSource.hh:14
PixelFormat.hh
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5