Commit a2c69214 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

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
parent ec7f6996
......@@ -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)
......
......@@ -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);
......
......@@ -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')
......
......@@ -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);
......
......@@ -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,},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment