summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi A Wang <yi.a.wang@intel.com>2017-08-09 18:32:13 -0700
committerSreerenj Balachandran <sreerenj.balachandran@intel.com>2017-08-09 18:32:13 -0700
commit7c577390c6518d6645c2694ea63081dc47fe5659 (patch)
tree5b1b6852354c0ee3dc6140bc2f4c5b39bedc6bc4
parent05e1c7801c3c95f47b14f2394030a5c4865d813f (diff)
FEI: plugin: Add virtual methods to base encode
Two new virtual methods are added to gstvaapiencode. load_control_data(): load the FEI input buffers set by the upstream elements save_stats_to_meta(): save the FEI output buffers to Meta for downnstream elements https://bugzilla.gnome.org/show_bug.cgi?id=785712 https://bugzilla.gnome.org/show_bug.cgi?id=784667 Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
-rw-r--r--gst/vaapi/gstvaapiencode.c22
-rw-r--r--gst/vaapi/gstvaapiencode.h18
2 files changed, 40 insertions, 0 deletions
diff --git a/gst/vaapi/gstvaapiencode.c b/gst/vaapi/gstvaapiencode.c
index fc8cf6e0..b3988394 100644
--- a/gst/vaapi/gstvaapiencode.c
+++ b/gst/vaapi/gstvaapiencode.c
@@ -271,6 +271,9 @@ gst_vaapiencode_push_frame (GstVaapiEncode * encode, gint64 timeout)
GstVaapiEncoderStatus status;
GstBuffer *out_buffer;
GstFlowReturn ret;
+#if USE_H264_FEI_ENCODER
+ GstVaapiFeiVideoMeta *feimeta = NULL;
+#endif
status = gst_vaapi_encoder_get_buffer_with_timeout (encode->encoder,
&codedbuf_proxy, timeout);
@@ -295,6 +298,15 @@ gst_vaapiencode_push_frame (GstVaapiEncode * encode, gint64 timeout)
out_buffer = NULL;
ret = klass->alloc_buffer (encode,
GST_VAAPI_CODED_BUFFER_PROXY_BUFFER (codedbuf_proxy), &out_buffer);
+
+#if USE_H264_FEI_ENCODER
+ if (klass->save_stats_to_meta) {
+ feimeta = klass->save_stats_to_meta (encode, codedbuf_proxy);
+ if (feimeta != NULL)
+ gst_buffer_set_vaapi_fei_video_meta (out_buffer, feimeta);
+ }
+#endif
+
gst_vaapi_coded_buffer_proxy_replace (&codedbuf_proxy, NULL);
if (ret != GST_FLOW_OK)
goto error_allocate_buffer;
@@ -617,6 +629,10 @@ gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
GstVaapiSurfaceProxy *proxy;
GstFlowReturn ret;
GstBuffer *buf;
+#if USE_H264_FEI_ENCODER
+ GstVaapiFeiVideoMeta *feimeta = NULL;
+ GstVaapiEncodeClass *const klass = GST_VAAPIENCODE_GET_CLASS (venc);
+#endif
buf = NULL;
ret = gst_vaapi_plugin_base_get_input_buffer (GST_VAAPI_PLUGIN_BASE (encode),
@@ -635,6 +651,12 @@ gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
if (!proxy)
goto error_buffer_no_surface_proxy;
+#if USE_H264_FEI_ENCODER
+ feimeta = gst_buffer_get_vaapi_fei_video_meta (buf);
+ if (feimeta && klass->load_control_data)
+ klass->load_control_data (encode, feimeta, proxy);
+#endif
+
gst_video_codec_frame_set_user_data (frame,
gst_vaapi_surface_proxy_ref (proxy),
(GDestroyNotify) gst_vaapi_surface_proxy_unref);
diff --git a/gst/vaapi/gstvaapiencode.h b/gst/vaapi/gstvaapiencode.h
index 72121f79..b6382852 100644
--- a/gst/vaapi/gstvaapiencode.h
+++ b/gst/vaapi/gstvaapiencode.h
@@ -27,6 +27,12 @@
#include "gstvaapipluginbase.h"
#include <gst/vaapi/gstvaapiencoder.h>
+#if USE_H264_FEI_ENCODER
+#include <gst/vaapi/gstvaapisurface.h>
+#include <gst/vaapi/gstvaapicodedbufferproxy.h>
+#include "gstvaapifeivideometa.h"
+#endif
+
G_BEGIN_DECLS
#define GST_TYPE_VAAPIENCODE \
@@ -81,6 +87,18 @@ struct _GstVaapiEncodeClass
GstVaapiCodedBuffer * coded_buf,
GstBuffer ** outbuf_ptr);
GstVaapiProfile (*get_profile) (GstCaps * caps);
+
+#if USE_H264_FEI_ENCODER
+
+ gboolean (*load_control_data) (GstVaapiEncode *encoder,
+ GstVaapiFeiVideoMeta *feimeta,
+ GstVaapiSurfaceProxy *proxy);
+
+ GstVaapiFeiVideoMeta* (*save_stats_to_meta) (GstVaapiEncode *base_encode,
+ GstVaapiCodedBufferProxy *proxy);
+
+#endif
+
};
GType