Skip to content

Commit

Permalink
Relax constraints on Y4M header parsing
Browse files Browse the repository at this point in the history
Some refactoring and cleanup -- do not count the first 9 bytes against
the header limit. Add a unit test.

BUG=aomedia:2876

Change-Id: Id897d565e2917b48460cc77cd082cec4c98b42cb
  • Loading branch information
Elliott Karpilovsky committed Jan 15, 2021
1 parent 576e080 commit ecbb0e0
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 190 deletions.
25 changes: 25 additions & 0 deletions test/y4m_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,29 @@ TEST_P(Y4mVideoWriteTest, WriteTest) {

INSTANTIATE_TEST_SUITE_P(C, Y4mVideoWriteTest,
::testing::ValuesIn(kY4mTestVectors));

static const char kY4MRegularHeader[] =
"YUV4MPEG2 W4 H4 F30:1 Ip A0:0 C420jpeg XYSCSS=420JPEG\n"
"FRAME\n"
"012345678912345601230123";

TEST(Y4MHeaderTest, RegularHeader) {
libvpx_test::TempOutFile f;
fwrite(kY4MRegularHeader, 1, sizeof(kY4MRegularHeader), f.file());
fflush(f.file());
EXPECT_EQ(0, fseek(f.file(), 0, 0));

y4m_input y4m;
EXPECT_EQ(y4m_input_open(&y4m, f.file(), /*skip_buffer=*/NULL,
/*num_skip=*/0, /*only_420=*/0),
0);
EXPECT_EQ(y4m.pic_w, 4);
EXPECT_EQ(y4m.pic_h, 4);
EXPECT_EQ(y4m.fps_n, 30);
EXPECT_EQ(y4m.fps_d, 1);
EXPECT_EQ(y4m.interlace, 'p');
EXPECT_EQ(strcmp("420jpeg", y4m.chroma_type), 0);
y4m_input_close(&y4m);
}

} // namespace
Loading

0 comments on commit ecbb0e0

Please sign in to comment.