summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJerome Jiang <jianj@google.com>2017-11-29 15:06:35 -0800
committerJerome Jiang <jianj@google.com>2017-12-06 13:55:18 -0800
commitbd1d995cd38b4e31a01356079f1d94067273eb28 (patch)
treeeb9bd9305ee058336b7b026b5f4b79d10560dc85 /test
parentc22ab8ab9fda2fc38128e72f3c051739a32a71d4 (diff)
downloadlibvpx-bd1d995cd38b4e31a01356079f1d94067273eb28.tar
libvpx-bd1d995cd38b4e31a01356079f1d94067273eb28.tar.gz
libvpx-bd1d995cd38b4e31a01356079f1d94067273eb28.tar.bz2
libvpx-bd1d995cd38b4e31a01356079f1d94067273eb28.zip
Add frame width & height to frame pkt. Add test.
Used to return correct frame width and height when dynamic resizing happens. BUG=webm:1474 Change-Id: Ia2043f7e1635b3821848a67b9b134f47f14b0f3a
Diffstat (limited to 'test')
-rw-r--r--test/resize_test.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/resize_test.cc b/test/resize_test.cc
index e95dc6651..39952074b 100644
--- a/test/resize_test.cc
+++ b/test/resize_test.cc
@@ -277,12 +277,29 @@ class ResizeTest
SetMode(GET_PARAM(1));
}
+ virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
+ ASSERT_NE(static_cast<int>(pkt->data.frame.width), 0);
+ ASSERT_NE(static_cast<int>(pkt->data.frame.height), 0);
+ encode_frame_width_.push_back(pkt->data.frame.width);
+ encode_frame_height_.push_back(pkt->data.frame.height);
+ }
+
+ unsigned int GetFrameWidth(size_t idx) const {
+ return encode_frame_width_[idx];
+ }
+
+ unsigned int GetFrameHeight(size_t idx) const {
+ return encode_frame_height_[idx];
+ }
+
virtual void DecompressedFrameHook(const vpx_image_t &img,
vpx_codec_pts_t pts) {
frame_info_list_.push_back(FrameInfo(pts, img.d_w, img.d_h));
}
std::vector<FrameInfo> frame_info_list_;
+ std::vector<unsigned int> encode_frame_width_;
+ std::vector<unsigned int> encode_frame_height_;
};
TEST_P(ResizeTest, TestExternalResizeWorks) {
@@ -296,6 +313,9 @@ TEST_P(ResizeTest, TestExternalResizeWorks) {
const unsigned int frame = static_cast<unsigned>(info->pts);
unsigned int expected_w;
unsigned int expected_h;
+ const size_t idx = info - frame_info_list_.begin();
+ ASSERT_EQ(info->w, GetFrameWidth(idx));
+ ASSERT_EQ(info->h, GetFrameHeight(idx));
ScaleForFrameNumber(frame, kInitialWidth, kInitialHeight, &expected_w,
&expected_h, 0);
EXPECT_EQ(expected_w, info->w)
@@ -464,8 +484,23 @@ class ResizeRealtimeTest
++mismatch_nframes_;
}
+ virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
+ ASSERT_NE(static_cast<int>(pkt->data.frame.width), 0);
+ ASSERT_NE(static_cast<int>(pkt->data.frame.height), 0);
+ encode_frame_width_.push_back(pkt->data.frame.width);
+ encode_frame_height_.push_back(pkt->data.frame.height);
+ }
+
unsigned int GetMismatchFrames() { return mismatch_nframes_; }
+ unsigned int GetFrameWidth(size_t idx) const {
+ return encode_frame_width_[idx];
+ }
+
+ unsigned int GetFrameHeight(size_t idx) const {
+ return encode_frame_height_[idx];
+ }
+
void DefaultConfig() {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 600;
@@ -493,6 +528,8 @@ class ResizeRealtimeTest
bool change_bitrate_;
double mismatch_psnr_;
int mismatch_nframes_;
+ std::vector<unsigned int> encode_frame_width_;
+ std::vector<unsigned int> encode_frame_height_;
};
TEST_P(ResizeRealtimeTest, TestExternalResizeWorks) {
@@ -582,6 +619,9 @@ TEST_P(ResizeRealtimeTest, TestInternalResizeDownUpChangeBitRate) {
int resize_count = 0;
for (std::vector<FrameInfo>::const_iterator info = frame_info_list_.begin();
info != frame_info_list_.end(); ++info) {
+ const size_t idx = info - frame_info_list_.begin();
+ ASSERT_EQ(info->w, GetFrameWidth(idx));
+ ASSERT_EQ(info->h, GetFrameHeight(idx));
if (info->w != last_w || info->h != last_h) {
resize_count++;
if (resize_count == 1) {