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 "MemBuffer.hh"
7 #include <cstdint>
8 #include <zlib.h>
9 
10 struct SDL_PixelFormat;
11 
12 namespace openmsx {
13 
14 class FrameSource;
15 template<class P> class PixelOperations;
16 
18 {
19 public:
20  static const char* CODEC_4CC;
21 
22  ZMBVEncoder(unsigned width, unsigned height, unsigned bpp);
23 
24  void compressFrame(bool keyFrame, FrameSource* frame,
25  void*& buffer, unsigned& written);
26 
27 private:
28  enum Format {
29  ZMBV_FORMAT_16BPP = 6,
30  ZMBV_FORMAT_32BPP = 8
31  };
32 
33  void setupBuffers(unsigned bpp);
34  unsigned neededSize();
35  template<class P> void addFullFrame(const SDL_PixelFormat& pixelFormat, unsigned& workUsed);
36  template<class P> void addXorFrame (const SDL_PixelFormat& pixelFormat, unsigned& workUsed);
37  template<class P> unsigned possibleBlock(int vx, int vy, unsigned offset);
38  template<class P> unsigned compareBlock(int vx, int vy, unsigned offset);
39  template<class P> void addXorBlock(
40  const PixelOperations<P>& pixelOps, int vx, int vy,
41  unsigned offset, unsigned& workUsed);
42  const void* getScaledLine(FrameSource* frame, unsigned y, void* workBuf);
43 
47  MemBuffer<uint8_t> output;
48  MemBuffer<unsigned> blockOffsets;
49  unsigned outputSize;
50 
51  z_stream zstream;
52 
53  const unsigned width;
54  const unsigned height;
55  unsigned pitch;
56  unsigned pixelSize;
57  Format format;
58 };
59 
60 } // namespace openmsx
61 
62 #endif
void compressFrame(bool keyFrame, FrameSource *frame, void *&buffer, unsigned &written)
Definition: ZMBVEncoder.cc:349
Interface for getting lines from a video frame.
Definition: FrameSource.hh:14
static const char * CODEC_4CC
Definition: ZMBVEncoder.hh:20
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
ZMBVEncoder(unsigned width, unsigned height, unsigned bpp)
Definition: ZMBVEncoder.cc:119