Commit c147cf3d authored by hkuang's avatar hkuang

Add unit test to test tile decoding error handling.

Also fix bugs related with corrupted frame handling.
Return VPX_CODEC_CORRUPT_FRAME when getting corrupted
block.

Change-Id: I7207ccc7c68c4df2b40b561315d16e49ccf7ff41
parent 84744a49
...@@ -39,8 +39,8 @@ vpx_codec_err_t Decoder::DecodeFrame(const uint8_t *cxdata, size_t size, ...@@ -39,8 +39,8 @@ vpx_codec_err_t Decoder::DecodeFrame(const uint8_t *cxdata, size_t size,
return res_dec; return res_dec;
} }
void DecoderTest::RunLoop(CompressedVideoSource *video) { void DecoderTest::RunLoop(CompressedVideoSource *video,
vpx_codec_dec_cfg_t dec_cfg = {0}; const vpx_codec_dec_cfg_t &dec_cfg) {
Decoder* const decoder = codec_->CreateDecoder(dec_cfg, 0); Decoder* const decoder = codec_->CreateDecoder(dec_cfg, 0);
ASSERT_TRUE(decoder != NULL); ASSERT_TRUE(decoder != NULL);
const char *codec_name = decoder->GetDecoderName(); const char *codec_name = decoder->GetDecoderName();
...@@ -82,7 +82,12 @@ void DecoderTest::RunLoop(CompressedVideoSource *video) { ...@@ -82,7 +82,12 @@ void DecoderTest::RunLoop(CompressedVideoSource *video) {
while ((img = dec_iter.Next())) while ((img = dec_iter.Next()))
DecompressedFrameHook(*img, video->frame_number()); DecompressedFrameHook(*img, video->frame_number());
} }
delete decoder; delete decoder;
} }
void DecoderTest::RunLoop(CompressedVideoSource *video) {
vpx_codec_dec_cfg_t dec_cfg = {0};
RunLoop(video, dec_cfg);
}
} // namespace libvpx_test } // namespace libvpx_test
...@@ -119,6 +119,8 @@ class DecoderTest { ...@@ -119,6 +119,8 @@ class DecoderTest {
public: public:
// Main decoding loop // Main decoding loop
virtual void RunLoop(CompressedVideoSource *video); virtual void RunLoop(CompressedVideoSource *video);
virtual void RunLoop(CompressedVideoSource *video,
const vpx_codec_dec_cfg_t &dec_cfg);
// Hook to be called before decompressing every frame. // Hook to be called before decompressing every frame.
virtual void PreDecodeFrameHook(const CompressedVideoSource& video, virtual void PreDecodeFrameHook(const CompressedVideoSource& video,
......
...@@ -25,9 +25,13 @@ ...@@ -25,9 +25,13 @@
namespace { namespace {
using std::tr1::make_tuple;
typedef std::tr1::tuple<int, const char *> DecodeParam;
class InvalidFileTest class InvalidFileTest
: public ::libvpx_test::DecoderTest, : public ::libvpx_test::DecoderTest,
public ::libvpx_test::CodecTestWithParam<const char*> { public ::libvpx_test::CodecTestWithParam<DecodeParam> {
protected: protected:
InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {} InvalidFileTest() : DecoderTest(GET_PARAM(0)), res_file_(NULL) {}
...@@ -66,8 +70,11 @@ class InvalidFileTest ...@@ -66,8 +70,11 @@ class InvalidFileTest
}; };
TEST_P(InvalidFileTest, ReturnCode) { TEST_P(InvalidFileTest, ReturnCode) {
const std::string filename = GET_PARAM(1);
libvpx_test::CompressedVideoSource *video = NULL; libvpx_test::CompressedVideoSource *video = NULL;
const DecodeParam input = GET_PARAM(1);
vpx_codec_dec_cfg_t cfg = {0};
cfg.threads = std::tr1::get<0>(input);
const std::string filename = std::tr1::get<1>(input);
// Open compressed video file. // Open compressed video file.
if (filename.substr(filename.length() - 3, 3) == "ivf") { if (filename.substr(filename.length() - 3, 3) == "ivf") {
...@@ -90,24 +97,35 @@ TEST_P(InvalidFileTest, ReturnCode) { ...@@ -90,24 +97,35 @@ TEST_P(InvalidFileTest, ReturnCode) {
OpenResFile(res_filename); OpenResFile(res_filename);
// Decode frame, and check the md5 matching. // Decode frame, and check the md5 matching.
ASSERT_NO_FATAL_FAILURE(RunLoop(video)); ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg));
delete video; delete video;
} }
const char *const kVP9InvalidFileTests[] = { const char *const kVP9InvalidFileTests[] = {
"invalid-vp90-01.webm", "invalid-vp90-01-v2.webm",
"invalid-vp90-02.webm", "invalid-vp90-02-v2.webm",
"invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf", "invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf",
"invalid-vp90-03.webm", "invalid-vp90-03-v2.webm",
"invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf", "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf",
"invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf", "invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf",
}; };
#define NELEMENTS(x) static_cast<int>(sizeof(x) / sizeof(x[0])) INSTANTIATE_TEST_CASE_P(
VP9, InvalidFileTest,
::testing::Combine(
::testing::Values(
static_cast<const libvpx_test::CodecFactory*>(&libvpx_test::kVP9)),
::testing::Combine(::testing::Values(1),
::testing::ValuesIn(kVP9InvalidFileTests))));
VP9_INSTANTIATE_TEST_CASE(InvalidFileTest, const DecodeParam kMultiThreadedVP9InvalidFileTests[] = {
::testing::ValuesIn(kVP9InvalidFileTests, make_tuple(4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm"),
kVP9InvalidFileTests + };
NELEMENTS(kVP9InvalidFileTests)));
INSTANTIATE_TEST_CASE_P(
VP9MultiThreaded, InvalidFileTest,
::testing::Combine(
::testing::Values(
static_cast<const libvpx_test::CodecFactory*>(&libvpx_test::kVP9)),
::testing::ValuesIn(kMultiThreadedVP9InvalidFileTests)));
} // namespace } // namespace
...@@ -663,3 +663,11 @@ d3964f9dad9f60363c81b688324d95b4ec7c8038 invalid-vp90-2-00-quantizer-00.webm.iv ...@@ -663,3 +663,11 @@ d3964f9dad9f60363c81b688324d95b4ec7c8038 invalid-vp90-2-00-quantizer-00.webm.iv
456d1493e52d32a5c30edf44a27debc1fa6b253a invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf.res 456d1493e52d32a5c30edf44a27debc1fa6b253a invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf.res
c123d1f9f02fb4143abb5e271916e3a3080de8f6 invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf c123d1f9f02fb4143abb5e271916e3a3080de8f6 invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf
456d1493e52d32a5c30edf44a27debc1fa6b253a invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf.res 456d1493e52d32a5c30edf44a27debc1fa6b253a invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf.res
fe346136b9b8c1e6f6084cc106485706915795e4 invalid-vp90-01-v2.webm
25751f5d3b05ff03f0719ad42cd625348eb8961e invalid-vp90-01-v2.webm.res
d78e2fceba5ac942246503ec8366f879c4775ca5 invalid-vp90-02-v2.webm
8e2eff4af87d2b561cce2365713269e301457ef3 invalid-vp90-02-v2.webm.res
df1a1453feb3c00d7d89746c7003b4163523bff3 invalid-vp90-03-v2.webm
25dd58c22d23f75304d7ce7f69f4e5b02ef9119a invalid-vp90-03-v2.webm.res
d637297561dd904eb2c97a9015deeb31c4a1e8d2 invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm
3a204bdbeaa3c6458b77bcebb8366d107267f55d invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm.res
...@@ -777,18 +777,20 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv444.webm ...@@ -777,18 +777,20 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv444.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv444.webm.md5 LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += vp91-2-04-yuv444.webm.md5
# Invalid files for testing libvpx error checking. # Invalid files for testing libvpx error checking.
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-01.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-01-v2.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-01.webm.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-01-v2.webm.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-02.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-02-v2.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-02.webm.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-02-v2.webm.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-03.webm LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-03-v2.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-03.webm.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-03-v2.webm.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-00.webm.ivf.s5861_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf.res LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-00-quantizer-11.webm.ivf.s52984_r01-05_b6-z.ivf.res
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm
LIBVPX_TEST_DATA-$(CONFIG_VP9_DECODER) += invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm.res
ifeq ($(CONFIG_DECODE_PERF_TESTS),yes) ifeq ($(CONFIG_DECODE_PERF_TESTS),yes)
# BBB VP9 streams # BBB VP9 streams
......
...@@ -858,6 +858,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi, ...@@ -858,6 +858,7 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
decode_partition(tile_data->cm, &tile_data->xd, &tile, mi_row, mi_col, decode_partition(tile_data->cm, &tile_data->xd, &tile, mi_row, mi_col,
&tile_data->bit_reader, BLOCK_64X64); &tile_data->bit_reader, BLOCK_64X64);
} }
pbi->mb.corrupted |= tile_data->xd.corrupted;
} }
// Loopfilter one row. // Loopfilter one row.
if (cm->lf.filter_level) { if (cm->lf.filter_level) {
...@@ -1411,6 +1412,9 @@ void vp9_decode_frame(VP9Decoder *pbi, ...@@ -1411,6 +1412,9 @@ void vp9_decode_frame(VP9Decoder *pbi,
} else { } else {
debug_check_frame_counts(cm); debug_check_frame_counts(cm);
} }
} else {
vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
"Decode failed. Frame data is corrupted.");
} }
if (cm->refresh_frame_context) if (cm->refresh_frame_context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment