diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2016-09-30 17:58:37 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-11-01 20:41:22 +0200 |
commit | a2c692148241a7e255593b9b2ebd3bd42421a90b (patch) | |
tree | dbc8b6247cd024aeef465a9342fe68405d49a25c | |
parent | ec7f69960484ce244495770b96808186ffe171eb (diff) |
qtmux: Write 'clap' atom for ProRes
It's required for ProRes to work with other software.
It is also in the MP4 standard, but inventing values here seems a bit
tricky for the general case and it does not really give any extra
information.
https://bugzilla.gnome.org/show_bug.cgi?id=769048
-rw-r--r-- | gst/isomp4/atoms.c | 23 | ||||
-rw-r--r-- | gst/isomp4/atoms.h | 1 | ||||
-rw-r--r-- | gst/isomp4/fourcc.h | 5 | ||||
-rw-r--r-- | gst/isomp4/gstqtmux.c | 16 | ||||
-rw-r--r-- | gst/isomp4/qtdemux_types.c | 1 |
5 files changed, 44 insertions, 2 deletions
diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c index eb32bf78b..1ea648531 100644 --- a/gst/isomp4/atoms.c +++ b/gst/isomp4/atoms.c @@ -4030,6 +4030,29 @@ build_colr_extension (const GstVideoColorimetry * colorimetry, gboolean is_mp4) atom_data_free); } +AtomInfo * +build_clap_extension (gint width_n, gint width_d, gint height_n, gint height_d, + gint h_off_n, gint h_off_d, gint v_off_n, gint v_off_d) +{ + AtomData *atom_data = atom_data_new (FOURCC_clap); + guint8 *data; + + atom_data_alloc_mem (atom_data, 32); + data = atom_data->data; + + GST_WRITE_UINT32_BE (data, width_n); + GST_WRITE_UINT32_BE (data + 4, width_d); + GST_WRITE_UINT32_BE (data + 8, height_n); + GST_WRITE_UINT32_BE (data + 12, height_d); + GST_WRITE_UINT32_BE (data + 16, h_off_n); + GST_WRITE_UINT32_BE (data + 20, h_off_d); + GST_WRITE_UINT32_BE (data + 24, v_off_n); + GST_WRITE_UINT32_BE (data + 28, v_off_d); + + return build_atom_info_wrapper ((Atom *) atom_data, atom_data_copy_data, + atom_data_free); +} + SampleTableEntryMP4V * atom_trak_set_video_type (AtomTRAK * trak, AtomsContext * context, VisualSampleEntry * entry, guint32 scale, GList * ext_atoms_list) diff --git a/gst/isomp4/atoms.h b/gst/isomp4/atoms.h index f164ebf00..b56311688 100644 --- a/gst/isomp4/atoms.h +++ b/gst/isomp4/atoms.h @@ -1045,6 +1045,7 @@ AtomInfo * build_jp2h_extension (gint width, gint height, const gchar * AtomInfo * build_jp2x_extension (const GstBuffer * prefix); AtomInfo * build_fiel_extension (GstVideoInterlaceMode mode, GstVideoFieldOrder order); AtomInfo * build_colr_extension (const GstVideoColorimetry *colorimetry, gboolean is_mp4); +AtomInfo * build_clap_extension (gint width_n, gint width_d, gint height_n, gint height_d, gint h_off_n, gint h_off_d, gint v_off_n, gint v_off_d); AtomInfo * build_ac3_extension (guint8 fscod, guint8 bsid, guint8 bsmod, guint8 acmod, guint8 lfe_on, guint8 bitrate_code); diff --git a/gst/isomp4/fourcc.h b/gst/isomp4/fourcc.h index 076a5f22f..160e6ca28 100644 --- a/gst/isomp4/fourcc.h +++ b/gst/isomp4/fourcc.h @@ -174,6 +174,9 @@ G_BEGIN_DECLS #define FOURCC_opus GST_MAKE_FOURCC('O','p','u','s') #define FOURCC_dops GST_MAKE_FOURCC('d','O','p','s') #define FOURCC_pasp GST_MAKE_FOURCC('p','a','s','p') +#define FOURCC_colr GST_MAKE_FOURCC('c','o','l','r') +#define FOURCC_clap GST_MAKE_FOURCC('c','l','a','p') +#define FOURCC_fiel GST_MAKE_FOURCC('f','i','e','l') #define FOURCC_pcst GST_MAKE_FOURCC('p','c','s','t') #define FOURCC_pgap GST_MAKE_FOURCC('p','g','a','p') #define FOURCC_pnot GST_MAKE_FOURCC('p','n','o','t') @@ -286,8 +289,6 @@ G_BEGIN_DECLS /* ISO Motion JPEG 2000 fourcc */ #define FOURCC_cdef GST_MAKE_FOURCC('c','d','e','f') #define FOURCC_cmap GST_MAKE_FOURCC('c','m','a','p') -#define FOURCC_colr GST_MAKE_FOURCC('c','o','l','r') -#define FOURCC_fiel GST_MAKE_FOURCC('f','i','e','l') #define FOURCC_ihdr GST_MAKE_FOURCC('i','h','d','r') #define FOURCC_jp2h GST_MAKE_FOURCC('j','p','2','h') #define FOURCC_jp2x GST_MAKE_FOURCC('j','p','2','x') diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index 4a4187d14..49d59618d 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -4317,6 +4317,22 @@ gst_qt_mux_video_sink_set_caps (GstQTPad * qtpad, GstCaps * caps) mp4v->spatial_quality = 0x3FF; mp4v->temporal_quality = 0; mp4v->vendor = FOURCC_appl; + + /* The 'clap' extension is also defined for MP4 but inventing values in + * general seems a bit tricky for this one. We only write it for ProRes + * then, where it is a requirement. + * + * NTSC and PAL have special values, otherwise just take width and height + */ + if (width == 720 && (height == 480 || height == 486)) + ext_atom = build_clap_extension (704, 1, height, 1, 0, 1, 0, 1); + else if (width == 720 && height == 576) + ext_atom = build_clap_extension (768 * 54, 59, 576, 1, 0, 1, 0, 1); + else + ext_atom = build_clap_extension (width, 1, height, 1, 0, 1, 0, 1); + + if (ext_atom) + mp4v->extension_atoms = g_list_append (mp4v->extension_atoms, ext_atom); } gst_object_unref (qtmux); diff --git a/gst/isomp4/qtdemux_types.c b/gst/isomp4/qtdemux_types.c index 0208e8b65..693ad5d1c 100644 --- a/gst/isomp4/qtdemux_types.c +++ b/gst/isomp4/qtdemux_types.c @@ -84,6 +84,7 @@ static const QtNodeType qt_node_types[] = { {FOURCC_mhdr, "mhdr", QT_FLAG_CONTAINER,}, {FOURCC_jp2h, "jp2h", QT_FLAG_CONTAINER,}, {FOURCC_colr, "colr", 0,}, + {FOURCC_clap, "clap", 0,}, {FOURCC_ihdr, "ihdr", 0,}, {FOURCC_fiel, "fiel", 0,}, {FOURCC_jp2x, "jp2x", 0,}, |