MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / AgatEncoder

Class AgatEncoder

arch/agat/encoder.cc:12–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "lib/encoders/encoders.pb.h"
11
12class AgatEncoder : public Encoder
13{
14public:
15 AgatEncoder(const EncoderProto& config):
16 Encoder(config),
17 _config(config.agat())
18 {
19 }
20
21private:
22 void writeRawBits(uint64_t data, int width)
23 {
24 _cursor += width;
25 _lastBit = data & 1;
26 for (int i = 0; i < width; i++)
27 {
28 unsigned pos = _cursor - i - 1;
29 if (pos < _bits.size())
30 _bits[pos] = data & 1;
31 data >>= 1;
32 }
33 }
34
35 void writeBytes(const Bytes& bytes)
36 {
37 encodeMfm(_bits, _cursor, bytes, _lastBit);
38 }
39
40 void writeByte(uint8_t byte)
41 {
42 Bytes b;
43 b.writer().write_8(byte);
44 writeBytes(b);
45 }
46
47 void writeFillerRawBytes(int count, uint16_t byte)
48 {
49 for (int i = 0; i < count; i++)
50 writeRawBits(byte, 16);
51 };
52
53 void writeFillerBytes(int count, uint8_t byte)
54 {
55 Bytes b{byte};
56 for (int i = 0; i < count; i++)
57 writeBytes(b);
58 };
59
60public:
61 std::unique_ptr<Fluxmap> encode(const LogicalTrackLayout& ltl,
62 const std::vector<std::shared_ptr<const Sector>>& sectors,
63 const Image& image) override
64 {
65 double clockRateUs = _config.target_clock_period_us() / 2.0;
66 int bitsPerRevolution =
67 (_config.target_rotational_period_ms() * 1000.0) / clockRateUs;
68 _bits.resize(bitsPerRevolution);
69 _cursor = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected