Commit 77498fa4 authored by Laurent Aimar's avatar Laurent Aimar

* mp4: support vobsub in .mp4 (NeroRecode), but won't work if the video

has been cropped.
parent b53e633c
...@@ -409,7 +409,12 @@ static int MP4_NextBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -409,7 +409,12 @@ static int MP4_NextBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
return( 0 ); /* out of bound */ return( 0 ); /* out of bound */
} }
} }
return( MP4_SeekStream( p_stream, p_box->i_size + p_box->i_pos ) ? 0 : 1 ); if( MP4_SeekStream( p_stream, p_box->i_size + p_box->i_pos ) )
{
return 0;
}
return 1;
} }
/***************************************************************************** /*****************************************************************************
...@@ -1390,6 +1395,12 @@ static void MP4_FreeBox_sample_vide( MP4_Box_t *p_box ) ...@@ -1390,6 +1395,12 @@ static void MP4_FreeBox_sample_vide( MP4_Box_t *p_box )
FREE( p_box->data.p_sample_vide->p_qt_image_description ); FREE( p_box->data.p_sample_vide->p_qt_image_description );
} }
static int MP4_ReadBox_sample_mp4s( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 8 );
MP4_ReadBoxContainerRaw( p_stream, p_box );
return 1;
}
static int MP4_ReadBox_sample_text( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) static int MP4_ReadBox_sample_text( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{ {
...@@ -2322,7 +2333,7 @@ static struct ...@@ -2322,7 +2333,7 @@ static struct
{ FOURCC_jpeg, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide }, { FOURCC_jpeg, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_avc1, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide }, { FOURCC_avc1, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_mp4s, MP4_ReadBox_default, MP4_FreeBox_Common }, { FOURCC_mp4s, MP4_ReadBox_sample_mp4s, MP4_FreeBox_Common },
/* XXX there is 2 box where we could find this entry stbl and tref*/ /* XXX there is 2 box where we could find this entry stbl and tref*/
{ FOURCC_hint, MP4_ReadBox_default, MP4_FreeBox_Common }, { FOURCC_hint, MP4_ReadBox_default, MP4_FreeBox_Common },
......
...@@ -170,6 +170,7 @@ ...@@ -170,6 +170,7 @@
#define FOURCC_priv VLC_FOURCC( 'p', 'r', 'i', 'v' ) #define FOURCC_priv VLC_FOURCC( 'p', 'r', 'i', 'v' )
#define FOURCC_text VLC_FOURCC( 't', 'e', 'x', 't' ) #define FOURCC_text VLC_FOURCC( 't', 'e', 'x', 't' )
#define FOURCC_subp VLC_FOURCC( 's', 'u', 'b', 'p' )
#define FOURCC_0xa9nam VLC_FOURCC( 0xa9, 'n', 'a', 'm' ) #define FOURCC_0xa9nam VLC_FOURCC( 0xa9, 'n', 'a', 'm' )
#define FOURCC_0xa9aut VLC_FOURCC( 0xa9, 'a', 'u', 't' ) #define FOURCC_0xa9aut VLC_FOURCC( 0xa9, 'a', 'u', 't' )
......
...@@ -597,31 +597,35 @@ static int Demux( demux_t *p_demux ) ...@@ -597,31 +597,35 @@ static int Demux( demux_t *p_demux )
(uint32_t*)p_block->p_buffer, (uint32_t*)p_block->p_buffer,
p_block->i_buffer ); p_block->i_buffer );
} }
else if( tk->fmt.i_cat == SPU_ES && p_block->i_buffer >= 2 ) else if( tk->fmt.i_cat == SPU_ES )
{ {
uint16_t i_size = GetWBE( p_block->p_buffer ); if( tk->fmt.i_codec == VLC_FOURCC( 's', 'u', 'b', 't' ) && p_block->i_buffer >= 2 )
if( i_size + 2 <= p_block->i_buffer )
{ {
char *p; uint16_t i_size = GetWBE( p_block->p_buffer );
/* remove the length field, and append a '\0' */
memmove( &p_block->p_buffer[0], &p_block->p_buffer[2], i_size ); if( i_size + 2 <= p_block->i_buffer )
p_block->p_buffer[i_size] = '\0';
p_block->i_buffer = i_size + 1;
/* convert \r -> \n */
while( ( p = strchr( p_block->p_buffer, '\r' ) ) )
{ {
*p = '\n'; char *p;
/* remove the length field, and append a '\0' */
memmove( &p_block->p_buffer[0], &p_block->p_buffer[2], i_size );
p_block->p_buffer[i_size] = '\0';
p_block->i_buffer = i_size + 1;
/* convert \r -> \n */
while( ( p = strchr( p_block->p_buffer, '\r' ) ) )
{
*p = '\n';
}
}
else
{
/* Invalid */
p_block->i_buffer = 0;
} }
}
else
{
/* Invalid */
p_block->i_buffer = 0;
} }
} }
p_block->i_dts = MP4_TrackGetPTS( p_demux, tk ) + 1; p_block->i_dts = MP4_TrackGetPTS( p_demux, tk ) + 1;
fprintf( stderr, "dts=%lld\n", p_block->i_dts );
p_block->i_pts = tk->fmt.i_cat == VIDEO_ES ? 0 : p_block->i_dts + 1; p_block->i_pts = tk->fmt.i_cat == VIDEO_ES ? 0 : p_block->i_dts + 1;
...@@ -787,8 +791,13 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -787,8 +791,13 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
case DEMUX_GET_TITLE_INFO:
case DEMUX_SET_NEXT_DEMUX_TIME:
case DEMUX_SET_GROUP:
return VLC_EGENERIC;
default: default:
msg_Err( p_demux, "control query unimplemented !!!" ); msg_Warn( p_demux, "control query unimplemented !!!" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
...@@ -1048,7 +1057,7 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track, ...@@ -1048,7 +1057,7 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
p_sample = MP4_BoxGet( p_track->p_stsd, "[%d]", p_sample = MP4_BoxGet( p_track->p_stsd, "[%d]",
p_track->chunk[i_chunk].i_sample_description_index - 1 ); p_track->chunk[i_chunk].i_sample_description_index - 1 );
if( !p_sample || !p_sample->data.p_data ) if( !p_sample || ( !p_sample->data.p_data && p_track->fmt.i_cat != SPU_ES ) )
{ {
msg_Warn( p_demux, msg_Warn( p_demux,
"cannot find SampleEntry (track[Id 0x%x])", "cannot find SampleEntry (track[Id 0x%x])",
...@@ -1058,7 +1067,7 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track, ...@@ -1058,7 +1067,7 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
p_track->p_sample = p_sample; p_track->p_sample = p_sample;
if( p_track->i_sample_size == 1 ) if( p_track->fmt.i_cat == AUDIO_ES && p_track->i_sample_size == 1 )
{ {
MP4_Box_data_sample_soun_t *p_soun; MP4_Box_data_sample_soun_t *p_soun;
...@@ -1175,6 +1184,15 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track, ...@@ -1175,6 +1184,15 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
case( 0x6c ): /* jpeg */ case( 0x6c ): /* jpeg */
p_track->fmt.i_codec = VLC_FOURCC( 'j','p','e','g' ); p_track->fmt.i_codec = VLC_FOURCC( 'j','p','e','g' );
break; break;
/* Private ID */
case( 0xe0 ): /* NeroDigital: dvd subs */
if( p_track->fmt.i_cat == SPU_ES )
{
p_track->fmt.i_codec = VLC_FOURCC( 's','p','u',' ' );
break;
}
/* Fallback */
default: default:
/* Unknown entry, but don't touch i_fourcc */ /* Unknown entry, but don't touch i_fourcc */
msg_Warn( p_demux, msg_Warn( p_demux,
...@@ -1597,6 +1615,7 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track, ...@@ -1597,6 +1615,7 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track,
break; break;
case( FOURCC_text ): case( FOURCC_text ):
case( FOURCC_subp ):
p_track->fmt.i_cat = SPU_ES; p_track->fmt.i_cat = SPU_ES;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment