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 @@
* codecs.h: codec related structures needed by the demuxers and decoders
*****************************************************************************
* 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>
*
......@@ -82,14 +82,64 @@ typedef struct {
#define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */
#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */
/* Need to check these */
#define WAVE_FORMAT_A52 0x2000
#define WAVE_FORMAT_WMA1 0x0160
#define WAVE_FORMAT_WMA2 0x0161
#define WAVE_FORMAT_WMA3 0x0162
/* Need to check these */
#define WAVE_FORMAT_DK3 0x0061
#define WAVE_FORMAT_DK4 0x0061
#if !defined(WAVE_FORMAT_EXTENSIBLE)
#define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */
#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" */
......@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc
*****************************************************************************
* 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>
*
* This program is free software; you can redistribute it and/or modify
......@@ -198,34 +198,9 @@ static int Open( vlc_object_t * p_this )
"adding new audio stream(codec:0x%x,ID:%d)",
i_codec,
p_sp->i_stream_number );
switch( i_codec )
{
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 );
}
wf_tag_to_fourcc( i_codec, &p_stream->p_es->i_fourcc, NULL );
input_AddInfo( p_cat, _("Codec"), "%.4s", (char*)&p_stream->p_es->i_fourcc );
if( p_sp->i_type_specific_data_length > 0 )
{
WAVEFORMATEX *p_wf;
......
......@@ -2,7 +2,7 @@
* avi.c : AVI file Stream input module for vlc
*****************************************************************************
* 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>
*
* 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 )
switch( i_cat )
{
case AUDIO_ES:
switch( 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 );
}
wf_tag_to_fourcc( i_codec, &i_codec, NULL );
return i_codec;
case VIDEO_ES:
// XXX DIV1 <- msmpeg4v1, DIV2 <- msmpeg4v2, DIV3 <- msmpeg4v3, mp4v for mpeg4
switch( i_codec )
......
......@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer
*****************************************************************************
* 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>
*
......@@ -1087,44 +1087,7 @@ static int Activate( vlc_object_t * p_this )
p_wf->wBitsPerSample = GetWLE( &p_wf->wBitsPerSample );
p_wf->cbSize = GetWLE( &p_wf->cbSize );
switch( p_wf->wFormatTag )
{
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;
}
wf_tag_to_fourcc( p_wf->wFormatTag, &tk.i_codec, NULL );
tk.p_es->p_waveformatex = p_wf;
}
}
......
......@@ -2,7 +2,7 @@
* wav.c : wav file input module for vlc
*****************************************************************************
* 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>
*
......@@ -89,6 +89,7 @@ static int Open( vlc_object_t * p_this )
uint8_t *p_peek;
unsigned int i_size;
vlc_fourcc_t i_fourcc;
char *psz_name;
/* Is it a wav file ? */
if( input_Peek( p_input, &p_peek, 12 ) < 12 )
......@@ -167,50 +168,41 @@ static int Open( vlc_object_t * p_this )
stream_Read( p_sys->s, NULL, 8 ); /* cannot fail */
/* XXX p_sys->psz_demux shouldn't be NULL ! */
switch( p_sys->p_wf->wFormatTag )
wf_tag_to_fourcc( p_sys->p_wf->wFormatTag, &i_fourcc, &psz_name );
if( i_fourcc == VLC_FOURCC( 'u', 'n', 'd', 'f' ) )
{
case( WAVE_FORMAT_PCM ):
msg_Dbg( p_input,"found raw pcm audio format" );
i_fourcc = VLC_FOURCC( 'a', 'r', 'a', 'w' );
FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
case( WAVE_FORMAT_MULAW ):
msg_Dbg( p_input,"found mulaw pcm audio format" );
i_fourcc = VLC_FOURCC( 'u', 'l', 'a', 'w' );
FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
case( WAVE_FORMAT_ALAW ):
msg_Dbg( p_input,"found alaw pcm audio format" );
i_fourcc = VLC_FOURCC( 'a', 'l', 'a', 'w' );
msg_Err( p_input,"unrecognize audio format(0x%x)",
p_sys->p_wf->wFormatTag );
goto error;
}
switch( i_fourcc )
{
case VLC_FOURCC( 'a', 'r', 'a', 'w' ):
case VLC_FOURCC( 'u', 'l', 'a', 'w' ):
case VLC_FOURCC( 'a', 'l', 'a', 'w' ):
FrameInfo_PCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
case( WAVE_FORMAT_ADPCM ):
msg_Dbg( p_input, "found ms adpcm audio format" );
i_fourcc = VLC_FOURCC( 'm', 's', 0x00, 0x02 );
case VLC_FOURCC( 'm', 's', 0x00, 0x02 ):
FrameInfo_MS_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
case( WAVE_FORMAT_IMA_ADPCM ):
msg_Dbg( p_input, "found ima adpcm audio format" );
i_fourcc = VLC_FOURCC( 'm', 's', 0x00, 0x11 );
case VLC_FOURCC( 'm', 's', 0x00, 0x11 ):
FrameInfo_IMA_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
case( WAVE_FORMAT_MPEG ):
case( WAVE_FORMAT_MPEGLAYER3 ):
msg_Dbg( p_input, "found mpeg audio format (relaying to another demux)" );
/* FIXME set end of area FIXME */
goto relay;
case( WAVE_FORMAT_A52 ):
msg_Dbg( p_input,"found a52 audio format (relaying to another demux)" );
case VLC_FOURCC( 'm', 's', 0x00, 0x61 ):
case VLC_FOURCC( 'm', 's', 0x00, 0x62 ):
/* FIXME not sure at all FIXME */
FrameInfo_MS_ADPCM( p_input, &p_sys->i_frame_size, &p_sys->i_frame_length );
break;
case VLC_FOURCC( 'm', 'p', 'g', 'a' ):
case VLC_FOURCC( 'a', '5', '2', ' ' ):
/* FIXME set end of area FIXME */
goto relay;
default:
msg_Err( p_input,"unrecognize audio format(0x%x)",
p_sys->p_wf->wFormatTag );
msg_Err( p_input, "unsupported codec (%4.4s)", (char*)&i_fourcc );
goto error;
}
msg_Dbg( p_input, "found %s audio format", psz_name );
/* create one program */
......@@ -231,7 +223,8 @@ static int Open( vlc_object_t * p_this )
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
{
......
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