mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Cache good thumbnail in Webp for Webm stickers.
This commit is contained in:
parent
581b84afe0
commit
d18e28978a
2 changed files with 11 additions and 6 deletions
|
@ -37,6 +37,7 @@ constexpr auto kGoodThumbQuality = 87;
|
|||
|
||||
enum class FileType {
|
||||
Video,
|
||||
VideoSticker,
|
||||
AnimatedSticker,
|
||||
WallPaper,
|
||||
WallPatternPNG,
|
||||
|
@ -56,7 +57,7 @@ enum class FileType {
|
|||
const QString &path,
|
||||
QByteArray data,
|
||||
FileType type) {
|
||||
if (type == FileType::Video) {
|
||||
if (type == FileType::Video || type == FileType::VideoSticker) {
|
||||
return ::Media::Clip::PrepareForSending(path, data).thumbnail;
|
||||
} else if (type == FileType::AnimatedSticker) {
|
||||
return Lottie::ReadThumbnail(Lottie::ReadContent(data, path));
|
||||
|
@ -409,9 +410,11 @@ void DocumentMedia::GenerateGoodThumbnail(
|
|||
? FileType::WallPaper
|
||||
: document->isTheme()
|
||||
? FileType::Theme
|
||||
: (document->sticker() && document->sticker()->isLottie())
|
||||
: !document->sticker()
|
||||
? FileType::Video
|
||||
: document->sticker()->isLottie()
|
||||
? FileType::AnimatedSticker
|
||||
: FileType::Video;
|
||||
: FileType::VideoSticker;
|
||||
auto location = document->location().isEmpty()
|
||||
? nullptr
|
||||
: std::make_unique<Core::FileLocation>(document->location());
|
||||
|
@ -428,7 +431,8 @@ void DocumentMedia::GenerateGoodThumbnail(
|
|||
auto bytes = QByteArray();
|
||||
if (!result.isNull()) {
|
||||
auto buffer = QBuffer(&bytes);
|
||||
const auto format = (type == FileType::AnimatedSticker)
|
||||
const auto format = (type == FileType::AnimatedSticker
|
||||
|| type == FileType::VideoSticker)
|
||||
? "WEBP"
|
||||
: (type == FileType::WallPatternPNG
|
||||
|| type == FileType::WallPatternSVG)
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
constexpr auto kWaitingFastDuration = crl::time(200);
|
||||
constexpr auto kWaitingShowDuration = crl::time(500);
|
||||
constexpr auto kWaitingShowDelay = crl::time(500);
|
||||
constexpr auto kGoodThumbnailQuality = 87;
|
||||
constexpr auto kGoodThumbQuality = 87;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -217,6 +217,7 @@ void Document::validateGoodThumbnail() {
|
|||
|| _document->goodThumbnailChecked()) {
|
||||
return;
|
||||
}
|
||||
const auto sticker = (_document->sticker() != nullptr);
|
||||
const auto document = _document;
|
||||
const auto information = _info.video;
|
||||
const auto key = document->goodThumbnailCacheKey();
|
||||
|
@ -243,7 +244,7 @@ void Document::validateGoodThumbnail() {
|
|||
auto bytes = QByteArray();
|
||||
{
|
||||
auto buffer = QBuffer(&bytes);
|
||||
image.save(&buffer, "JPG", kGoodThumbnailQuality);
|
||||
image.save(&buffer, sticker ? "WEBP" : "JPG", kGoodThumbQuality);
|
||||
}
|
||||
const auto length = bytes.size();
|
||||
if (!length || length > Storage::kMaxFileInMemory) {
|
||||
|
|
Loading…
Add table
Reference in a new issue