/*****************************************************************************
* Declaration of local function
*****************************************************************************/
-static void MP4_TrackCreate ( demux_t *, mp4_track_t *, MP4_Box_t *);
-static void MP4_TrackDestroy( demux_t *, mp4_track_t * );
+static void MP4_TrackCreate ( demux_t *, mp4_track_t *, MP4_Box_t *, bool b_force_enable );
+static void MP4_TrackDestroy( mp4_track_t * );
static int MP4_TrackSelect ( demux_t *, mp4_track_t *, mtime_t );
static void MP4_TrackUnselect(demux_t *, mp4_track_t * );
return INT64_C(1000000) * i_dts / p_track->i_timescale;
}
-static inline int64_t MP4_TrackGetPTSDelta( demux_t *p_demux, mp4_track_t *p_track )
+static inline int64_t MP4_TrackGetPTSDelta( mp4_track_t *p_track )
{
mp4_chunk_t *ck = &p_track->chunk[p_track->i_chunk];
unsigned int i_index = 0;
unsigned int i;
bool b_seekable;
+ bool b_enabled_es;
/* A little test to see if it could be a mp4 */
if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 ) return VLC_EGENERIC;
if( end ) end[1] = '\0';
else *psz_path = '\0';
- asprintf( &psz_absolute, "%s://%s%s",
- p_demux->psz_access, psz_path, psz_ref );
+ if( asprintf( &psz_absolute, "%s://%s%s",
+ p_demux->psz_access, psz_path, psz_ref ) < 0 )
+ return VLC_ENOMEM;
free( psz_ref );
psz_ref = psz_absolute;
goto error;
memset( p_sys->track, 0, p_sys->i_tracks * sizeof( mp4_track_t ) );
- /* Search the first chap reference (like quicktime) */
+ /* Search the first chap reference (like quicktime) and
+ * check that at least 1 stream is enabled */
p_sys->p_tref_chap = NULL;
+ b_enabled_es = false;
for( i = 0; i < p_sys->i_tracks; i++ )
{
MP4_Box_t *p_trak = MP4_BoxGet( p_sys->p_root, "/moov/trak[%d]", i );
- MP4_Box_t *p_chap = MP4_BoxGet( p_trak, "tref/chap", i );
- if( !p_chap || p_chap->data.p_tref_generic->i_entry_count <= 0 )
- continue;
- p_sys->p_tref_chap = p_chap;
- break;
+
+ MP4_Box_t *p_tkhd = MP4_BoxGet( p_trak, "tkhd" );
+ if( p_tkhd && (p_tkhd->data.p_tkhd->i_flags&MP4_TRACK_ENABLED) )
+ b_enabled_es = true;
+
+ MP4_Box_t *p_chap = MP4_BoxGet( p_trak, "tref/chap", i );
+ if( p_chap && p_chap->data.p_tref_generic->i_entry_count > 0 && !p_sys->p_tref_chap )
+ p_sys->p_tref_chap = p_chap;
}
/* now process each track and extract all usefull information */
for( i = 0; i < p_sys->i_tracks; i++ )
{
p_trak = MP4_BoxGet( p_sys->p_root, "/moov/trak[%d]", i );
- MP4_TrackCreate( p_demux, &p_sys->track[i], p_trak );
+ MP4_TrackCreate( p_demux, &p_sys->track[i], p_trak, !b_enabled_es );
if( p_sys->track[i].b_ok && !p_sys->track[i].b_chapter )
{
/* dts */
p_block->i_dts = MP4_TrackGetDTS( p_demux, tk ) + 1;
/* pts */
- i_delta = MP4_TrackGetPTSDelta( p_demux, tk );
+ i_delta = MP4_TrackGetPTSDelta( tk );
if( i_delta != -1 )
p_block->i_pts = p_block->i_dts + i_delta;
else if( tk->fmt.i_cat != VIDEO_ES )
MP4_BoxFree( p_demux->s, p_sys->p_root );
for( i_track = 0; i_track < p_sys->i_tracks; i_track++ )
{
- MP4_TrackDestroy( p_demux, &p_sys->track[i_track] );
+ MP4_TrackDestroy( &p_sys->track[i_track] );
}
FREENULL( p_sys->track );
for( tk->i_sample = 0; tk->i_sample < tk->i_sample_count; tk->i_sample++ )
{
const int64_t i_dts = MP4_TrackGetDTS( p_demux, tk );
- const int64_t i_pts_delta = MP4_TrackGetPTSDelta( p_demux, tk );
+ const int64_t i_pts_delta = MP4_TrackGetPTSDelta( tk );
const unsigned int i_size = MP4_TrackSampleSize( tk );
if( i_size > 0 && !stream_Seek( p_demux->s, MP4_TrackGetPos( tk ) ) )
p_track->p_sample = p_sample;
- if( p_track->fmt.i_cat == AUDIO_ES && p_track->i_sample_size == 1 )
+ if( p_track->fmt.i_cat == AUDIO_ES && ( p_track->i_sample_size == 1 || p_track->i_sample_size == 2 ) )
{
MP4_Box_data_sample_soun_t *p_soun;
case VLC_FOURCC( 'u', 'l', 'a', 'w' ):
p_soun->i_samplesize = 8;
break;
+ case VLC_FOURCC( 'N', 'O', 'N', 'E' ):
+ case VLC_FOURCC( 'r', 'a', 'w', ' ' ):
+ case VLC_FOURCC( 't', 'w', 'o', 's' ):
+ case VLC_FOURCC( 's', 'o', 'w', 't' ):
+ /* What would be the fun if you could trust the .mov */
+ p_track->i_sample_size = ((p_soun->i_samplesize+7)/8) * p_soun->i_channelcount;
+ break;
default:
break;
}
}
}
-
/* It's a little ugly but .. there are special cases */
switch( p_sample->i_type )
{
break;
case( VLC_FOURCC( 'r', 'a', 'w', ' ' ) ):
- p_track->fmt.i_codec = VLC_FOURCC( 'a', 'r', 'a', 'w' );
+ case( VLC_FOURCC( 'N', 'O', 'N', 'E' ) ):
+ {
+ MP4_Box_data_sample_soun_t *p_soun = p_sample->data.p_sample_soun;
+
+ if(p_soun && (p_soun->i_samplesize+7)/8 == 1 )
+ p_track->fmt.i_codec = VLC_FOURCC( 'u', '8', ' ', ' ' );
+ else
+ p_track->fmt.i_codec = VLC_FOURCC( 't', 'w', 'o', 's' );
/* Buggy files workaround */
if( p_sample->data.p_sample_soun && (p_track->i_timescale !=
p_soun->i_sampleratehi = p_track->i_timescale;
}
break;
+ }
case( VLC_FOURCC( 's', '2', '6', '3' ) ):
p_track->fmt.i_codec = VLC_FOURCC( 'h', '2', '6', '3' );
case( 0x6c ): /* jpeg */
p_track->fmt.i_codec = VLC_FOURCC( 'j','p','e','g' );
break;
+ case( 0x6d ): /* png */
+ p_track->fmt.i_codec = VLC_FOURCC( 'p','n','g',' ' );
+ break;
+ case( 0x6e ): /* jpeg200 */
+ p_track->fmt.i_codec = VLC_FOURCC( 'M','J','2','C' );
+ break;
+ case( 0xa3 ): /* vc1 */
+ p_track->fmt.i_codec = VLC_FOURCC( 'W','V','C','1' );
+ break;
/* Private ID */
case( 0xe0 ): /* NeroDigital: dvd subs */
p_track->fmt.subs.spu.i_original_frame_height = p_track->i_height;
break;
}
+ case( 0xe1 ): /* QCelp for 3gp */
+ if( p_track->fmt.i_cat == AUDIO_ES )
+ {
+ p_track->fmt.i_codec = VLC_FOURCC( 'Q','c','l','p' );
+ }
+ break;
+
/* Fallback */
default:
/* Unknown entry, but don't touch i_fourcc */
break;
}
+ case VLC_FOURCC('m','s',0x00,0x02):
+ case VLC_FOURCC('m','s',0x00,0x11):
+ p_track->fmt.audio.i_blockalign = p_sample->data.p_sample_soun->i_bytes_per_frame;
+ break;
+
default:
break;
}
* If it succeed b_ok is set to 1 else to 0
****************************************************************************/
static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track,
- MP4_Box_t *p_box_trak )
+ MP4_Box_t *p_box_trak,
+ bool b_force_enable )
{
demux_sys_t *p_sys = p_demux->p_sys;
/* do we launch this track by default ? */
p_track->b_enable =
( ( p_tkhd->data.p_tkhd->i_flags&MP4_TRACK_ENABLED ) != 0 );
+ if( !p_track->b_enable )
+ p_track->fmt.i_priority = -1;
p_track->i_track_ID = p_tkhd->data.p_tkhd->i_track_ID;
p_track->i_width = p_tkhd->data.p_tkhd->i_width / 65536;
}
/* now create es */
+ if( b_force_enable &&
+ ( p_track->fmt.i_cat == VIDEO_ES || p_track->fmt.i_cat == AUDIO_ES ) )
+ {
+ msg_Warn( p_demux, "Enabling track[Id 0x%x] (buggy file without enabled track)",
+ p_track->i_track_ID );
+ p_track->b_enable = true;
+ p_track->fmt.i_priority = 0;
+ }
+
p_track->p_es = NULL;
if( TrackCreateES( p_demux,
p_track, p_track->i_chunk,
****************************************************************************
* Destroy a track created by MP4_TrackCreate.
****************************************************************************/
-static void MP4_TrackDestroy( demux_t *p_demux, mp4_track_t *p_track )
+static void MP4_TrackDestroy( mp4_track_t *p_track )
{
unsigned int i_chunk;