qtdemux: Use pbutils for H.264 profile/level extraction

The functions used to extract this data have been moved to gstpbutils to
facilitate reuse.

https://bugzilla.gnome.org/show_bug.cgi?id=617318
This commit is contained in:
Arun Raghavan 2010-04-30 21:00:31 +05:30 committed by Tim-Philipp Müller
parent 9e786de9c8
commit c65305d70e
2 changed files with 10 additions and 103 deletions

View file

@ -5114,95 +5114,6 @@ qtdemux_get_rtsp_uri_from_hndl (GstQTDemux * qtdemux, GNode * minf)
return uri;
}
/*
* XXX: This code is duplicated in gst/mastroska/matroska-demux.c. Please
* replicate any changes you make over there as well.
*/
static gchar *
avc_profile_idc_to_string (guint profile_idc, guint constraint_set_flags)
{
const gchar *profile = NULL;
gint csf1, csf3;
csf1 = (constraint_set_flags & 0x40) >> 6;
csf3 = (constraint_set_flags & 0x10) >> 4;
switch (profile_idc) {
case 66:
if (csf1)
profile = "constrained-baseline";
else
profile = "baseline";
break;
case 77:
profile = "main";
break;
case 88:
profile = "extended";
break;
case 100:
profile = "high";
break;
case 110:
if (csf3)
profile = "high-10-intra";
else
profile = "high-10";
break;
case 122:
if (csf3)
profile = "high-4:2:2-intra";
else
profile = "high-4:2:2";
break;
case 244:
if (csf3)
profile = "high-4:4:4-intra";
else
profile = "high-4:4:4";
break;
case 44:
profile = "cavlc-4:4:4-intra";
break;
default:
return NULL;
}
return g_strdup (profile);
}
static gchar *
avc_level_idc_to_string (guint level_idc, guint constraint_set_flags)
{
gint csf3;
csf3 = (constraint_set_flags & 0x10) >> 4;
if (level_idc == 11 && csf3)
return g_strdup ("1b");
else if (level_idc % 10 == 0)
return g_strdup_printf ("%u", level_idc / 10);
else
return g_strdup_printf ("%u.%u", level_idc / 10, level_idc % 10);
}
static void
avc_get_profile_and_level_string (const guint8 * avc_data, gint size,
gchar ** profile, gchar ** level)
{
if (size >= 3)
/* First byte is the version, second is the profile indication,
* and third is the 5 contraint_set_flags and 3 reserved bits */
*profile = avc_profile_idc_to_string (QT_UINT8 (avc_data + 1),
QT_UINT8 (avc_data + 2));
if (size >= 4)
/* Fourth byte is the level indication */
*level = avc_level_idc_to_string (QT_UINT8 (avc_data + 3),
QT_UINT8 (avc_data + 2));
}
static gint
less_than (gconstpointer a, gconstpointer b)
{
@ -5460,23 +5371,15 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
{
/* parse, if found */
GstBuffer *buf;
gchar *profile = NULL, *level = NULL;
avc_get_profile_and_level_string (avc_data + 0x8, size,
&profile, &level);
if (profile) {
gst_caps_set_simple (stream->caps, "profile", G_TYPE_STRING,
profile, NULL);
g_free (profile);
}
if (level) {
gst_caps_set_simple (stream->caps, "level", G_TYPE_STRING,
level, NULL);
g_free (level);
}
GST_DEBUG_OBJECT (qtdemux, "found avcC codec_data in stsd");
/* First 4 bytes are the length of the atom, the next 4 bytes
* are the fourcc, the next 1 byte is the version, and the
* subsequent bytes are sequence parameter set like data. */
gst_codec_utils_h264_caps_set_level_and_profile (stream->caps,
avc_data + 8 + 1, size - 1);
buf = gst_buffer_new_and_alloc (size);
memcpy (GST_BUFFER_DATA (buf), avc_data + 0x8, size);
gst_caps_set_simple (stream->caps,

View file

@ -27,6 +27,8 @@
#include "qtdemux.h"
#include "gstrtpxqtdepay.h"
#include <gst/pbutils/pbutils.h>
static gboolean
plugin_init (GstPlugin * plugin)
{
@ -36,6 +38,8 @@ plugin_init (GstPlugin * plugin)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
gst_pb_utils_init ();
/* ensure private tag is registered */
gst_tag_register (GST_QT_DEMUX_PRIVATE_TAG, GST_TAG_FLAG_META,
GST_TYPE_BUFFER, "QT atom", "unparsed QT tag atom",