Commit b428dafd authored by Laurent Aimar's avatar Laurent Aimar

* all: move "wave format tag to fourcc" from demuxers to codecs.h

 (only one place to keep updated).
parent 22fca623
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* codecs.h: codec related structures needed by the demuxers and decoders * codecs.h: codec related structures needed by the demuxers and decoders
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: codecs.h,v 1.4 2003/07/01 17:14:58 sam Exp $ * $Id: codecs.h,v 1.5 2003/08/18 00:17:44 fenrir Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -82,14 +82,64 @@ typedef struct { ...@@ -82,14 +82,64 @@ typedef struct {
#define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */ #define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */
#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */ #define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */
/* Need to check these */
#define WAVE_FORMAT_A52 0x2000 #define WAVE_FORMAT_A52 0x2000
#define WAVE_FORMAT_WMA1 0x0160 #define WAVE_FORMAT_WMA1 0x0160
#define WAVE_FORMAT_WMA2 0x0161 #define WAVE_FORMAT_WMA2 0x0161
#define WAVE_FORMAT_WMA3 0x0162 #define WAVE_FORMAT_WMA3 0x0162
/* Need to check these */
#define WAVE_FORMAT_DK3 0x0061
#define WAVE_FORMAT_DK4 0x0061
#if !defined(WAVE_FORMAT_EXTENSIBLE) #if !defined(WAVE_FORMAT_EXTENSIBLE)
#define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */ #define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */
#endif #endif
static struct
{
uint16_t i_tag;
vlc_fourcc_t i_fourcc;
char *psz_name;
}
wave_format_tag_to_fourcc[] =
{
{ WAVE_FORMAT_PCM, VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" },
{ WAVE_FORMAT_ADPCM, VLC_FOURCC( 'm', 's', 0x00,0x02), "Adpcm" },
{ WAVE_FORMAT_ALAW, VLC_FOURCC( 'a', 'l', 'a', 'w' ), "A-Law" },
{ WAVE_FORMAT_MULAW, VLC_FOURCC( 'm', 'l', 'a', 'w' ), "Mu-Law" },
{ WAVE_FORMAT_IMA_ADPCM,VLC_FOURCC( 'm', 's', 0x00,0x11), "Ima-Adpcm" },
{ WAVE_FORMAT_MPEGLAYER3,VLC_FOURCC('m', 'p', 'g', 'a' ), "Mpeg Audio" },
{ WAVE_FORMAT_MPEG, VLC_FOURCC( 'm', 'p', 'g', 'a' ), "Mpeg Audio" },
{ WAVE_FORMAT_A52, VLC_FOURCC( 'a', '5', '2', ' ' ), "A/52" },
{ WAVE_FORMAT_WMA1, VLC_FOURCC( 'w', 'm', 'a', '1' ), "Window Media Audio 1" },
{ WAVE_FORMAT_WMA2, VLC_FOURCC( 'w', 'm', 'a', '2' ), "Window Media Audio 2" },
{ WAVE_FORMAT_WMA3, VLC_FOURCC( 'w', 'm', 'a', '3' ), "Window Media Audio 3" },
{ WAVE_FORMAT_DK3, VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" },
{ WAVE_FORMAT_DK4, VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" },
{ WAVE_FORMAT_UNKNOWN, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" }
};
static inline void wf_tag_to_fourcc( uint16_t i_tag,
vlc_fourcc_t *fcc, char **ppsz_name )
{
int i;
for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ )
{
if( wave_format_tag_to_fourcc[i].i_tag == i_tag )
{
break;
}
}
if( fcc )
{
*fcc = wave_format_tag_to_fourcc[i].i_fourcc;
}
if( ppsz_name )
{
*ppsz_name = wave_format_tag_to_fourcc[i].psz_name;
}
}
#endif /* "codecs.h" */ #endif /* "codecs.h" */
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc * asf.c : ASFv01 file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: asf.c,v 1.32 2003/08/17 23:42:37 fenrir Exp $ * $Id: asf.c,v 1.33 2003/08/18 00:17:44 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -198,34 +198,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -198,34 +198,9 @@ static int Open( vlc_object_t * p_this )
"adding new audio stream(codec:0x%x,ID:%d)", "adding new audio stream(codec:0x%x,ID:%d)",
i_codec, i_codec,
p_sp->i_stream_number ); p_sp->i_stream_number );
switch( i_codec ) wf_tag_to_fourcc( i_codec, &p_stream->p_es->i_fourcc, NULL );
{
case( 0x01 ):
p_stream->p_es->i_fourcc =
VLC_FOURCC( 'a', 'r', 'a', 'w' );
break;
case( 0x50 ):
case( 0x55 ):
p_stream->p_es->i_fourcc =
VLC_FOURCC( 'm','p','g','a' );
break;
case( 0x2000 ):
p_stream->p_es->i_fourcc =
VLC_FOURCC( 'a','5','2',' ' );
break;
case( 0x160 ):
p_stream->p_es->i_fourcc =
VLC_FOURCC( 'w','m','a','1' );
break;
case( 0x161 ):
p_stream->p_es->i_fourcc =
VLC_FOURCC( 'w','m','a','2' );
break;
default:
p_stream->p_es->i_fourcc =
VLC_FOURCC( 'm','s',(i_codec >> 8)&0xff,i_codec&0xff );
}
input_AddInfo( p_cat, _("Codec"), "%.4s", (char*)&p_stream->p_es->i_fourcc ); input_AddInfo( p_cat, _("Codec"), "%.4s", (char*)&p_stream->p_es->i_fourcc );
if( p_sp->i_type_specific_data_length > 0 ) if( p_sp->i_type_specific_data_length > 0 )
{ {
WAVEFORMATEX *p_wf; WAVEFORMATEX *p_wf;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* avi.c : AVI file Stream input module for vlc * avi.c : AVI file Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: avi.c,v 1.54 2003/08/17 23:02:52 fenrir Exp $ * $Id: avi.c,v 1.55 2003/08/18 00:17:44 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -200,23 +200,9 @@ vlc_fourcc_t AVI_FourccGetCodec( unsigned int i_cat, vlc_fourcc_t i_codec ) ...@@ -200,23 +200,9 @@ vlc_fourcc_t AVI_FourccGetCodec( unsigned int i_cat, vlc_fourcc_t i_codec )
switch( i_cat ) switch( i_cat )
{ {
case AUDIO_ES: case AUDIO_ES:
switch( i_codec ) wf_tag_to_fourcc( i_codec, &i_codec, NULL );
{ return i_codec;
case WAVE_FORMAT_PCM:
return VLC_FOURCC( 'a', 'r', 'a', 'w' );
case WAVE_FORMAT_MPEG:
case WAVE_FORMAT_MPEGLAYER3:
return VLC_FOURCC( 'm', 'p', 'g', 'a' );
case WAVE_FORMAT_A52:
return VLC_FOURCC( 'a', '5', '2', ' ' );
case WAVE_FORMAT_WMA1:
return VLC_FOURCC( 'w', 'm', 'a', '1' );
case WAVE_FORMAT_WMA2:
return VLC_FOURCC( 'w', 'm', 'a', '2' );
default:
return VLC_FOURCC( 'm', 's',
( i_codec >> 8 )&0xff, i_codec&0xff );
}
case VIDEO_ES: case VIDEO_ES:
// XXX DIV1 <- msmpeg4v1, DIV2 <- msmpeg4v2, DIV3 <- msmpeg4v3, mp4v for mpeg4 // XXX DIV1 <- msmpeg4v1, DIV2 <- msmpeg4v2, DIV3 <- msmpeg4v3, mp4v for mpeg4
switch( i_codec ) switch( i_codec )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer * mkv.cpp : matroska demuxer
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: mkv.cpp,v 1.21 2003/08/17 23:02:52 fenrir Exp $ * $Id: mkv.cpp,v 1.22 2003/08/18 00:17:44 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -1087,44 +1087,7 @@ static int Activate( vlc_object_t * p_this ) ...@@ -1087,44 +1087,7 @@ static int Activate( vlc_object_t * p_this )
p_wf->wBitsPerSample = GetWLE( &p_wf->wBitsPerSample ); p_wf->wBitsPerSample = GetWLE( &p_wf->wBitsPerSample );
p_wf->cbSize = GetWLE( &p_wf->cbSize ); p_wf->cbSize = GetWLE( &p_wf->cbSize );
switch( p_wf->wFormatTag ) wf_tag_to_fourcc( p_wf->wFormatTag, &tk.i_codec, NULL );
{
case WAVE_FORMAT_PCM:
tk.i_codec = VLC_FOURCC( 'a', 'r', 'a', 'w' );
break;
case WAVE_FORMAT_ADPCM:
tk.i_codec = VLC_FOURCC( 'm', 's', 0x00, 0x02 );
break;
case WAVE_FORMAT_ALAW:
tk.i_codec = VLC_FOURCC( 'a', 'l', 'a', 'w' );
break;
case WAVE_FORMAT_MULAW:
tk.i_codec = VLC_FOURCC( 'm', 'l', 'a', 'w' );
break;
case WAVE_FORMAT_IMA_ADPCM:
tk.i_codec = VLC_FOURCC( 'm', 's', 0x00, 0x11 );
break;
case WAVE_FORMAT_MPEG:
case WAVE_FORMAT_MPEGLAYER3:
tk.i_codec = VLC_FOURCC( 'm', 'p', 'g', 'a' );
break;
case WAVE_FORMAT_A52:
tk.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' );
break;
case WAVE_FORMAT_WMA1:
tk.i_codec = VLC_FOURCC( 'w', 'm', 'a', '1' );
break;
case WAVE_FORMAT_WMA2:
tk.i_codec = VLC_FOURCC( 'w', 'm', 'a', '2' );
break;
case WAVE_FORMAT_WMA3:
tk.i_codec = VLC_FOURCC( 'w', 'm', 'a', '3' );
break;
default:
msg_Err( p_input, "unknown wFormatTag=0x%x", p_wf->wFormatTag );
tk.i_codec = VLC_FOURCC( 'm', 's', p_wf->wFormatTag >> 8, p_wf->wFormatTag&0xff );
break;
}
tk.p_es->p_waveformatex = p_wf; tk.p_es->p_waveformatex = p_wf;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* wav.c : wav file input module for vlc * wav.c : wav file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: wav.c,v 1.3 2003/08/17 23:02:52 fenrir Exp $ * $Id: wav.c,v 1.4 2003/08/18 00:17:44 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -89,6 +89,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -89,6 +89,7 @@ static int Open( vlc_object_t * p_this )
uint8_t *p_peek; uint8_t *p_peek;
unsigned int i_size; unsigned int i_size;
vlc_fourcc_t i_fourcc; vlc_fourcc_t i_fourcc;
char *psz_name;
/* Is it a wav file ? */ /* Is it a wav file ? */
if( input_Peek( p_input, &p_peek, 12 ) < 12 ) if( input_Peek( p_input, &p_peek, 12 ) < 12 )
...@@ -167,50 +168,41 @@ static int Open( vlc_object_t * p_this ) ...@@ -167,50 +168,41 @@ static int Open( vlc_object_t * p_this )
stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */ stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */
/* XXX p_sys->psz_demux shouldn't be NULL ! */ wf_tag_to_fourcc( p_sys->p_wf->wFormatTag, &i_fourcc, &psz_name );
switch( p_sys->p_wf->wFormatTag ) if( i_fourcc == VLC_FOURCC( 'u', 'n', 'd', 'f' ) )
{ {
case( WAVE_FORMAT_PCM ): msg_Err( p_input,"unrecognize audio format(0x%x)",
msg_Dbg( p_input,"found raw pcm audio format" ); p_sys->p_wf->wFormatTag );
i_fourcc = VLC_FOURCC( 'a', 'r', 'a', 'w' ); goto error;
FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length ); }
break;
case( WAVE_FORMAT_MULAW ): switch( i_fourcc )
msg_Dbg( p_input,"found mulaw pcm audio format" ); {
i_fourcc = VLC_FOURCC( 'u', 'l', 'a', 'w' ); case VLC_FOURCC( 'a', 'r', 'a', 'w' ):
FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length ); case VLC_FOURCC( 'u', 'l', 'a', 'w' ):
break; case VLC_FOURCC( 'a', 'l', 'a', 'w' ):
case( WAVE_FORMAT_ALAW ):
msg_Dbg( p_input,"found alaw pcm audio format" );
i_fourcc = VLC_FOURCC( 'a', 'l', 'a', 'w' );
FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length ); FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break; break;
case( WAVE_FORMAT_ADPCM ): case VLC_FOURCC( 'm', 's', 0x00, 0x02 ):
msg_Dbg( p_input, "found ms adpcm audio format" );
i_fourcc = VLC_FOURCC( 'm', 's', 0x00, 0x02 );
FrameInfo_MS_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length ); FrameInfo_MS_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break; break;
case( WAVE_FORMAT_IMA_ADPCM ): case VLC_FOURCC( 'm', 's', 0x00, 0x11 ):
msg_Dbg( p_input, "found ima adpcm audio format" );
i_fourcc = VLC_FOURCC( 'm', 's', 0x00, 0x11 );
FrameInfo_IMA_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length ); FrameInfo_IMA_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break; break;
case VLC_FOURCC( 'm', 's', 0x00, 0x61 ):
case( WAVE_FORMAT_MPEG ): case VLC_FOURCC( 'm', 's', 0x00, 0x62 ):
case( WAVE_FORMAT_MPEGLAYER3 ): /* FIXME not sure at all FIXME */
msg_Dbg( p_input, "found mpeg audio format (relaying to another demux)" ); FrameInfo_MS_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
/* FIXME set end of area FIXME */ break;
goto relay; case VLC_FOURCC( 'm', 'p', 'g', 'a' ):
case( WAVE_FORMAT_A52 ): case VLC_FOURCC( 'a', '5', '2', ' ' ):
msg_Dbg( p_input,"found a52 audio format (relaying to another demux)" );
/* FIXME set end of area FIXME */ /* FIXME set end of area FIXME */
goto relay; goto relay;
default: default:
msg_Err( p_input,"unrecognize audio format(0x%x)", msg_Err( p_input, "unsupported codec (%4.4s)", (char*)&i_fourcc );
p_sys->p_wf->wFormatTag );
goto error; goto error;
} }
msg_Dbg( p_input, "found %s audio format", psz_name );
/* create one program */ /* create one program */
...@@ -231,7 +223,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -231,7 +223,8 @@ static int Open( vlc_object_t * p_this )
if( p_sys->i_data_size > 0 ) if( p_sys->i_data_size > 0 )
{ {
p_input->stream.i_mux_rate = (mtime_t)p_sys->i_frame_size * (mtime_t)1000000 / 50 / p_sys->i_frame_length; p_input->stream.i_mux_rate = (mtime_t)p_sys->i_frame_size *
(mtime_t)1000000 / 50 / p_sys->i_frame_length;
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment