#include <climits>
#include <vector>
#include "gtest/gtest.h"
#include "test/codec_factory.h"
#include "test/encode_test_driver.h"
#include "test/i420_video_source.h"
#include "test/util.h"
#include "test/video_source.h"
#include "vpx_config.h"
#define WRITE_COMPRESSED_STREAM …
namespace {
#if WRITE_COMPRESSED_STREAM
static void mem_put_le16(char *const mem, const unsigned int val) {
mem[0] = val;
mem[1] = val >> 8;
}
static void mem_put_le32(char *const mem, const unsigned int val) {
mem[0] = val;
mem[1] = val >> 8;
mem[2] = val >> 16;
mem[3] = val >> 24;
}
static void write_ivf_file_header(const vpx_codec_enc_cfg_t *const cfg,
int frame_cnt, FILE *const outfile) {
char header[32];
header[0] = 'D';
header[1] = 'K';
header[2] = 'I';
header[3] = 'F';
mem_put_le16(header + 4, 0);
mem_put_le16(header + 6, 32);
mem_put_le32(header + 8, 0x30395056);
mem_put_le16(header + 12, cfg->g_w);
mem_put_le16(header + 14, cfg->g_h);
mem_put_le32(header + 16, cfg->g_timebase.den);
mem_put_le32(header + 20, cfg->g_timebase.num);
mem_put_le32(header + 24, frame_cnt);
mem_put_le32(header + 28, 0);
(void)fwrite(header, 1, 32, outfile);
}
static void write_ivf_frame_size(FILE *const outfile, const size_t size) {
char header[4];
mem_put_le32(header, static_cast<unsigned int>(size));
(void)fwrite(header, 1, 4, outfile);
}
static void write_ivf_frame_header(const vpx_codec_cx_pkt_t *const pkt,
FILE *const outfile) {
char header[12];
vpx_codec_pts_t pts;
if (pkt->kind != VPX_CODEC_CX_FRAME_PKT) return;
pts = pkt->data.frame.pts;
mem_put_le32(header, static_cast<unsigned int>(pkt->data.frame.sz));
mem_put_le32(header + 4, pts & 0xFFFFFFFF);
mem_put_le32(header + 8, pts >> 32);
(void)fwrite(header, 1, 12, outfile);
}
#endif
const unsigned int kInitialWidth = …;
const unsigned int kInitialHeight = …;
struct FrameInfo { … };
void ScaleForFrameNumber(unsigned int frame, unsigned int initial_w,
unsigned int initial_h, unsigned int *w,
unsigned int *h, bool flag_codec,
bool smaller_width_larger_size_) { … }
class ResizingVideoSource : public ::libvpx_test::DummyVideoSource { … };
class ResizeTest
: public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> { … };
TEST_P(ResizeTest, TestExternalResizeWorks) { … }
const unsigned int kStepDownFrame = …;
const unsigned int kStepUpFrame = …;
class ResizeInternalTest : public ResizeTest { … };
TEST_P(ResizeInternalTest, TestInternalResizeWorks) { … }
TEST_P(ResizeInternalTest, TestInternalResizeChangeConfig) { … }
class ResizeRealtimeTest
: public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> { … };
TEST_P(ResizeRealtimeTest, TestExternalResizeWorks) { … }
TEST_P(ResizeRealtimeTest, TestExternalResizeSmallerWidthBiggerSize) { … }
TEST_P(ResizeRealtimeTest, TestInternalResizeDown) { … }
TEST_P(ResizeRealtimeTest, TestInternalResizeDownUpChangeBitRate) { … }
vpx_img_fmt_t CspForFrameNumber(int frame) { … }
class ResizeCspTest : public ResizeTest { … };
class ResizingCspVideoSource : public ::libvpx_test::DummyVideoSource { … };
TEST_P(ResizeCspTest, TestResizeCspWorks) { … }
VP8_INSTANTIATE_TEST_SUITE(…);
VP9_INSTANTIATE_TEST_SUITE(…);
VP9_INSTANTIATE_TEST_SUITE(…);
VP9_INSTANTIATE_TEST_SUITE(…) …;
VP9_INSTANTIATE_TEST_SUITE(…);
}