Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata Compression #2

Closed
apavlenko opened this issue Nov 30, 2015 · 4 comments
Closed

Metadata Compression #2

apavlenko opened this issue Nov 30, 2015 · 4 comments
Assignees
Milestone

Comments

@apavlenko
Copy link
Owner

Requirements:

  1. ability to compresses the entire metadata schema on save into media file and de-compress back on load
  2. ability to compress and de-compress exported XML/JSON metadata representation (including incremental mode)
  3. out-of-box compression algo + API (and a sample) of user-provided algo using open-source compression lib(s) (bz2, gz, lzma)
  4. test(s) and sample(s)
@apavlenko apavlenko added this to the 3.0-pre milestone Nov 30, 2015
@savuor
Copy link
Collaborator

savuor commented Dec 1, 2015

A prototype implemented: transparent encoding/decoding from/to base64 inside XMPDataSource.
See rv/compression_prototype branch for details.

@savuor
Copy link
Collaborator

savuor commented Dec 2, 2015

Design proposal

  1. Each compression method should be implemented as a class implementing ICompressor interface:

    • void compress(const string& in, string& out);
    • void decompress(const string& in, string& out);
    • string getId();

    If user wants to use his own compression method, the function vmf::registerCompressor(ICompressor*) should be called before that.

  2. Exporting metadata to separate file is performed now using IReader and IWriter interfaces.
    I propose to create CompressionReader class derived from IReader interface.

    It should use the following user-provided instances of interfaces:

    • ICompressor to decompress data
    • IReader to parse data

    The same for CompressionWriter class.

  3. To write metadata to video file a user now calls the method vmf::MetadataStream::save() or saveTo(string).
    I propose to add the optional argument ICompressor* to the methods.

    Implementation of the in-video metadata compression should be the following:

    • create methods XMPDataSource::loadXMPStructs() and XMPDataSource::saveXMPStructs() as an intermediate layer
    • reimplement them in derived class CompressedXMPDataSource taking ICompressor* as the constructor argument
    • this class should perform encoding to and decoding from base64

@apavlenko
Copy link
Owner Author

I suggest

class ICompressor
{
public:
    void compress(const std::string& in, vmf_rawbuffer& out);
    void decompress(const vmf_rawbuffer& in, std::string& out);
    const std::string& getID();
};

since VMF uses vmf_rawbuffer type for arbitrary binary data (BTW, vmf_rawbuffer implementation can be improved).

Also vmf::registerCompressor(std::shared_ptr<ICompressor> compressor) is much safer than use of naked pointer.

I'm not sure we really need CompressedXMPDataSource as an inheritor of XMPDataSource for compression support - please consider possibility of adding compression-related code directly into XMPDataSource. (Same for IReader and IWriter.)

@apavlenko
Copy link
Owner Author

#10 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants