mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
qtmux: Write 'btrt' atom for H.264 media if possible
This writes out the optional 'btrt' atom (MPEG4BitrateBox) for H.264 media if either or both of average and maximum bitrate are available for the stream. https://bugzilla.gnome.org/show_bug.cgi?id=623678
This commit is contained in:
parent
4b4398c9dd
commit
9e5c575b49
3 changed files with 29 additions and 0 deletions
|
@ -3124,6 +3124,30 @@ build_esds_extension (AtomTRAK * trak, guint8 object_type, guint8 stream_type,
|
||||||
atom_esds_free);
|
atom_esds_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AtomInfo *
|
||||||
|
build_btrt_extension (guint32 buffer_size_db, guint32 avg_bitrate,
|
||||||
|
guint32 max_bitrate)
|
||||||
|
{
|
||||||
|
AtomData *atom_data;
|
||||||
|
GstBuffer *buf;
|
||||||
|
|
||||||
|
if (buffer_size_db == 0 && avg_bitrate == 0 && max_bitrate == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
buf = gst_buffer_new_and_alloc (12);
|
||||||
|
|
||||||
|
GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf), buffer_size_db);
|
||||||
|
GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + 4, avg_bitrate);
|
||||||
|
GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + 8, max_bitrate);
|
||||||
|
|
||||||
|
atom_data =
|
||||||
|
atom_data_new_from_gst_buffer (GST_MAKE_FOURCC ('b', 't', 'r', 't'), buf);
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
|
return build_atom_info_wrapper ((Atom *) atom_data, atom_data_copy_data,
|
||||||
|
atom_data_free);
|
||||||
|
}
|
||||||
|
|
||||||
static AtomInfo *
|
static AtomInfo *
|
||||||
build_mov_wave_extension (AtomTRAK * trak, guint32 fourcc, AtomInfo * atom1,
|
build_mov_wave_extension (AtomTRAK * trak, guint32 fourcc, AtomInfo * atom1,
|
||||||
AtomInfo * atom2, gboolean terminator)
|
AtomInfo * atom2, gboolean terminator)
|
||||||
|
|
|
@ -726,6 +726,8 @@ AtomInfo * build_mov_alac_extension (AtomTRAK * trak, const GstBuffer * cod
|
||||||
AtomInfo * build_esds_extension (AtomTRAK * trak, guint8 object_type,
|
AtomInfo * build_esds_extension (AtomTRAK * trak, guint8 object_type,
|
||||||
guint8 stream_type, const GstBuffer * codec_data,
|
guint8 stream_type, const GstBuffer * codec_data,
|
||||||
guint32 avg_bitrate, guint32 max_bitrate);
|
guint32 avg_bitrate, guint32 max_bitrate);
|
||||||
|
AtomInfo * build_btrt_extension (guint32 buffer_size_db, guint32 avg_bitrate,
|
||||||
|
guint32 max_bitrate);
|
||||||
AtomInfo * build_jp2h_extension (AtomTRAK * trak, gint width, gint height,
|
AtomInfo * build_jp2h_extension (AtomTRAK * trak, gint width, gint height,
|
||||||
guint32 fourcc, gint ncomp,
|
guint32 fourcc, gint ncomp,
|
||||||
const GValue * cmap_array,
|
const GValue * cmap_array,
|
||||||
|
|
|
@ -2318,6 +2318,9 @@ gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps)
|
||||||
} else if (strcmp (mimetype, "video/x-h264") == 0) {
|
} else if (strcmp (mimetype, "video/x-h264") == 0) {
|
||||||
entry.fourcc = FOURCC_avc1;
|
entry.fourcc = FOURCC_avc1;
|
||||||
qtpad->is_out_of_order = TRUE;
|
qtpad->is_out_of_order = TRUE;
|
||||||
|
ext_atom = build_btrt_extension (0, qtpad->avg_bitrate, qtpad->max_bitrate);
|
||||||
|
if (ext_atom != NULL)
|
||||||
|
ext_atom_list = g_list_prepend (ext_atom_list, ext_atom);
|
||||||
if (!codec_data)
|
if (!codec_data)
|
||||||
GST_WARNING_OBJECT (qtmux, "no codec_data in h264 caps");
|
GST_WARNING_OBJECT (qtmux, "no codec_data in h264 caps");
|
||||||
ext_atom = build_codec_data_extension (FOURCC_avcC, codec_data);
|
ext_atom = build_codec_data_extension (FOURCC_avcC, codec_data);
|
||||||
|
|
Loading…
Reference in a new issue