#include "compression.h" #if defined(ENABLE_GPL) #include #endif #include #include #include #include #include #include TCompressionCodecFactory::TCompressionCodecFactory() { auto gzip = [](auto s) { return MakeHolder(s); }; Add("gzip", gzip, [](auto s) { return MakeHolder(s, ZLib::GZip); }); Add("deflate", gzip, [](auto s) { return MakeHolder(s, ZLib::ZLib); }); Add("br", [](auto s) { return MakeHolder(s); }, [](auto s) { return MakeHolder(s, 4); }); Add("x-gzip", gzip, [](auto s) { return MakeHolder(s, ZLib::GZip); }); Add("x-deflate", gzip, [](auto s) { return MakeHolder(s, ZLib::ZLib); }); #if defined(ENABLE_GPL) const ui16 bs = 32 * 1024; Add("y-lzo", [](auto s) { return MakeHolder(s); }, [bs](auto s) { return MakeHolder >(s, bs); }); Add("y-lzf", [](auto s) { return MakeHolder(s); }, [bs](auto s) { return MakeHolder >(s, bs); }); Add("y-lzq", [](auto s) { return MakeHolder(s); }, [bs](auto s) { return MakeHolder >(s, bs); }); #endif Add("y-bzip2", [](auto s) { return MakeHolder(s); }, [](auto s) { return MakeHolder(s); }); Add("y-lzma", [](auto s) { return MakeHolder(s); }, [](auto s) { return MakeHolder(s); }); for (auto codecName : NBlockCodecs::ListAllCodecs()) { if (codecName.StartsWith("zstd06")) { continue; } if (codecName.StartsWith("zstd08")) { continue; } auto codec = NBlockCodecs::Codec(codecName); auto enc = [codec](auto s) { return MakeHolder(s, codec, 32 * 1024); }; auto dec = [codec](auto s) { return MakeHolder(s, codec); }; Add(TString("z-") + codecName, dec, enc); } } void TCompressionCodecFactory::Add(TStringBuf name, TDecoderConstructor d, TEncoderConstructor e) { Strings_.emplace_back(name); Codecs_[Strings_.back()] = TCodec{d, e}; BestCodecs_.emplace_back(Strings_.back()); }