summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demux_mov.c
diff options
context:
space:
mode:
authorrtognimp <rtognimp@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-29 23:26:01 +0000
committerrtognimp <rtognimp@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-29 23:26:01 +0000
commitdbbe18f4500c2707f2e9c0967c7b79312edecd3d (patch)
tree957a4c66bff4e891d2cc529983ef9c2aeae295ee /libmpdemux/demux_mov.c
parent1aaf2bbabcb0e59b81d76576e049d0d810d00d2f (diff)
downloadmpv-dbbe18f4500c2707f2e9c0967c7b79312edecd3d.tar.bz2
mpv-dbbe18f4500c2707f2e9c0967c7b79312edecd3d.tar.xz
Fix channels, sample rate and sample size for 3gp files
Patch by Richard van der Hoff [ richardv at mxtelecom dot com ] git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14280 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/demux_mov.c')
-rw-r--r--libmpdemux/demux_mov.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/libmpdemux/demux_mov.c b/libmpdemux/demux_mov.c
index 3a186f8b95..a1e79cdedc 100644
--- a/libmpdemux/demux_mov.c
+++ b/libmpdemux/demux_mov.c
@@ -112,6 +112,8 @@ typedef struct {
int duration; // 0 = variable
int width,height; // for video
unsigned int fourcc;
+ unsigned int nchannels;
+ unsigned int samplebytes;
//
int tkdata_len; // track data
unsigned char* tkdata;
@@ -866,6 +868,23 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak
sh_audio_t* sh=new_sh_audio(demuxer,priv->track_db);
sh->format=trak->fourcc;
+ switch( sh->format ) {
+ case 0x726D6173: /* samr */
+ /* amr narrowband */
+ trak->samplebytes=sh->samplesize=1;
+ trak->nchannels=sh->channels=1;
+ sh->samplerate=8000;
+ break;
+
+ case 0x62776173: /* sawb */
+ /* amr wideband */
+ trak->samplebytes=sh->samplesize=1;
+ trak->nchannels=sh->channels=1;
+ sh->samplerate=16000;
+ break;
+
+ default:
+
// assumptions for below table: short is 16bit, int is 32bit, intfp is 16bit
// XXX: 32bit fixed point numbers (intfp) are only 2 Byte!
// short values are usually one byte leftpadded by zero
@@ -892,8 +911,8 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak
// 32 char[4] atom type (fourc charater code -> esds)
// 36 char[] atom data (len=size-8)
- sh->samplesize=char2short(trak->stdata,18)/8;
- sh->channels=char2short(trak->stdata,16);
+ trak->samplebytes=sh->samplesize=char2short(trak->stdata,18)/8;
+ trak->nchannels=sh->channels=char2short(trak->stdata,16);
/*printf("MOV: timescale: %d samplerate: %d durmap: %d (%d) -> %d (%d)\n",
trak->timescale, char2short(trak->stdata,24), trak->durmap[0].dur,
trak->durmap[0].num, trak->timescale/trak->durmap[0].dur,
@@ -916,9 +935,9 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak
sh->samplerate = 44100;
}
}
-
+ }
mp_msg(MSGT_DEMUX, MSGL_INFO, "Audio bits: %d chans: %d rate: %d\n",
- trak->stdata[19],trak->stdata[17],sh->samplerate);
+ sh->samplesize*8,sh->channels,sh->samplerate);
if(trak->stdata_len >= 44 && trak->stdata[9]>=1){
mp_msg(MSGT_DEMUX,MSGL_V,"Audio header: samp/pack=%d bytes/pack=%d bytes/frame=%d bytes/samp=%d \n",
@@ -985,7 +1004,7 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak
// Emulate WAVEFORMATEX struct:
sh->wf=malloc(sizeof(WAVEFORMATEX));
memset(sh->wf,0,sizeof(WAVEFORMATEX));
- sh->wf->nChannels=(trak->stdata[16]<<8)+trak->stdata[17];
+ sh->wf->nChannels=sh->channels;
sh->wf->wBitsPerSample=(trak->stdata[18]<<8)+trak->stdata[19];
// sh->wf->nSamplesPerSec=trak->timescale;
sh->wf->nSamplesPerSec=(trak->stdata[24]<<8)+trak->stdata[25];
@@ -1748,9 +1767,8 @@ if(trak->samplesize){
// with missing stsd v1 header containing compression rate
x/=ds->ss_div; x*=ds->ss_mul; // compression ratio fix ! HACK !
} else {
- x*=(trak->stdata[16]<<8)+trak->stdata[17]; //channels
- x*=(trak->stdata[18]<<8)+trak->stdata[19]; //bits/sample
- x/=8; // bits/sample
+ x*=trak->nchannels;
+ x*=trak->samplebytes;
}
}
mp_msg(MSGT_DEMUX, MSGL_DBG2, "Audio sample %d bytes pts %5.3f\n",trak->chunks[trak->pos].size*trak->samplesize,pts);