[Pkg-gstreamer-commits] [gstreamer-vaapi] 42/176: encoder: simplify VA context initialization process.
Vincent Cheng
vcheng at moszumanska.debian.org
Tue Jun 3 08:09:26 UTC 2014
This is an automated email from the git hooks/post-receive script.
vcheng pushed a commit to branch upstream
in repository gstreamer-vaapi.
commit fd9c855f140af83f34081403c09d6bfac005ca78
Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Date: Wed Dec 4 18:48:35 2013 +0100
encoder: simplify VA context initialization process.
Change get_context_info() into a set_context_info() function that
initializes common defaults into the base class, thus allowing the
subclasses to specialize the context info further on.
The set_context_info() hook is also the location where additional
context specific data could be initialized. At this point, we are
guaranteed to have valid video resolution size and framerate. i.e.
gst_vaapi_encoder_set_format() was called beforehand.
---
gst-libs/gst/vaapi/gstvaapiencoder.c | 17 ++++++++++-------
gst-libs/gst/vaapi/gstvaapiencoder_h264.c | 22 +++++++---------------
gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c | 20 ++++++--------------
gst-libs/gst/vaapi/gstvaapiencoder_priv.h | 6 +++---
4 files changed, 26 insertions(+), 39 deletions(-)
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c
index ef2675f..e56886f 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -307,18 +307,21 @@ static gboolean
gst_vaapi_encoder_ensure_context (GstVaapiEncoder * encoder)
{
GstVaapiEncoderClass *const klass = GST_VAAPI_ENCODER_GET_CLASS (encoder);
- GstVaapiContextInfo info;
+ GstVaapiContextInfo *const cip = &encoder->context_info;
GstVaapiContext *context;
if (GST_VAAPI_ENCODER_CONTEXT (encoder))
return TRUE;
- memset (&info, 0, sizeof (info));
- if (!klass->get_context_info (encoder, &info))
- return FALSE;
+ cip->profile = GST_VAAPI_PROFILE_UNKNOWN;
+ cip->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
+ cip->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
+ cip->width = GST_VAAPI_ENCODER_WIDTH (encoder);
+ cip->height = GST_VAAPI_ENCODER_HEIGHT (encoder);
+ cip->ref_frames = 0;
+ klass->set_context_info (encoder);
- context = gst_vaapi_context_new_full (GST_VAAPI_ENCODER_DISPLAY (encoder),
- &info);
+ context = gst_vaapi_context_new_full (encoder->display, cip);
if (!context)
return FALSE;
@@ -406,7 +409,7 @@ gst_vaapi_encoder_init (GstVaapiEncoder * encoder, GstVaapiDisplay * display)
CHECK_VTABLE_HOOK (encode);
CHECK_VTABLE_HOOK (reordering);
CHECK_VTABLE_HOOK (flush);
- CHECK_VTABLE_HOOK (get_context_info);
+ CHECK_VTABLE_HOOK (set_context_info);
CHECK_VTABLE_HOOK (set_format);
#undef CHECK_VTABLE_HOOK
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
index 076273c..d23646f 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
@@ -1585,23 +1585,15 @@ end:
return GST_VAAPI_ENCODER_STATUS_SUCCESS;
}
-static gboolean
-gst_vaapi_encoder_h264_get_context_info (GstVaapiEncoder * base,
- GstVaapiContextInfo * info)
+static void
+gst_vaapi_encoder_h264_set_context_info (GstVaapiEncoder * base_encoder)
{
- GstVaapiEncoderH264 *encoder = GST_VAAPI_ENCODER_H264 (base);
- const static guint default_surface_num = 3;
+ GstVaapiEncoderH264 *const encoder = GST_VAAPI_ENCODER_H264 (base_encoder);
+ GstVaapiContextInfo *const cip = &base_encoder->context_info;
+ const guint DEFAULT_SURFACES_COUNT = 3;
- g_return_val_if_fail (info, FALSE);
-
- info->profile = encoder->profile;
- info->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
- info->width = GST_VAAPI_ENCODER_WIDTH (encoder);
- info->height = GST_VAAPI_ENCODER_HEIGHT (encoder);
- info->ref_frames = (encoder->b_frame_num ? 2 : 1) + default_surface_num;
- info->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
-
- return TRUE;
+ cip->profile = encoder->profile;
+ cip->ref_frames = (encoder->b_frame_num ? 2 : 1) + DEFAULT_SURFACES_COUNT;
}
static GstCaps *
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
index 5bc01d5..876dc6d 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
@@ -627,22 +627,14 @@ to_vaapi_profile (guint32 profile)
return p;
}
-static gboolean
-gst_vaapi_encoder_mpeg2_get_context_info (GstVaapiEncoder * base,
- GstVaapiContextInfo * info)
+static void
+gst_vaapi_encoder_mpeg2_set_context_info (GstVaapiEncoder * base_encoder)
{
- GstVaapiEncoderMpeg2 *encoder = GST_VAAPI_ENCODER_MPEG2 (base);
+ GstVaapiEncoderMpeg2 *const encoder = GST_VAAPI_ENCODER_MPEG2 (base_encoder);
+ GstVaapiContextInfo *const cip = &base_encoder->context_info;
- g_return_val_if_fail (info, FALSE);
-
- info->profile = to_vaapi_profile (encoder->profile);
- info->entrypoint = GST_VAAPI_ENTRYPOINT_SLICE_ENCODE;
- info->width = GST_VAAPI_ENCODER_WIDTH (encoder);
- info->height = GST_VAAPI_ENCODER_HEIGHT (encoder);
- info->ref_frames = 2;
- info->rc_mode = GST_VAAPI_ENCODER_RATE_CONTROL (encoder);
-
- return TRUE;
+ cip->profile = to_vaapi_profile (encoder->profile);
+ cip->ref_frames = 2;
}
static gboolean
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h
index 10b1ff9..e570602 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_priv.h
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_priv.h
@@ -80,6 +80,7 @@ struct _GstVaapiEncoder
GstVaapiDisplay *display;
GstVaapiContext *context;
+ GstVaapiContextInfo context_info;
GstCaps *caps;
VADisplay va_display;
@@ -106,8 +107,7 @@ struct _GstVaapiEncoderClass
GstVideoCodecState * in_state,
GstCaps * ref_caps);
- gboolean (*get_context_info) (GstVaapiEncoder * encoder,
- GstVaapiContextInfo * info);
+ void (*set_context_info) (GstVaapiEncoder * encoder);
GstVaapiEncoderStatus (*reordering) (GstVaapiEncoder * encoder,
GstVideoCodecFrame * in,
@@ -137,7 +137,7 @@ struct _GstVaapiEncoderClass
GST_VAAPI_ENCODER_CLASS_HOOK (codec, init), \
GST_VAAPI_ENCODER_CLASS_HOOK (codec, finalize), \
GST_VAAPI_ENCODER_CLASS_HOOK (codec, set_format), \
- GST_VAAPI_ENCODER_CLASS_HOOK (codec, get_context_info), \
+ GST_VAAPI_ENCODER_CLASS_HOOK (codec, set_context_info), \
GST_VAAPI_ENCODER_CLASS_HOOK (codec, reordering), \
GST_VAAPI_ENCODER_CLASS_HOOK (codec, encode), \
GST_VAAPI_ENCODER_CLASS_HOOK (codec, flush)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gstreamer/gstreamer-vaapi.git
More information about the Pkg-gstreamer-commits
mailing list