summaryrefslogtreecommitdiff
path: root/ext/xvid
diff options
context:
space:
mode:
authorEdward Hervey <edward.hervey@collabora.co.uk>2011-12-30 11:41:17 +0100
committerEdward Hervey <edward.hervey@collabora.co.uk>2011-12-30 11:41:17 +0100
commitf70a623418a52eada0278002f8d266d49957b3d5 (patch)
treefc54fd9fab400e886b11a9a2b313478b66dd7969 /ext/xvid
parentd5aaefa59f9ef4153644a2aa254c39a3a9d108e3 (diff)
parentd465188879cd4dd0735e3fbcaeb83d98f217ed88 (diff)
downloadgstreamer-plugins-bad-f70a623418a52eada0278002f8d266d49957b3d5.tar.gz
Merge remote-tracking branch 'origin/master' into 0.11-premerge
Conflicts: docs/libs/Makefile.am ext/kate/gstkatetiger.c ext/opus/gstopusdec.c ext/xvid/gstxvidenc.c gst-libs/gst/basecamerabinsrc/Makefile.am gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.h gst-libs/gst/video/gstbasevideocodec.c gst-libs/gst/video/gstbasevideocodec.h gst-libs/gst/video/gstbasevideodecoder.c gst-libs/gst/video/gstbasevideoencoder.c gst/asfmux/gstasfmux.c gst/audiovisualizers/gstwavescope.c gst/camerabin2/gstcamerabin2.c gst/debugutils/gstcompare.c gst/frei0r/gstfrei0rmixer.c gst/mpegpsmux/mpegpsmux.c gst/mpegtsmux/mpegtsmux.c gst/mxf/mxfmux.c gst/videomeasure/gstvideomeasure_ssim.c gst/videoparsers/gsth264parse.c gst/videoparsers/gstmpeg4videoparse.c
Diffstat (limited to 'ext/xvid')
-rw-r--r--ext/xvid/gstxvidenc.c192
-rw-r--r--ext/xvid/gstxvidenc.h1
2 files changed, 189 insertions, 4 deletions
diff --git a/ext/xvid/gstxvidenc.c b/ext/xvid/gstxvidenc.c
index dc60d0d8c..57e9a3317 100644
--- a/ext/xvid/gstxvidenc.c
+++ b/ext/xvid/gstxvidenc.c
@@ -51,14 +51,37 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-xvid, "
+ GST_STATIC_CAPS ("video/mpeg, "
+ "mpegversion = (int) 4, "
+ "systemstream = (boolean) FALSE, "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], "
+ "framerate = (fraction) [ 0/1, MAX ], "
+ "profile = (string) simple, "
+ "level = (string) { 0, 1, 2, 3, 4a, 5, 6 };"
+ "video/mpeg, "
+ "mpegversion = (int) 4, "
+ "systemstream = (boolean) FALSE, "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], "
+ "framerate = (fraction) [ 0/1, MAX ], "
+ "profile = (string) advanced-real-time-simple, "
+ "level = (string) { 1, 2, 3, 4 };"
+ "video/mpeg, "
+ "mpegversion = (int) 4, "
+ "systemstream = (boolean) FALSE, "
"width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ], " "framerate = (fraction) [ 0/1, MAX ]; "
+ "height = (int) [ 0, MAX ], "
+ "framerate = (fraction) [ 0/1, MAX ], "
+ "profile = (string) advanced-simple, "
+ "level = (string) { 0, 1, 2, 3, 4 };"
"video/mpeg, "
"mpegversion = (int) 4, "
"systemstream = (boolean) FALSE, "
+ "width = (int) [ 0, MAX ], " "height = (int) [ 0, MAX ]; "
+ "video/x-xvid, "
"width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ], " "framerate = (fraction) [ 0/1, MAX ]")
+ "height = (int) [ 0, MAX ], " "framerate = (fraction) [ 0/1, MAX ];")
);
@@ -106,6 +129,9 @@ gst_xvidenc_profile_get_type (void)
{XVID_PROFILE_S_L1, "S_L1", "Simple profile, L1"},
{XVID_PROFILE_S_L2, "S_L2", "Simple profile, L2"},
{XVID_PROFILE_S_L3, "S_L3", "Simple profile, L3"},
+ {XVID_PROFILE_S_L4a, "S_L4a", "Simple profile, L4a"},
+ {XVID_PROFILE_S_L5, "S_L5", "Simple profile, L5"},
+ {XVID_PROFILE_S_L6, "S_L6", "Simple profile, L6"},
{XVID_PROFILE_ARTS_L1, "ARTS_L1",
"Advanced real-time simple profile, L1"},
{XVID_PROFILE_ARTS_L2, "ARTS_L2",
@@ -578,11 +604,97 @@ gst_xvidenc_setup (GstXvidEnc * xvidenc)
xvid_enc_create_t xenc;
xvid_enc_plugin_t xplugin[2];
gint ret;
+ GstCaps *allowed_caps;
+ gint profile = -1;
+
+ /* Negotiate profile/level with downstream */
+ allowed_caps = gst_pad_get_allowed_caps (xvidenc->srcpad);
+ if (allowed_caps && !gst_caps_is_empty (allowed_caps)) {
+ const gchar *profile_str, *level_str;
+
+ allowed_caps = gst_caps_make_writable (allowed_caps);
+ gst_caps_truncate (allowed_caps);
+
+ profile_str =
+ gst_structure_get_string (gst_caps_get_structure (allowed_caps, 0),
+ "profile");
+ level_str =
+ gst_structure_get_string (gst_caps_get_structure (allowed_caps, 0),
+ "level");
+ if (profile_str) {
+ if (g_str_equal (profile_str, "simple")) {
+ if (!level_str) {
+ profile = XVID_PROFILE_S_L0;
+ } else if (g_str_equal (level_str, "0")) {
+ profile = XVID_PROFILE_S_L0;
+ } else if (g_str_equal (level_str, "1")) {
+ profile = XVID_PROFILE_S_L1;
+ } else if (g_str_equal (level_str, "2")) {
+ profile = XVID_PROFILE_S_L2;
+ } else if (g_str_equal (level_str, "3")) {
+ profile = XVID_PROFILE_S_L3;
+ } else if (g_str_equal (level_str, "4a")) {
+ profile = XVID_PROFILE_S_L4a;
+ } else if (g_str_equal (level_str, "5")) {
+ profile = XVID_PROFILE_S_L5;
+ } else if (g_str_equal (level_str, "6")) {
+ profile = XVID_PROFILE_S_L6;
+ } else {
+ GST_ERROR_OBJECT (xvidenc,
+ "Invalid profile/level combination (%s %s)", profile_str,
+ level_str);
+ }
+ } else if (g_str_equal (profile_str, "advanced-real-time-simple")) {
+ if (!level_str) {
+ profile = XVID_PROFILE_ARTS_L1;
+ } else if (g_str_equal (level_str, "1")) {
+ profile = XVID_PROFILE_ARTS_L1;
+ } else if (g_str_equal (level_str, "2")) {
+ profile = XVID_PROFILE_ARTS_L2;
+ } else if (g_str_equal (level_str, "3")) {
+ profile = XVID_PROFILE_ARTS_L3;
+ } else if (g_str_equal (level_str, "4")) {
+ profile = XVID_PROFILE_ARTS_L4;
+ } else {
+ GST_ERROR_OBJECT (xvidenc,
+ "Invalid profile/level combination (%s %s)", profile_str,
+ level_str);
+ }
+ } else if (g_str_equal (profile_str, "advanced-simple")) {
+ if (!level_str) {
+ profile = XVID_PROFILE_AS_L0;
+ } else if (g_str_equal (level_str, "0")) {
+ profile = XVID_PROFILE_AS_L0;
+ } else if (g_str_equal (level_str, "1")) {
+ profile = XVID_PROFILE_AS_L1;
+ } else if (g_str_equal (level_str, "2")) {
+ profile = XVID_PROFILE_AS_L2;
+ } else if (g_str_equal (level_str, "3")) {
+ profile = XVID_PROFILE_AS_L3;
+ } else if (g_str_equal (level_str, "4")) {
+ profile = XVID_PROFILE_AS_L4;
+ } else {
+ GST_ERROR_OBJECT (xvidenc,
+ "Invalid profile/level combination (%s %s)", profile_str,
+ level_str);
+ }
+ } else {
+ GST_ERROR_OBJECT (xvidenc, "Invalid profile (%s)", profile_str);
+ }
+ }
+ }
+ if (allowed_caps)
+ gst_caps_unref (allowed_caps);
+
+ if (profile != -1) {
+ xvidenc->profile = profile;
+ g_object_notify (G_OBJECT (xvidenc), "profile");
+ }
/* see xvid.h for the meaning of all this. */
gst_xvid_init_struct (xenc);
- xenc.profile = xvidenc->profile;
+ xenc.profile = xvidenc->used_profile = xvidenc->profile;
xenc.width = xvidenc->width;
xenc.height = xvidenc->height;
xenc.max_bframes = xvidenc->max_bframes;
@@ -783,6 +895,78 @@ gst_xvidenc_setcaps (GstPad * pad, GstCaps * vscaps)
/* just to be sure */
gst_pad_fixate_caps (xvidenc->srcpad, new_caps);
+ if (xvidenc->used_profile != 0) {
+ switch (xvidenc->used_profile) {
+ case XVID_PROFILE_S_L0:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING, "simple",
+ "level", G_TYPE_STRING, "0", NULL);
+ break;
+ case XVID_PROFILE_S_L1:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING, "simple",
+ "level", G_TYPE_STRING, "1", NULL);
+ break;
+ case XVID_PROFILE_S_L2:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING, "simple",
+ "level", G_TYPE_STRING, "2", NULL);
+ break;
+ case XVID_PROFILE_S_L3:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING, "simple",
+ "level", G_TYPE_STRING, "3", NULL);
+ break;
+ case XVID_PROFILE_S_L4a:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING, "simple",
+ "level", G_TYPE_STRING, "4a", NULL);
+ break;
+ case XVID_PROFILE_S_L5:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING, "simple",
+ "level", G_TYPE_STRING, "5", NULL);
+ break;
+ case XVID_PROFILE_S_L6:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING, "simple",
+ "level", G_TYPE_STRING, "6", NULL);
+ break;
+ case XVID_PROFILE_ARTS_L1:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-real-time-simple", "level", G_TYPE_STRING, "1", NULL);
+ break;
+ case XVID_PROFILE_ARTS_L2:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-real-time-simple", "level", G_TYPE_STRING, "2", NULL);
+ break;
+ case XVID_PROFILE_ARTS_L3:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-real-time-simple", "level", G_TYPE_STRING, "3", NULL);
+ break;
+ case XVID_PROFILE_ARTS_L4:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-real-time-simple", "level", G_TYPE_STRING, "4", NULL);
+ break;
+ case XVID_PROFILE_AS_L0:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-simple", "level", G_TYPE_STRING, "0", NULL);
+ break;
+ case XVID_PROFILE_AS_L1:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-simple", "level", G_TYPE_STRING, "1", NULL);
+ break;
+ case XVID_PROFILE_AS_L2:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-simple", "level", G_TYPE_STRING, "2", NULL);
+ break;
+ case XVID_PROFILE_AS_L3:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-simple", "level", G_TYPE_STRING, "3", NULL);
+ break;
+ case XVID_PROFILE_AS_L4:
+ gst_caps_set_simple (new_caps, "profile", G_TYPE_STRING,
+ "advanced-simple", "level", G_TYPE_STRING, "4", NULL);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+
/* src pad should accept anyway */
ret = gst_pad_set_caps (xvidenc->srcpad, new_caps);
gst_caps_unref (new_caps);
diff --git a/ext/xvid/gstxvidenc.h b/ext/xvid/gstxvidenc.h
index a2f32d0a8..121c99d41 100644
--- a/ext/xvid/gstxvidenc.h
+++ b/ext/xvid/gstxvidenc.h
@@ -64,6 +64,7 @@ struct _GstXvidEnc {
/* encoding profile */
gint profile;
+ gint used_profile;
/* quantizer type; h263, MPEG */
gint quant_type;