summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2016-07-18 18:36:42 +0100
committerTim-Philipp Müller <tim@centricular.com>2016-08-13 16:38:02 +0100
commit934d645de327045a3b16079d8ab0b8817891420d (patch)
tree108f122cc65fe4f7d67a7c5841ee13cd52e31eba
parent0c4e6ee20113d28416412a805085559b7a0c4e46 (diff)
downloadgstreamer-plugins-bad-934d645de327045a3b16079d8ab0b8817891420d.tar.gz
openh264: fix up for API changes in v1.6.0
Update for API changes in v1.6.0. https://bugzilla.gnome.org/show_bug.cgi?id=768771
-rw-r--r--ext/openh264/gstopenh264dec.cpp2
-rw-r--r--ext/openh264/gstopenh264enc.cpp50
-rw-r--r--ext/openh264/gstopenh264enc.h7
3 files changed, 47 insertions, 12 deletions
diff --git a/ext/openh264/gstopenh264dec.cpp b/ext/openh264/gstopenh264dec.cpp
index 6333fe497..a10e38eb5 100644
--- a/ext/openh264/gstopenh264dec.cpp
+++ b/ext/openh264/gstopenh264dec.cpp
@@ -191,7 +191,9 @@ gst_openh264dec_start (GstVideoDecoder * decoder)
dec_param.uiTargetDqLayer = 255;
dec_param.eEcActiveIdc = ERROR_CON_FRAME_COPY;
+#if OPENH264_MAJOR == 1 && OPENH264_MINOR < 6
dec_param.eOutputColorFormat = videoFormatI420;
+#endif
dec_param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
ret = openh264dec->priv->decoder->Initialize (&dec_param);
diff --git a/ext/openh264/gstopenh264enc.cpp b/ext/openh264/gstopenh264enc.cpp
index d48193fc4..8411e37dc 100644
--- a/ext/openh264/gstopenh264enc.cpp
+++ b/ext/openh264/gstopenh264enc.cpp
@@ -46,6 +46,8 @@
GST_DEBUG_CATEGORY_STATIC (gst_openh264enc_debug_category);
#define GST_CAT_DEFAULT gst_openh264enc_debug_category
+/* FIXME: we should not really directly use the enums from the openh264 API
+ * here, since it might change or be removed */
#define GST_TYPE_USAGE_TYPE (gst_openh264enc_usage_type_get_type ())
static GType
gst_openh264enc_usage_type_get_type (void)
@@ -119,15 +121,15 @@ static GType
gst_openh264enc_slice_mode_get_type (void)
{
static const GEnumValue types[] = {
- {SM_FIXEDSLCNUM_SLICE, "num-slices slices", "n-slices"},
- {SM_AUTO_SLICE, "Number of slices equal to number of threads", "auto"},
+ {GST_OPENH264_SLICE_MODE_N_SLICES, "Fixed number of slices", "n-slices"},
+ {GST_OPENH264_SLICE_MODE_AUTO, "Number of slices equal to number of threads", "auto"},
{0, NULL, NULL},
};
static gsize id = 0;
- if (g_once_init_enter (& id)) {
- GType _id = g_enum_register_static ("GstOpenh264encSliceModes", types);
- g_once_init_leave (& id, _id);
+ if (g_once_init_enter (&id)) {
+ GType _id = g_enum_register_static ("GstOpenh264EncSliceMode", types);
+ g_once_init_leave (&id, _id);
}
return (GType) id;
@@ -189,7 +191,7 @@ static void gst_openh264enc_set_rate_control (GstOpenh264Enc * openh264enc,
#define DEFAULT_BACKGROUND_DETECTION TRUE
#define DEFAULT_ADAPTIVE_QUANTIZATION TRUE
#define DEFAULT_SCENE_CHANGE_DETECTION TRUE
-#define DEFAULT_SLICE_MODE SM_FIXEDSLCNUM_SLICE
+#define DEFAULT_SLICE_MODE GST_OPENH264_SLICE_MODE_N_SLICES
#define DEFAULT_NUM_SLICES 1
#define DEFAULT_COMPLEXITY MEDIUM_COMPLEXITY
@@ -235,7 +237,7 @@ struct _GstOpenh264EncPrivate
gboolean background_detection;
gboolean adaptive_quantization;
gboolean scene_change_detection;
- SliceModeEnum slice_mode;
+ GstOpenh264EncSliceMode slice_mode;
guint num_slices;
ECOMPLEXITY_MODE complexity;
};
@@ -508,7 +510,7 @@ gst_openh264enc_set_property (GObject * object, guint property_id,
break;
case PROP_SLICE_MODE:
- openh264enc->priv->slice_mode = (SliceModeEnum) g_value_get_enum (value);
+ openh264enc->priv->slice_mode = (GstOpenh264EncSliceMode) g_value_get_enum (value);
break;
case PROP_NUM_SLICES:
@@ -660,6 +662,8 @@ gst_openh264enc_set_format (GstVideoEncoder * encoder,
gchar *debug_caps;
guint width, height, fps_n, fps_d;
SEncParamExt enc_params;
+ SliceModeEnum slice_mode = SM_SINGLE_SLICE;
+ guint n_slices = 1;
gint ret;
GstCaps *outcaps;
GstVideoCodecState *output_state;
@@ -726,10 +730,32 @@ gst_openh264enc_set_format (GstVideoEncoder * encoder,
enc_params.sSpatialLayers[0].iVideoHeight = height;
enc_params.sSpatialLayers[0].fFrameRate = fps_n * 1.0 / fps_d;
enc_params.sSpatialLayers[0].iSpatialBitrate = openh264enc->priv->bitrate;
- enc_params.sSpatialLayers[0].sSliceCfg.uiSliceMode =
- openh264enc->priv->slice_mode;
- enc_params.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum =
- openh264enc->priv->num_slices;
+
+ if (priv->slice_mode == GST_OPENH264_SLICE_MODE_N_SLICES) {
+ if (priv->num_slices == 1)
+ slice_mode = SM_SINGLE_SLICE;
+ else
+ slice_mode = SM_FIXEDSLCNUM_SLICE;
+ n_slices = priv->num_slices;
+ } else if (priv->slice_mode == GST_OPENH264_SLICE_MODE_AUTO) {
+#if OPENH264_MAJOR == 1 && OPENH264_MINOR < 6
+ slice_mode = SM_AUTO_SLICE;
+#else
+ slice_mode = SM_FIXEDSLCNUM_SLICE;
+ n_slices = 0;
+#endif
+ } else {
+ GST_ERROR_OBJECT (openh264enc, "unexpected slice mode %d", priv->slice_mode);
+ slice_mode = SM_SINGLE_SLICE;
+ }
+
+#if OPENH264_MAJOR == 1 && OPENH264_MINOR < 6
+ enc_params.sSpatialLayers[0].sSliceCfg.uiSliceMode = slice_mode;
+ enc_params.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = n_slices;
+#else
+ enc_params.sSpatialLayers[0].sSliceArgument.uiSliceMode = slice_mode;
+ enc_params.sSpatialLayers[0].sSliceArgument.uiSliceNum = n_slices;
+#endif
priv->framerate = (1 + fps_n / fps_d);
diff --git a/ext/openh264/gstopenh264enc.h b/ext/openh264/gstopenh264enc.h
index 009210a6c..613c48893 100644
--- a/ext/openh264/gstopenh264enc.h
+++ b/ext/openh264/gstopenh264enc.h
@@ -34,6 +34,13 @@
#include <gst/video/gstvideoencoder.h>
G_BEGIN_DECLS
+
+typedef enum
+{
+ GST_OPENH264_SLICE_MODE_N_SLICES = 1, /* SM_FIXEDSLCNUM_SLICE */
+ GST_OPENH264_SLICE_MODE_AUTO = 5 /* former SM_AUTO_SLICE */
+} GstOpenh264EncSliceMode;
+
#define GST_TYPE_OPENH264ENC (gst_openh264enc_get_type())
#define GST_OPENH264ENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPENH264ENC,GstOpenh264Enc))
#define GST_OPENH264ENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OPENH264ENC,GstOpenh264EncClass))