decoder_test: Share constants between C/C++ tests
Split the constexpr array into a bunch of #define statements into
an .inc file and include them in both the C and C++ tests.
PiperOrigin-RevId: 456537084
PiperOrigin-RevId: 457044665
Change-Id: I028c1e27f209adb65374e39ef82ae864c48f32a8
diff --git a/src/c_decoder_test.c b/src/c_decoder_test.c
index 10ef29f..f80d6a6 100644
--- a/src/c_decoder_test.c
+++ b/src/c_decoder_test.c
@@ -20,6 +20,9 @@
// clang-format off
#include "src/gav1/decoder.h"
+
+// Import the test frame #defines.
+#include "src/decoder_test_data.h"
// clang-format on
#include <stddef.h>
@@ -67,40 +70,10 @@
} \
} while (0)
-// These two frames come from the libaom test vector av1-1-b8-01-size-32x32.ivf
-static const 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, 0x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Frame1[] = {OBU_TEMPORAL_DELIMITER, OBU_SEQUENCE_HEADER,
+ OBU_FRAME_1};
-static const 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};
+static const uint8_t kFrame2[] = {OBU_TEMPORAL_DELIMITER, OBU_FRAME_2};
typedef struct DecoderTest {
Libgav1Decoder* decoder;
diff --git a/src/decoder_test.cc b/src/decoder_test.cc
index de7d490..fdf7fb4 100644
--- a/src/decoder_test.cc
+++ b/src/decoder_test.cc
@@ -20,44 +20,15 @@
#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, 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9b, 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 kFrame1[] = {OBU_TEMPORAL_DELIMITER, OBU_SEQUENCE_HEADER,
+ OBU_FRAME_1};
-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 kFrame2[] = {OBU_TEMPORAL_DELIMITER, OBU_FRAME_2};
class DecoderTest : public testing::Test {
public:
diff --git a/src/decoder_test_data.h b/src/decoder_test_data.h
new file mode 100644
index 0000000..b44fdce
--- /dev/null
+++ b/src/decoder_test_data.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2022 The libgav1 Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LIBGAV1_SRC_DECODER_TEST_DATA_H_
+#define LIBGAV1_SRC_DECODER_TEST_DATA_H_
+
+// The bytes for these two frames come from the libaom test vector
+// av1-1-b8-01-size-32x32.ivf
+#define OBU_TEMPORAL_DELIMITER 0x12, 0x0
+#define OBU_SEQUENCE_HEADER \
+ 0xa, 0xa, 0x0, 0x0, 0x0, 0x2, 0x27, 0xfe, 0xff, 0xfc, 0xc0, 0x20
+#define OBU_FRAME_1 \
+ 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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 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
+
+#endif // LIBGAV1_SRC_DECODER_TEST_DATA_H_
diff --git a/tests/libgav1_tests.cmake b/tests/libgav1_tests.cmake
index 34c9626..c759d4f 100644
--- a/tests/libgav1_tests.cmake
+++ b/tests/libgav1_tests.cmake
@@ -96,9 +96,13 @@
list(APPEND libgav1_convolve_test_sources
"${libgav1_source}/dsp/convolve_test.cc")
list(APPEND libgav1_cpu_test_sources "${libgav1_source}/utils/cpu_test.cc")
-list(APPEND libgav1_c_decoder_test_sources "${libgav1_source}/c_decoder_test.c")
+list(APPEND libgav1_c_decoder_test_sources
+ "${libgav1_source}/c_decoder_test.c"
+ "${libgav1_source}/decoder_test_data.h")
list(APPEND libgav1_c_version_test_sources "${libgav1_source}/c_version_test.c")
-list(APPEND libgav1_decoder_test_sources "${libgav1_source}/decoder_test.cc")
+list(APPEND libgav1_decoder_test_sources
+ "${libgav1_source}/decoder_test.cc"
+ "${libgav1_source}/decoder_test_data.h")
list(APPEND libgav1_decoder_buffer_test_sources
"${libgav1_source}/decoder_buffer_test.cc")
list(APPEND libgav1_distance_weighted_blend_test_sources