diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2001-11-07 19:06:15 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2001-11-07 19:06:15 +0000 |
commit | c053feafaf72f6dc4b6e159c0bd206820e839b7f (patch) | |
tree | 4067d752ab094892d32c63c1c6d7a169f150f432 | |
parent | b9863e2de7c47a70764f16eb9c00f0bea8a6a602 (diff) | |
download | xine-lib-c053feafaf72f6dc4b6e159c0bd206820e839b7f.tar.gz xine-lib-c053feafaf72f6dc4b6e159c0bd206820e839b7f.tar.bz2 |
buf types cleanup (audio stuff)
CVS patchset: 989
CVS date: 2001/11/07 19:06:15
-rw-r--r-- | src/demuxers/demux_asf.c | 41 | ||||
-rw-r--r-- | src/demuxers/demux_avi.c | 39 | ||||
-rw-r--r-- | src/xine-engine/buffer.h | 16 | ||||
-rw-r--r-- | src/xine-engine/buffer_types.c | 118 |
4 files changed, 148 insertions, 66 deletions
diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index 0ec0e1acb..b2da7551b 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_asf.c,v 1.7 2001/11/07 18:26:36 miguelfreitas Exp $ + * $Id: demux_asf.c,v 1.8 2001/11/07 19:06:15 miguelfreitas Exp $ * * demultiplexer for asf streams * @@ -295,40 +295,17 @@ static void asf_send_audio_header (demux_asf_t *this, int stream_id) { if (!this->audio_fifo) return; - switch (wavex->wFormatTag) { - case 0x01: - this->streams[this->num_streams].buf_type = BUF_AUDIO_LPCM_LE; - break; - case 0x2000: - this->streams[this->num_streams].buf_type = BUF_AUDIO_A52; - break; - case 0x50: - case 0x55: - this->streams[this->num_streams].buf_type = BUF_AUDIO_MPEG; - break; - case 0x160: - case 0x161: - this->streams[this->num_streams].buf_type = BUF_AUDIO_DIVXA; - break; - case 0x02: - this->streams[this->num_streams].buf_type = BUF_AUDIO_MSADPCM; - break; - case 0x11: - this->streams[this->num_streams].buf_type = BUF_AUDIO_IMAADPCM; - break; - case 0x31: - case 0x32: - this->streams[this->num_streams].buf_type = BUF_AUDIO_MSGSM; - break; - default: + this->streams[this->num_streams].buf_type = + formattag_to_buf_audio ( wavex->wFormatTag ); + + if ( !this->streams[this->num_streams].buf_type ) { printf ("demux_asf: unknown audio type 0x%x\n", wavex->wFormatTag); this->streams[this->num_streams].buf_type = BUF_CONTROL_NOP; - break; } - - printf ("demux_asf: audio format :0x%02x (buf_type %08x)\n", - wavex->wFormatTag, this->streams[this->num_streams].buf_type ); - + else + printf ("demux_asf: audio format : %s (wFormatTag 0x%x)\n", + buf_audio_name(this->streams[this->num_streams].buf_type), + wavex->wFormatTag); this->streams[this->num_streams].buf_type |= this->num_audio_streams; this->streams[this->num_streams].fifo = this->audio_fifo; diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index a144b7344..81afaf1f9 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_avi.c,v 1.49 2001/11/07 18:26:36 miguelfreitas Exp $ + * $Id: demux_avi.c,v 1.50 2001/11/07 19:06:15 miguelfreitas Exp $ * * demultiplexer for avi streams * @@ -879,37 +879,18 @@ static void demux_avi_start (demux_plugin_t *this_gen, printf ("demux_avi: video format = %s, audio format = 0x%lx\n", this->avi->compressor, this->avi->a_fmt); this->no_audio = 0; - switch (this->avi->a_fmt) { - case 0x01: - this->avi->audio_type = BUF_AUDIO_LPCM_LE; - break; - case 0x2000: - this->avi->audio_type = BUF_AUDIO_A52; - break; - case 0x50: - case 0x55: - this->avi->audio_type = BUF_AUDIO_MPEG; - break; - case 0x160: - case 0x161: - this->avi->audio_type = BUF_AUDIO_DIVXA; - break; - case 0x02: - this->avi->audio_type = BUF_AUDIO_MSADPCM; - break; - case 0x11: - this->avi->audio_type = BUF_AUDIO_IMAADPCM; - break; - case 0x31: - case 0x32: - this->avi->audio_type = BUF_AUDIO_MSGSM; - break; - default: + + this->avi->audio_type = formattag_to_buf_audio (this->avi->a_fmt); + + if( !this->avi->audio_type ) { printf ("demux_avi: unknown audio type 0x%lx\n", this->avi->a_fmt); this->no_audio = 1; - this->avi->audio_type = BUF_AUDIO_MPEG; - break; + this->avi->audio_type = BUF_CONTROL_NOP; } + else + printf ("demux_avi: audio type %s (wFormatTag 0x%x)\n", + buf_audio_name(this->avi->audio_type), + (int)this->avi->a_fmt); AVI_seek_start (this->avi); diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index edee1c32c..f47b691b4 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer.h,v 1.21 2001/11/07 18:26:36 miguelfreitas Exp $ + * $Id: buffer.h,v 1.22 2001/11/07 19:06:15 miguelfreitas Exp $ * * * contents: @@ -70,7 +70,7 @@ extern "C" { #define BUF_CONTROL_AUDIO_CHANNEL 0x01050000 #define BUF_CONTROL_SPU_CHANNEL 0x01060000 -/* video buffer types: */ +/* video buffer types: (please keep in sync with buffer_types.c) */ #define BUF_VIDEO_BASE 0x02000000 #define BUF_VIDEO_MPEG 0x02000000 @@ -95,7 +95,7 @@ extern "C" { #define BUF_VIDEO_WMV7 0x02130000 #define BUF_VIDEO_WMV8 0x02140000 -/* audio buffer types: */ +/* audio buffer types: (please keep in sync with buffer_types.c) */ #define BUF_AUDIO_BASE 0x03000000 #define BUF_AUDIO_A52 0x03000000 @@ -193,10 +193,18 @@ struct fifo_buffer_s fifo_buffer_t *fifo_buffer_new (int num_buffers, uint32_t buf_size); -/* provide BUF_VIDEO_xxx given the fourcc */ +/* return BUF_VIDEO_xxx given the fourcc */ uint32_t fourcc_to_buf_video( void * fourcc ); + +/* return codec name given BUF_VIDEO_xxx */ char * buf_video_name( uint32_t buf_type ); +/* return BUF_VIDEO_xxx given the formattag */ +uint32_t formattag_to_buf_audio( uint16_t formattag ); + +/* return codec name given BUF_VIDEO_xxx */ +char * buf_audio_name( uint32_t buf_type ); + #ifdef __cplusplus } #endif diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c index 927a0eaba..64d55c3b9 100644 --- a/src/xine-engine/buffer_types.c +++ b/src/xine-engine/buffer_types.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer_types.c,v 1.1 2001/11/07 18:27:45 miguelfreitas Exp $ + * $Id: buffer_types.c,v 1.2 2001/11/07 19:06:15 miguelfreitas Exp $ * * * contents: @@ -50,6 +50,13 @@ typedef struct video_db_s { char *name; } video_db_t; +typedef struct audio_db_s { + uint16_t formattag[10]; + uint32_t buf_type; + char *name; +} audio_db_t; + + static video_db_t video_db[] = { { { @@ -253,6 +260,82 @@ static video_db_t video_db[] = { { { 0 }, 0, "last entry" } }; + +static audio_db_t audio_db[] = { +{ + { + 0x2000, 0 + }, + BUF_AUDIO_A52, + "AC3" +}, +{ + { + 0x50, 0x55, 0 + }, + BUF_AUDIO_MPEG, + "MPEG layer 2/3" +}, +{ + { + 0 + }, + BUF_AUDIO_LPCM_BE, + "Uncompressed PCM big endian" +}, +{ + { + 0x01, 0 + }, + BUF_AUDIO_LPCM_LE, + "Uncompressed PCM little endian" +}, +{ + { + 0x160, 0x161, 0 + }, + BUF_AUDIO_DIVXA, + "DivX audio (WMA)" +}, +{ + { + 0 + }, + BUF_AUDIO_DTS, + "DTS" +}, +{ + { + 0x02, 0 + }, + BUF_AUDIO_MSADPCM, + "MS ADPCM" +}, +{ + { + 0x11, 0 + }, + BUF_AUDIO_IMAADPCM, + "IMA ADPCM" +}, +{ + { + 0x31, 0x32, 0 + }, + BUF_AUDIO_MSGSM, + "MS GSM" +}, +{ + { + 0 + }, + BUF_AUDIO_VORBIS, + "OggVorbis Audio" +}, +{ { 0 }, 0, "last entry" } +}; + + static unsigned long str2ulong(unsigned char *str) { return ( str[0] | (str[1]<<8) | (str[2]<<16) | (str[3]<<24) ); @@ -295,3 +378,36 @@ int i; return "unknow"; } +uint32_t formattag_to_buf_audio( uint16_t formattag ) { +int i, j; +static uint16_t cached_formattag=0; +static uint32_t cached_buf_type=0; + + if( formattag == cached_formattag ) + return cached_buf_type; + + for( i = 0; audio_db[i].buf_type; i++ ) { + for( j = 0; audio_db[i].formattag[j]; j++ ) { + if( formattag == audio_db[i].formattag[j] ) { + cached_formattag = formattag; + cached_buf_type = audio_db[i].buf_type; + return audio_db[i].buf_type; + } + } + } + return 0; +} + +char * buf_audio_name( uint32_t buf_type ) { +int i; + + buf_type &= 0xffff0000; + + for( i = 0; audio_db[i].buf_type; i++ ) { + if( buf_type == audio_db[i].buf_type ) { + return audio_db[i].name; + } + } + + return "unknow"; +} |