tagparser/aspectratio.h

74 lines
1.7 KiB
C
Raw Permalink Normal View History

#ifndef TAG_PARSER_ASPECTRATIO_H
#define TAG_PARSER_ASPECTRATIO_H
2016-02-17 20:19:05 +01:00
2016-08-29 15:43:05 +02:00
#include "./global.h"
2018-07-28 15:07:15 +02:00
#include <c++utilities/conversion/stringbuilder.h>
2016-02-17 20:19:05 +01:00
2019-03-13 19:06:42 +01:00
#include <cstdint>
2018-07-28 15:07:15 +02:00
#include <string>
namespace TagParser {
2016-02-17 20:19:05 +01:00
2016-08-29 15:43:05 +02:00
struct TAG_PARSER_EXPORT AspectRatio {
constexpr explicit AspectRatio();
explicit AspectRatio(std::uint8_t aspectRatioType);
constexpr explicit AspectRatio(std::uint16_t numerator, std::uint16_t denominator);
constexpr bool isValid() const;
constexpr bool isExtended() const;
2018-07-28 15:07:15 +02:00
std::string toString() const;
2016-02-17 20:19:05 +01:00
2019-03-13 19:06:42 +01:00
std::uint8_t type;
std::uint16_t numerator;
std::uint16_t denominator;
2016-02-17 20:19:05 +01:00
};
/*!
* \brief Constructs an invalid aspect ratio.
*/
2018-03-07 01:17:50 +01:00
constexpr AspectRatio::AspectRatio()
: type(0)
, numerator(0)
, denominator(0)
{
}
2016-02-17 20:19:05 +01:00
/*!
* \brief Constructs a aspect ratio with the specified \a numerator and \a denominator.
2017-08-17 19:04:58 +02:00
* \remarks Allows defining a custom aspect ratio, hence counts as "extended" (see isExtended()).
2016-02-17 20:19:05 +01:00
*/
2019-03-13 19:06:42 +01:00
constexpr AspectRatio::AspectRatio(std::uint16_t numerator, std::uint16_t denominator)
2018-03-07 01:17:50 +01:00
: type(0xFF)
, numerator(numerator)
, denominator(denominator)
{
}
2016-02-17 20:19:05 +01:00
/*!
* \brief Returns an indication whether the aspect ratio is present and valid.
*/
constexpr bool AspectRatio::isValid() const
2016-02-17 20:19:05 +01:00
{
2016-04-24 22:10:45 +02:00
return type && numerator && denominator;
2016-02-17 20:19:05 +01:00
}
/*!
* \brief Returns whether numerator and denominator must be read from extended SAR header.
*/
constexpr bool AspectRatio::isExtended() const
2016-02-17 20:19:05 +01:00
{
return type == 0xFF;
}
2018-07-28 15:07:15 +02:00
/*!
* \brief Returns the string representation "numerator : denominator".
*/
inline std::string AspectRatio::toString() const
{
2019-06-10 22:49:11 +02:00
return CppUtilities::argsToString(numerator, " : ", denominator);
2018-07-28 15:07:15 +02:00
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser
2016-02-17 20:19:05 +01:00
#endif // TAG_PARSER_ASPECTRATIO_H