From a556e08e83e8834f5ad4b47cd424cf8af2bc757b Mon Sep 17 00:00:00 2001 From: gb Date: Fri, 30 Apr 2010 15:50:19 +0000 Subject: [PATCH] Decode as many surfaces as possible in gst_vaapidecode_step(). --- gst/vaapidecode/gstvaapidecode.c | 58 +++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/gst/vaapidecode/gstvaapidecode.c b/gst/vaapidecode/gstvaapidecode.c index b9564f2da7..7261185235 100644 --- a/gst/vaapidecode/gstvaapidecode.c +++ b/gst/vaapidecode/gstvaapidecode.c @@ -99,35 +99,37 @@ gst_vaapidecode_step(GstVaapiDecode *decode) GstBuffer *buffer; GstFlowReturn ret; - proxy = gst_vaapi_decoder_get_surface(decode->decoder, &status); - if (!proxy) { - if (status != GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA) - goto error_decode; - /* More data is needed */ - return GST_FLOW_OK; + for (;;) { + proxy = gst_vaapi_decoder_get_surface(decode->decoder, &status); + if (!proxy) { + if (status != GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA) + goto error_decode; + /* More data is needed */ + break; + } + + buffer = NULL; + ret = gst_pad_alloc_buffer( + decode->srcpad, + 0, 0, + GST_PAD_CAPS(decode->srcpad), + &buffer + ); + if (ret != GST_FLOW_OK || !buffer) + goto error_create_buffer; + + GST_BUFFER_TIMESTAMP(buffer) = GST_VAAPI_SURFACE_PROXY_TIMESTAMP(proxy); + gst_vaapi_video_buffer_set_surface_proxy( + GST_VAAPI_VIDEO_BUFFER(buffer), + proxy + ); + + ret = gst_pad_push(decode->srcpad, buffer); + if (ret != GST_FLOW_OK) + goto error_commit_buffer; + + g_object_unref(proxy); } - - buffer = NULL; - ret = gst_pad_alloc_buffer( - decode->srcpad, - 0, 0, - GST_PAD_CAPS(decode->srcpad), - &buffer - ); - if (ret != GST_FLOW_OK || !buffer) - goto error_create_buffer; - - GST_BUFFER_TIMESTAMP(buffer) = GST_VAAPI_SURFACE_PROXY_TIMESTAMP(proxy); - gst_vaapi_video_buffer_set_surface_proxy( - GST_VAAPI_VIDEO_BUFFER(buffer), - proxy - ); - - ret = gst_pad_push(decode->srcpad, buffer); - if (ret != GST_FLOW_OK) - goto error_commit_buffer; - - g_object_unref(proxy); return GST_FLOW_OK; /* ERRORS */