gppmux: enhance ftyp brand heuristic. Fixes #584360.

This commit is contained in:
Mark Nauwelaerts 2009-06-01 22:42:08 +02:00
parent 7709bf5f2a
commit 7f82fe3b46
4 changed files with 57 additions and 4 deletions

View file

@ -2783,6 +2783,9 @@ atom_trak_set_audio_type (AtomTRAK * trak, AtomsContext * context,
atom_trak_set_audio_commons (trak, context, scale);
ste = atom_trak_add_audio_entry (trak, context, entry->fourcc);
trak->is_video = FALSE;
trak->is_h264 = FALSE;
ste->version = entry->version;
ste->compression_id = entry->compression_id;
ste->sample_size = entry->sample_size;
@ -2811,6 +2814,9 @@ atom_trak_set_video_type (AtomTRAK * trak, AtomsContext * context,
entry->height);
ste = atom_trak_add_video_entry (trak, context, entry->fourcc);
trak->is_video = TRUE;
trak->is_h264 = (entry->fourcc == FOURCC_avc1);
ste->width = entry->width;
ste->height = entry->height;
ste->depth = entry->depth;

View file

@ -518,6 +518,10 @@ typedef struct _AtomTRAK
AtomTKHD tkhd;
AtomMDIA mdia;
/* some helper info for structural conformity checks */
gboolean is_video;
gboolean is_h264;
} AtomTRAK;
typedef struct _AtomMOOV

View file

@ -53,6 +53,9 @@ G_BEGIN_DECLS
#define FOURCC_mp41 GST_MAKE_FOURCC('m','p','4','1')
#define FOURCC_mp42 GST_MAKE_FOURCC('m','p','4','2')
#define FOURCC_mjp2 GST_MAKE_FOURCC('m','j','p','2')
#define FOURCC_3gp4 GST_MAKE_FOURCC('3','g','p','4')
#define FOURCC_3gp6 GST_MAKE_FOURCC('3','g','p','6')
#define FOURCC_3gg6 GST_MAKE_FOURCC('3','g','g','6')
#define FOURCC_3gg7 GST_MAKE_FOURCC('3','g','g','7')
#define FOURCC_avc1 GST_MAKE_FOURCC('a','v','c','1')
#define FOURCC_qt__ GST_MAKE_FOURCC('q','t',' ',' ')

View file

@ -205,14 +205,40 @@ gst_qt_mux_map_format_to_flavor (GstQTMuxFormat format)
return ATOMS_TREE_FLAVOR_ISOM;
}
static void
gst_qt_mux_map_check_tracks (AtomMOOV * moov, gint * _video, gint * _audio,
gboolean * _has_h264)
{
GList *it;
gint video = 0, audio = 0;
gboolean has_h264 = FALSE;
for (it = moov->traks; it != NULL; it = g_list_next (it)) {
AtomTRAK *track = it->data;
if (track->is_video) {
video++;
if (track->is_h264)
has_h264 = TRUE;
} else
audio++;
}
if (_video)
*_video = video;
if (_audio)
*_audio = audio;
if (_has_h264)
*_has_h264 = has_h264;
}
/* pretty static, but possibly dynamic format info */
/* notes:
* - avc1 brand is not used, since the specific extensions indicated by it
* are not used (e.g. sample groupings, etc)
* - 3GPP2 specific formats not (yet) used, only 3GPP, so no need yet either
* for 3g2a (but later on, moov might be used to conditionally switch to
* 3g2a if needed) */
* - TODO: maybe even more 3GPP brand fine-tuning ??
* (but that might need ftyp rewriting at the end) */
void
gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
guint32 * _major, guint32 * _version, GList ** _compatible, AtomMOOV * moov)
@ -244,9 +270,23 @@ gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
comp = mp4_brands;
break;
case GST_QT_MUX_FORMAT_3GP:
major = FOURCC_3gg7;
{
gint video, audio;
gboolean has_h264;
gst_qt_mux_map_check_tracks (moov, &video, &audio, &has_h264);
/* only track restriction really matters for Basic Profile */
if (video <= 1 && audio <= 1) {
/* it seems only newer spec knows about H264 */
major = has_h264 ? FOURCC_3gp6 : FOURCC_3gp4;
version = has_h264 ? 0x100 : 0x200;
} else {
major = FOURCC_3gg6;
version = 0x100;
}
comp = gpp_brands;
break;
}
case GST_QT_MUX_FORMAT_MJ2:
major = FOURCC_mjp2;
comp = mjp2_brands;