mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix webm emoji/stickers with unknown dimensions.
This commit is contained in:
parent
52ef8e780a
commit
254ca57bf3
1 changed files with 39 additions and 7 deletions
|
@ -48,6 +48,8 @@ namespace {
|
||||||
|
|
||||||
constexpr auto kDefaultCoverThumbnailSize = 100;
|
constexpr auto kDefaultCoverThumbnailSize = 100;
|
||||||
constexpr auto kMaxAllowedPreloadPrefix = 6 * 1024 * 1024;
|
constexpr auto kMaxAllowedPreloadPrefix = 6 * 1024 * 1024;
|
||||||
|
constexpr auto kDefaultWebmEmojiSize = 100;
|
||||||
|
constexpr auto kDefaultWebmStickerLargerSize = kStickerSideSize;
|
||||||
|
|
||||||
const auto kLottieStickerDimensions = QSize(
|
const auto kLottieStickerDimensions = QSize(
|
||||||
kStickerSideSize,
|
kStickerSideSize,
|
||||||
|
@ -430,6 +432,42 @@ void DocumentData::setattributes(
|
||||||
_flags |= Flag::HasAttachedStickers;
|
_flags |= Flag::HasAttachedStickers;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Any "video/webm" file is treated as a video-sticker.
|
||||||
|
if (hasMimeType(u"video/webm"_q)) {
|
||||||
|
if (type == FileDocument) {
|
||||||
|
type = StickerDocument;
|
||||||
|
_additional = std::make_unique<StickerData>();
|
||||||
|
}
|
||||||
|
if (type == StickerDocument) {
|
||||||
|
sticker()->type = StickerType::Webm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If "video/webm" sticker without dimensions we set them to default.
|
||||||
|
if (const auto info = sticker(); info
|
||||||
|
&& info->set
|
||||||
|
&& info->type == StickerType::Webm
|
||||||
|
&& dimensions.isEmpty()) {
|
||||||
|
if (info->setType == Data::StickersType::Emoji) {
|
||||||
|
// Always fixed.
|
||||||
|
dimensions = { kDefaultWebmEmojiSize, kDefaultWebmEmojiSize };
|
||||||
|
} else if (info->setType == Data::StickersType::Stickers) {
|
||||||
|
// May have aspect != 1, so we count it from the thumbnail.
|
||||||
|
const auto thumbnail = QSize(
|
||||||
|
_thumbnail.location.width(),
|
||||||
|
_thumbnail.location.height()
|
||||||
|
).scaled(
|
||||||
|
kDefaultWebmStickerLargerSize,
|
||||||
|
kDefaultWebmStickerLargerSize,
|
||||||
|
Qt::KeepAspectRatio);
|
||||||
|
if (!thumbnail.isEmpty()) {
|
||||||
|
dimensions = thumbnail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check sticker size/dimensions properties (for sticker of any type).
|
||||||
if (type == StickerDocument
|
if (type == StickerDocument
|
||||||
&& ((size > Storage::kMaxStickerBytesSize)
|
&& ((size > Storage::kMaxStickerBytesSize)
|
||||||
|| (!sticker()->isLottie()
|
|| (!sticker()->isLottie()
|
||||||
|
@ -438,14 +476,8 @@ void DocumentData::setattributes(
|
||||||
dimensions.height())))) {
|
dimensions.height())))) {
|
||||||
type = FileDocument;
|
type = FileDocument;
|
||||||
_additional = nullptr;
|
_additional = nullptr;
|
||||||
} else if (type == FileDocument
|
|
||||||
&& hasMimeType(u"video/webm"_q)
|
|
||||||
&& (size < Storage::kMaxStickerBytesSize)
|
|
||||||
&& GoodStickerDimensions(dimensions.width(), dimensions.height())) {
|
|
||||||
type = StickerDocument;
|
|
||||||
_additional = std::make_unique<StickerData>();
|
|
||||||
sticker()->type = StickerType::Webm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAudioFile()
|
if (isAudioFile()
|
||||||
|| isAnimation()
|
|| isAnimation()
|
||||||
|| isVoiceMessage()
|
|| isVoiceMessage()
|
||||||
|
|
Loading…
Add table
Reference in a new issue