vlc | branch: master | Francois Cartegnie <[email protected]> | Mon Oct 20 17:51:16 2014 +0200| [7f4166b98d61e2e280ca9e6158e007477fdc2920] | committer: Francois Cartegnie
demux: mp4: set track priority by elst time /samples/mov/variable-fourcc/kldatei.mov > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7f4166b98d61e2e280ca9e6158e007477fdc2920 --- modules/demux/mp4/mp4.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index a8eb4c2..6867bc2 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -2737,6 +2737,7 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track, } } + const MP4_Box_t *p_tsel; /* now create es */ if( b_force_enable && ( p_track->fmt.i_cat == VIDEO_ES || p_track->fmt.i_cat == AUDIO_ES ) ) @@ -2746,10 +2747,9 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track, p_track->b_enable = true; p_track->fmt.i_priority = ES_PRIORITY_SELECTABLE_MIN; } - else + else if ( (p_tsel = MP4_BoxGet( p_box_trak, "udta/tsel" )) ) { - const MP4_Box_t *p_tsel = MP4_BoxGet( p_box_trak, "udta/tsel" ); - if ( p_tsel && BOXDATA(p_tsel) && BOXDATA(p_tsel)->i_switch_group ) + if ( BOXDATA(p_tsel) && BOXDATA(p_tsel)->i_switch_group ) { p_track->i_switch_group = BOXDATA(p_tsel)->i_switch_group; int i_priority = ES_PRIORITY_SELECTABLE_MIN; @@ -2769,6 +2769,23 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track, p_track->fmt.i_priority = i_priority; } } + /* If there's no tsel, try to enable the track coming first in edit list */ + else if ( p_track->p_elst && p_track->fmt.i_priority == ES_PRIORITY_SELECTABLE_MIN ) + { +#define MAX_SELECTABLE (INT_MAX - ES_PRIORITY_SELECTABLE_MIN) + for ( uint32_t i=0; i<p_track->BOXDATA(p_elst)->i_entry_count; i++ ) + { + if ( p_track->BOXDATA(p_elst)->i_media_time[i] >= 0 && + p_track->BOXDATA(p_elst)->i_segment_duration[i] ) + { + /* We do selection by inverting start time into priority. + The track with earliest edit will have the highest prio */ + const int i_time = __MIN( MAX_SELECTABLE, p_track->BOXDATA(p_elst)->i_media_time[i] ); + p_track->fmt.i_priority = ES_PRIORITY_SELECTABLE_MIN + MAX_SELECTABLE - i_time; + break; + } + } + } p_track->p_es = NULL; if( TrackCreateES( p_demux, _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
