From 9d6371405e13ed6442cc5981aa98957f11af8814 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 22 Aug 2011 12:24:15 +0200 Subject: [PATCH] fourcc: remove fourcc from caps --- gst/avi/gstavidemux.c | 4 +- gst/isomp4/atoms.c | 11 ++-- gst/isomp4/atoms.h | 2 +- gst/isomp4/gstqtmux.c | 12 +++-- gst/isomp4/qtdemux.c | 128 +++++++++++++++++------------------------------ gst/rtp/gstrtpj2kdepay.c | 3 +- 6 files changed, 64 insertions(+), 96 deletions(-) diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c index 97aecdf..f9c5390 100644 --- a/gst/avi/gstavidemux.c +++ b/gst/avi/gstavidemux.c @@ -2168,7 +2168,7 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf) stream->strf.vids, stream->extradata, stream->initdata, &codec_name); if (!caps) { caps = gst_caps_new_simple ("video/x-avi-unknown", "fourcc", - GST_TYPE_FOURCC, fourcc, NULL); + G_TYPE_INT, fourcc, NULL); } else if (got_vprp && vprp) { guint32 aspect_n, aspect_d; gint n, d; @@ -2212,7 +2212,7 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf) stream->strf.iavs, stream->extradata, stream->initdata, &codec_name); if (!caps) { caps = gst_caps_new_simple ("video/x-avi-unknown", "fourcc", - GST_TYPE_FOURCC, fourcc, NULL); + G_TYPE_INT, fourcc, NULL); } tag_name = GST_TAG_VIDEO_CODEC; avi->num_v_streams++; diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c index 35b4c8d..4ab097d 100644 --- a/gst/isomp4/atoms.c +++ b/gst/isomp4/atoms.c @@ -4096,8 +4096,9 @@ build_jp2x_extension (const GstBuffer * prefix) } AtomInfo * -build_jp2h_extension (AtomTRAK * trak, gint width, gint height, guint32 fourcc, - gint ncomp, const GValue * cmap_array, const GValue * cdef_array) +build_jp2h_extension (AtomTRAK * trak, gint width, gint height, + const gchar * colorspace, gint ncomp, const GValue * cmap_array, + const GValue * cdef_array) { AtomData *atom_data; GstBuffer *buf; @@ -4115,15 +4116,15 @@ build_jp2h_extension (AtomTRAK * trak, gint width, gint height, guint32 fourcc, g_return_val_if_fail (cdef_array == NULL || GST_VALUE_HOLDS_ARRAY (cdef_array), NULL); - if (fourcc == GST_MAKE_FOURCC ('s', 'R', 'G', 'B')) { + if (g_str_equal (colorspace, "sRGB")) { cenum = 0x10; if (ncomp == 0) ncomp = 3; - } else if (fourcc == GST_MAKE_FOURCC ('G', 'R', 'A', 'Y')) { + } else if (g_str_equal (colorspace, "GRAY")) { cenum = 0x11; if (ncomp == 0) ncomp = 1; - } else if (fourcc == GST_MAKE_FOURCC ('s', 'Y', 'U', 'V')) { + } else if (g_str_equal (colorspace, "sYUV")) { cenum = 0x12; if (ncomp == 0) ncomp = 3; diff --git a/gst/isomp4/atoms.h b/gst/isomp4/atoms.h index 5aeb5f8..336fa38 100644 --- a/gst/isomp4/atoms.h +++ b/gst/isomp4/atoms.h @@ -916,7 +916,7 @@ AtomInfo * build_esds_extension (AtomTRAK * trak, guint8 object_type, AtomInfo * build_btrt_extension (guint32 buffer_size_db, guint32 avg_bitrate, guint32 max_bitrate); AtomInfo * build_jp2h_extension (AtomTRAK * trak, gint width, gint height, - guint32 fourcc, gint ncomp, + const gchar *colorspace, gint ncomp, const GValue * cmap_array, const GValue * cdef_array); diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index fa08a42..9dc9fba 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -3120,7 +3120,7 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps) sync = FALSE; } else if (strcmp (mimetype, "image/x-j2c") == 0 || strcmp (mimetype, "image/x-jpc") == 0) { - guint32 fourcc; + const gchar *colorspace; const GValue *cmap_array; const GValue *cdef_array; gint ncomp = 0; @@ -3138,9 +3138,11 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps) ext_atom = NULL; entry.fourcc = FOURCC_mjp2; sync = FALSE; - if (gst_structure_get_fourcc (structure, "fourcc", &fourcc) && + + colorspace = gst_structure_get_string (structure, "colorspace"); + if (colorspace && (ext_atom = - build_jp2h_extension (qtpad->trak, width, height, fourcc, ncomp, + build_jp2h_extension (qtpad->trak, width, height, colorspace, ncomp, cmap_array, cdef_array)) != NULL) { ext_atom_list = g_list_append (ext_atom_list, ext_atom); @@ -3164,13 +3166,13 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps) } else if (strcmp (mimetype, "video/x-qt-part") == 0) { guint32 fourcc; - gst_structure_get_fourcc (structure, "format", &fourcc); + gst_structure_get_uint (structure, "format", &fourcc); entry.fourcc = fourcc; qtpad->have_dts = TRUE; } else if (strcmp (mimetype, "video/x-mp4-part") == 0) { guint32 fourcc; - gst_structure_get_fourcc (structure, "format", &fourcc); + gst_structure_get_uint (structure, "format", &fourcc); entry.fourcc = fourcc; qtpad->have_dts = TRUE; } diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 5a8508e..057d03d 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -51,6 +51,7 @@ #include #include +#include #include "qtatomparser.h" #include "qtdemux_types.h" @@ -5255,7 +5256,7 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl) /* sync sample atom */ stream->stps_present = FALSE; if ((stream->stss_present = - !!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stss, + ! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stss, &stream->stss) ? TRUE : FALSE) == TRUE) { /* copy atom data into a new buffer for later use */ stream->stss.data = g_memdup (stream->stss.data, stream->stss.size); @@ -5273,7 +5274,7 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl) /* partial sync sample atom */ if ((stream->stps_present = - !!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stps, + ! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_stps, &stream->stps) ? TRUE : FALSE) == TRUE) { /* copy atom data into a new buffer for later use */ stream->stps.data = g_memdup (stream->stps.data, stream->stps.size); @@ -5392,7 +5393,7 @@ qtdemux_stbl_init (GstQTDemux * qtdemux, QtDemuxStream * stream, GNode * stbl) /* composition time-to-sample */ if ((stream->ctts_present = - !!qtdemux_tree_get_child_by_type_full (stbl, FOURCC_ctts, + ! !qtdemux_tree_get_child_by_type_full (stbl, FOURCC_ctts, &stream->ctts) ? TRUE : FALSE) == TRUE) { /* copy atom data into a new buffer for later use */ stream->ctts.data = g_memdup (stream->ctts.data, stream->ctts.size); @@ -6579,7 +6580,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) /* see annex I of the jpeg2000 spec */ GNode *jp2h, *ihdr, *colr, *mjp2, *field, *prefix, *cmap, *cdef; const guint8 *data; - guint32 fourcc = 0; + const gchar *colorspace; gint ncomp = 0; guint32 ncomp_map = 0; gint32 *comp_map = NULL; @@ -6610,21 +6611,22 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) if (QT_UINT8 ((guint8 *) colr->data + 8) == 1) { switch (QT_UINT32 ((guint8 *) colr->data + 11)) { case 16: - fourcc = GST_MAKE_FOURCC ('s', 'R', 'G', 'B'); + colorspace = "sRGB"; break; case 17: - fourcc = GST_MAKE_FOURCC ('G', 'R', 'A', 'Y'); + colorspace = "GRAY"; break; case 18: - fourcc = GST_MAKE_FOURCC ('s', 'Y', 'U', 'V'); + colorspace = "sYUV"; break; default: + colorspace = NULL; break; } } - if (!fourcc) + if (!colorspace) /* colr is required, and only values 16, 17, and 18 are specified, - so error if we have no fourcc */ + so error if we have no colorspace */ break; /* extract component mapping */ @@ -6691,7 +6693,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) gst_caps_set_simple (stream->caps, "num-components", G_TYPE_INT, ncomp, NULL); gst_caps_set_simple (stream->caps, - "fourcc", GST_TYPE_FOURCC, fourcc, NULL); + "colorspace", G_TYPE_STRING, colorspace, NULL); if (comp_map) { GValue arr = { 0, }; @@ -7003,7 +7005,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) } if (enda) { gst_caps_set_simple (stream->caps, - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL); + "format", G_TYPE_STRING, "S24_3LE", NULL); } break; } @@ -9085,43 +9087,20 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, _codec ("Raw RGB video"); bps = QT_UINT16 (stsd_data + 98); /* set common stuff */ - caps = gst_caps_new_simple ("video/x-raw-rgb", - "endianness", G_TYPE_INT, G_BYTE_ORDER, "depth", G_TYPE_INT, bps, - NULL); + caps = gst_caps_new_simple ("video/x-raw", NULL); switch (bps) { case 15: - gst_caps_set_simple (caps, - "bpp", G_TYPE_INT, 16, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "red_mask", G_TYPE_INT, 0x7c00, - "green_mask", G_TYPE_INT, 0x03e0, - "blue_mask", G_TYPE_INT, 0x001f, NULL); + gst_caps_set_simple (caps, "format", G_TYPE_STRING, "RGB15", NULL); break; case 16: - gst_caps_set_simple (caps, - "bpp", G_TYPE_INT, 16, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "red_mask", G_TYPE_INT, 0xf800, - "green_mask", G_TYPE_INT, 0x07e0, - "blue_mask", G_TYPE_INT, 0x001f, NULL); + gst_caps_set_simple (caps, "format", G_TYPE_STRING, "RGB16", NULL); break; case 24: - gst_caps_set_simple (caps, - "bpp", G_TYPE_INT, 24, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "red_mask", G_TYPE_INT, 0xff0000, - "green_mask", G_TYPE_INT, 0x00ff00, - "blue_mask", G_TYPE_INT, 0x0000ff, NULL); + gst_caps_set_simple (caps, "format", G_TYPE_STRING, "RGB", NULL); break; case 32: - gst_caps_set_simple (caps, - "bpp", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "alpha_mask", G_TYPE_INT, 0xff000000, - "red_mask", G_TYPE_INT, 0x00ff0000, - "green_mask", G_TYPE_INT, 0x0000ff00, - "blue_mask", G_TYPE_INT, 0x000000ff, NULL); + gst_caps_set_simple (caps, "format", G_TYPE_STRING, "ARGB", NULL); break; default: /* unknown */ @@ -9131,39 +9110,30 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, } case GST_MAKE_FOURCC ('y', 'v', '1', '2'): _codec ("Raw planar YUV 4:2:0"); - caps = gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'), - NULL); + caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, "I420", NULL); break; case GST_MAKE_FOURCC ('y', 'u', 'v', '2'): case GST_MAKE_FOURCC ('Y', 'u', 'v', '2'): _codec ("Raw packed YUV 4:2:2"); - caps = gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), - NULL); + caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, "YUY2", NULL); break; case GST_MAKE_FOURCC ('2', 'v', 'u', 'y'): case GST_MAKE_FOURCC ('2', 'V', 'u', 'y'): _codec ("Raw packed YUV 4:2:2"); - caps = gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), - NULL); + caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, "UYVY", NULL); break; case GST_MAKE_FOURCC ('v', '2', '1', '0'): _codec ("Raw packed YUV 10-bit 4:2:2"); - caps = gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('v', '2', '1', '0'), - NULL); + caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, "v210", NULL); break; case GST_MAKE_FOURCC ('r', '2', '1', '0'): _codec ("Raw packed RGB 10-bit 4:4:4"); - caps = gst_caps_new_simple ("video/x-raw-rgb", - "endianness", G_TYPE_INT, G_BIG_ENDIAN, "depth", G_TYPE_INT, 30, - "bpp", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "red_mask", G_TYPE_INT, 0x3ff00000, - "green_mask", G_TYPE_INT, 0x000ffc00, - "blue_mask", G_TYPE_INT, 0x000003ff, NULL); + caps = gst_caps_new_simple ("video/x-raw", + "format", G_TYPE_STRING, "r210", NULL); break; case GST_MAKE_FOURCC ('m', 'p', 'e', 'g'): case GST_MAKE_FOURCC ('m', 'p', 'g', '1'): @@ -9345,9 +9315,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, case FOURCC_ovc1: _codec ("VC-1"); caps = gst_caps_new_simple ("video/x-wmv", - "wmvversion", G_TYPE_INT, 3, - "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('W', 'V', 'C', '1'), - NULL); + "wmvversion", G_TYPE_INT, 3, "format", G_TYPE_STRING, "WVC1", NULL); break; case GST_MAKE_FOURCC ('k', 'p', 'c', 'd'): default: @@ -9364,7 +9332,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, /* enable clipping for raw video streams */ s = gst_caps_get_structure (caps, 0); name = gst_structure_get_name (s); - if (g_str_has_prefix (name, "video/x-raw-")) { + if (g_str_has_prefix (name, "video/x-raw")) { stream->need_clip = TRUE; } return caps; @@ -9385,8 +9353,8 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, case GST_MAKE_FOURCC ('N', 'O', 'N', 'E'): case GST_MAKE_FOURCC ('r', 'a', 'w', ' '): _codec ("Raw 8-bit PCM audio"); - caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 8, - "depth", G_TYPE_INT, 8, "signed", G_TYPE_BOOLEAN, FALSE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "U8", NULL); break; case GST_MAKE_FOURCC ('t', 'w', 'o', 's'): endian = G_BIG_ENDIAN; @@ -9395,45 +9363,43 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, { gchar *str; gint depth; + GstAudioFormat format; if (!endian) endian = G_LITTLE_ENDIAN; depth = stream->bytes_per_packet * 8; + format = gst_audio_format_build_integer (TRUE, endian, depth, depth); + str = g_strdup_printf ("Raw %d-bit PCM audio", depth); _codec (str); g_free (str); - caps = gst_caps_new_simple ("audio/x-raw-int", - "width", G_TYPE_INT, depth, "depth", G_TYPE_INT, depth, - "endianness", G_TYPE_INT, endian, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, gst_audio_format_to_string (format), NULL); break; } case GST_MAKE_FOURCC ('f', 'l', '6', '4'): _codec ("Raw 64-bit floating-point audio"); - caps = gst_caps_new_simple ("audio/x-raw-float", "width", G_TYPE_INT, 64, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "F64_BE", NULL); break; case GST_MAKE_FOURCC ('f', 'l', '3', '2'): _codec ("Raw 32-bit floating-point audio"); - caps = gst_caps_new_simple ("audio/x-raw-float", "width", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "F32_BE", NULL); break; case FOURCC_in24: _codec ("Raw 24-bit PCM audio"); /* we assume BIG ENDIAN, an enda box will tell us to change this to little * endian later */ - caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 24, - "depth", G_TYPE_INT, 24, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S24_3BE", NULL); break; case GST_MAKE_FOURCC ('i', 'n', '3', '2'): _codec ("Raw 32-bit PCM audio"); - caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 32, - "depth", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S32_BE", NULL); break; case GST_MAKE_FOURCC ('u', 'l', 'a', 'w'): _codec ("Mu-law audio"); @@ -9570,7 +9536,7 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream, /* enable clipping for raw audio streams */ s = gst_caps_get_structure (caps, 0); name = gst_structure_get_name (s); - if (g_str_has_prefix (name, "audio/x-raw-")) { + if (g_str_has_prefix (name, "audio/x-raw")) { stream->need_clip = TRUE; } return caps; diff --git a/gst/rtp/gstrtpj2kdepay.c b/gst/rtp/gstrtpj2kdepay.c index f63e0c1..be6ba97 100644 --- a/gst/rtp/gstrtpj2kdepay.c +++ b/gst/rtp/gstrtpj2kdepay.c @@ -197,8 +197,7 @@ gst_rtp_j2k_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) outcaps = gst_caps_new_simple ("image/x-jpc", "framerate", GST_TYPE_FRACTION, 0, 1, - "fields", G_TYPE_INT, 1, "fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('s', - 'Y', 'U', 'V'), NULL); + "fields", G_TYPE_INT, 1, "colorspace", G_TYPE_STRING, "sYUV", NULL); res = gst_pad_set_caps (depayload->srcpad, outcaps); gst_caps_unref (outcaps); -- 2.7.4