ref: c3ae212e80f599c2cee40301c7b619383db33896
parent: b71542dc13ea959ed2b42dab6ee9dfbb3444e274
author: Scott LaVarnway <[email protected]>
date: Fri Jun 7 08:39:03 EDT 2013
Modified vpxdec loop to work like vpxenc. This is required for the frame-based multithreading. Change-Id: I338ae9c7d52b0541f3536cc033d6b89f00866e74
--- a/vp8/vp8_dx_iface.c
+++ b/vp8/vp8_dx_iface.c
@@ -659,7 +659,7 @@
/* 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 @@
{
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;
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -714,6 +714,7 @@
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 @@
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));
@@ -1010,14 +1031,6 @@
goto fail;
}
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);