comparison libmpdemux/demux_mov.c @ 6612:de59eb5cf6ce

CBR audio PTS fixes (using stsd v1 header)
author arpi
date Sun, 30 Jun 2002 00:37:02 +0000
parents 958a46ceb865
children 9eefcaf88e56
comparison
equal deleted inserted replaced
6611:958a46ceb865 6612:de59eb5cf6ce
30 #include "stheader.h" 30 #include "stheader.h"
31 31
32 #include "bswap.h" 32 #include "bswap.h"
33 33
34 #include "qtpalette.h" 34 #include "qtpalette.h"
35 #include "parse_mp4.h" // MP3 specific stuff 35 #include "parse_mp4.h" // .MP4 specific stuff
36 36
37 #ifdef USE_QTX_CODECS 37 #ifdef USE_QTX_CODECS
38 #include "../loader/qtx/qtxsdk/components.h" 38 #include "../loader/qtx/qtxsdk/components.h"
39 #endif 39 #endif
40 40
665 // 18 short samplesize 665 // 18 short samplesize
666 // 20 short compression_id 666 // 20 short compression_id
667 // 22 short packet_size (==0) 667 // 22 short packet_size (==0)
668 // 24 intfp sample_rate 668 // 24 intfp sample_rate
669 // (26 short) unknown (==0) 669 // (26 short) unknown (==0)
670 // ---- qt3.0+ 670 // ---- qt3.0+ (version>=1)
671 // 28 int samples_per_packet 671 // 28 int samples_per_packet
672 // 32 int bytes_per_packet 672 // 32 int bytes_per_packet
673 // 36 int bytes_per_frame 673 // 36 int bytes_per_frame
674 // 40 int bytes_per_sample 674 // 40 int bytes_per_sample
675 // there may be additional atoms following at 28 (version 0) 675 // there may be additional atoms following at 28 (version 0)
704 } 704 }
705 } 705 }
706 706
707 mp_msg(MSGT_DEMUX, MSGL_INFO, "Audio bits: %d chans: %d rate: %d\n", 707 mp_msg(MSGT_DEMUX, MSGL_INFO, "Audio bits: %d chans: %d rate: %d\n",
708 trak->stdata[19],trak->stdata[17],sh->samplerate); 708 trak->stdata[19],trak->stdata[17],sh->samplerate);
709
710 if(trak->stdata_len >= 44 && trak->stdata[9]>=1)
711 mp_msg(MSGT_DEMUX,MSGL_V,"Audio header: samp/pack=%d bytes/pack=%d bytes/frame=%d bytes/samp=%d \n",
712 char2int(trak->stdata,28),
713 char2int(trak->stdata,32),
714 char2int(trak->stdata,36),
715 char2int(trak->stdata,40));
716
709 if((trak->stdata[9]==0) && trak->stdata_len >= 36) { // version 0 with extra atoms 717 if((trak->stdata[9]==0) && trak->stdata_len >= 36) { // version 0 with extra atoms
710 int atom_len = char2int(trak->stdata,28); 718 int atom_len = char2int(trak->stdata,28);
711 switch(char2int(trak->stdata,32)) { // atom type 719 switch(char2int(trak->stdata,32)) { // atom type
712 case MOV_FOURCC('e','s','d','s'): { 720 case MOV_FOURCC('e','s','d','s'): {
713 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len); 721 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len);
1288 } 1296 }
1289 else 1297 else
1290 x=trak->chunks[trak->pos].size; 1298 x=trak->chunks[trak->pos].size;
1291 // printf("X = %d\n", x); 1299 // printf("X = %d\n", x);
1292 /* the following stuff is audio related */ 1300 /* the following stuff is audio related */
1293 if (trak->type == MOV_TRAK_AUDIO) 1301 if (trak->type == MOV_TRAK_AUDIO){
1294 { 1302 if(trak->stdata_len>=44 && trak->stdata[9]>=1){
1295 if(trak->stdata_len>=36 && trak->stdata[30] && trak->stdata[31]){ 1303 // stsd version 1 - we have audio compression ratio info:
1296 // extended stsd header - works for CBR MP3: 1304 x/=char2int(trak->stdata,28); // samples/packet
1297 x/=(trak->stdata[30]<<8)+trak->stdata[31]; // samples/packet 1305 x*=char2int(trak->stdata,32); // bytes/packet
1298 // x*=(trak->stdata[34]<<8)+trak->stdata[35]; // bytes/packet 1306 // x*=char2int(trak->stdata,36); // bytes/frame
1299 x*=(trak->stdata[38]<<8)+trak->stdata[39]; // bytes/frame 1307 } else {
1300 } else {
1301 // works for ima4: -- we should find this info in mov headers!
1302 if(ds->ss_div!=1 || ds->ss_mul!=1){ 1308 if(ds->ss_div!=1 || ds->ss_mul!=1){
1309 // workaround for buggy files like 7up-high-traffic-areas.mov,
1310 // with missing stsd v1 header containing compression rate
1303 x/=ds->ss_div; x*=ds->ss_mul; // compression ratio fix ! HACK ! 1311 x/=ds->ss_div; x*=ds->ss_mul; // compression ratio fix ! HACK !
1304 } else { 1312 } else {
1305 x*=(trak->stdata[18]<<8)+trak->stdata[19];x/=8; // bits/sample 1313 x*=(trak->stdata[16]<<8)+trak->stdata[17]; //channels
1314 x*=(trak->stdata[18]<<8)+trak->stdata[19]; //bits/sample
1315 x/=8; // bits/sample
1306 } 1316 }
1307 } 1317 }
1308 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Audio sample %d bytes pts %5.3f\n",trak->chunks[trak->pos].size*trak->samplesize,pts); 1318 mp_msg(MSGT_DEMUX, MSGL_DBG2, "Audio sample %d bytes pts %5.3f\n",trak->chunks[trak->pos].size*trak->samplesize,pts);
1309 } /* MOV_TRAK_AUDIO */ 1319 } /* MOV_TRAK_AUDIO */
1310 pos=trak->chunks[trak->pos].pos; 1320 pos=trak->chunks[trak->pos].pos;
1311 } else { 1321 } else {
1312 // read sample: 1322 // read sample:
1313 if(trak->pos>=trak->samples_size) return 0; // EOF 1323 if(trak->pos>=trak->samples_size) return 0; // EOF