From 1f841c3218532c07edd514947e824d60b2eae399 Mon Sep 17 00:00:00 2001 From: hkuang Date: Fri, 6 Mar 2015 13:03:18 -0800 Subject: [PATCH] Add frame parallel decode option to vpxdec. Change-Id: I0ba02d501d65a2f219fa1bb87b8eb81f7e6ab332 --- test/tools_common.sh | 1 + test/vpxdec.sh | 17 +++++++++++++++-- vpxdec.c | 29 ++++++++++++++++++++++++----- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/test/tools_common.sh b/test/tools_common.sh index 27785c3ef..34c15168a 100755 --- a/test/tools_common.sh +++ b/test/tools_common.sh @@ -401,6 +401,7 @@ VP8_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp80-00-comprehensive-001.ivf" VP9_IVF_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-09-subpixel-00.ivf" VP9_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-00-quantizer-00.webm" +VP9_FPM_WEBM_FILE="${LIBVPX_TEST_DATA_PATH}/vp90-2-07-frame_parallel-1.webm" YUV_RAW_INPUT="${LIBVPX_TEST_DATA_PATH}/hantro_collage_w352h288.yuv" YUV_RAW_INPUT_WIDTH=352 diff --git a/test/vpxdec.sh b/test/vpxdec.sh index f92acbd66..d73a447ee 100755 --- a/test/vpxdec.sh +++ b/test/vpxdec.sh @@ -16,7 +16,8 @@ # Environment check: Make sure input is available. vpxdec_verify_environment() { - if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_WEBM_FILE}" ]; then + if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_WEBM_FILE}" ] || \ + [ ! -e "${VP9_FPM_WEBM_FILE}" ] ; then elog "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH." return 1 fi @@ -78,8 +79,20 @@ vpxdec_vp9_webm() { fi } +vpxdec_vp9_webm_frame_parallel() { + if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \ + [ "$(webm_io_available)" = "yes" ]; then + for threads in 2 3 4 5 6 7 8; do + vpxdec "${VP9_FPM_WEBM_FILE}" --summary --noblit --threads=$threads \ + --frame-parallel + done + fi + +} + vpxdec_tests="vpxdec_vp8_ivf vpxdec_vp8_ivf_pipe_input - vpxdec_vp9_webm" + vpxdec_vp9_webm + vpxdec_vp9_webm_frame_parallel" run_tests vpxdec_verify_environment "${vpxdec_tests}" diff --git a/vpxdec.c b/vpxdec.c index 59c982d87..62a5e93e5 100644 --- a/vpxdec.c +++ b/vpxdec.c @@ -75,6 +75,8 @@ static const arg_def_t outputfile = ARG_DEF( "o", "output", 1, "Output file name pattern (see below)"); static const arg_def_t threadsarg = ARG_DEF( "t", "threads", 1, "Max threads to use"); +static const arg_def_t frameparallelarg = ARG_DEF( + NULL, "frame-parallel", 0, "Frame parallel decode"); static const arg_def_t verbosearg = ARG_DEF( "v", "verbose", 0, "Show version string"); static const arg_def_t error_concealment = ARG_DEF( @@ -95,7 +97,7 @@ static const arg_def_t outbitdeptharg = ARG_DEF( static const arg_def_t *all_args[] = { &codecarg, &use_yv12, &use_i420, &flipuvarg, &rawvideo, &noblitarg, &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile, - &threadsarg, &verbosearg, &scalearg, &fb_arg, + &threadsarg, &frameparallelarg, &verbosearg, &scalearg, &fb_arg, &md5arg, &error_concealment, &continuearg, #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH &outbitdeptharg, @@ -542,7 +544,7 @@ int main_loop(int argc, const char **argv_) { size_t bytes_in_buffer = 0, buffer_size = 0; FILE *infile; int frame_in = 0, frame_out = 0, flipuv = 0, noblit = 0; - int do_md5 = 0, progress = 0; + int do_md5 = 0, progress = 0, frame_parallel = 0; int stop_after = 0, postproc = 0, summary = 0, quiet = 1; int arg_skip = 0; int ec_enabled = 0; @@ -575,7 +577,7 @@ int main_loop(int argc, const char **argv_) { #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH vpx_image_t *img_shifted = NULL; #endif - int frame_avail, got_data; + int frame_avail, got_data, flush_decoder = 0; int num_external_frame_buffers = 0; struct ExternalFrameBufferList ext_fb_list = {0, NULL}; @@ -642,6 +644,10 @@ int main_loop(int argc, const char **argv_) { summary = 1; else if (arg_match(&arg, &threadsarg, argi)) cfg.threads = arg_parse_uint(&arg); +#if CONFIG_VP9_DECODER + else if (arg_match(&arg, &frameparallelarg, argi)) + frame_parallel = 1; +#endif else if (arg_match(&arg, &verbosearg, argi)) quiet = 0; else if (arg_match(&arg, &scalearg, argi)) @@ -794,7 +800,8 @@ int main_loop(int argc, const char **argv_) { interface = get_vpx_decoder_by_index(0); dec_flags = (postproc ? VPX_CODEC_USE_POSTPROC : 0) | - (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0); + (ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0) | + (frame_parallel ? VPX_CODEC_USE_FRAME_THREADING : 0); if (vpx_codec_dec_init(&decoder, interface->codec_interface(), &cfg, dec_flags)) { fprintf(stderr, "Failed to initialize decoder: %s\n", @@ -892,11 +899,22 @@ int main_loop(int argc, const char **argv_) { vpx_usec_timer_mark(&timer); dx_time += vpx_usec_timer_elapsed(&timer); + } else { + flush_decoder = 1; } + } else { + flush_decoder = 1; } vpx_usec_timer_start(&timer); + if (flush_decoder) { + // Flush the decoder in frame parallel decode. + if (vpx_codec_decode(&decoder, NULL, 0, NULL, 0)) { + warn("Failed to flush decoder: %s", vpx_codec_error(&decoder)); + } + } + got_data = 0; if ((img = vpx_codec_get_frame(&decoder, &iter))) { ++frame_out; @@ -906,7 +924,8 @@ int main_loop(int argc, const char **argv_) { vpx_usec_timer_mark(&timer); dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer); - if (vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted)) { + if (!frame_parallel && + vpx_codec_control(&decoder, VP8D_GET_FRAME_CORRUPTED, &corrupted)) { warn("Failed VP8_GET_FRAME_CORRUPTED: %s", vpx_codec_error(&decoder)); if (!keep_going) goto fail;