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 "aligned.hh"
9#include <concepts>
10#include <cstdint>
11#include <span>
12#include <string_view>
13#include <zlib.h>
14
15namespace openmsx {
16
17class FrameSource;
18template<std::unsigned_integral P> class PixelOperations;
19
21{
22public:
23 static constexpr std::string_view CODEC_4CC = "ZMBV";
24
25 ZMBVEncoder(unsigned width, unsigned height, unsigned bpp);
26
27 [[nodiscard]] std::span<const uint8_t> compressFrame(bool keyFrame, FrameSource* frame);
28
29private:
30 enum Format {
31 ZMBV_FORMAT_16BPP = 6,
32 ZMBV_FORMAT_32BPP = 8
33 };
34
35 void setupBuffers(unsigned bpp);
36 [[nodiscard]] unsigned neededSize() const;
37 template<std::unsigned_integral P> void addFullFrame(const PixelFormat& pixelFormat, unsigned& workUsed);
38 template<std::unsigned_integral P> void addXorFrame (const PixelFormat& pixelFormat, unsigned& workUsed);
39 template<std::unsigned_integral P> [[nodiscard]] unsigned possibleBlock(int vx, int vy, size_t offset);
40 template<std::unsigned_integral P> [[nodiscard]] unsigned compareBlock(int vx, int vy, size_t offset);
41 template<std::unsigned_integral P> void addXorBlock(
42 const PixelOperations<P>& pixelOps, int vx, int vy,
43 size_t offset, unsigned& workUsed);
44 [[nodiscard]] const void* getScaledLine(FrameSource* frame, unsigned y, void* workBuf) const;
45
46private:
50 MemBuffer<uint8_t> output;
51 MemBuffer<size_t> blockOffsets;
52 unsigned outputSize;
53
54 z_stream zstream;
55
56 const unsigned width;
57 const unsigned height;
58 size_t pitch;
59 unsigned pixelSize;
60 Format format;
61};
62
63} // namespace openmsx
64
65#endif
Interface for getting lines from a video frame.
Definition: FrameSource.hh:20
static constexpr std::string_view CODEC_4CC
Definition: ZMBVEncoder.hh:23
std::span< const uint8_t > compressFrame(bool keyFrame, FrameSource *frame)
Definition: ZMBVEncoder.cc:354
ZMBVEncoder(unsigned width, unsigned height, unsigned bpp)
Definition: ZMBVEncoder.cc:125
This file implemented 3 utility functions:
Definition: Autofire.cc:9