mpegvideoparse: Add methods to get names of various values.

This commit is contained in:
Edward Hervey 2009-06-05 10:49:41 +02:00
parent 22496517e0
commit 37254a21f4

View file

@ -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) {