diff options
author | Wind Yuan <feng.yuan@intel.com> | 2013-04-10 13:30:58 +0800 |
---|---|---|
committer | Wind Yuan <feng.yuan@intel.com> | 2013-04-11 16:51:29 +0800 |
commit | 0c1d2de25dbc50951f1b3ef129fc508b3741024e (patch) | |
tree | e088ecd733f648ea7014653b59d458b3143d05cd | |
parent | 3158544012b7158b3a492b8992368d8c75914df2 (diff) | |
download | gstreamer-vaapi-0c1d2de25dbc50951f1b3ef129fc508b3741024e.tar.gz gstreamer-vaapi-0c1d2de25dbc50951f1b3ef129fc508b3741024e.tar.bz2 gstreamer-vaapi-0c1d2de25dbc50951f1b3ef129fc508b3741024e.zip |
encoder: move vaSyncSurface to another thread
This helped improve encoder performance
Change-Id: I4ce91b23764eb3d941040796cfd2acf3388f91fd
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapibaseencoder.c | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapibaseencoder.c b/gst-libs/gst/vaapi/gstvaapibaseencoder.c index d4fefec..96087ee 100644 --- a/gst-libs/gst/vaapi/gstvaapibaseencoder.c +++ b/gst-libs/gst/vaapi/gstvaapibaseencoder.c @@ -98,6 +98,7 @@ typedef struct _GstVaapiEncoderBufferInfoClass GstVaapiEncoderBufferInfoClass; struct _GstVaapiEncoderBufferInfo { GObject base; GstVaapiBaseEncoder *encoder; + GstBuffer *frame; VABufferID *id; GstClockTime timestamp; GstClockTime duration; @@ -239,6 +240,7 @@ gst_vaapi_encoder_buffer_info_init( ) { info->encoder = NULL; + info->frame = NULL; info->id = NULL; info->timestamp = 0; info->duration = 0; @@ -258,6 +260,11 @@ gst_vaapi_encoder_buffer_info_finalize(GObject *object) push_idle_buffer_id(info->encoder, info->id); } + if (info->frame) { + gst_buffer_unref(info->frame); + info->frame = NULL; + } + if (info->encoder) { g_object_unref(info->encoder); info->encoder = NULL; @@ -571,6 +578,25 @@ end: return ret; } +static GstVaapiVideoBuffer * +_get_video_buffer( + GstVaapiBaseEncoder* encoder, + GstBuffer *buf +) +{ + GstVaapiBaseEncoderPrivate *priv = encoder->priv; + GstBuffer *video_buffer; + + if (priv->buffer_sharing_flag) + video_buffer = (GstBuffer *)buf->data; + else + video_buffer = buf; + + if (GST_VAAPI_IS_VIDEO_BUFFER(video_buffer)) + return GST_VAAPI_VIDEO_BUFFER(video_buffer); + return NULL; +} + static inline guint get_buf_list_size(VACodedBufferSegment *buf_list) { @@ -615,6 +641,8 @@ gst_vaapi_base_encoder_get_coded_buffer( GstVaapiBaseEncoderClass *klass = GST_VAAPI_BASE_ENCODER_GET_CLASS(encoder); GstVaapiEncoderBufferInfo* info; + GstVaapiVideoBuffer *video_buffer; + GstVaapiSurface *surface; EncoderStatus ret; VACodedBufferSegment *buf_list = NULL; GstBuffer* buffer = NULL; @@ -629,11 +657,22 @@ gst_vaapi_base_encoder_get_coded_buffer( ret = ENCODER_NO_ERROR; ENCODER_CHECK_STATUS( - info->id && *info->id != VA_INVALID_ID, + info->frame || (info->id && *info->id != VA_INVALID_ID), ENCODER_DATA_ERR, "get invalid buffer info" ); + video_buffer = _get_video_buffer(encoder, info->frame); + ENCODER_CHECK_STATUS(video_buffer, + ENCODER_DATA_ERR, + "Get video buffer failed"); + surface = gst_vaapi_video_buffer_get_surface(video_buffer); + + ret = query_encoding_status(encoder, surface); + if (ENCODER_NO_ERROR != ret) { + goto end; + } + ENCODER_CHECK_STATUS( gst_vaapi_encoder_buffer_info_map(info, (void**)&buf_list), ENCODER_DATA_ERR, @@ -681,25 +720,6 @@ end: return ret; } -static GstVaapiVideoBuffer * -_get_video_buffer( - GstVaapiBaseEncoder* encoder, - GstBuffer *buf -) -{ - GstVaapiBaseEncoderPrivate *priv = encoder->priv; - GstBuffer *video_buffer; - - if (priv->buffer_sharing_flag) - video_buffer = (GstBuffer *)buf->data; - else - video_buffer = buf; - - if (GST_VAAPI_IS_VIDEO_BUFFER(video_buffer)) - return GST_VAAPI_VIDEO_BUFFER(video_buffer); - return NULL; -} - static EncoderStatus gst_vaapi_base_encoder_encode_default( GstVaapiEncoder* base, @@ -773,15 +793,17 @@ again: ENCODER_CHECK_STATUS(ENCODER_NO_ERROR == ret, ENCODER_PICTURE_ERR, "base_prepare_encoding failed"); - +#if 0 /*query surface result*/ ret = query_encoding_status(encoder, buffer_surface); if (ENCODER_NO_ERROR != ret) { goto end; } +#endif /* Push coded buffer to another task */ GstVaapiEncoderBufferInfo* info = gst_vaapi_encoder_buffer_info_new(encoder); + info->frame = gst_buffer_ref(pic); info->id = coded_buf; info->timestamp = GST_BUFFER_TIMESTAMP(pic); info->duration = GST_BUFFER_DURATION(pic); |