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 "aligned.hh"
8#include <concepts>
9#include <cstdint>
10#include <span>
11#include <string_view>
12#include <zlib.h>
13
14namespace openmsx {
15
16class FrameSource;
17
19{
20public:
21 static constexpr std::string_view CODEC_4CC = "ZMBV";
22 using Pixel = uint32_t;
23
24 ZMBVEncoder(unsigned width, unsigned height);
25
26 [[nodiscard]] std::span<const uint8_t> compressFrame(bool keyFrame, FrameSource* frame);
27
28private:
29 void setupBuffers();
30 [[nodiscard]] unsigned neededSize() const;
31 void addFullFrame(unsigned& workUsed);
32 void addXorFrame (unsigned& workUsed);
33 [[nodiscard]] unsigned possibleBlock(int vx, int vy, size_t offset);
34 [[nodiscard]] unsigned compareBlock(int vx, int vy, size_t offset);
35 void addXorBlock(int vx, int vy, size_t offset, unsigned& workUsed);
36 [[nodiscard]] const void* getScaledLine(const FrameSource* frame, unsigned y, void* workBuf) const;
37
38private:
42 MemBuffer<uint8_t> output;
43 MemBuffer<size_t> blockOffsets;
44 unsigned outputSize;
45
46 z_stream zstream;
47
48 const unsigned width;
49 const unsigned height;
50 size_t pitch;
51};
52
53} // namespace openmsx
54
55#endif
Interface for getting lines from a video frame.
This class manages the lifetime of a block of memory.
Definition MemBuffer.hh:29
static constexpr std::string_view CODEC_4CC
std::span< const uint8_t > compressFrame(bool keyFrame, FrameSource *frame)
This file implemented 3 utility functions:
Definition Autofire.cc:9