[vlc-commits] demux: mp4: add support for gsm/quicktime builtin
Francois Cartegnie
git at videolan.org
Fri Apr 17 22:12:00 CEST 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Apr 17 22:07:08 2015 +0200| [40e2844f4897c444f4c9f4575d5f2c7e452b5f9a] | committer: Francois Cartegnie
demux: mp4: add support for gsm/quicktime builtin
Some quicktime mov have invalid sample tables, requiring
quicktime "built-in" support, aka figure out.
The agsm atom must also not be used as codec as it is
apple GSM which has different block size and sample count
than the MS GSM codec (33,160/65,320).
refs samples/A-codecs/GSM/sample-gsm-8000.mov
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=40e2844f4897c444f4c9f4575d5f2c7e452b5f9a
---
modules/demux/mp4/essetup.c | 3 +++
modules/demux/mp4/libmp4.c | 1 +
modules/demux/mp4/libmp4.h | 1 +
modules/demux/mp4/mp4.c | 56 +++++++++++++++++++++++++++++++++++++------
4 files changed, 54 insertions(+), 7 deletions(-)
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 3bf5c61..1414c09 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -485,6 +485,9 @@ int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
/* It's a little ugly but .. there are special cases */
switch( p_sample->i_type )
{
+ case ATOM_agsm: /* Apple gsm 33 bytes != MS GSM (agsm fourcc, 65 bytes) */
+ p_track->fmt.i_codec = VLC_CODEC_GSM;
+ break;
case( VLC_FOURCC( '.', 'm', 'p', '3' ) ):
case( VLC_FOURCC( 'm', 's', 0x00, 0x55 ) ):
{
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 0abb781..dd30d3b 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -3736,6 +3736,7 @@ static const struct
/* for codecs */
{ ATOM_soun, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd },
+ { ATOM_agsm, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd },
{ ATOM_ac3, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd },
{ ATOM_eac3, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd },
{ ATOM_lpcm, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 4a88676..1196623 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -150,6 +150,7 @@
#define ATOM_samr VLC_FOURCC( 's', 'a', 'm', 'r' )
#define ATOM_sawb VLC_FOURCC( 's', 'a', 'w', 'b' )
#define ATOM_OggS VLC_FOURCC( 'O', 'g', 'g', 'S' )
+#define ATOM_agsm VLC_FOURCC( 'a', 'g', 's', 'm' )
#define ATOM_alac VLC_FOURCC( 'a', 'l', 'a', 'c' )
#define ATOM_ac3 VLC_FOURCC( 'a', 'c', '-', '3' )
#define ATOM_eac3 VLC_FOURCC( 'e', 'c', '-', '3' )
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index c842252..4d3f517 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -3009,16 +3009,28 @@ static int MP4_TrackSeek( demux_t *p_demux, mp4_track_t *p_track,
static inline uint32_t MP4_GetFixedSampleSize( const mp4_track_t *p_track,
const MP4_Box_data_sample_soun_t *p_soun )
{
- uint32_t i_size = 0;
+ uint32_t i_size = p_track->i_sample_size;
assert( p_track->i_sample_size != 0 );
- /* broken stsz sample size == 1 */
- if ( p_track->fmt.i_cat == AUDIO_ES &&
- p_track->i_sample_size == 1 && p_soun->i_samplesize > p_track->i_sample_size * 8 )
- i_size = p_soun->i_samplesize * p_soun->i_channelcount / 8;
- else
- i_size = p_track->i_sample_size;
+ /* QuickTime "built-in" support case fixups */
+ if( p_track->fmt.i_cat == AUDIO_ES &&
+ p_soun->i_compressionid == 0 && p_track->i_sample_size == 1 )
+ {
+ switch( p_track->fmt.i_codec )
+ {
+ case VLC_CODEC_GSM:
+ i_size = p_soun->i_channelcount;
+ break;
+ case ATOM_twos:
+ case ATOM_sowt:
+ case ATOM_raw:
+ i_size = p_soun->i_samplesize * p_soun->i_channelcount / 8;
+ break;
+ default:
+ break;
+ }
+ }
return i_size;
}
@@ -3105,6 +3117,21 @@ static uint32_t MP4_TrackGetReadSize( mp4_track_t *p_track, uint32_t *pi_nb_samp
/* uncompressed v0 (qt) or... not (ISO) */
+ /* Quicktime built-in support handling */
+ if( p_soun->i_compressionid == 0 && p_track->i_sample_size == 1 )
+ {
+ switch( p_track->fmt.i_codec )
+ {
+ /* sample size is not integer */
+ case VLC_CODEC_GSM:
+ *pi_nb_samples = 160 * p_track->fmt.audio.i_channels;
+ return 33 * p_track->fmt.audio.i_channels;
+ default:
+ break;
+ }
+ }
+
+ /* More regular V0 cases */
uint32_t i_max_v0_samples;
switch( p_track->fmt.i_codec )
{
@@ -3162,6 +3189,21 @@ static uint64_t MP4_TrackGetPos( mp4_track_t *p_track )
MP4_Box_data_sample_soun_t *p_soun =
p_track->p_sample->data.p_sample_soun;
+ /* Quicktime builtin support, _must_ ignore sample tables */
+ if( p_track->fmt.i_cat == AUDIO_ES && p_soun->i_compressionid == 0 &&
+ p_track->i_sample_size == 1 )
+ {
+ switch( p_track->fmt.i_codec )
+ {
+ case VLC_CODEC_GSM: /* # Samples > data size */
+ i_pos += ( p_track->i_sample -
+ p_track->chunk[p_track->i_chunk].i_sample_first ) / 160 * 33;
+ return i_pos;
+ default:
+ break;
+ }
+ }
+
if( p_track->fmt.i_cat != AUDIO_ES || p_soun->i_qt_version == 0 ||
p_track->fmt.audio.i_blockalign <= 1 ||
p_soun->i_sample_per_packet * p_soun->i_bytes_per_frame == 0 )
More information about the vlc-commits
mailing list