From: Scott LaVarnway Date: Fri, 7 Jun 2013 16:39:03 +0000 (-0400) Subject: Modified vpxdec loop X-Git-Tag: v1.3.0~1113^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c3ae212e80f599c2cee40301c7b619383db33896;p=libvpx Modified vpxdec loop to work like vpxenc. This is required for the frame-based multithreading. Change-Id: I338ae9c7d52b0541f3536cc033d6b89f00866e74 --- diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c index 90a175436..45cf3859e 100644 --- a/vp8/vp8_dx_iface.c +++ b/vp8/vp8_dx_iface.c @@ -659,7 +659,7 @@ static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t *ctx, /* iter acts as a flip flop, so an image is only returned on the first * call to get_frame. */ - if (!(*iter)) + if (!(*iter) && ctx->yv12_frame_buffers.pbi[0]) { YV12_BUFFER_CONFIG sd; int64_t time_stamp = 0, time_end_stamp = 0; @@ -943,10 +943,10 @@ static vpx_codec_err_t vp8_get_frame_corrupted(vpx_codec_alg_priv_t *ctx, { int *corrupted = va_arg(args, int *); + VP8D_COMP *pbi = (VP8D_COMP *)ctx->yv12_frame_buffers.pbi[0]; - if (corrupted) + if (corrupted && pbi) { - VP8D_COMP *pbi = (VP8D_COMP *)ctx->yv12_frame_buffers.pbi[0]; *corrupted = pbi->common.frame_to_show->corrupted; return VPX_CODEC_OK; diff --git a/vpxdec.c b/vpxdec.c index 41c654fae..5bde0c862 100644 --- a/vpxdec.c +++ b/vpxdec.c @@ -714,6 +714,7 @@ int main(int argc, const char **argv_) { int do_scale = 0; int stream_w = 0, stream_h = 0; vpx_image_t *scaled_img = NULL; + int frame_avail, got_data; /* Parse command line */ exec_name = argv_[0]; @@ -980,30 +981,50 @@ int main(int argc, const char **argv_) { arg_skip--; } + frame_avail = 1; + got_data = 0; + /* Decode file */ - while (!read_frame(&input, &buf, &buf_sz, &buf_alloc_sz)) { + while (frame_avail || got_data) { vpx_codec_iter_t iter = NULL; vpx_image_t *img; struct vpx_usec_timer timer; int corrupted; - vpx_usec_timer_start(&timer); + frame_avail = 0; + if (!stop_after || frame_in < stop_after) { + if(!read_frame(&input, &buf, &buf_sz, &buf_alloc_sz)) { + frame_avail = 1; + frame_in++; - if (vpx_codec_decode(&decoder, buf, (unsigned int)buf_sz, NULL, 0)) { - const char *detail = vpx_codec_error_detail(&decoder); - fprintf(stderr, "Failed to decode frame: %s\n", vpx_codec_error(&decoder)); + vpx_usec_timer_start(&timer); - if (detail) - fprintf(stderr, " Additional information: %s\n", detail); + if (vpx_codec_decode(&decoder, buf, (unsigned int)buf_sz, NULL, 0)) { + const char *detail = vpx_codec_error_detail(&decoder); + fprintf(stderr, "Failed to decode frame: %s\n", + vpx_codec_error(&decoder)); - goto fail; + if (detail) + fprintf(stderr, " Additional information: %s\n", detail); + goto fail; + } + + vpx_usec_timer_mark(&timer); + dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer); + } + } + + vpx_usec_timer_start(&timer); + + got_data = 0; + if ((img = vpx_codec_get_frame(&decoder, &iter))) { + ++frame_out; + got_data = 1; } vpx_usec_timer_mark(&timer); dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer); - ++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)); @@ -1011,14 +1032,6 @@ int main(int argc, const char **argv_) { } frames_corrupted += corrupted; - vpx_usec_timer_start(&timer); - - if ((img = vpx_codec_get_frame(&decoder, &iter))) - ++frame_out; - - vpx_usec_timer_mark(&timer); - dx_time += (unsigned int)vpx_usec_timer_elapsed(&timer); - if (progress) show_progress(frame_in, frame_out, dx_time);