*/
#include "gst/vaapi/sysdeps.h"
+#include <gst/vaapi/gstvaapivalue.h>
#include <gst/vaapi/gstvaapidisplay.h>
#include <gst/vaapi/gstvaapiencoder_priv.h>
#include <gst/vaapi/gstvaapiencoder_objects.h>
#endif
)
+enum
+{
+ PROP_0,
+ PROP_RATE_CONTROL,
+ PROP_BITRATE,
+};
+
static inline gboolean
ensure_display (GstVaapiEncode * encode)
{
}
#endif
+static inline gboolean
+check_ratecontrol (GstVaapiEncode * encode, GstVaapiRateControl rate_control)
+{
+ GstVaapiEncodeClass *const klass = GST_VAAPIENCODE_GET_CLASS (encode);
+
+ return !klass->check_ratecontrol || klass->check_ratecontrol (encode,
+ rate_control);
+}
+
+static void
+gst_vaapiencode_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (object);
+
+ switch (prop_id) {
+ case PROP_RATE_CONTROL:
+ {
+ GstVaapiRateControl rate_control = g_value_get_enum (value);
+ if (check_ratecontrol (encode, rate_control)) {
+ encode->rate_control = rate_control;
+ } else {
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+ break;
+ }
+ case PROP_BITRATE:
+ encode->bitrate = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_vaapiencode_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (object);
+
+ switch (prop_id) {
+ case PROP_RATE_CONTROL:
+ g_value_set_enum (value, encode->rate_control);
+ break;
+ case PROP_BITRATE:
+ g_value_set_uint (value, encode->bitrate);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
static void
gst_vaapiencode_finalize (GObject * object)
{
GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
object_class->finalize = gst_vaapiencode_finalize;
+ object_class->set_property = gst_vaapiencode_set_property;
+ object_class->get_property = gst_vaapiencode_get_property;
#if GST_CHECK_VERSION(1,1,0)
element_class->set_context = GST_DEBUG_FUNCPTR (gst_vaapiencode_set_context);
/* Registering debug symbols for function pointers */
GST_DEBUG_REGISTER_FUNCPTR (gst_vaapiencode_query);
+
+ g_object_class_install_property (object_class,
+ PROP_RATE_CONTROL,
+ g_param_spec_enum ("rate-control",
+ "Rate Control",
+ "Rate control mode",
+ GST_VAAPI_TYPE_RATE_CONTROL,
+ GST_VAAPI_RATECONTROL_NONE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class,
+ 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_PARAM_STATIC_STRINGS));
}
#endif
guint video_buffer_size;
+ GstVaapiRateControl rate_control;
+ guint32 bitrate; /* kbps */
+
guint32 is_running:1;
guint32 out_caps_done:1;
};
/*< private >*/
GstVideoEncoderClass parent_class;
+ gboolean (*check_ratecontrol) (GstVaapiEncode * encode,
+ GstVaapiRateControl rate_control);
GstVaapiEncoder * (*create_encoder) (GstVaapiEncode * encode,
GstVaapiDisplay * display);
GstFlowReturn (*allocate_buffer) (GstVaapiEncode * encode,
*/
#include "gst/vaapi/sysdeps.h"
-#include <gst/vaapi/gstvaapivalue.h>
#include <gst/vaapi/gstvaapidisplay.h>
#include <gst/vaapi/gstvaapiencoder_h264.h>
#include "gst/vaapi/gstvaapiencoder_h264_priv.h"
enum
{
PROP_0,
- PROP_RATE_CONTROL,
- PROP_BITRATE,
PROP_KEY_PERIOD,
PROP_MAX_BFRAMES,
PROP_INIT_QP,
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264_CAST (object);
switch (prop_id) {
- case PROP_RATE_CONTROL:
- encode->rate_control = g_value_get_enum (value);
- break;
- case PROP_BITRATE:
- encode->bitrate = g_value_get_uint (value);
- break;
case PROP_KEY_PERIOD:
encode->intra_period = g_value_get_uint (value);
break;
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264_CAST (object);
switch (prop_id) {
- case PROP_RATE_CONTROL:
- g_value_set_enum (value, encode->rate_control);
- break;
- case PROP_BITRATE:
- g_value_set_uint (value, encode->bitrate);
- break;
case PROP_KEY_PERIOD:
g_value_set_uint (value, encode->intra_period);
break;
GstVaapiDisplay * display)
{
GstVaapiEncodeH264 *const encode = GST_VAAPIENCODE_H264_CAST (base);
+ GstVaapiEncode *const base_encode = GST_VAAPIENCODE_CAST (base);
GstVaapiEncoder *base_encoder;
GstVaapiEncoderH264 *encoder;
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;
+ GST_VAAPI_ENCODER_RATE_CONTROL (encoder) = base_encode->rate_control;
+ encoder->bitrate = base_encode->bitrate;
encoder->intra_period = encode->intra_period;
encoder->init_qp = encode->init_qp;
encoder->min_qp = encode->min_qp;
);
g_object_class_install_property (object_class,
- PROP_RATE_CONTROL,
- g_param_spec_enum ("rate-control",
- "Rate Control",
- "Rate control mode",
- GST_VAAPI_TYPE_RATE_CONTROL,
- GST_VAAPI_RATECONTROL_NONE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- 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,
PROP_KEY_PERIOD,
g_param_spec_uint ("key-period",
"Key Period",
GstVaapiProfile profile;
guint32 level;
- GstVaapiRateControl rate_control;
- guint32 bitrate; /* kbps */
guint32 intra_period;
guint32 init_qp;
guint32 min_qp;
*/
#include "gst/vaapi/sysdeps.h"
-#include <gst/vaapi/gstvaapivalue.h>
#include <gst/vaapi/gstvaapidisplay.h>
#include <gst/vaapi/gstvaapiencoder_mpeg2.h>
#include "gst/vaapi/gstvaapiencoder_mpeg2_priv.h"
enum
{
PROP_0,
- PROP_RATE_CONTROL,
- PROP_BITRATE,
PROP_QUANTIZER,
PROP_KEY_PERIOD,
PROP_MAX_BFRAMES
static void
gst_vaapiencode_mpeg2_init (GstVaapiEncodeMpeg2 * mpeg2_encode)
{
- mpeg2_encode->rate_control = GST_VAAPI_ENCODER_MPEG2_DEFAULT_RATE_CONTROL;
- mpeg2_encode->bitrate = 0;
+ GstVaapiEncode *const base_encode = GST_VAAPIENCODE_CAST (mpeg2_encode);
+
+ base_encode->rate_control = GST_VAAPI_ENCODER_MPEG2_DEFAULT_RATE_CONTROL;
mpeg2_encode->quantizer = GST_VAAPI_ENCODER_MPEG2_DEFAULT_CQP;
mpeg2_encode->intra_period = GST_VAAPI_ENCODER_MPEG2_DEFAULT_GOP_SIZE;
mpeg2_encode->ip_period = GST_VAAPI_ENCODER_MPEG2_DEFAULT_MAX_BFRAMES;
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2_CAST (object);
switch (prop_id) {
- case PROP_RATE_CONTROL:
- {
- GstVaapiRateControl rate_control = g_value_get_enum (value);
- if (rate_control == GST_VAAPI_RATECONTROL_CBR ||
- rate_control == GST_VAAPI_RATECONTROL_CQP) {
- encode->rate_control = g_value_get_enum (value);
- } else {
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
- break;
- }
- case PROP_BITRATE:
- encode->bitrate = g_value_get_uint (value);
- break;
case PROP_QUANTIZER:
encode->quantizer = g_value_get_uint (value);
break;
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2_CAST (object);
switch (prop_id) {
- case PROP_RATE_CONTROL:
- g_value_set_enum (value, encode->rate_control);
- break;
- case PROP_BITRATE:
- g_value_set_uint (value, encode->bitrate);
- break;
case PROP_QUANTIZER:
g_value_set_uint (value, encode->quantizer);
break;
GstVaapiDisplay * display)
{
GstVaapiEncodeMpeg2 *encode = GST_VAAPIENCODE_MPEG2_CAST (base);
+ GstVaapiEncode *const base_encode = GST_VAAPIENCODE_CAST (base);
GstVaapiEncoder *base_encoder;
GstVaapiEncoderMpeg2 *encoder;
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;
+ GST_VAAPI_ENCODER_RATE_CONTROL (encoder) = base_encode->rate_control;
+ encoder->bitrate = base_encode->bitrate;
encoder->cqp = encode->quantizer;
encoder->intra_period = encode->intra_period;
encoder->ip_period = encode->ip_period;
return base_encoder;
}
+static gboolean
+gst_vaapiencode_mpeg2_check_ratecontrol (GstVaapiEncode * encode,
+ GstVaapiRateControl rate_control)
+{
+ /* XXX: get information from GstVaapiEncoder object */
+ return rate_control == GST_VAAPI_RATECONTROL_CQP ||
+ rate_control == GST_VAAPI_RATECONTROL_CBR;
+}
+
static void
gst_vaapiencode_mpeg2_class_init (GstVaapiEncodeMpeg2Class * klass)
{
object_class->get_property = gst_vaapiencode_mpeg2_get_property;
encode_class->create_encoder = gst_vaapiencode_mpeg2_create_encoder;
+ encode_class->check_ratecontrol = gst_vaapiencode_mpeg2_check_ratecontrol;
gst_element_class_set_static_metadata (element_class,
"VA-API MPEG-2 encoder",
);
g_object_class_install_property (object_class,
- PROP_RATE_CONTROL,
- g_param_spec_enum ("rate-control",
- "Rate Control",
- "Rate control mode (CQP or CBR only)",
- GST_VAAPI_TYPE_RATE_CONTROL,
- GST_VAAPI_RATECONTROL_NONE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_BITRATE,
- g_param_spec_uint ("bitrate",
- "Bitrate (kbps)",
- "The desired bitrate expressed in kbps (0: auto-calculate)",
- 0, GST_VAAPI_ENCODER_MPEG2_MAX_BITRATE, 0, G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
PROP_QUANTIZER,
g_param_spec_uint ("quantizer",
"Constant Quantizer",
/*< private >*/
GstVaapiEncode parent_instance;
- GstVaapiRateControl rate_control;
- guint32 bitrate; /* kbps */
guint32 quantizer;
guint32 intra_period;
guint32 ip_period;