From 4226f0ce64953aa7636552ccfb3487fda30e4122 Mon Sep 17 00:00:00 2001 From: John Koleszar <jkoleszar@google.com> Date: Wed, 27 Apr 2011 12:04:48 -0400 Subject: [PATCH] vpxdec: test for frame corruption This change simply exercises the VP8D_GET_FRAME_CORRUPTED control, outputting a warning message at the end if the bit was set for any frames. Should never produce any output for good input. Change-Id: Idaf6ba8f53660f47763cd563fa1485938580a37d --- vpxdec.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/vpxdec.c b/vpxdec.c index ca9af1ec18..3869e20ad3 100644 --- a/vpxdec.c +++ b/vpxdec.c @@ -725,6 +725,7 @@ int main(int argc, const char **argv_) int vp8_dbg_display_mv = 0; #endif struct input_ctx input = {0}; + int frames_corrupted = 0; /* Parse command line */ exec_name = argv_[0]; @@ -1018,6 +1019,7 @@ int main(int argc, const char **argv_) vpx_codec_iter_t iter = NULL; vpx_image_t *img; struct vpx_usec_timer timer; + int corrupted; vpx_usec_timer_start(&timer); @@ -1037,6 +1039,14 @@ int main(int argc, const char **argv_) ++frame_in; + if (vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted)) + { + fprintf(stderr, "Failed VP8_GET_FRAME_CORRUPTED: %s\n", + vpx_codec_error(&decoder)); + goto fail; + } + frames_corrupted += corrupted; + if ((img = vpx_codec_get_frame(&decoder, &iter))) ++frame_out; @@ -1102,6 +1112,9 @@ int main(int argc, const char **argv_) fprintf(stderr, "\n"); } + if (frames_corrupted) + fprintf(stderr, "WARNING: %d frames corrupted.\n",frames_corrupted); + fail: if (vpx_codec_destroy(&decoder)) @@ -1120,5 +1133,5 @@ fail: fclose(infile); free(argv); - return EXIT_SUCCESS; + return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS; } -- GitLab