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
9#include <cstdint>
10#include <span>
11#include <string_view>
12
13#include <zlib.h>
14
15namespace openmsx {
16
17class FrameSource;
18
20{
21public:
22 static constexpr std::string_view CODEC_4CC = "ZMBV";
23 using Pixel = uint32_t;
24
25 ZMBVEncoder(unsigned width, unsigned height);
26 ZMBVEncoder(const ZMBVEncoder&) = delete;
30 ~ZMBVEncoder() = default;
31
32 [[nodiscard]] std::span<const uint8_t> compressFrame(bool keyFrame, const FrameSource* frame);
33
34private:
35 void setupBuffers();
36 [[nodiscard]] unsigned neededSize() const;
37 void addFullFrame(unsigned& workUsed);
38 void addXorFrame (unsigned& workUsed);
39 [[nodiscard]] unsigned possibleBlock(int vx, int vy, size_t offset);
40 [[nodiscard]] unsigned compareBlock(int vx, int vy, size_t offset);
41 void addXorBlock(int vx, int vy, size_t offset, unsigned& workUsed);
42 [[nodiscard]] const Pixel* getScaledLine(const FrameSource* frame, unsigned y, Pixel* workBuf) const;
43
44private:
48 MemBuffer<uint8_t> output;
49 MemBuffer<size_t> blockOffsets;
50 unsigned outputSize;
51
52 z_stream zstream;
53
54 unsigned width;
55 unsigned height;
56 size_t pitch;
57};
58
59} // namespace openmsx
60
61#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
ZMBVEncoder & operator=(ZMBVEncoder &&)=delete
ZMBVEncoder & operator=(const ZMBVEncoder &)=delete
std::span< const uint8_t > compressFrame(bool keyFrame, const FrameSource *frame)
ZMBVEncoder(ZMBVEncoder &&)=delete
ZMBVEncoder(const ZMBVEncoder &)=delete
This file implemented 3 utility functions:
Definition Autofire.cc:11