moetsi / Sensor-Stream-Pipe

Open Source Sensor Stream Server and Client for Digitizing Reality
MIT License
70 stars 11 forks source link

Zstd codec implementation #14

Closed eidetic-av closed 1 year ago

eidetic-av commented 2 years ago

This is my initial attempt at setting up Zstandard for frame encoding and decoding:

https://github.com/eidetic-av/Sensor-Stream-Pipe/commit/fb58d85f54a3c269ab7ddba9808aa85e18248527

I am primarily using this to stream iOS depth frames, but zstd could be frame-type agnostic.

At the moment it is used like any other IEncoder/IDecoder:

ZstdEncoder encoder(zstd_dict_path);
encoder.AddFrameStruct(frameStruct);
std::shared_ptr<FrameSctruct> frame_compressed = encoder.CurrentFrameEncoded();

ZstdDecoder decoder(zstd_dict_path);
cv::Mat decoded = decoder.Decode(*frame_compressed);

Encoding and decoding is tested and working on Linux and iOS 15.3. I'm getting a crash on Windows. Not sure what's the problem there yet.

I need to commit a few more changes before any pull request:

I'll keep posting to this issue as I make changes... Let me know initial thoughts if anyone has a chance to have a quick look!

adammpolak commented 2 years ago