#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/base/video_util.h"
#include <stdint.h>
#include <cmath>
#include <memory>
#include "base/memory/raw_ptr_exclusion.h"
#include "media/base/limits.h"
#include "media/base/video_frame.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"
namespace {
void FillPlaneWithPattern(uint8_t* data,
int stride,
const gfx::Size& visible_size) { … }
scoped_refptr<media::VideoFrame> CreateFrameWithPatternFilled(
media::VideoPixelFormat format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp) { … }
bool VerifyPlanCopyWithPadding(const uint8_t* src,
size_t src_stride,
const gfx::Size& src_size,
const uint8_t* dst,
size_t dst_stride,
const gfx::Size& dst_size) { … }
bool VerifyCopyWithPadding(const media::VideoFrame& src_frame,
const media::VideoFrame& dst_frame) { … }
}
namespace media {
class VideoUtilTest : public testing::Test { … };
namespace {
uint8_t src6x4[] = …;
uint8_t* target6x4_0_n_n = …;
uint8_t target6x4_0_n_y[] = …;
uint8_t target6x4_0_y_n[] = …;
uint8_t target6x4_0_y_y[] = …;
uint8_t target6x4_90_n_n[] = …;
uint8_t target6x4_90_n_y[] = …;
uint8_t target6x4_90_y_n[] = …;
uint8_t target6x4_90_y_y[] = …;
uint8_t* target6x4_180_n_n = …;
uint8_t* target6x4_180_n_y = …;
uint8_t* target6x4_180_y_n = …;
uint8_t* target6x4_180_y_y = …;
uint8_t* target6x4_270_n_n = …;
uint8_t* target6x4_270_n_y = …;
uint8_t* target6x4_270_y_n = …;
uint8_t* target6x4_270_y_y = …;
uint8_t src4x6[] = …;
uint8_t* target4x6_0_n_n = …;
uint8_t target4x6_0_n_y[] = …;
uint8_t target4x6_0_y_n[] = …;
uint8_t target4x6_0_y_y[] = …;
uint8_t target4x6_90_n_n[] = …;
uint8_t target4x6_90_n_y[] = …;
uint8_t target4x6_90_y_n[] = …;
uint8_t target4x6_90_y_y[] = …;
uint8_t* target4x6_180_n_n = …;
uint8_t* target4x6_180_n_y = …;
uint8_t* target4x6_180_y_n = …;
uint8_t* target4x6_180_y_y = …;
uint8_t* target4x6_270_n_n = …;
uint8_t* target4x6_270_n_y = …;
uint8_t* target4x6_270_y_n = …;
uint8_t* target4x6_270_y_y = …;
struct VideoRotationTestData { … };
const VideoRotationTestData kVideoRotationTestData[] = …;
}
class VideoUtilRotationTest
: public testing::TestWithParam<VideoRotationTestData> { … };
TEST_P(VideoUtilRotationTest, Rotate) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(VideoUtilTest, ComputeLetterboxRegion) { … }
TEST_F(VideoUtilTest, ComputeLetterboxRegionForI420) { … }
TEST_F(VideoUtilTest, MinimallyShrinkRectForI420) { … }
TEST_F(VideoUtilTest, ScaleSizeToEncompassTarget) { … }
TEST_F(VideoUtilTest, CropSizeForScalingToTarget) { … }
TEST_F(VideoUtilTest, PadToMatchAspectRatio) { … }
TEST_F(VideoUtilTest, LetterboxVideoFrame) { … }
TEST_F(VideoUtilTest, I420CopyWithPadding) { … }
TEST_F(VideoUtilTest, WrapAsI420VideoFrame) { … }
}