mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
vaapiencode: minor clean-ups.
Add a GST_VAAPIENCODE_CAST() helper to avoid run-time checks against the GObject type system. We are guaranteed to only deal with the same plug-in element object.
This commit is contained in:
parent
84af151796
commit
e01d48feba
6 changed files with 147 additions and 182 deletions
|
@ -45,11 +45,8 @@ typedef struct _GstVaapiEncodeFrameUserData
|
|||
} GstVaapiEncodeFrameUserData;
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_vaapiencode_debug);
|
||||
|
||||
#define GST_CAT_DEFAULT gst_vaapiencode_debug
|
||||
|
||||
#define GstVideoContextClass GstVideoContextInterface
|
||||
|
||||
/* GstImplementsInterface interface */
|
||||
#if !GST_CHECK_VERSION(1,0,0)
|
||||
static gboolean
|
||||
|
@ -66,12 +63,12 @@ gst_vaapiencode_implements_iface_init (GstImplementsInterfaceClass * iface)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* context(display) interface */
|
||||
/* GstContext interface */
|
||||
#if GST_CHECK_VERSION(1,1,0)
|
||||
static void
|
||||
gst_vaapiencode_set_context (GstElement * element, GstContext * context)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (element);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (element);
|
||||
GstVaapiDisplay *display = NULL;
|
||||
|
||||
if (gst_vaapi_video_context_get_display (context, &display)) {
|
||||
|
@ -84,7 +81,7 @@ static void
|
|||
gst_vaapiencode_set_video_context (GstVideoContext * context,
|
||||
const gchar * type, const GValue * value)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (context);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (context);
|
||||
|
||||
gst_vaapi_set_display (type, value, &encode->display);
|
||||
}
|
||||
|
@ -94,6 +91,8 @@ gst_video_context_interface_init (GstVideoContextInterface * iface)
|
|||
{
|
||||
iface->set_context = gst_vaapiencode_set_video_context;
|
||||
}
|
||||
|
||||
#define GstVideoContextClass GstVideoContextInterface
|
||||
#endif
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GstVaapiEncode,
|
||||
|
@ -112,10 +111,10 @@ static gboolean
|
|||
gst_vaapiencode_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (parent);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (parent);
|
||||
gboolean success;
|
||||
|
||||
GST_DEBUG ("vaapiencode query %s", GST_QUERY_TYPE_NAME (query));
|
||||
GST_INFO_OBJECT(encode, "query type %s", GST_QUERY_TYPE_NAME(query));
|
||||
|
||||
if (gst_vaapi_reply_to_query (query, encode->display))
|
||||
success = TRUE;
|
||||
|
@ -277,7 +276,7 @@ gst_vaapiencode_buffer_loop (GstVaapiEncode * encode)
|
|||
static GstCaps *
|
||||
gst_vaapiencode_get_caps_impl (GstVideoEncoder * venc)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (venc);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||
GstCaps *caps;
|
||||
|
||||
if (encode->sinkpad_caps)
|
||||
|
@ -306,17 +305,8 @@ gst_vaapiencode_destroy (GstVaapiEncode * encode)
|
|||
{
|
||||
gst_vaapi_encoder_replace (&encode->encoder, NULL);
|
||||
g_clear_object (&encode->video_buffer_pool);
|
||||
|
||||
if (encode->sinkpad_caps) {
|
||||
gst_caps_unref (encode->sinkpad_caps);
|
||||
encode->sinkpad_caps = NULL;
|
||||
}
|
||||
|
||||
if (encode->srcpad_caps) {
|
||||
gst_caps_unref (encode->srcpad_caps);
|
||||
encode->srcpad_caps = NULL;
|
||||
}
|
||||
|
||||
gst_caps_replace (&encode->sinkpad_caps, NULL);
|
||||
gst_caps_replace (&encode->srcpad_caps, NULL);
|
||||
gst_vaapi_display_replace (&encode->display, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -339,14 +329,15 @@ ensure_encoder (GstVaapiEncode * encode)
|
|||
return FALSE;
|
||||
|
||||
encode->encoder = klass->create_encoder (encode, encode->display);
|
||||
g_assert (encode->encoder);
|
||||
return (encode->encoder ? TRUE : FALSE);
|
||||
if (!encode->encoder)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapiencode_open (GstVideoEncoder * venc)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (venc);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||
GstVaapiDisplay *const old_display = encode->display;
|
||||
gboolean success;
|
||||
|
||||
|
@ -354,18 +345,13 @@ gst_vaapiencode_open (GstVideoEncoder * venc)
|
|||
success = ensure_display (encode);
|
||||
if (old_display)
|
||||
gst_vaapi_display_unref (old_display);
|
||||
|
||||
GST_DEBUG ("ensure display %s, display:%p",
|
||||
(success ? "okay" : "failed"), encode->display);
|
||||
return success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapiencode_close (GstVideoEncoder * venc)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (venc);
|
||||
|
||||
GST_DEBUG ("vaapiencode starting close");
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||
|
||||
return gst_vaapiencode_destroy (encode);
|
||||
}
|
||||
|
@ -502,7 +488,7 @@ error_pool_config:
|
|||
static gboolean
|
||||
gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (venc);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||
|
||||
g_return_val_if_fail (state->caps != NULL, FALSE);
|
||||
|
||||
|
@ -524,13 +510,12 @@ gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
|
|||
|
||||
return gst_pad_start_task (encode->srcpad,
|
||||
(GstTaskFunction) gst_vaapiencode_buffer_loop, encode, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_vaapiencode_reset (GstVideoEncoder * venc, gboolean hard)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (venc);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||
|
||||
GST_DEBUG ("vaapiencode starting reset");
|
||||
|
||||
|
@ -671,7 +656,7 @@ static GstFlowReturn
|
|||
gst_vaapiencode_handle_frame (GstVideoEncoder * venc,
|
||||
GstVideoCodecFrame * frame)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (venc);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GstVaapiEncoderStatus encoder_ret = GST_VAAPI_ENCODER_STATUS_SUCCESS;
|
||||
GstBuffer *buf;
|
||||
|
@ -707,12 +692,10 @@ end:
|
|||
static GstFlowReturn
|
||||
gst_vaapiencode_finish (GstVideoEncoder * venc)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (venc);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||
GstVaapiEncoderStatus status;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
GST_DEBUG ("vaapiencode starting finish");
|
||||
|
||||
status = gst_vaapi_encoder_flush (encode->encoder);
|
||||
|
||||
GST_VIDEO_ENCODER_STREAM_UNLOCK (encode);
|
||||
|
@ -730,7 +713,7 @@ gst_vaapiencode_finish (GstVideoEncoder * venc)
|
|||
static gboolean
|
||||
gst_vaapiencode_propose_allocation (GstVideoEncoder * venc, GstQuery * query)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (venc);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
|
||||
GstCaps *caps = NULL;
|
||||
gboolean need_pool;
|
||||
|
||||
|
@ -760,7 +743,7 @@ error_no_caps:
|
|||
static void
|
||||
gst_vaapiencode_finalize (GObject * object)
|
||||
{
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE (object);
|
||||
GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (object);
|
||||
|
||||
gst_vaapiencode_destroy (encode);
|
||||
|
||||
|
@ -791,7 +774,9 @@ static void
|
|||
gst_vaapiencode_class_init (GstVaapiEncodeClass * klass)
|
||||
{
|
||||
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
||||
#if GST_CHECK_VERSION(1,1,0)
|
||||
GstElementClass *const element_class = GST_ELEMENT_CLASS (klass);
|
||||
#endif
|
||||
GstVideoEncoderClass *const venc_class = GST_VIDEO_ENCODER_CLASS (klass);
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_vaapiencode_debug,
|
||||
|
@ -799,6 +784,10 @@ gst_vaapiencode_class_init (GstVaapiEncodeClass * klass)
|
|||
|
||||
object_class->finalize = gst_vaapiencode_finalize;
|
||||
|
||||
#if GST_CHECK_VERSION(1,1,0)
|
||||
element_class->set_context = GST_DEBUG_FUNCPTR (gst_vaapiencode_set_context);
|
||||
#endif
|
||||
|
||||
venc_class->open = GST_DEBUG_FUNCPTR (gst_vaapiencode_open);
|
||||
venc_class->close = GST_DEBUG_FUNCPTR (gst_vaapiencode_close);
|
||||
venc_class->set_format = GST_DEBUG_FUNCPTR (gst_vaapiencode_set_format);
|
||||
|
@ -812,10 +801,6 @@ gst_vaapiencode_class_init (GstVaapiEncodeClass * klass)
|
|||
|
||||
klass->allocate_buffer = gst_vaapiencode_default_allocate_buffer;
|
||||
|
||||
#if GST_CHECK_VERSION(1,1,0)
|
||||
element_class->set_context = GST_DEBUG_FUNCPTR (gst_vaapiencode_set_context);
|
||||
#endif
|
||||
|
||||
/* Registering debug symbols for function pointers */
|
||||
GST_DEBUG_REGISTER_FUNCPTR (gst_vaapiencode_query);
|
||||
}
|
||||
|
|
|
@ -30,35 +30,26 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_VAAPIENCODE \
|
||||
(gst_vaapiencode_get_type ())
|
||||
|
||||
(gst_vaapiencode_get_type ())
|
||||
#define GST_VAAPIENCODE_CAST(obj) \
|
||||
((GstVaapiEncode *)(obj))
|
||||
#define GST_VAAPIENCODE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPIENCODE, GstVaapiEncode))
|
||||
#define GST_VAAPIENCODE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPIENCODE, GstVaapiEncodeClass))
|
||||
#define GST_VAAPIENCODE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPIENCODE, GstVaapiEncodeClass))
|
||||
#define GST_IS_VAAPIENCODE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPIENCODE))
|
||||
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPIENCODE))
|
||||
#define GST_IS_VAAPIENCODE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE))
|
||||
|
||||
#define GST_VAAPIENCODE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
GST_TYPE_VAAPIENCODE, \
|
||||
GstVaapiEncodeClass))
|
||||
|
||||
#define GST_VAAPIENCODE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
GST_TYPE_VAAPIENCODE, \
|
||||
GstVaapiEncode))
|
||||
|
||||
#define GST_VAAPIENCODE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
GST_TYPE_VAAPIENCODE, \
|
||||
GstVaapiEncodeClass))
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE))
|
||||
|
||||
typedef struct _GstVaapiEncode GstVaapiEncode;
|
||||
typedef struct _GstVaapiEncodeClass GstVaapiEncodeClass;
|
||||
|
||||
struct _GstVaapiEncode
|
||||
{
|
||||
/*< private > */
|
||||
/*< private >*/
|
||||
GstVideoEncoder parent_instance;
|
||||
|
||||
GstPad *sinkpad;
|
||||
|
@ -82,7 +73,7 @@ struct _GstVaapiEncode
|
|||
|
||||
struct _GstVaapiEncodeClass
|
||||
{
|
||||
/*< private > */
|
||||
/*< private >*/
|
||||
GstVideoEncoderClass parent_class;
|
||||
|
||||
GstVaapiEncoder * (*create_encoder) (GstVaapiEncode * encode,
|
||||
|
|
|
@ -20,18 +20,13 @@
|
|||
*/
|
||||
|
||||
#include "gst/vaapi/sysdeps.h"
|
||||
#include "gst/vaapi/gstvaapicompat.h"
|
||||
|
||||
#include <gst/vaapi/gstvaapivalue.h>
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include <gst/vaapi/gstvaapiencoder_h264.h>
|
||||
#include "gst/vaapi/gstvaapiencoder_h264_priv.h"
|
||||
#include "gstvaapiencode_h264.h"
|
||||
#include "gstvaapipluginutil.h"
|
||||
#include "gstvaapivideomemory.h"
|
||||
#include "gst/vaapi/gstvaapiencoder_h264.h"
|
||||
#include "gst/vaapi/gstvaapiencoder_h264_priv.h"
|
||||
#include "gst/vaapi/gstvaapidisplay.h"
|
||||
#include "gst/vaapi/gstvaapivalue.h"
|
||||
#include "gst/vaapi/gstvaapisurface.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_vaapi_h264_encode_debug);
|
||||
#define GST_CAT_DEFAULT gst_vaapi_h264_encode_debug
|
||||
|
@ -69,14 +64,14 @@ G_DEFINE_TYPE (GstVaapiEncodeH264, gst_vaapiencode_h264, GST_TYPE_VAAPIENCODE)
|
|||
|
||||
enum
|
||||
{
|
||||
H264_PROP_0,
|
||||
H264_PROP_RATE_CONTROL,
|
||||
H264_PROP_BITRATE,
|
||||
H264_PROP_KEY_PERIOD,
|
||||
H264_PROP_MAX_BFRAMES,
|
||||
H264_PROP_INIT_QP,
|
||||
H264_PROP_MIN_QP,
|
||||
H264_PROP_NUM_SLICES,
|
||||
PROP_0,
|
||||
PROP_RATE_CONTROL,
|
||||
PROP_BITRATE,
|
||||
PROP_KEY_PERIOD,
|
||||
PROP_MAX_BFRAMES,
|
||||
PROP_INIT_QP,
|
||||
PROP_MIN_QP,
|
||||
PROP_NUM_SLICES,
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -94,28 +89,28 @@ static void
|
|||
gst_vaapiencode_h264_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264 (object);
|
||||
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264_CAST (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case H264_PROP_RATE_CONTROL:
|
||||
case PROP_RATE_CONTROL:
|
||||
encode->rate_control = g_value_get_enum (value);
|
||||
break;
|
||||
case H264_PROP_BITRATE:
|
||||
case PROP_BITRATE:
|
||||
encode->bitrate = g_value_get_uint (value);
|
||||
break;
|
||||
case H264_PROP_KEY_PERIOD:
|
||||
case PROP_KEY_PERIOD:
|
||||
encode->intra_period = g_value_get_uint (value);
|
||||
break;
|
||||
case H264_PROP_INIT_QP:
|
||||
case PROP_INIT_QP:
|
||||
encode->init_qp = g_value_get_uint (value);
|
||||
break;
|
||||
case H264_PROP_MIN_QP:
|
||||
case PROP_MIN_QP:
|
||||
encode->min_qp = g_value_get_uint (value);
|
||||
break;
|
||||
case H264_PROP_NUM_SLICES:
|
||||
case PROP_NUM_SLICES:
|
||||
encode->num_slices = g_value_get_uint (value);
|
||||
break;
|
||||
case H264_PROP_MAX_BFRAMES:
|
||||
case PROP_MAX_BFRAMES:
|
||||
encode->max_bframes = g_value_get_uint (value);
|
||||
break;
|
||||
default:
|
||||
|
@ -128,28 +123,28 @@ static void
|
|||
gst_vaapiencode_h264_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264 (object);
|
||||
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264_CAST (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case H264_PROP_RATE_CONTROL:
|
||||
case PROP_RATE_CONTROL:
|
||||
g_value_set_enum (value, encode->rate_control);
|
||||
break;
|
||||
case H264_PROP_BITRATE:
|
||||
case PROP_BITRATE:
|
||||
g_value_set_uint (value, encode->bitrate);
|
||||
break;
|
||||
case H264_PROP_KEY_PERIOD:
|
||||
case PROP_KEY_PERIOD:
|
||||
g_value_set_uint (value, encode->intra_period);
|
||||
break;
|
||||
case H264_PROP_INIT_QP:
|
||||
case PROP_INIT_QP:
|
||||
g_value_set_uint (value, encode->init_qp);
|
||||
break;
|
||||
case H264_PROP_MIN_QP:
|
||||
case PROP_MIN_QP:
|
||||
g_value_set_uint (value, encode->min_qp);
|
||||
break;
|
||||
case H264_PROP_NUM_SLICES:
|
||||
case PROP_NUM_SLICES:
|
||||
g_value_set_uint (value, encode->num_slices);
|
||||
break;
|
||||
case H264_PROP_MAX_BFRAMES:
|
||||
case PROP_MAX_BFRAMES:
|
||||
g_value_set_uint (value, encode->max_bframes);
|
||||
break;
|
||||
default:
|
||||
|
@ -162,23 +157,25 @@ static GstVaapiEncoder *
|
|||
gst_vaapiencode_h264_create_encoder (GstVaapiEncode * base,
|
||||
GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264 (base);
|
||||
GstVaapiEncoder *ret;
|
||||
GstVaapiEncoderH264 *h264encoder;
|
||||
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264_CAST (base);
|
||||
GstVaapiEncoder *base_encoder;
|
||||
GstVaapiEncoderH264 *encoder;
|
||||
|
||||
ret = gst_vaapi_encoder_h264_new (display);
|
||||
h264encoder = GST_VAAPI_ENCODER_H264 (ret);
|
||||
base_encoder = gst_vaapi_encoder_h264_new (display);
|
||||
if (!base_encoder)
|
||||
return NULL;
|
||||
encoder = GST_VAAPI_ENCODER_H264 (base_encoder);
|
||||
|
||||
h264encoder->profile = GST_VAAPI_PROFILE_UNKNOWN;
|
||||
h264encoder->level = GST_VAAPI_ENCODER_H264_DEFAULT_LEVEL;
|
||||
GST_VAAPI_ENCODER_RATE_CONTROL (h264encoder) = encode->rate_control;
|
||||
h264encoder->bitrate = encode->bitrate;
|
||||
h264encoder->intra_period = encode->intra_period;
|
||||
h264encoder->init_qp = encode->init_qp;
|
||||
h264encoder->min_qp = encode->min_qp;
|
||||
h264encoder->slice_num = encode->num_slices;
|
||||
h264encoder->b_frame_num = encode->max_bframes;
|
||||
return ret;
|
||||
encoder->profile = GST_VAAPI_PROFILE_UNKNOWN;
|
||||
encoder->level = GST_VAAPI_ENCODER_H264_DEFAULT_LEVEL;
|
||||
GST_VAAPI_ENCODER_RATE_CONTROL (encoder) = encode->rate_control;
|
||||
encoder->bitrate = encode->bitrate;
|
||||
encoder->intra_period = encode->intra_period;
|
||||
encoder->init_qp = encode->init_qp;
|
||||
encoder->min_qp = encode->min_qp;
|
||||
encoder->slice_num = encode->num_slices;
|
||||
encoder->b_frame_num = encode->max_bframes;
|
||||
return base_encoder;
|
||||
}
|
||||
|
||||
/* h264 NAL byte stream operations */
|
||||
|
@ -292,7 +289,7 @@ gst_vaapiencode_h264_alloc_buffer (GstVaapiEncode * encode,
|
|||
if (!gst_vaapi_encoder_h264_is_avc (h264encoder))
|
||||
return ret;
|
||||
|
||||
/* convert to avc format */
|
||||
/* Convert to avcC format */
|
||||
if (!_h264_convert_byte_stream_to_avc (*out_buf)) {
|
||||
GST_ERROR ("convert H.264 bytestream to avc buf failed.");
|
||||
gst_buffer_replace (out_buf, NULL);
|
||||
|
@ -333,7 +330,7 @@ gst_vaapiencode_h264_class_init (GstVaapiEncodeH264Class * klass)
|
|||
);
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
H264_PROP_RATE_CONTROL,
|
||||
PROP_RATE_CONTROL,
|
||||
g_param_spec_enum ("rate-control",
|
||||
"Rate Control",
|
||||
"Rate control mode",
|
||||
|
@ -342,14 +339,14 @@ gst_vaapiencode_h264_class_init (GstVaapiEncodeH264Class * klass)
|
|||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
H264_PROP_BITRATE,
|
||||
PROP_BITRATE,
|
||||
g_param_spec_uint ("bitrate",
|
||||
"Bitrate (kbps)",
|
||||
"The desired bitrate expressed in kbps (0: auto-calculate)",
|
||||
0, 100 * 1024, 0, G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
H264_PROP_KEY_PERIOD,
|
||||
PROP_KEY_PERIOD,
|
||||
g_param_spec_uint ("key-period",
|
||||
"Key Period",
|
||||
"Maximal distance between two key-frames",
|
||||
|
@ -357,27 +354,27 @@ gst_vaapiencode_h264_class_init (GstVaapiEncodeH264Class * klass)
|
|||
300, GST_VAAPI_ENCODER_H264_DEFAULT_INTRA_PERIOD, G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
H264_PROP_MAX_BFRAMES,
|
||||
PROP_MAX_BFRAMES,
|
||||
g_param_spec_uint ("max-bframes",
|
||||
"Max B-Frames",
|
||||
"Number of B-frames between I and P", 0, 10, 0, G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
H264_PROP_INIT_QP,
|
||||
PROP_INIT_QP,
|
||||
g_param_spec_uint ("init-qp",
|
||||
"Initial QP",
|
||||
"Initial quantizer value",
|
||||
1, 51, GST_VAAPI_ENCODER_H264_DEFAULT_INIT_QP, G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
H264_PROP_MIN_QP,
|
||||
PROP_MIN_QP,
|
||||
g_param_spec_uint ("min-qp",
|
||||
"Minimum QP",
|
||||
"Minimum quantizer value",
|
||||
1, 51, GST_VAAPI_ENCODER_H264_DEFAULT_MIN_QP, G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
H264_PROP_NUM_SLICES,
|
||||
PROP_NUM_SLICES,
|
||||
g_param_spec_uint ("num-slices",
|
||||
"Number of Slices", "Number of slices per frame", 1, 200,
|
||||
1, G_PARAM_READWRITE));
|
||||
|
|
|
@ -29,32 +29,29 @@ G_BEGIN_DECLS
|
|||
|
||||
#define GST_TYPE_VAAPIENCODE_H264 \
|
||||
(gst_vaapiencode_h264_get_type ())
|
||||
#define GST_VAAPIENCODE_H264_CAST(obj) \
|
||||
((GstVaapiEncodeH264 *)(obj))
|
||||
#define GST_VAAPIENCODE_H264(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPIENCODE_H264, \
|
||||
GstVaapiEncodeH264))
|
||||
#define GST_VAAPIENCODE_H264_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPIENCODE_H264, \
|
||||
GstVaapiEncodeH264Class))
|
||||
#define GST_VAAPIENCODE_H264_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPIENCODE_H264, \
|
||||
GstVaapiEncodeH264Class))
|
||||
#define GST_IS_VAAPIENCODE_H264(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPIENCODE_H264))
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPIENCODE_H264))
|
||||
#define GST_IS_VAAPIENCODE_H264_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE_H264))
|
||||
|
||||
#define GST_VAAPIENCODE_H264_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
GST_TYPE_VAAPIENCODE_H264, \
|
||||
GstVaapiEncodeH264Class))
|
||||
|
||||
#define GST_VAAPIENCODE_H264(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
GST_TYPE_VAAPIENCODE_H264, \
|
||||
GstVaapiEncodeH264))
|
||||
|
||||
#define GST_VAAPIENCODE_H264_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
GST_TYPE_VAAPIENCODE_H264, \
|
||||
GstVaapiEncodeH264Class))
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE_H264))
|
||||
|
||||
typedef struct _GstVaapiEncodeH264 GstVaapiEncodeH264;
|
||||
typedef struct _GstVaapiEncodeH264Class GstVaapiEncodeH264Class;
|
||||
|
||||
struct _GstVaapiEncodeH264
|
||||
{
|
||||
GstVaapiEncode parent;
|
||||
/*< private >*/
|
||||
GstVaapiEncode parent_instance;
|
||||
|
||||
GstVaapiProfile profile;
|
||||
guint32 level;
|
||||
|
@ -69,6 +66,7 @@ struct _GstVaapiEncodeH264
|
|||
|
||||
struct _GstVaapiEncodeH264Class
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiEncodeClass parent_class;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,18 +20,13 @@
|
|||
*/
|
||||
|
||||
#include "gst/vaapi/sysdeps.h"
|
||||
#include "gst/vaapi/gstvaapicompat.h"
|
||||
|
||||
#include <gst/vaapi/gstvaapivalue.h>
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include <gst/vaapi/gstvaapiencoder_mpeg2.h>
|
||||
#include "gst/vaapi/gstvaapiencoder_mpeg2_priv.h"
|
||||
#include "gstvaapiencode_mpeg2.h"
|
||||
#include "gstvaapipluginutil.h"
|
||||
#include "gstvaapivideomemory.h"
|
||||
#include "gst/vaapi/gstvaapiencoder_mpeg2.h"
|
||||
#include "gst/vaapi/gstvaapiencoder_mpeg2_priv.h"
|
||||
#include "gst/vaapi/gstvaapidisplay.h"
|
||||
#include "gst/vaapi/gstvaapivalue.h"
|
||||
#include "gst/vaapi/gstvaapisurface.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_vaapi_mpeg2_encode_debug);
|
||||
#define GST_CAT_DEFAULT gst_vaapi_mpeg2_encode_debug
|
||||
|
@ -98,7 +93,7 @@ static void
|
|||
gst_vaapiencode_mpeg2_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2 (object);
|
||||
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2_CAST (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_RATE_CONTROL:
|
||||
|
@ -134,7 +129,7 @@ static void
|
|||
gst_vaapiencode_mpeg2_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2 (object);
|
||||
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2_CAST (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_RATE_CONTROL:
|
||||
|
@ -162,22 +157,23 @@ static GstVaapiEncoder *
|
|||
gst_vaapiencode_mpeg2_create_encoder (GstVaapiEncode * base,
|
||||
GstVaapiDisplay * display)
|
||||
{
|
||||
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2 (base);
|
||||
GstVaapiEncoder *ret;
|
||||
GstVaapiEncoderMpeg2 *mpeg2encoder;
|
||||
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2_CAST (base);
|
||||
GstVaapiEncoder *base_encoder;
|
||||
GstVaapiEncoderMpeg2 *encoder;
|
||||
|
||||
ret = gst_vaapi_encoder_mpeg2_new (display);
|
||||
mpeg2encoder = GST_VAAPI_ENCODER_MPEG2 (ret);
|
||||
base_encoder = gst_vaapi_encoder_mpeg2_new (display);
|
||||
if (!base_encoder)
|
||||
return NULL;
|
||||
encoder = GST_VAAPI_ENCODER_MPEG2 (base_encoder);
|
||||
|
||||
mpeg2encoder->profile = GST_VAAPI_ENCODER_MPEG2_DEFAULT_PROFILE;
|
||||
mpeg2encoder->level = GST_VAAPI_ENCODER_MPEG2_DEFAULT_LEVEL;
|
||||
GST_VAAPI_ENCODER_RATE_CONTROL (mpeg2encoder) = encode->rate_control;
|
||||
mpeg2encoder->bitrate = encode->bitrate;
|
||||
mpeg2encoder->cqp = encode->quantizer;
|
||||
mpeg2encoder->intra_period = encode->intra_period;
|
||||
mpeg2encoder->ip_period = encode->ip_period;
|
||||
|
||||
return ret;
|
||||
encoder->profile = GST_VAAPI_ENCODER_MPEG2_DEFAULT_PROFILE;
|
||||
encoder->level = GST_VAAPI_ENCODER_MPEG2_DEFAULT_LEVEL;
|
||||
GST_VAAPI_ENCODER_RATE_CONTROL (encoder) = encode->rate_control;
|
||||
encoder->bitrate = encode->bitrate;
|
||||
encoder->cqp = encode->quantizer;
|
||||
encoder->intra_period = encode->intra_period;
|
||||
encoder->ip_period = encode->ip_period;
|
||||
return base_encoder;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -28,33 +28,30 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_VAAPIENCODE_MPEG2 \
|
||||
(gst_vaapiencode_mpeg2_get_type())
|
||||
(gst_vaapiencode_mpeg2_get_type ())
|
||||
#define GST_VAAPIENCODE_MPEG2_CAST(obj) \
|
||||
((GstVaapiEncodeMpeg2 *)(obj))
|
||||
#define GST_VAAPIENCODE_MPEG2(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPIENCODE_MPEG2, \
|
||||
GstVaapiEncodeMpeg2))
|
||||
#define GST_VAAPIENCODE_MPEG2_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPIENCODE_MPEG2, \
|
||||
GstVaapiEncodeMpeg2Class))
|
||||
#define GST_VAAPIENCODE_MPEG2_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VAAPIENCODE_MPEG2, \
|
||||
GstVaapiEncodeMpeg2Class))
|
||||
#define GST_IS_VAAPIENCODE_MPEG2(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPIENCODE_MPEG2))
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPIENCODE_MPEG2))
|
||||
#define GST_IS_VAAPIENCODE_MPEG2_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE_MPEG2))
|
||||
|
||||
#define GST_VAAPIENCODE_MPEG2_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||
GST_TYPE_VAAPIENCODE_MPEG2, \
|
||||
GstVaapiEncodeMpeg2Class))
|
||||
|
||||
#define GST_VAAPIENCODE_MPEG2(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||
GST_TYPE_VAAPIENCODE_MPEG2, \
|
||||
GstVaapiEncodeMpeg2))
|
||||
|
||||
#define GST_VAAPIENCODE_MPEG2_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||
GST_TYPE_VAAPIENCODE_MPEG2, \
|
||||
GstVaapiEncodeMpeg2Class))
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VAAPIENCODE_MPEG2))
|
||||
|
||||
typedef struct _GstVaapiEncodeMpeg2 GstVaapiEncodeMpeg2;
|
||||
typedef struct _GstVaapiEncodeMpeg2Class GstVaapiEncodeMpeg2Class;
|
||||
|
||||
struct _GstVaapiEncodeMpeg2
|
||||
{
|
||||
GstVaapiEncode parent;
|
||||
/*< private >*/
|
||||
GstVaapiEncode parent_instance;
|
||||
|
||||
GstVaapiRateControl rate_control;
|
||||
guint32 bitrate; /* kbps */
|
||||
|
@ -65,6 +62,7 @@ struct _GstVaapiEncodeMpeg2
|
|||
|
||||
struct _GstVaapiEncodeMpeg2Class
|
||||
{
|
||||
/*< private >*/
|
||||
GstVaapiEncodeClass parent_class;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue