summaryrefslogtreecommitdiffstats
path: root/gst/mpegvideoparse
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2009-06-05 10:49:41 +0200
committerEdward Hervey <bilboed@bilboed.com>2009-06-05 20:23:44 +0200
commit37254a21f44707aef9141dc1e700b05d4e75b11e (patch)
tree0779fe1d4dc9ef4aadd338de52afb5a41453ce78 /gst/mpegvideoparse
parent22496517e0f8a25202c42659c2720a5924275ab5 (diff)
downloadgst-plugins-bad-37254a21f44707aef9141dc1e700b05d4e75b11e.tar.gz
gst-plugins-bad-37254a21f44707aef9141dc1e700b05d4e75b11e.tar.bz2
gst-plugins-bad-37254a21f44707aef9141dc1e700b05d4e75b11e.zip
mpegvideoparse: Add methods to get names of various values.
Diffstat (limited to 'gst/mpegvideoparse')
-rw-r--r--gst/mpegvideoparse/mpegvideoparse.c67
1 files changed, 64 insertions, 3 deletions
diff --git a/gst/mpegvideoparse/mpegvideoparse.c b/gst/mpegvideoparse/mpegvideoparse.c
index 2a7f9153..312b33f4 100644
--- a/gst/mpegvideoparse/mpegvideoparse.c
+++ b/gst/mpegvideoparse/mpegvideoparse.c
@@ -278,6 +278,62 @@ mpegvideoparse_handle_sequence (MpegVideoParse * mpegvideoparse,
return TRUE;
}
+static const gchar *
+picture_start_code_name (guint8 psc)
+{
+ guint i;
+ const struct
+ {
+ guint8 psc;
+ const gchar *name;
+ } psc_names[] = {
+ {
+ 0x00, "Picture Start"}, {
+ 0xb0, "Reserved"}, {
+ 0xb1, "Reserved"}, {
+ 0xb2, "User Data Start"}, {
+ 0xb3, "Sequence Header Start"}, {
+ 0xb4, "Sequence Error"}, {
+ 0xb5, "Extnsion Start"}, {
+ 0xb6, "Reserved"}, {
+ 0xb7, "Sequence End"}, {
+ 0xb8, "Group Start"}, {
+ 0xb9, "Program End"}
+ };
+ if (psc < 0xB0 && psc > 0)
+ return "Slice Start";
+
+ for (i = 0; i < G_N_ELEMENTS (psc_names); i++)
+ if (psc_names[i].psc == psc)
+ return psc_names[i].name;
+
+ return "UNKNOWN";
+};
+
+static const gchar *
+picture_type_name (guint8 pct)
+{
+ guint i;
+ const struct
+ {
+ guint8 pct;
+ const gchar *name;
+ } pct_names[] = {
+ {
+ 0, "Forbidden"}, {
+ 1, "I Frame"}, {
+ 2, "P Frame"}, {
+ 3, "B Frame"}, {
+ 4, "DC Intra Coded (Shall Not Be Used!)"}
+ };
+
+ for (i = 0; i < G_N_ELEMENTS (pct_names); i++)
+ if (pct_names[i].pct == pct)
+ return pct_names[i].name;
+
+ return "Reserved/Unknown";
+}
+
static gboolean
mpegvideoparse_handle_picture (MpegVideoParse * mpegvideoparse, GstBuffer * buf)
{
@@ -289,6 +345,9 @@ mpegvideoparse_handle_picture (MpegVideoParse * mpegvideoparse, GstBuffer * buf)
cur = mpeg_util_find_start_code (&sync_word, cur, end);
while (cur != NULL) {
+ if (cur[0] == 0 || cur[0] > 0xaf)
+ GST_LOG_OBJECT (mpegvideoparse, "Picture Start Code : %s",
+ picture_start_code_name (cur[0]));
/* Cur points at the last byte of the start code */
if (cur[0] == MPEG_PACKET_PICTURE) {
guint8 *pic_data = cur - 3;
@@ -301,7 +360,8 @@ mpegvideoparse_handle_picture (MpegVideoParse * mpegvideoparse, GstBuffer * buf)
if (hdr.pic_type != MPEG_PICTURE_TYPE_I)
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
- GST_LOG_OBJECT (mpegvideoparse, "Picture type is %u", hdr.pic_type);
+ GST_LOG_OBJECT (mpegvideoparse, "Picture type is %s",
+ picture_type_name (hdr.pic_type));
/* FIXME: Can use the picture type and number of fields to track a
* timestamp */
}
@@ -359,8 +419,9 @@ mpegvideoparse_drain_avail (MpegVideoParse * mpegvideoparse)
while ((cur != NULL) && (res == GST_FLOW_OK)) {
/* Handle the block */
GST_LOG_OBJECT (mpegvideoparse,
- "Have block of size %u with pack_type 0x%02x and flags 0x%02x",
- cur->length, cur->first_pack_type, cur->flags);
+ "Have block of size %u with pack_type %s and flags 0x%02x",
+ cur->length, picture_start_code_name (cur->first_pack_type),
+ cur->flags);
/* Don't start pushing out buffers until we've seen a sequence header */
if (mpegvideoparse->seq_hdr.mpeg_version == 0) {