7 #include "packager/media/base/video_util.h"
13 uint64_t CalculateGCD(uint64_t a, uint64_t b) {
22 void ReducePixelWidthHeight(uint64_t* pixel_width, uint64_t* pixel_height) {
23 if (*pixel_width == 0 || *pixel_height == 0)
25 const uint64_t kMaxUint32 = std::numeric_limits<uint32_t>::max();
27 uint64_t gcd = CalculateGCD(*pixel_width, *pixel_height);
31 if (*pixel_width <= kMaxUint32 && *pixel_height <= kMaxUint32)
43 void DerivePixelWidthHeight(uint32_t frame_width,
44 uint32_t frame_height,
45 uint32_t display_width,
46 uint32_t display_height,
47 uint32_t* pixel_width,
48 uint32_t* pixel_height) {
58 uint64_t pixel_width_unreduced =
59 static_cast<uint64_t
>(display_width) * frame_height;
60 uint64_t pixel_height_unreduced =
61 static_cast<uint64_t
>(display_height) * frame_width;
62 ReducePixelWidthHeight(&pixel_width_unreduced, &pixel_height_unreduced);
63 *pixel_width = pixel_width_unreduced;
64 *pixel_height = pixel_height_unreduced;