2017-08-17 18:18:10 +02:00
|
|
|
|
#include "./size.h"
|
|
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
|
namespace TagParser {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
|
2021-02-16 00:07:42 +01:00
|
|
|
|
/// \cond
|
|
|
|
|
constexpr Size fromHeightAndAspectRatio(std::uint32_t height, std::uint32_t numerator = 4, std::uint32_t denominator = 3)
|
|
|
|
|
{
|
|
|
|
|
return Size(height * numerator / denominator, height);
|
|
|
|
|
}
|
|
|
|
|
/// \endcond
|
|
|
|
|
|
2017-08-17 18:18:10 +02:00
|
|
|
|
/*!
|
2021-07-02 03:00:50 +02:00
|
|
|
|
* \brief Returns an abbreviation for the current instance, eg. 720p for sizes greater than 960×720
|
|
|
|
|
* and 1080p for sizes greater than 1440×1080.
|
2021-02-16 00:07:42 +01:00
|
|
|
|
* \remarks The width thresolds are for 4:3 resolutions so both, 4:3 and 16:9 "720p" is considered as such.
|
2017-08-17 18:18:10 +02:00
|
|
|
|
*/
|
2021-01-30 21:53:06 +01:00
|
|
|
|
std::string_view Size::abbreviation() const
|
2017-08-17 18:18:10 +02:00
|
|
|
|
{
|
2021-02-16 00:07:42 +01:00
|
|
|
|
if (*this >= fromHeightAndAspectRatio(4320)) {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
return "8k";
|
2021-02-16 00:07:42 +01:00
|
|
|
|
} else if (*this >= fromHeightAndAspectRatio(2160)) {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
return "4k";
|
2021-02-16 00:07:42 +01:00
|
|
|
|
} else if (*this >= fromHeightAndAspectRatio(1080)) {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
return "1080p";
|
2021-02-16 00:07:42 +01:00
|
|
|
|
} else if (*this >= fromHeightAndAspectRatio(720)) {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
return "720p";
|
2021-02-16 00:07:42 +01:00
|
|
|
|
} else if (*this >= fromHeightAndAspectRatio(576)) {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
return "576p";
|
2021-02-16 00:07:42 +01:00
|
|
|
|
} else if (*this >= fromHeightAndAspectRatio(480)) {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
return "480p";
|
2021-02-16 00:07:42 +01:00
|
|
|
|
} else if (*this >= fromHeightAndAspectRatio(320)) {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
return "320p";
|
2021-02-16 00:07:42 +01:00
|
|
|
|
} else if (*this >= fromHeightAndAspectRatio(240)) {
|
2017-08-17 18:18:10 +02:00
|
|
|
|
return "240p";
|
|
|
|
|
}
|
|
|
|
|
return "<240p";
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
|
} // namespace TagParser
|