Add progressive JPEG support.
GitOrigin-RevId: 48c56c3c2575da76df5e9237f6fb043e374bf30d
This commit is contained in:
parent
1843e92961
commit
1a4a834b2d
@ -178,8 +178,10 @@ inputFileLocal path:string = InputFile;
|
|||||||
inputFileGenerated original_path:string conversion:string expected_size:int32 = InputFile;
|
inputFileGenerated original_path:string conversion:string expected_size:int32 = InputFile;
|
||||||
|
|
||||||
|
|
||||||
//@description Photo description @type Thumbnail type (see https://core.telegram.org/constructor/photoSize) @photo Information about the photo file @width Photo width @height Photo height
|
//@description Describes an image in JPEG format @type Image type (see https://core.telegram.org/constructor/photoSize)
|
||||||
photoSize type:string photo:file width:int32 height:int32 = PhotoSize;
|
//@photo Information about the image file @width Image width @height Image height
|
||||||
|
//@progressive_sizes Sizes of progressive JPEG file prefixes, which can be used to preliminarily show the image
|
||||||
|
photoSize type:string photo:file width:int32 height:int32 progressive_sizes:vector<int32> = PhotoSize;
|
||||||
|
|
||||||
//@description Thumbnail image of a very poor quality and low resolution @width Thumbnail width, usually doesn't exceed 40 @height Thumbnail height, usually doesn't exceed 40 @data The thumbnail in JPEG format
|
//@description Thumbnail image of a very poor quality and low resolution @width Thumbnail width, usually doesn't exceed 40 @height Thumbnail height, usually doesn't exceed 40 @data The thumbnail in JPEG format
|
||||||
minithumbnail width:int32 height:int32 data:bytes = Minithumbnail;
|
minithumbnail width:int32 height:int32 data:bytes = Minithumbnail;
|
||||||
|
Binary file not shown.
@ -864,7 +864,8 @@ tl_object_ptr<td_api::minithumbnail> copy(const td_api::minithumbnail &obj) {
|
|||||||
|
|
||||||
template <>
|
template <>
|
||||||
tl_object_ptr<td_api::photoSize> copy(const td_api::photoSize &obj) {
|
tl_object_ptr<td_api::photoSize> copy(const td_api::photoSize &obj) {
|
||||||
return make_tl_object<td_api::photoSize>(obj.type_, copy(obj.photo_), obj.width_, obj.height_);
|
return make_tl_object<td_api::photoSize>(obj.type_, copy(obj.photo_), obj.width_, obj.height_,
|
||||||
|
vector<int32>(obj.progressive_sizes_));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -3355,17 +3355,17 @@ void unregister_message_content(Td *td, const MessageContent *content, FullMessa
|
|||||||
template <class ToT, class FromT>
|
template <class ToT, class FromT>
|
||||||
static tl_object_ptr<ToT> secret_to_telegram(FromT &from);
|
static tl_object_ptr<ToT> secret_to_telegram(FromT &from);
|
||||||
|
|
||||||
// fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileLocation;
|
// fileLocationUnavailable volume_id:long local_id:int secret:long = FileLocation;
|
||||||
static auto secret_to_telegram(secret_api::fileLocationUnavailable &file_location) {
|
static auto secret_to_telegram(secret_api::fileLocationUnavailable &file_location) {
|
||||||
return make_tl_object<telegram_api::fileLocationToBeDeprecated>(file_location.volume_id_, file_location.local_id_);
|
return make_tl_object<telegram_api::fileLocationToBeDeprecated>(file_location.volume_id_, file_location.local_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fileLocation#53d69076 dc_id:int volume_id:long local_id:int secret:long = FileLocation;
|
// fileLocation dc_id:int volume_id:long local_id:int secret:long = FileLocation;
|
||||||
static auto secret_to_telegram(secret_api::fileLocation &file_location) {
|
static auto secret_to_telegram(secret_api::fileLocation &file_location) {
|
||||||
return make_tl_object<telegram_api::fileLocationToBeDeprecated>(file_location.volume_id_, file_location.local_id_);
|
return make_tl_object<telegram_api::fileLocationToBeDeprecated>(file_location.volume_id_, file_location.local_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// photoSizeEmpty#e17e23c type:string = PhotoSize;
|
// photoSizeEmpty type:string = PhotoSize;
|
||||||
static auto secret_to_telegram(secret_api::photoSizeEmpty &empty) {
|
static auto secret_to_telegram(secret_api::photoSizeEmpty &empty) {
|
||||||
if (!clean_input_string(empty.type_)) {
|
if (!clean_input_string(empty.type_)) {
|
||||||
empty.type_.clear();
|
empty.type_.clear();
|
||||||
@ -3373,7 +3373,7 @@ static auto secret_to_telegram(secret_api::photoSizeEmpty &empty) {
|
|||||||
return make_tl_object<telegram_api::photoSizeEmpty>(empty.type_);
|
return make_tl_object<telegram_api::photoSizeEmpty>(empty.type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize;
|
// photoSize type:string location:FileLocation w:int h:int size:int = PhotoSize;
|
||||||
static auto secret_to_telegram(secret_api::photoSize &photo_size) {
|
static auto secret_to_telegram(secret_api::photoSize &photo_size) {
|
||||||
if (!clean_input_string(photo_size.type_)) {
|
if (!clean_input_string(photo_size.type_)) {
|
||||||
photo_size.type_.clear();
|
photo_size.type_.clear();
|
||||||
@ -3383,7 +3383,7 @@ static auto secret_to_telegram(secret_api::photoSize &photo_size) {
|
|||||||
photo_size.w_, photo_size.h_, photo_size.size_);
|
photo_size.w_, photo_size.h_, photo_size.size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
|
// photoCachedSize type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
|
||||||
static auto secret_to_telegram(secret_api::photoCachedSize &photo_size) {
|
static auto secret_to_telegram(secret_api::photoCachedSize &photo_size) {
|
||||||
if (!clean_input_string(photo_size.type_)) {
|
if (!clean_input_string(photo_size.type_)) {
|
||||||
photo_size.type_.clear();
|
photo_size.type_.clear();
|
||||||
@ -3393,17 +3393,17 @@ static auto secret_to_telegram(secret_api::photoCachedSize &photo_size) {
|
|||||||
photo_size.w_, photo_size.h_, photo_size.bytes_.clone());
|
photo_size.w_, photo_size.h_, photo_size.bytes_.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeImageSize #6c37c15c w:int h:int = DocumentAttribute;
|
// documentAttributeImageSize w:int h:int = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeImageSize &image_size) {
|
static auto secret_to_telegram(secret_api::documentAttributeImageSize &image_size) {
|
||||||
return make_tl_object<telegram_api::documentAttributeImageSize>(image_size.w_, image_size.h_);
|
return make_tl_object<telegram_api::documentAttributeImageSize>(image_size.w_, image_size.h_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeAnimated #11b58939 = DocumentAttribute;
|
// documentAttributeAnimated = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeAnimated &animated) {
|
static auto secret_to_telegram(secret_api::documentAttributeAnimated &animated) {
|
||||||
return make_tl_object<telegram_api::documentAttributeAnimated>();
|
return make_tl_object<telegram_api::documentAttributeAnimated>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeSticker23 #fb0a5727 = DocumentAttribute;
|
// documentAttributeSticker23 = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeSticker23 &sticker) {
|
static auto secret_to_telegram(secret_api::documentAttributeSticker23 &sticker) {
|
||||||
return make_tl_object<telegram_api::documentAttributeSticker>(
|
return make_tl_object<telegram_api::documentAttributeSticker>(
|
||||||
0, false /*ignored*/, "", make_tl_object<telegram_api::inputStickerSetEmpty>(), nullptr);
|
0, false /*ignored*/, "", make_tl_object<telegram_api::inputStickerSetEmpty>(), nullptr);
|
||||||
@ -3420,7 +3420,7 @@ static auto secret_to_telegram(secret_api::inputStickerSetShortName &sticker_set
|
|||||||
return make_tl_object<telegram_api::inputStickerSetShortName>(sticker_set.short_name_);
|
return make_tl_object<telegram_api::inputStickerSetShortName>(sticker_set.short_name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeSticker #3a556302 alt:string stickerset:InputStickerSet = DocumentAttribute;
|
// documentAttributeSticker alt:string stickerset:InputStickerSet = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeSticker &sticker) {
|
static auto secret_to_telegram(secret_api::documentAttributeSticker &sticker) {
|
||||||
if (!clean_input_string(sticker.alt_)) {
|
if (!clean_input_string(sticker.alt_)) {
|
||||||
sticker.alt_.clear();
|
sticker.alt_.clear();
|
||||||
@ -3430,13 +3430,13 @@ static auto secret_to_telegram(secret_api::documentAttributeSticker &sticker) {
|
|||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeVideo #5910cccb duration:int w:int h:int = DocumentAttribute;
|
// documentAttributeVideo duration:int w:int h:int = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeVideo &video) {
|
static auto secret_to_telegram(secret_api::documentAttributeVideo &video) {
|
||||||
return make_tl_object<telegram_api::documentAttributeVideo>(0, false /*ignored*/, false /*ignored*/, video.duration_,
|
return make_tl_object<telegram_api::documentAttributeVideo>(0, false /*ignored*/, false /*ignored*/, video.duration_,
|
||||||
video.w_, video.h_);
|
video.w_, video.h_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeFilename #15590068 file_name:string = DocumentAttribute;
|
// documentAttributeFilename file_name:string = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeFilename &filename) {
|
static auto secret_to_telegram(secret_api::documentAttributeFilename &filename) {
|
||||||
if (!clean_input_string(filename.file_name_)) {
|
if (!clean_input_string(filename.file_name_)) {
|
||||||
filename.file_name_.clear();
|
filename.file_name_.clear();
|
||||||
@ -3444,7 +3444,7 @@ static auto secret_to_telegram(secret_api::documentAttributeFilename &filename)
|
|||||||
return make_tl_object<telegram_api::documentAttributeFilename>(filename.file_name_);
|
return make_tl_object<telegram_api::documentAttributeFilename>(filename.file_name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeVideo66#ef02ce6 flags:# round_message:flags.0?true duration:int w:int h:int = DocumentAttribute;
|
// documentAttributeVideo66 flags:# round_message:flags.0?true duration:int w:int h:int = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeVideo66 &video) {
|
static auto secret_to_telegram(secret_api::documentAttributeVideo66 &video) {
|
||||||
return make_tl_object<telegram_api::documentAttributeVideo>(
|
return make_tl_object<telegram_api::documentAttributeVideo>(
|
||||||
(video.flags_ & secret_api::documentAttributeVideo66::ROUND_MESSAGE_MASK) != 0
|
(video.flags_ & secret_api::documentAttributeVideo66::ROUND_MESSAGE_MASK) != 0
|
||||||
@ -3479,16 +3479,16 @@ static auto telegram_documentAttributeAudio(bool is_voice_note, int duration, st
|
|||||||
std::move(performer), std::move(waveform));
|
std::move(performer), std::move(waveform));
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeAudio23 #51448e5 duration:int = DocumentAttribute;
|
// documentAttributeAudio23 duration:int = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeAudio23 &audio) {
|
static auto secret_to_telegram(secret_api::documentAttributeAudio23 &audio) {
|
||||||
return telegram_documentAttributeAudio(false, audio.duration_, "", "", Auto());
|
return telegram_documentAttributeAudio(false, audio.duration_, "", "", Auto());
|
||||||
}
|
}
|
||||||
// documentAttributeAudio45 #ded218e0 duration:int title:string performer:string = DocumentAttribute;
|
// documentAttributeAudio45 duration:int title:string performer:string = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeAudio45 &audio) {
|
static auto secret_to_telegram(secret_api::documentAttributeAudio45 &audio) {
|
||||||
return telegram_documentAttributeAudio(false, audio.duration_, audio.title_, audio.performer_, Auto());
|
return telegram_documentAttributeAudio(false, audio.duration_, audio.title_, audio.performer_, Auto());
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentAttributeAudio#9852f9c6 flags:# voice:flags.10?true duration:int title:flags.0?string
|
// documentAttributeAudio flags:# voice:flags.10?true duration:int title:flags.0?string
|
||||||
// performer:flags.1?string waveform:flags.2?bytes = DocumentAttribute;
|
// performer:flags.1?string waveform:flags.2?bytes = DocumentAttribute;
|
||||||
static auto secret_to_telegram(secret_api::documentAttributeAudio &audio) {
|
static auto secret_to_telegram(secret_api::documentAttributeAudio &audio) {
|
||||||
return telegram_documentAttributeAudio((audio.flags_ & secret_api::documentAttributeAudio::VOICE_MASK) != 0,
|
return telegram_documentAttributeAudio((audio.flags_ & secret_api::documentAttributeAudio::VOICE_MASK) != 0,
|
||||||
@ -3506,7 +3506,7 @@ static auto secret_to_telegram(std::vector<tl_object_ptr<secret_api::DocumentAtt
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// decryptedMessageMediaExternalDocument#fa95b0dd id:long access_hash:long date:int mime_type:string size:int
|
// decryptedMessageMediaExternalDocument id:long access_hash:long date:int mime_type:string size:int
|
||||||
// thumb:PhotoSize dc_id:int attributes:Vector<DocumentAttribute> = DecryptedMessageMedia;
|
// thumb:PhotoSize dc_id:int attributes:Vector<DocumentAttribute> = DecryptedMessageMedia;
|
||||||
static auto secret_to_telegram_document(secret_api::decryptedMessageMediaExternalDocument &from) {
|
static auto secret_to_telegram_document(secret_api::decryptedMessageMediaExternalDocument &from) {
|
||||||
if (!clean_input_string(from.mime_type_)) {
|
if (!clean_input_string(from.mime_type_)) {
|
||||||
|
@ -408,6 +408,8 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSo
|
|||||||
location = std::move(size->location_);
|
location = std::move(size->location_);
|
||||||
res.dimensions = get_dimensions(size->w_, size->h_);
|
res.dimensions = get_dimensions(size->w_, size->h_);
|
||||||
res.size = size->sizes_.back();
|
res.size = size->sizes_.back();
|
||||||
|
size->sizes_.pop_back();
|
||||||
|
res.progressive_sizes = std::move(size->sizes_);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -567,7 +569,8 @@ static tl_object_ptr<td_api::photoSize> get_photo_size_object(FileManager *file_
|
|||||||
return td_api::make_object<td_api::photoSize>(
|
return td_api::make_object<td_api::photoSize>(
|
||||||
photo_size->type ? std::string(1, static_cast<char>(photo_size->type))
|
photo_size->type ? std::string(1, static_cast<char>(photo_size->type))
|
||||||
: std::string(), // TODO replace string type with integer type
|
: std::string(), // TODO replace string type with integer type
|
||||||
file_manager->get_file_object(photo_size->file_id), photo_size->dimensions.width, photo_size->dimensions.height);
|
file_manager->get_file_object(photo_size->file_id), photo_size->dimensions.width, photo_size->dimensions.height,
|
||||||
|
vector<int32>(photo_size->progressive_sizes));
|
||||||
}
|
}
|
||||||
|
|
||||||
static vector<td_api::object_ptr<td_api::photoSize>> get_photo_sizes_object(FileManager *file_manager,
|
static vector<td_api::object_ptr<td_api::photoSize>> get_photo_sizes_object(FileManager *file_manager,
|
||||||
@ -586,7 +589,8 @@ static vector<td_api::object_ptr<td_api::photoSize>> get_photo_sizes_object(File
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const PhotoSize &lhs, const PhotoSize &rhs) {
|
bool operator==(const PhotoSize &lhs, const PhotoSize &rhs) {
|
||||||
return lhs.type == rhs.type && lhs.dimensions == rhs.dimensions && lhs.size == rhs.size && lhs.file_id == rhs.file_id;
|
return lhs.type == rhs.type && lhs.dimensions == rhs.dimensions && lhs.size == rhs.size &&
|
||||||
|
lhs.file_id == rhs.file_id && lhs.progressive_sizes == rhs.progressive_sizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const PhotoSize &lhs, const PhotoSize &rhs) {
|
bool operator!=(const PhotoSize &lhs, const PhotoSize &rhs) {
|
||||||
@ -615,7 +619,8 @@ bool operator<(const PhotoSize &lhs, const PhotoSize &rhs) {
|
|||||||
|
|
||||||
StringBuilder &operator<<(StringBuilder &string_builder, const PhotoSize &photo_size) {
|
StringBuilder &operator<<(StringBuilder &string_builder, const PhotoSize &photo_size) {
|
||||||
return string_builder << "{type = " << photo_size.type << ", dimensions = " << photo_size.dimensions
|
return string_builder << "{type = " << photo_size.type << ", dimensions = " << photo_size.dimensions
|
||||||
<< ", size = " << photo_size.size << ", file_id = " << photo_size.file_id << "}";
|
<< ", size = " << photo_size.size << ", file_id = " << photo_size.file_id
|
||||||
|
<< ", progressive_sizes = " << photo_size.progressive_sizes << "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
static tl_object_ptr<td_api::animatedChatPhoto> get_animated_chat_photo_object(FileManager *file_manager,
|
static tl_object_ptr<td_api::animatedChatPhoto> get_animated_chat_photo_object(FileManager *file_manager,
|
||||||
@ -949,6 +954,15 @@ tl_object_ptr<telegram_api::userProfilePhoto> convert_photo_to_profile_photo(
|
|||||||
}
|
}
|
||||||
case telegram_api::photoStrippedSize::ID:
|
case telegram_api::photoStrippedSize::ID:
|
||||||
break;
|
break;
|
||||||
|
case telegram_api::photoSizeProgressive::ID: {
|
||||||
|
auto size = static_cast<const telegram_api::photoSizeProgressive *>(size_ptr.get());
|
||||||
|
if (size->type_ == "a") {
|
||||||
|
photo_small = copy_location(size->location_);
|
||||||
|
} else if (size->type_ == "c") {
|
||||||
|
photo_big = copy_location(size->location_);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
|
@ -48,6 +48,7 @@ struct PhotoSize {
|
|||||||
Dimensions dimensions;
|
Dimensions dimensions;
|
||||||
int32 size = 0;
|
int32 size = 0;
|
||||||
FileId file_id;
|
FileId file_id;
|
||||||
|
vector<int32> progressive_sizes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AnimationSize : public PhotoSize {
|
struct AnimationSize : public PhotoSize {
|
||||||
|
@ -75,6 +75,7 @@ void store(const PhotoSize &photo_size, StorerT &storer) {
|
|||||||
store(photo_size.dimensions, storer);
|
store(photo_size.dimensions, storer);
|
||||||
store(photo_size.size, storer);
|
store(photo_size.size, storer);
|
||||||
store(photo_size.file_id, storer);
|
store(photo_size.file_id, storer);
|
||||||
|
store(photo_size.progressive_sizes, storer);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
@ -83,6 +84,11 @@ void parse(PhotoSize &photo_size, ParserT &parser) {
|
|||||||
parse(photo_size.dimensions, parser);
|
parse(photo_size.dimensions, parser);
|
||||||
parse(photo_size.size, parser);
|
parse(photo_size.size, parser);
|
||||||
parse(photo_size.file_id, parser);
|
parse(photo_size.file_id, parser);
|
||||||
|
if (parser.version() >= static_cast<int32>(Version::AddPhotoProgressiveSizes)) {
|
||||||
|
parse(photo_size.progressive_sizes, parser);
|
||||||
|
} else {
|
||||||
|
photo_size.progressive_sizes.clear();
|
||||||
|
}
|
||||||
LOG(DEBUG) << "Parsed photo size " << photo_size;
|
LOG(DEBUG) << "Parsed photo size " << photo_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ enum class Version : int32 {
|
|||||||
AddDiceEmoji, // 25
|
AddDiceEmoji, // 25
|
||||||
AddAnimationStickers,
|
AddAnimationStickers,
|
||||||
AddDialogPhotoHasAnimation,
|
AddDialogPhotoHasAnimation,
|
||||||
|
AddPhotoProgressiveSizes,
|
||||||
Next
|
Next
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user