Mercurial > mplayer.hg
comparison libmpdemux/demux_mov.c @ 17283:4fea216307d2
Partial support for QuickTime sound atom version 2.
This doesn't add support for parsing the sound atom itself, but does
recognize the different offset at which the ESDS atom starts. Also,
this patch supports "3" in the channels field, which indicates
6-channel (5.1) audio. For more information, see this mail:
From: Corey Hickey <bugfood-ml@fatooh.org>
To: mplayer-dev-eng@mplayerhq.hu
Date: Wed, 28 Dec 2005 23:42:46 -0800
Subject: [PATCH] (partially) support QuickTime sound atom version 2
author | corey |
---|---|
date | Mon, 02 Jan 2006 06:56:22 +0000 |
parents | 6ff3379a0862 |
children | 934380353fd6 |
comparison
equal
deleted
inserted
replaced
17282:a9782d8c562f | 17283:4fea216307d2 |
---|---|
614 // --- | 614 // --- |
615 // optional additional atom-based fields | 615 // optional additional atom-based fields |
616 // ([int32_t size,int32_t type,some data ],repeat) | 616 // ([int32_t size,int32_t type,some data ],repeat) |
617 } my_stdata; | 617 } my_stdata; |
618 #endif | 618 #endif |
619 int version, adjust; | |
619 sh_audio_t* sh=new_sh_audio(demuxer,priv->track_db); | 620 sh_audio_t* sh=new_sh_audio(demuxer,priv->track_db); |
620 sh->format=trak->fourcc; | 621 sh->format=trak->fourcc; |
621 | 622 |
622 switch( sh->format ) { | 623 switch( sh->format ) { |
623 case 0x726D6173: /* samr */ | 624 case 0x726D6173: /* samr */ |
661 // 28 int atom size (bytes of int size, int type and data) | 662 // 28 int atom size (bytes of int size, int type and data) |
662 // 32 char[4] atom type (fourc charater code -> esds) | 663 // 32 char[4] atom type (fourc charater code -> esds) |
663 // 36 char[] atom data (len=size-8) | 664 // 36 char[] atom data (len=size-8) |
664 | 665 |
665 // TODO: fix parsing for files using version 2. | 666 // TODO: fix parsing for files using version 2. |
667 version=char2short(trak->stdata,8); | |
668 if (version > 1) | |
669 mp_msg(MSGT_DEMUX, MSGL_WARN, "MOV: version %d sound atom may not parse correctly!\n", version); | |
666 trak->samplebytes=sh->samplesize=char2short(trak->stdata,18)/8; | 670 trak->samplebytes=sh->samplesize=char2short(trak->stdata,18)/8; |
667 trak->nchannels=sh->channels=char2short(trak->stdata,16); | 671 |
672 /* I can't find documentation, but so far this is the case. -Corey */ | |
673 switch (char2short(trak->stdata,16)) { | |
674 case 1: | |
675 trak->nchannels = 1; break; | |
676 case 2: | |
677 trak->nchannels = 2; break; | |
678 case 3: | |
679 trak->nchannels = 6; break; | |
680 default: | |
681 mp_msg(MSGT_DEMUX, MSGL_WARN, | |
682 "MOV: unable to determine audio channels, assuming 2 (got %d)\n", | |
683 char2short(trak->stdata,16)); | |
684 trak->nchannels = 2; | |
685 } | |
686 sh->channels = trak->nchannels; | |
687 | |
668 /*printf("MOV: timescale: %d samplerate: %d durmap: %d (%d) -> %d (%d)\n", | 688 /*printf("MOV: timescale: %d samplerate: %d durmap: %d (%d) -> %d (%d)\n", |
669 trak->timescale, char2short(trak->stdata,24), trak->durmap[0].dur, | 689 trak->timescale, char2short(trak->stdata,24), trak->durmap[0].dur, |
670 trak->durmap[0].num, trak->timescale/trak->durmap[0].dur, | 690 trak->durmap[0].num, trak->timescale/trak->durmap[0].dur, |
671 char2short(trak->stdata,24)/trak->durmap[0].dur);*/ | 691 char2short(trak->stdata,24)/trak->durmap[0].dur);*/ |
672 sh->samplerate=char2short(trak->stdata,24); | 692 sh->samplerate=char2short(trak->stdata,24); |
718 } | 738 } |
719 } | 739 } |
720 } | 740 } |
721 } | 741 } |
722 | 742 |
723 if ((trak->stdata[9] == 0 && trak->stdata_len >= 36) || | 743 switch (version) { |
724 (trak->stdata[9] == 1 && trak->stdata_len >= 36 + 48)) { | 744 case 0: |
725 // version 0 with extra atoms | 745 adjust = 0; break; |
726 int adjust = (trak->stdata[9]==1)?48:0; | 746 case 1: |
747 adjust = 48; break; | |
748 case 2: | |
749 adjust = 68; break; | |
750 default: | |
751 mp_msg(MSGT_DEMUX, MSGL_WARN, "MOV: unknown sound atom version (%d); may not work!\n", version); | |
752 adjust = 68; | |
753 } | |
754 if (trak->stdata_len >= 36 + adjust) { | |
727 int atom_len = char2int(trak->stdata,28+adjust); | 755 int atom_len = char2int(trak->stdata,28+adjust); |
728 switch(char2int(trak->stdata,32+adjust)) { // atom type | 756 switch(char2int(trak->stdata,32+adjust)) { // atom type |
729 case MOV_FOURCC('e','s','d','s'): { | 757 case MOV_FOURCC('e','s','d','s'): { |
730 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len); | 758 mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len); |
731 if(atom_len > 8) { | 759 if(atom_len > 8) { |