qtmux: Also update btrt atom

When rewriting bitrates, also update the btrt atom under stsd
This commit is contained in:
Thiago Santos 2011-09-30 12:41:52 -03:00
parent e58b0466ec
commit 31acc88b39
2 changed files with 13 additions and 6 deletions

View file

@ -2747,6 +2747,7 @@ atom_trak_update_bitrates (AtomTRAK * trak, guint32 avg_bitrate,
guint32 max_bitrate)
{
AtomESDS *esds = NULL;
AtomData *btrt = NULL;
AtomSTSD *stsd;
GList *iter;
GList *extensioniter = NULL;
@ -2780,7 +2781,8 @@ atom_trak_update_bitrates (AtomTRAK * trak, guint32 avg_bitrate,
AtomInfo *atominfo = extensioniter->data;
if (atominfo->atom->type == FOURCC_esds) {
esds = (AtomESDS *) atominfo->atom;
break;
} else if (atominfo->atom->type == FOURCC_btrt) {
btrt = (AtomData *) atominfo->atom;
}
}
@ -2790,6 +2792,14 @@ atom_trak_update_bitrates (AtomTRAK * trak, guint32 avg_bitrate,
if (max_bitrate && esds->es.dec_conf_desc.max_bitrate == 0)
esds->es.dec_conf_desc.max_bitrate = max_bitrate;
}
if (btrt) {
/* type(4bytes) + size(4bytes) + buffersize(4bytes) +
* maxbitrate(bytes) + avgbitrate(bytes) */
if (max_bitrate && GST_READ_UINT32_BE (btrt->data + 4) == 0)
GST_WRITE_UINT32_BE (btrt->data + 4, max_bitrate);
if (avg_bitrate && GST_READ_UINT32_BE (btrt->data + 8) == 0)
GST_WRITE_UINT32_BE (btrt->data + 8, avg_bitrate);
}
}
/*
@ -4012,17 +4022,13 @@ build_btrt_extension (guint32 buffer_size_db, guint32 avg_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, max_bitrate);
GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf) + 8, avg_bitrate);
atom_data =
atom_data_new_from_gst_buffer (GST_MAKE_FOURCC ('b', 't', 'r', 't'), buf);
atom_data = atom_data_new_from_gst_buffer (FOURCC_btrt, buf);
gst_buffer_unref (buf);
return build_atom_info_wrapper ((Atom *) atom_data, atom_data_copy_data,

View file

@ -208,6 +208,7 @@ G_BEGIN_DECLS
#define FOURCC_mfhd GST_MAKE_FOURCC('m','f','h','d')
#define FOURCC_mvhd GST_MAKE_FOURCC('m','v','h','d')
#define FOURCC_traf GST_MAKE_FOURCC('t','r','a','f')
#define FOURCC_btrt GST_MAKE_FOURCC('b','t','r','t')
/* Xiph fourcc */
#define FOURCC_XiTh GST_MAKE_FOURCC('X','i','T','h')