MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / chooseQuality

Method chooseQuality

Telegram/SourceFiles/data/data_document.cpp:679–709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677}
678
679not_null<DocumentData*> DocumentData::chooseQuality(
680 HistoryItem *context,
681 Media::VideoQuality request) {
682 const auto &list = resolveQualities(context);
683 if (list.empty() || !request.height) {
684 return this;
685 }
686 const auto height = int(request.height);
687 if (request.original) {
688 return this;
689 }
690
691 auto closest = (DocumentData*)nullptr;
692 auto closestAbs = -1;
693 auto closestSize = -1;
694
695 for (const auto &quality : list) {
696 const auto qres = quality->resolveVideoQuality();
697 const auto abs = std::abs(height - qres);
698 if (!closest
699 || abs < closestAbs
700 || (abs == closestAbs && (quality->size < closestSize
701 || (closest == this && quality != this)))) {
702 closest = quality;
703 closestAbs = abs;
704 closestSize = quality->size;
705 }
706 }
707
708 return closest ? closest : this;
709}
710
711void DocumentData::validateLottieSticker() {
712 if (type == FileDocument

Callers 4

applyVideoQualityMethod · 0.80
assignMediaPointerMethod · 0.80
applyVideoQualityMethod · 0.80
createStreamedPlayerMethod · 0.80

Calls 2

resolveVideoQualityMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected