diff options
Diffstat (limited to 'src/decoder_test.cc')
-rw-r--r-- | src/decoder_test.cc | 95 |
1 files changed, 61 insertions, 34 deletions
diff --git a/src/decoder_test.cc b/src/decoder_test.cc index de7d490..e274122 100644 --- a/src/decoder_test.cc +++ b/src/decoder_test.cc @@ -20,44 +20,22 @@ #include <new> #include "gtest/gtest.h" +#include "src/decoder_test_data.h" namespace libgav1 { namespace { -// These two frames come from the libaom test vector av1-1-b8-01-size-32x32.ivf -constexpr uint8_t kFrame1[] = { - 0x12, 0x0, 0xa, 0xa, 0x0, 0x0, 0x0, 0x2, 0x27, 0xfe, 0xff, 0xfc, - 0xc0, 0x20, 0x32, 0x93, 0x2, 0x10, 0x0, 0xa8, 0x80, 0x0, 0x3, 0x0, - 0x10, 0x10, 0x30, 0x0, 0xd3, 0xc6, 0xc6, 0x82, 0xaa, 0x5e, 0xbf, 0x82, - 0xf2, 0xa4, 0xa4, 0x29, 0xab, 0xda, 0xd7, 0x1, 0x5, 0x0, 0xb3, 0xde, - 0xa8, 0x6f, 0x8d, 0xbf, 0x1b, 0xa8, 0x25, 0xc3, 0x84, 0x7c, 0x1a, 0x2b, - 0x8b, 0x0, 0xff, 0x19, 0x1f, 0x45, 0x7e, 0xe0, 0xbe, 0xe1, 0x3a, 0x63, - 0xc2, 0xc6, 0x6e, 0xf4, 0xc8, 0xce, 0x11, 0xe1, 0x9f, 0x48, 0x64, 0x72, - 0xeb, 0xbb, 0x4f, 0xf3, 0x94, 0xb4, 0xb6, 0x9d, 0x4f, 0x4, 0x18, 0x5e, - 0x5e, 0x1b, 0x65, 0x49, 0x74, 0x90, 0x13, 0x50, 0xef, 0x8c, 0xb8, 0xe8, - 0xd9, 0x8e, 0x9c, 0xc9, 0x4d, 0xda, 0x60, 0x6a, 0xa, 0xf9, 0x75, 0xd0, - 0x62, 0x69, 0xd, 0xf5, 0xdc, 0xa9, 0xb9, 0x4c, 0x8, 0x9e, 0x33, 0x15, - 0xa3, 0xe1, 0x42, 0x0, 0xe2, 0xb0, 0x46, 0xd0, 0xf7, 0xad, 0x55, 0xbc, - 0x75, 0xe9, 0xe3, 0x1f, 0xa3, 0x41, 0x11, 0xba, 0xaa, 0x81, 0xf3, 0xcb, - 0x82, 0x87, 0x71, 0x0, 0xe6, 0xb9, 0x8c, 0xe1, 0xe9, 0xd3, 0x21, 0xcc, - 0xcd, 0xe7, 0x12, 0xb9, 0xe, 0x43, 0x6a, 0xa3, 0x76, 0x5c, 0x35, 0x90, - 0x45, 0x36, 0x52, 0xb4, 0x2d, 0xa3, 0x55, 0xde, 0x20, 0xf8, 0x80, 0xe1, - 0x26, 0x46, 0x1b, 0x3f, 0x59, 0xc7, 0x2e, 0x5b, 0x4a, 0x73, 0xf8, 0xb3, - 0xf4, 0x62, 0xf4, 0xf5, 0xa4, 0xc2, 0xae, 0x9e, 0xa6, 0x9c, 0x10, 0xbb, - 0xe1, 0xd6, 0x88, 0x75, 0xb9, 0x85, 0x48, 0xe5, 0x7, 0x12, 0xf3, 0x11, - 0x85, 0x8e, 0xa2, 0x95, 0x9d, 0xed, 0x50, 0xfb, 0x6, 0x5a, 0x1, 0x37, - 0xc4, 0x8e, 0x9e, 0x73, 0x9b, 0x96, 0x64, 0xbd, 0x42, 0xb, 0x80, 0xde, - 0x57, 0x86, 0xcb, 0x7d, 0xab, 0x12, 0xb2, 0xcc, 0xe6, 0xea, 0xb5, 0x89, - 0xeb, 0x91, 0xb3, 0x93, 0xb2, 0x4f, 0x2f, 0x5b, 0xf3, 0x72, 0x12, 0x51, - 0x56, 0x75, 0xb3, 0xdd, 0x49, 0xb6, 0x5b, 0x77, 0xbe, 0xc5, 0xd7, 0xd4, - 0xaf, 0xd6, 0x6b, 0x38}; - -constexpr uint8_t kFrame2[] = { - 0x12, 0x0, 0x32, 0x33, 0x30, 0x3, 0xc3, 0x0, 0xa7, 0x2e, 0x46, - 0xa8, 0x80, 0x0, 0x3, 0x0, 0x10, 0x1, 0x0, 0xa0, 0x0, 0xed, - 0xb1, 0x51, 0x15, 0x58, 0xc7, 0x69, 0x3, 0x26, 0x35, 0xeb, 0x5a, - 0x2d, 0x7a, 0x53, 0x24, 0x26, 0x20, 0xa6, 0x11, 0x7, 0x49, 0x76, - 0xa3, 0xc7, 0x62, 0xf8, 0x3, 0x32, 0xb0, 0x98, 0x17, 0x3d, 0x80}; +constexpr uint8_t kFrame1[] = {OBU_TEMPORAL_DELIMITER, OBU_SEQUENCE_HEADER, + OBU_FRAME_1}; + +constexpr uint8_t kFrame2[] = {OBU_TEMPORAL_DELIMITER, OBU_FRAME_2}; + +constexpr uint8_t kFrame1WithHdrCllAndHdrMdcv[] = { + OBU_TEMPORAL_DELIMITER, OBU_SEQUENCE_HEADER, OBU_METADATA_HDR_CLL, + OBU_METADATA_HDR_MDCV, OBU_FRAME_1}; + +constexpr uint8_t kFrame2WithItutT35[] = {OBU_TEMPORAL_DELIMITER, + OBU_METADATA_ITUT_T35, OBU_FRAME_2}; class DecoderTest : public testing::Test { public: @@ -348,5 +326,54 @@ TEST_F(DecoderTest, NonFrameParallelModeInvalidFrameAfterEOS) { EXPECT_EQ(frames_in_use_, 0); } +TEST_F(DecoderTest, MetadataObu) { + StatusCode status; + const DecoderBuffer* buffer; + + // Enqueue frame1 for decoding. + status = decoder_->EnqueueFrame( + kFrame1WithHdrCllAndHdrMdcv, sizeof(kFrame1WithHdrCllAndHdrMdcv), 0, + const_cast<uint8_t*>(kFrame1WithHdrCllAndHdrMdcv)); + ASSERT_EQ(status, kStatusOk); + + // Dequeue the output of frame1. + status = decoder_->DequeueFrame(&buffer); + ASSERT_EQ(status, kStatusOk); + ASSERT_NE(buffer, nullptr); + EXPECT_EQ(buffer->has_hdr_cll, 1); + EXPECT_EQ(buffer->has_hdr_mdcv, 1); + EXPECT_EQ(buffer->has_itut_t35, 0); + EXPECT_EQ(released_input_buffer_, &kFrame1WithHdrCllAndHdrMdcv); + + // libgav1 has decoded frame1 and is holding a reference to it. + EXPECT_EQ(frames_in_use_, 1); + EXPECT_EQ(buffer_private_data_, buffer->buffer_private_data); + + // Enqueue frame2 for decoding. + status = + decoder_->EnqueueFrame(kFrame2WithItutT35, sizeof(kFrame2WithItutT35), 0, + const_cast<uint8_t*>(kFrame2WithItutT35)); + ASSERT_EQ(status, kStatusOk); + + EXPECT_EQ(frames_in_use_, 1); + + // Dequeue the output of frame2. + status = decoder_->DequeueFrame(&buffer); + ASSERT_EQ(status, kStatusOk); + ASSERT_NE(buffer, nullptr); + EXPECT_EQ(buffer->has_hdr_cll, 0); + EXPECT_EQ(buffer->has_hdr_mdcv, 0); + EXPECT_EQ(buffer->has_itut_t35, 1); + EXPECT_NE(buffer->itut_t35.payload_bytes, nullptr); + EXPECT_GT(buffer->itut_t35.payload_size, 0); + EXPECT_EQ(released_input_buffer_, &kFrame2WithItutT35); + + EXPECT_EQ(frames_in_use_, 2); + EXPECT_EQ(buffer_private_data_, buffer->buffer_private_data); + + status = decoder_->SignalEOS(); + EXPECT_EQ(frames_in_use_, 0); +} + } // namespace } // namespace libgav1 |