diff --git a/gst-libs/gst/vaapi/gstvaapidecoder.c b/gst-libs/gst/vaapi/gstvaapidecoder.c index e0d1b7b209..2f54e7a43d 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder.c @@ -122,21 +122,15 @@ decode_step(GstVaapiDecoder *decoder) return status; } -static gboolean -push_surface( - GstVaapiDecoder *decoder, - GstVaapiSurfaceProxy *proxy, - GstClockTime timestamp -) +static inline void +push_surface(GstVaapiDecoder *decoder, GstVaapiSurfaceProxy *proxy) { GstVaapiDecoderPrivate * const priv = decoder->priv; GST_DEBUG("queue decoded surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(gst_vaapi_surface_proxy_get_surface_id(proxy))); - gst_vaapi_surface_proxy_set_timestamp(proxy, timestamp); g_queue_push_tail(priv->surfaces, proxy); - return TRUE; } static inline GstVaapiSurfaceProxy * @@ -559,28 +553,11 @@ gst_vaapi_decoder_push_buffer_sub( return TRUE; } -gboolean -gst_vaapi_decoder_push_surface( - GstVaapiDecoder *decoder, - GstVaapiSurface *surface, - GstClockTime timestamp -) -{ - GstVaapiDecoderPrivate * const priv = decoder->priv; - GstVaapiSurfaceProxy *proxy; - - proxy = gst_vaapi_surface_proxy_new(priv->context, surface); - if (!proxy) - return FALSE; - return push_surface(decoder, proxy, timestamp); -} - -gboolean +void gst_vaapi_decoder_push_surface_proxy( GstVaapiDecoder *decoder, - GstVaapiSurfaceProxy *proxy, - GstClockTime timestamp + GstVaapiSurfaceProxy *proxy ) { - return push_surface(decoder, g_object_ref(proxy), timestamp); + return push_surface(decoder, proxy); } diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_ffmpeg.c b/gst-libs/gst/vaapi/gstvaapidecoder_ffmpeg.c index 8fb9099d8e..21425ac884 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_ffmpeg.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_ffmpeg.c @@ -483,12 +483,26 @@ gst_vaapi_decoder_ffmpeg_create(GstVaapiDecoderFfmpeg *ffdecoder) return TRUE; } +static GstVaapiDecoderStatus +render_frame(GstVaapiDecoderFfmpeg *decoder, AVFrame *frame) +{ + GstVaapiDecoder * const base_decoder = GST_VAAPI_DECODER(decoder); + GstVaapiSurfaceProxy *proxy; + + proxy = GST_VAAPI_SURFACE_PROXY(frame->data[0]); + if (!proxy) + return GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE; + + gst_vaapi_surface_proxy_set_timestamp(proxy, frame->pts); + gst_vaapi_decoder_push_surface_proxy(base_decoder, g_object_ref(proxy)); + return GST_VAAPI_DECODER_STATUS_SUCCESS; +} + static GstVaapiDecoderStatus decode_frame(GstVaapiDecoderFfmpeg *ffdecoder, guchar *buf, guint buf_size) { GstVaapiDecoderFfmpegPrivate * const priv = ffdecoder->priv; GstVaapiDisplay * const display = GST_VAAPI_DECODER_DISPLAY(ffdecoder); - GstVaapiSurfaceProxy *proxy; int bytes_read, got_picture = 0; AVPacket pkt; @@ -509,14 +523,7 @@ decode_frame(GstVaapiDecoderFfmpeg *ffdecoder, guchar *buf, guint buf_size) if (bytes_read < 0) return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN; - proxy = GST_VAAPI_SURFACE_PROXY(priv->frame->data[0]); - if (!proxy) - return GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE; - - if (!gst_vaapi_decoder_push_surface_proxy(GST_VAAPI_DECODER_CAST(ffdecoder), - proxy, priv->frame->pts)) - return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; - return GST_VAAPI_DECODER_STATUS_SUCCESS; + return render_frame(ffdecoder, priv->frame); } GstVaapiDecoderStatus diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_objects.c b/gst-libs/gst/vaapi/gstvaapidecoder_objects.c index 61ff4e6b19..c25e86cfea 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_objects.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_objects.c @@ -224,19 +224,16 @@ gboolean gst_vaapi_picture_output(GstVaapiPicture *picture) { GstVaapiSurfaceProxy *proxy; - gboolean success; g_return_val_if_fail(GST_VAAPI_IS_PICTURE(picture), FALSE); proxy = gst_vaapi_surface_proxy_new(GET_CONTEXT(picture), picture->surface); if (!proxy) return FALSE; - success = gst_vaapi_decoder_push_surface_proxy( - GET_DECODER(picture), - proxy, picture->pts - ); - g_object_unref(proxy); // ref'ed in gst_vaapi_decoder_push_surface_proxy() - return success; + + gst_vaapi_surface_proxy_set_timestamp(proxy, picture->pts); + gst_vaapi_decoder_push_surface_proxy(GET_DECODER(picture), proxy); + return TRUE; } /* ------------------------------------------------------------------------- */ diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_priv.h b/gst-libs/gst/vaapi/gstvaapidecoder_priv.h index 27efee1144..87ce200b21 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_priv.h +++ b/gst-libs/gst/vaapi/gstvaapidecoder_priv.h @@ -165,18 +165,10 @@ gst_vaapi_decoder_push_buffer_sub( guint size ) attribute_hidden; -gboolean -gst_vaapi_decoder_push_surface( - GstVaapiDecoder *decoder, - GstVaapiSurface *surface, - GstClockTime timestamp -) attribute_hidden; - -gboolean +void gst_vaapi_decoder_push_surface_proxy( GstVaapiDecoder *decoder, - GstVaapiSurfaceProxy *proxy, - GstClockTime timestamp + GstVaapiSurfaceProxy *proxy ) attribute_hidden; G_END_DECLS