2 * gstvaapiencode_mpeg4.c - VA-API MPEG-4 encoder
4 * Copyright (C) 2011 Intel Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
22 #include "gstvaapiencode_mpeg4.h"
23 #include "gst/vaapi/gstvaapiencoder_mpeg4.h"
25 GST_DEBUG_CATEGORY_STATIC (gst_vaapi_encode_mpeg4_debug);
26 #define GST_CAT_DEFAULT gst_vaapi_encode_mpeg4_debug
29 static const char gst_vaapi_encode_mpeg4_sink_caps_str[] =
30 GST_VAAPI_SURFACE_CAPS "; "
31 GST_VAAPI_BUFFER_SHARING_CAPS;
33 static const GstElementDetails gst_vaapi_encode_mpeg4_details =
35 "VA-API mpeg4 encoder",
36 "Codec/Encoder/Video",
37 "A VA-API based mpeg4 encoder",
38 "Feng Yuan<feng.yuan@intel.com>");
41 static const char gst_vaapi_encode_mpeg4_src_caps_str[] =
42 GST_CAPS_CODEC("video/mpeg, mpegversion=4");
44 static GstStaticPadTemplate gst_vaapi_encode_mpeg4_sink_factory =
45 GST_STATIC_PAD_TEMPLATE(
49 GST_STATIC_CAPS(gst_vaapi_encode_mpeg4_sink_caps_str));
51 static GstStaticPadTemplate gst_vaapi_encode_mpeg4_src_factory =
52 GST_STATIC_PAD_TEMPLATE(
56 GST_STATIC_CAPS(gst_vaapi_encode_mpeg4_src_caps_str));
62 gst_vaapi_encode_mpeg4,
64 GST_TYPE_VAAPI_ENCODE)
70 MPEG4_PROP_INTRA_PERIOD,
76 gst_vaapi_encode_mpeg4_init(
77 GstVaapiEncodeMpeg4 *mpeg4_encode,
78 GstVaapiEncodeMpeg4Class *klass)
80 GstVaapiEncode *encode = GST_VAAPI_ENCODE(mpeg4_encode);
81 encode->encoder = GST_VAAPI_ENCODER(gst_vaapi_encoder_mpeg4_new());
82 ENCODER_ASSERT(encode->encoder);
86 gst_vaapi_encode_mpeg4_finalize(GObject *object)
88 //GstVaapiEncodeMpeg4 * const mpeg4_encode = GST_VAAPI_ENCODE_MPEG4(object);
89 G_OBJECT_CLASS(parent_class)->finalize(object);
93 gst_vaapi_encode_mpeg4_set_property(
100 GstVaapiEncode *encode = GST_VAAPI_ENCODE(object);
101 GstVaapiEncoderMpeg4 *mpeg4encoder = GST_VAAPI_ENCODER_MPEG4(encode->encoder);
103 ENCODER_ASSERT(mpeg4encoder);
106 case MPEG4_PROP_PROFILE: {
107 mpeg4encoder->profile = g_value_get_uint(value);
111 case MPEG4_PROP_BITRATE: {
112 mpeg4encoder->bitrate = g_value_get_uint(value);
116 case MPEG4_PROP_INTRA_PERIOD: {
117 mpeg4encoder->intra_period = g_value_get_uint(value);
121 case MPEG4_PROP_INIT_QP: {
122 mpeg4encoder->init_qp = g_value_get_uint(value);
126 case MPEG4_PROP_MIN_QP: {
127 mpeg4encoder->min_qp = g_value_get_uint(value);
132 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
138 gst_vaapi_encode_mpeg4_get_property(
145 GstVaapiEncode *encode = GST_VAAPI_ENCODE(object);
146 GstVaapiEncoderMpeg4 *mpeg4encoder = GST_VAAPI_ENCODER_MPEG4(encode->encoder);
147 ENCODER_ASSERT(mpeg4encoder);
150 case MPEG4_PROP_PROFILE:
151 g_value_set_uint (value, mpeg4encoder->profile);
154 case MPEG4_PROP_BITRATE:
155 g_value_set_uint (value, mpeg4encoder->bitrate);
158 case MPEG4_PROP_INTRA_PERIOD:
159 g_value_set_uint (value, mpeg4encoder->intra_period);
162 case MPEG4_PROP_INIT_QP:
163 g_value_set_uint (value, mpeg4encoder->init_qp);
166 case MPEG4_PROP_MIN_QP:
167 g_value_set_uint (value, mpeg4encoder->min_qp);
171 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
177 gst_vaapi_encode_mpeg4_base_init(gpointer klass)
179 GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
181 gst_element_class_set_details(element_class, &gst_vaapi_encode_mpeg4_details);
184 gst_element_class_add_pad_template(
186 gst_static_pad_template_get(&gst_vaapi_encode_mpeg4_sink_factory)
190 gst_element_class_add_pad_template(
192 gst_static_pad_template_get(&gst_vaapi_encode_mpeg4_src_factory)
197 gst_vaapi_encode_mpeg4_class_init(GstVaapiEncodeMpeg4Class *klass)
199 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
201 GST_DEBUG_CATEGORY_INIT (gst_vaapi_encode_mpeg4_debug,
204 "vaapimpeg4encode element");
206 object_class->finalize = gst_vaapi_encode_mpeg4_finalize;
207 object_class->set_property = gst_vaapi_encode_mpeg4_set_property;
208 object_class->get_property = gst_vaapi_encode_mpeg4_get_property;
211 g_object_class_install_property (
217 "Profile supports: 2(Baseline), 3(ASP)",
223 g_object_class_install_property (
228 "MPEG4 encoding bitrate(kpbs)",
229 "MPEG4 encoding bitrate(kpbs), (0, auto-calculate)",
235 g_object_class_install_property (
237 MPEG4_PROP_INTRA_PERIOD,
240 "MPEG4 encoding intra-period",
241 "MPEG4 encoding intra-period",
244 MPEG4_DEFAULT_INTRA_PERIOD,
247 g_object_class_install_property (
256 MPEG4_DEFAULT_INIT_QP,
259 g_object_class_install_property (
268 MPEG4_DEFAULT_MIN_QP,