mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
qtmux: Always write colr atom with the colorimetry information
https://bugzilla.gnome.org/show_bug.cgi?id=772181
This commit is contained in:
parent
0584a71123
commit
53e436883a
4 changed files with 38 additions and 25 deletions
|
@ -3948,7 +3948,7 @@ build_fiel_extension (GstVideoInterlaceMode mode, GstVideoFieldOrder order)
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomInfo *
|
AtomInfo *
|
||||||
build_colr_extension (GstVideoColorimetry colorimetry)
|
build_colr_extension (const GstVideoColorimetry * colorimetry, gboolean is_mp4)
|
||||||
{
|
{
|
||||||
AtomData *atom_data = atom_data_new (FOURCC_colr);
|
AtomData *atom_data = atom_data_new (FOURCC_colr);
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
@ -3956,7 +3956,7 @@ build_colr_extension (GstVideoColorimetry colorimetry)
|
||||||
guint16 transfer_function;
|
guint16 transfer_function;
|
||||||
guint16 matrix;
|
guint16 matrix;
|
||||||
|
|
||||||
switch (colorimetry.primaries) {
|
switch (colorimetry->primaries) {
|
||||||
case GST_VIDEO_COLOR_PRIMARIES_BT709:
|
case GST_VIDEO_COLOR_PRIMARIES_BT709:
|
||||||
primaries = 1;
|
primaries = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -3967,13 +3967,16 @@ build_colr_extension (GstVideoColorimetry colorimetry)
|
||||||
case GST_VIDEO_COLOR_PRIMARIES_SMPTE240M:
|
case GST_VIDEO_COLOR_PRIMARIES_SMPTE240M:
|
||||||
primaries = 6;
|
primaries = 6;
|
||||||
break;
|
break;
|
||||||
|
case GST_VIDEO_COLOR_PRIMARIES_BT2020:
|
||||||
|
primaries = 9;
|
||||||
|
break;
|
||||||
case GST_VIDEO_COLOR_PRIMARIES_UNKNOWN:
|
case GST_VIDEO_COLOR_PRIMARIES_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
primaries = 2;
|
primaries = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (colorimetry.transfer) {
|
switch (colorimetry->transfer) {
|
||||||
case GST_VIDEO_TRANSFER_BT709:
|
case GST_VIDEO_TRANSFER_BT709:
|
||||||
transfer_function = 1;
|
transfer_function = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -3986,7 +3989,7 @@ build_colr_extension (GstVideoColorimetry colorimetry)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (colorimetry.matrix) {
|
switch (colorimetry->matrix) {
|
||||||
case GST_VIDEO_COLOR_MATRIX_BT709:
|
case GST_VIDEO_COLOR_MATRIX_BT709:
|
||||||
matrix = 1;
|
matrix = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -3996,22 +3999,33 @@ build_colr_extension (GstVideoColorimetry colorimetry)
|
||||||
case GST_VIDEO_COLOR_MATRIX_SMPTE240M:
|
case GST_VIDEO_COLOR_MATRIX_SMPTE240M:
|
||||||
matrix = 7;
|
matrix = 7;
|
||||||
break;
|
break;
|
||||||
|
case GST_VIDEO_COLOR_MATRIX_BT2020:
|
||||||
|
matrix = 9;
|
||||||
|
break;
|
||||||
case GST_VIDEO_COLOR_MATRIX_UNKNOWN:
|
case GST_VIDEO_COLOR_MATRIX_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
matrix = 2;
|
matrix = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
atom_data_alloc_mem (atom_data, 10);
|
atom_data_alloc_mem (atom_data, 10 + (is_mp4 ? 1 : 0));
|
||||||
data = atom_data->data;
|
data = atom_data->data;
|
||||||
|
|
||||||
/* colour specification box */
|
/* colour specification box */
|
||||||
GST_WRITE_UINT32_LE (data, FOURCC_nclc);
|
if (is_mp4)
|
||||||
|
GST_WRITE_UINT32_LE (data, FOURCC_nclx);
|
||||||
|
else
|
||||||
|
GST_WRITE_UINT32_LE (data, FOURCC_nclc);
|
||||||
|
|
||||||
GST_WRITE_UINT16_BE (data + 4, primaries);
|
GST_WRITE_UINT16_BE (data + 4, primaries);
|
||||||
GST_WRITE_UINT16_BE (data + 6, transfer_function); /* transfer function */
|
GST_WRITE_UINT16_BE (data + 6, transfer_function);
|
||||||
GST_WRITE_UINT16_BE (data + 8, matrix);
|
GST_WRITE_UINT16_BE (data + 8, matrix);
|
||||||
|
|
||||||
|
if (is_mp4) {
|
||||||
|
GST_WRITE_UINT8 (data + 10,
|
||||||
|
colorimetry->range == GST_VIDEO_COLOR_RANGE_0_255 ? 0x80 : 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
return build_atom_info_wrapper ((Atom *) atom_data, atom_data_copy_data,
|
return build_atom_info_wrapper ((Atom *) atom_data, atom_data_copy_data,
|
||||||
atom_data_free);
|
atom_data_free);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ AtomInfo * build_jp2h_extension (gint width, gint height, const gchar *
|
||||||
|
|
||||||
AtomInfo * build_jp2x_extension (const GstBuffer * prefix);
|
AtomInfo * build_jp2x_extension (const GstBuffer * prefix);
|
||||||
AtomInfo * build_fiel_extension (GstVideoInterlaceMode mode, GstVideoFieldOrder order);
|
AtomInfo * build_fiel_extension (GstVideoInterlaceMode mode, GstVideoFieldOrder order);
|
||||||
AtomInfo * build_colr_extension (GstVideoColorimetry colorimetry);
|
AtomInfo * build_colr_extension (const GstVideoColorimetry *colorimetry, gboolean is_mp4);
|
||||||
AtomInfo * build_ac3_extension (guint8 fscod, guint8 bsid,
|
AtomInfo * build_ac3_extension (guint8 fscod, guint8 bsid,
|
||||||
guint8 bsmod, guint8 acmod,
|
guint8 bsmod, guint8 acmod,
|
||||||
guint8 lfe_on, guint8 bitrate_code);
|
guint8 lfe_on, guint8 bitrate_code);
|
||||||
|
|
|
@ -170,6 +170,7 @@ G_BEGIN_DECLS
|
||||||
#define FOURCC_mp4v GST_MAKE_FOURCC('m','p','4','v')
|
#define FOURCC_mp4v GST_MAKE_FOURCC('m','p','4','v')
|
||||||
#define FOURCC_name GST_MAKE_FOURCC('n','a','m','e')
|
#define FOURCC_name GST_MAKE_FOURCC('n','a','m','e')
|
||||||
#define FOURCC_nclc GST_MAKE_FOURCC('n','c','l','c')
|
#define FOURCC_nclc GST_MAKE_FOURCC('n','c','l','c')
|
||||||
|
#define FOURCC_nclx GST_MAKE_FOURCC('n','c','l','x')
|
||||||
#define FOURCC_opus GST_MAKE_FOURCC('O','p','u','s')
|
#define FOURCC_opus GST_MAKE_FOURCC('O','p','u','s')
|
||||||
#define FOURCC_dops GST_MAKE_FOURCC('d','O','p','s')
|
#define FOURCC_dops GST_MAKE_FOURCC('d','O','p','s')
|
||||||
#define FOURCC_pasp GST_MAKE_FOURCC('p','a','s','p')
|
#define FOURCC_pasp GST_MAKE_FOURCC('p','a','s','p')
|
||||||
|
|
|
@ -4240,11 +4240,8 @@ gst_qt_mux_video_sink_set_caps (GstQTPad * qtpad, GstCaps * caps)
|
||||||
entry.fourcc = fourcc;
|
entry.fourcc = fourcc;
|
||||||
} else if (strcmp (mimetype, "video/x-prores") == 0) {
|
} else if (strcmp (mimetype, "video/x-prores") == 0) {
|
||||||
const gchar *variant;
|
const gchar *variant;
|
||||||
const gchar *colorimetry_str;
|
|
||||||
GstVideoColorimetry colorimetry;
|
|
||||||
|
|
||||||
variant = gst_structure_get_string (structure, "variant");
|
variant = gst_structure_get_string (structure, "variant");
|
||||||
colorimetry_str = gst_structure_get_string (structure, "colorimetry");
|
|
||||||
if (!variant || !g_strcmp0 (variant, "standard"))
|
if (!variant || !g_strcmp0 (variant, "standard"))
|
||||||
entry.fourcc = FOURCC_apcn;
|
entry.fourcc = FOURCC_apcn;
|
||||||
else if (!g_strcmp0 (variant, "lt"))
|
else if (!g_strcmp0 (variant, "lt"))
|
||||||
|
@ -4253,25 +4250,26 @@ gst_qt_mux_video_sink_set_caps (GstQTPad * qtpad, GstCaps * caps)
|
||||||
entry.fourcc = FOURCC_apch;
|
entry.fourcc = FOURCC_apch;
|
||||||
else if (!g_strcmp0 (variant, "proxy"))
|
else if (!g_strcmp0 (variant, "proxy"))
|
||||||
entry.fourcc = FOURCC_apco;
|
entry.fourcc = FOURCC_apco;
|
||||||
|
|
||||||
if (gst_video_colorimetry_from_string (&colorimetry, colorimetry_str)) {
|
|
||||||
ext_atom = build_colr_extension (colorimetry);
|
|
||||||
if (ext_atom)
|
|
||||||
ext_atom_list = g_list_append (ext_atom_list, ext_atom);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colorimetry_str == NULL) {
|
|
||||||
/* TODO: Maybe implement better heuristics */
|
|
||||||
GST_WARNING_OBJECT (qtmux,
|
|
||||||
"Colorimetry information not found in caps. The resulting file's "
|
|
||||||
"color information might be wrong");
|
|
||||||
colorimetry_str = height < 720 ? "bt601" : "bt709";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entry.fourcc)
|
if (!entry.fourcc)
|
||||||
goto refuse_caps;
|
goto refuse_caps;
|
||||||
|
|
||||||
|
if (qtmux_klass->format == GST_QT_MUX_FORMAT_QT ||
|
||||||
|
qtmux_klass->format == GST_QT_MUX_FORMAT_MP4) {
|
||||||
|
const gchar *s;
|
||||||
|
GstVideoColorimetry colorimetry;
|
||||||
|
|
||||||
|
s = gst_structure_get_string (structure, "colorimetry");
|
||||||
|
if (s && gst_video_colorimetry_from_string (&colorimetry, s)) {
|
||||||
|
ext_atom =
|
||||||
|
build_colr_extension (&colorimetry,
|
||||||
|
qtmux_klass->format == GST_QT_MUX_FORMAT_MP4);
|
||||||
|
if (ext_atom)
|
||||||
|
ext_atom_list = g_list_append (ext_atom_list, ext_atom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (qtmux_klass->format == GST_QT_MUX_FORMAT_QT
|
if (qtmux_klass->format == GST_QT_MUX_FORMAT_QT
|
||||||
|| strcmp (mimetype, "image/x-j2c") == 0
|
|| strcmp (mimetype, "image/x-j2c") == 0
|
||||||
|| strcmp (mimetype, "image/x-jpc") == 0) {
|
|| strcmp (mimetype, "image/x-jpc") == 0) {
|
||||||
|
|
Loading…
Reference in a new issue