mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 23:18:52 +00:00
vaapidecode: Remove NO_SURFACE error handling
Since surfaces are not bounded to decoding context it makes no sense to keep the surface semaphore. This patch removes the handling of this error. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/353>
This commit is contained in:
parent
a4c4314be6
commit
2a93455137
5 changed files with 1 additions and 83 deletions
|
@ -305,10 +305,6 @@ decode_step (GstVaapiDecoder * decoder)
|
||||||
gboolean got_frame;
|
gboolean got_frame;
|
||||||
guint got_unit_size, input_size;
|
guint got_unit_size, input_size;
|
||||||
|
|
||||||
status = gst_vaapi_decoder_check_status (decoder);
|
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
/* Fill adapter with all buffers we have in the queue */
|
/* Fill adapter with all buffers we have in the queue */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
buffer = pop_buffer (decoder);
|
buffer = pop_buffer (decoder);
|
||||||
|
@ -1002,15 +998,6 @@ gst_vaapi_decoder_push_frame (GstVaapiDecoder * decoder,
|
||||||
push_frame (decoder, frame);
|
push_frame (decoder, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
GstVaapiDecoderStatus
|
|
||||||
gst_vaapi_decoder_check_status (GstVaapiDecoder * decoder)
|
|
||||||
{
|
|
||||||
if (decoder->context &&
|
|
||||||
gst_vaapi_context_get_surface_count (decoder->context) < 1)
|
|
||||||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE;
|
|
||||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
GstVaapiDecoderStatus
|
GstVaapiDecoderStatus
|
||||||
gst_vaapi_decoder_parse (GstVaapiDecoder * decoder,
|
gst_vaapi_decoder_parse (GstVaapiDecoder * decoder,
|
||||||
GstVideoCodecFrame * base_frame, GstAdapter * adapter, gboolean at_eos,
|
GstVideoCodecFrame * base_frame, GstAdapter * adapter, gboolean at_eos,
|
||||||
|
@ -1034,8 +1021,6 @@ gst_vaapi_decoder_parse (GstVaapiDecoder * decoder,
|
||||||
GstVaapiDecoderStatus
|
GstVaapiDecoderStatus
|
||||||
gst_vaapi_decoder_decode (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame)
|
gst_vaapi_decoder_decode (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame)
|
||||||
{
|
{
|
||||||
GstVaapiDecoderStatus status;
|
|
||||||
|
|
||||||
g_return_val_if_fail (decoder != NULL,
|
g_return_val_if_fail (decoder != NULL,
|
||||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||||
g_return_val_if_fail (frame != NULL,
|
g_return_val_if_fail (frame != NULL,
|
||||||
|
@ -1043,9 +1028,6 @@ gst_vaapi_decoder_decode (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame)
|
||||||
g_return_val_if_fail (frame->user_data != NULL,
|
g_return_val_if_fail (frame->user_data != NULL,
|
||||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||||
|
|
||||||
status = gst_vaapi_decoder_check_status (decoder);
|
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
|
||||||
return status;
|
|
||||||
return do_decode (decoder, frame);
|
return do_decode (decoder, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,9 +136,6 @@ gst_vaapi_decoder_flush (GstVaapiDecoder * decoder);
|
||||||
GstVaapiDecoderStatus
|
GstVaapiDecoderStatus
|
||||||
gst_vaapi_decoder_reset (GstVaapiDecoder * decoder);
|
gst_vaapi_decoder_reset (GstVaapiDecoder * decoder);
|
||||||
|
|
||||||
GstVaapiDecoderStatus
|
|
||||||
gst_vaapi_decoder_check_status (GstVaapiDecoder * decoder);
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_decoder_update_caps (GstVaapiDecoder * decoder, GstCaps * caps);
|
gst_vaapi_decoder_update_caps (GstVaapiDecoder * decoder, GstCaps * caps);
|
||||||
|
|
||||||
|
|
|
@ -375,15 +375,6 @@ gst_vaapidecode_update_src_caps (GstVaapiDecode * decode)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapidecode_release (GstVaapiDecode * decode)
|
|
||||||
{
|
|
||||||
g_mutex_lock (&decode->surface_ready_mutex);
|
|
||||||
g_cond_signal (&decode->surface_ready);
|
|
||||||
g_mutex_unlock (&decode->surface_ready_mutex);
|
|
||||||
gst_object_unref (decode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check whether the decoded surface size has changed */
|
/* check whether the decoded surface size has changed */
|
||||||
static gboolean
|
static gboolean
|
||||||
is_surface_resolution_changed (GstVaapiDecode * decode,
|
is_surface_resolution_changed (GstVaapiDecode * decode,
|
||||||
|
@ -541,9 +532,6 @@ gst_vaapidecode_push_decoded_frame (GstVideoDecoder * vdec,
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_vaapi_surface_proxy_set_destroy_notify (proxy,
|
|
||||||
(GDestroyNotify) gst_vaapidecode_release, gst_object_ref (decode));
|
|
||||||
|
|
||||||
if (is_src_allocator_dmabuf (decode)) {
|
if (is_src_allocator_dmabuf (decode)) {
|
||||||
vaapi_params.proxy = gst_vaapi_surface_proxy_ref (proxy);
|
vaapi_params.proxy = gst_vaapi_surface_proxy_ref (proxy);
|
||||||
params = (GstBufferPoolAcquireParams *) & vaapi_params;
|
params = (GstBufferPoolAcquireParams *) & vaapi_params;
|
||||||
|
@ -706,18 +694,6 @@ gst_vaapidecode_handle_frame (GstVideoDecoder * vdec,
|
||||||
/* Decode current frame */
|
/* Decode current frame */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
status = gst_vaapi_decoder_decode (decode->decoder, frame);
|
status = gst_vaapi_decoder_decode (decode->decoder, frame);
|
||||||
if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE) {
|
|
||||||
/* Make sure that there are no decoded frames waiting in the
|
|
||||||
output queue. */
|
|
||||||
gst_vaapidecode_push_all_decoded_frames (decode);
|
|
||||||
|
|
||||||
g_mutex_lock (&decode->surface_ready_mutex);
|
|
||||||
if (gst_vaapi_decoder_check_status (decode->decoder) ==
|
|
||||||
GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE)
|
|
||||||
g_cond_wait (&decode->surface_ready, &decode->surface_ready_mutex);
|
|
||||||
g_mutex_unlock (&decode->surface_ready_mutex);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||||
goto error_decode;
|
goto error_decode;
|
||||||
break;
|
break;
|
||||||
|
@ -987,8 +963,6 @@ gst_vaapidecode_destroy (GstVaapiDecode * decode)
|
||||||
gst_vaapidecode_purge (decode);
|
gst_vaapidecode_purge (decode);
|
||||||
|
|
||||||
gst_vaapi_decoder_replace (&decode->decoder, NULL);
|
gst_vaapi_decoder_replace (&decode->decoder, NULL);
|
||||||
|
|
||||||
gst_vaapidecode_release (gst_object_ref (decode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -1016,11 +990,6 @@ gst_vaapidecode_reset (GstVaapiDecode * decode, GstCaps * caps,
|
||||||
static void
|
static void
|
||||||
gst_vaapidecode_finalize (GObject * object)
|
gst_vaapidecode_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstVaapiDecode *const decode = GST_VAAPIDECODE (object);
|
|
||||||
|
|
||||||
g_cond_clear (&decode->surface_ready);
|
|
||||||
g_mutex_clear (&decode->surface_ready_mutex);
|
|
||||||
|
|
||||||
gst_vaapi_plugin_base_finalize (GST_VAAPI_PLUGIN_BASE (object));
|
gst_vaapi_plugin_base_finalize (GST_VAAPI_PLUGIN_BASE (object));
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -1537,9 +1506,6 @@ gst_vaapidecode_init (GstVaapiDecode * decode)
|
||||||
|
|
||||||
gst_vaapi_plugin_base_init (GST_VAAPI_PLUGIN_BASE (decode), GST_CAT_DEFAULT);
|
gst_vaapi_plugin_base_init (GST_VAAPI_PLUGIN_BASE (decode), GST_CAT_DEFAULT);
|
||||||
|
|
||||||
g_mutex_init (&decode->surface_ready_mutex);
|
|
||||||
g_cond_init (&decode->surface_ready);
|
|
||||||
|
|
||||||
gst_video_decoder_set_packetized (vdec, FALSE);
|
gst_video_decoder_set_packetized (vdec, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,6 @@ struct _GstVaapiDecode {
|
||||||
GstCaps *srcpad_caps;
|
GstCaps *srcpad_caps;
|
||||||
GstVideoInfo decoded_info;
|
GstVideoInfo decoded_info;
|
||||||
GstVaapiDecoder *decoder;
|
GstVaapiDecoder *decoder;
|
||||||
GMutex surface_ready_mutex;
|
|
||||||
GCond surface_ready;
|
|
||||||
GstCaps *allowed_sinkpad_caps;
|
GstCaps *allowed_sinkpad_caps;
|
||||||
GstCaps *allowed_srcpad_caps;
|
GstCaps *allowed_srcpad_caps;
|
||||||
guint current_frame_size;
|
guint current_frame_size;
|
||||||
|
|
|
@ -86,7 +86,6 @@ typedef struct
|
||||||
GstVaapiDecoder *decoder;
|
GstVaapiDecoder *decoder;
|
||||||
GThread *decoder_thread;
|
GThread *decoder_thread;
|
||||||
volatile gboolean decoder_thread_cancel;
|
volatile gboolean decoder_thread_cancel;
|
||||||
GCond decoder_ready;
|
|
||||||
GAsyncQueue *decoder_queue;
|
GAsyncQueue *decoder_queue;
|
||||||
GstVaapiCodec codec;
|
GstVaapiCodec codec;
|
||||||
guint fps_n;
|
guint fps_n;
|
||||||
|
@ -219,14 +218,6 @@ get_error_string (AppError error)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
decoder_release (App * app)
|
|
||||||
{
|
|
||||||
g_mutex_lock (&app->mutex);
|
|
||||||
g_cond_signal (&app->decoder_ready);
|
|
||||||
g_mutex_unlock (&app->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
decoder_thread (gpointer data)
|
decoder_thread (gpointer data)
|
||||||
{
|
{
|
||||||
|
@ -237,8 +228,7 @@ decoder_thread (gpointer data)
|
||||||
RenderFrame *rfp;
|
RenderFrame *rfp;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstClockTime pts;
|
GstClockTime pts;
|
||||||
gboolean got_surface, got_eos = FALSE;
|
gboolean got_eos = FALSE;
|
||||||
gint64 end_time;
|
|
||||||
guint ofs;
|
guint ofs;
|
||||||
|
|
||||||
g_print ("Decoder thread started\n");
|
g_print ("Decoder thread started\n");
|
||||||
|
@ -266,12 +256,9 @@ decoder_thread (gpointer data)
|
||||||
SEND_ERROR ("failed to push buffer to decoder");
|
SEND_ERROR ("failed to push buffer to decoder");
|
||||||
gst_buffer_replace (&buffer, NULL);
|
gst_buffer_replace (&buffer, NULL);
|
||||||
|
|
||||||
get_surface:
|
|
||||||
status = gst_vaapi_decoder_get_surface (app->decoder, &proxy);
|
status = gst_vaapi_decoder_get_surface (app->decoder, &proxy);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case GST_VAAPI_DECODER_STATUS_SUCCESS:
|
case GST_VAAPI_DECODER_STATUS_SUCCESS:
|
||||||
gst_vaapi_surface_proxy_set_destroy_notify (proxy,
|
|
||||||
(GDestroyNotify) decoder_release, app);
|
|
||||||
rfp = render_frame_new ();
|
rfp = render_frame_new ();
|
||||||
if (!rfp)
|
if (!rfp)
|
||||||
SEND_ERROR ("failed to allocate render frame");
|
SEND_ERROR ("failed to allocate render frame");
|
||||||
|
@ -290,16 +277,6 @@ decoder_thread (gpointer data)
|
||||||
goto send_eos;
|
goto send_eos;
|
||||||
got_eos = TRUE;
|
got_eos = TRUE;
|
||||||
break;
|
break;
|
||||||
case GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE:
|
|
||||||
end_time = g_get_monotonic_time () + G_TIME_SPAN_SECOND;
|
|
||||||
g_mutex_lock (&app->mutex);
|
|
||||||
got_surface = g_cond_wait_until (&app->decoder_ready, &app->mutex,
|
|
||||||
end_time);
|
|
||||||
g_mutex_unlock (&app->mutex);
|
|
||||||
if (got_surface)
|
|
||||||
goto get_surface;
|
|
||||||
SEND_ERROR ("failed to acquire a surface within one second");
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
SEND_ERROR ("%s", get_decoder_status_string (status));
|
SEND_ERROR ("%s", get_decoder_status_string (status));
|
||||||
break;
|
break;
|
||||||
|
@ -550,7 +527,6 @@ app_free (App * app)
|
||||||
g_async_queue_unref (app->decoder_queue);
|
g_async_queue_unref (app->decoder_queue);
|
||||||
app->decoder_queue = NULL;
|
app->decoder_queue = NULL;
|
||||||
}
|
}
|
||||||
g_cond_clear (&app->decoder_ready);
|
|
||||||
|
|
||||||
if (app->timer) {
|
if (app->timer) {
|
||||||
g_timer_destroy (app->timer);
|
g_timer_destroy (app->timer);
|
||||||
|
@ -574,7 +550,6 @@ app_new (void)
|
||||||
|
|
||||||
g_mutex_init (&app->mutex);
|
g_mutex_init (&app->mutex);
|
||||||
g_cond_init (&app->event_cond);
|
g_cond_init (&app->event_cond);
|
||||||
g_cond_init (&app->decoder_ready);
|
|
||||||
g_cond_init (&app->render_ready);
|
g_cond_init (&app->render_ready);
|
||||||
|
|
||||||
app_set_framerate (app, 60, 1);
|
app_set_framerate (app, 60, 1);
|
||||||
|
|
Loading…
Reference in a new issue