Commit c330b1e1 authored by Gildas Bazin's avatar Gildas Bazin

* modules/mux/asf.c: only add an audio error correction field in the case of WMA.

* include/codecs.h: added a couple more audio tags.
parent e97f4e98
......@@ -114,7 +114,12 @@ typedef struct
uint32_t biClrUsed;
uint32_t biClrImportant;
} BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER;
typedef struct {
typedef struct
#ifdef HAVE_ATTRIBUTE_PACKED
__attribute__((__packed__))
#endif
{
BITMAPINFOHEADER bmiHeader;
int bmiColors[1];
} BITMAPINFO, *LPBITMAPINFO;
......@@ -149,10 +154,59 @@ typedef struct
uint32_t dwBitErrorRate;
REFERENCE_TIME AvgTimePerFrame;
BITMAPINFOHEADER bmiHeader;
//int reserved[3];
} VIDEOINFOHEADER;
#endif
#ifndef _RGBQUAD_
#define _RGBQUAD_
typedef struct
#ifdef HAVE_ATTRIBUTE_PACKED
__attribute__((__packed__))
#endif
{
uint8_t rgbBlue;
uint8_t rgbGreen;
uint8_t rgbRed;
uint8_t rgbReserved;
} RGBQUAD1;
#endif
#ifndef _TRUECOLORINFO_
#define _TRUECOLORINFO_
typedef struct
#ifdef HAVE_ATTRIBUTE_PACKED
__attribute__((__packed__))
#endif
{
uint32_t dwBitMasks[3];
RGBQUAD1 bmiColors[256];
} TRUECOLORINFO;
#endif
#ifndef _VIDEOINFO_
#define _VIDEOINFO_
typedef struct
#ifdef HAVE_ATTRIBUTE_PACKED
__attribute__((__packed__))
#endif
{
RECT32 rcSource;
RECT32 rcTarget;
uint32_t dwBitRate;
uint32_t dwBitErrorRate;
REFERENCE_TIME AvgTimePerFrame;
BITMAPINFOHEADER bmiHeader;
union
{
RGBQUAD1 bmiColors[256]; /* Colour palette */
uint32_t dwBitMasks[3]; /* True colour masks */
TRUECOLORINFO TrueColorInfo; /* Both of the above */
};
} VIDEOINFO;
#endif
/* WAVE format wFormatTag IDs */
#define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */
#define WAVE_FORMAT_PCM 0x0001 /* Microsoft Corporation */
......@@ -171,9 +225,10 @@ typedef struct
#define WAVE_FORMAT_A52 0x2000
#define WAVE_FORMAT_DTS 0x2001
#define WAVE_FORMAT_WMA1 0x0160
#define WAVE_FORMAT_WMA2 0x0161
#define WAVE_FORMAT_WMA3 0x0162
#define WAVE_FORMAT_WMA1 0x0160 /* WMA version 1 */
#define WAVE_FORMAT_WMA2 0x0161 /* WMA (v2) 7, 8, 9 Series */
#define WAVE_FORMAT_WMAP 0x0162 /* WMA 9 Professional */
#define WAVE_FORMAT_WMAL 0x0163 /* WMA 9 Lossless */
#define WAVE_FORMAT_DIVIO_AAC 0x4143
#define WAVE_FORMAT_AAC 0x00FF
......@@ -240,9 +295,11 @@ wave_format_tag_to_fourcc[] =
{ 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_WMA1, VLC_FOURCC( 'w', 'm', 'a', '1' ), "Window Media Audio v1" },
{ WAVE_FORMAT_WMA2, VLC_FOURCC( 'w', 'm', 'a', '2' ), "Window Media Audio v2" },
{ WAVE_FORMAT_WMA2, VLC_FOURCC( 'w', 'm', 'a', ' ' ), "Window Media Audio v2" },
{ WAVE_FORMAT_WMAP, VLC_FOURCC( 'w', 'm', 'a', 'p' ), "Window Media Audio 9 Professional" },
{ WAVE_FORMAT_WMAL, VLC_FOURCC( 'w', 'm', 'a', 'l' ), "Window Media Audio 9 Lossless" },
{ WAVE_FORMAT_DK3, VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" },
{ WAVE_FORMAT_DK4, VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" },
{ WAVE_FORMAT_DTS, VLC_FOURCC( 'd', 't', 's', ' ' ), "DTS Coherent Acoustics" },
......
......@@ -105,6 +105,7 @@ typedef struct
vlc_fourcc_t i_fourcc; /* for video */
char *psz_name; /* codec name */
int i_blockalign; /* for audio only */
vlc_bool_t b_audio_correction;
int i_sequence;
......@@ -335,6 +336,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
tk->i_id = p_sys->i_track + 1;
tk->i_cat = p_input->p_fmt->i_cat;
tk->i_sequence = 0;
tk->b_audio_correction = 0;
switch( tk->i_cat )
{
......@@ -365,16 +367,25 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
break;
#endif
case VLC_FOURCC( 'w', 'm', 'a', '1' ):
tk->psz_name = "Windows Media Audio 1";
tk->psz_name = "Windows Media Audio v1";
tk->i_tag = WAVE_FORMAT_WMA1;
tk->b_audio_correction = VLC_TRUE;
break;
case VLC_FOURCC( 'w', 'm', 'a', ' ' ):
case VLC_FOURCC( 'w', 'm', 'a', '2' ):
tk->psz_name = "Windows Media Audio 2";
tk->psz_name= "Windows Media Audio (v2) 7, 8 and 9 Series";
tk->i_tag = WAVE_FORMAT_WMA2;
tk->b_audio_correction = VLC_TRUE;
break;
case VLC_FOURCC( 'w', 'm', 'a', '3' ):
tk->psz_name = "Windows Media Audio 3";
tk->i_tag = WAVE_FORMAT_WMA3;
case VLC_FOURCC( 'w', 'm', 'a', 'p' ):
tk->psz_name = "Windows Media Audio 9 Professional";
tk->i_tag = WAVE_FORMAT_WMAP;
tk->b_audio_correction = VLC_TRUE;
break;
case VLC_FOURCC( 'w', 'm', 'a', 'l' ):
tk->psz_name = "Windows Media Audio 9 Lossless";
tk->i_tag = WAVE_FORMAT_WMAL;
tk->b_audio_correction = VLC_TRUE;
break;
/* raw codec */
case VLC_FOURCC( 'u', '8', ' ', ' ' ):
......@@ -804,15 +815,8 @@ static block_t *asf_header_create( sout_mux_t *p_mux, vlc_bool_t b_broadcast )
{
i_size += 78 + p_sys->track[i].i_extra;
i_ci_size += 8 + 2 * strlen( p_sys->track[i].psz_name );
if( p_sys->track[i].i_cat == AUDIO_ES )
{
i_ci_size += 4;
i_size += 8; /* Error correction data field */
}
else if( p_sys->track[i].i_cat == VIDEO_ES )
{
i_ci_size += 6;
}
if( p_sys->track[i].i_cat == AUDIO_ES ) i_ci_size += 4;
else if( p_sys->track[i].i_cat == VIDEO_ES ) i_ci_size += 6;
}
/* size of the content description object */
......@@ -838,6 +842,8 @@ static block_t *asf_header_create( sout_mux_t *p_mux, vlc_bool_t b_broadcast )
i_header_ext_size = i_cm_size ? i_cm_size + 46 : 0;
i_size += i_ci_size + i_cd_size + i_header_ext_size ;
/* Error correction data field */
if( tk->b_audio_correction ) i_size += 8;
if( p_sys->b_asf_http )
{
......@@ -949,7 +955,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, vlc_bool_t b_broadcast )
bo_add_guid ( &bo, &asf_object_stream_properties_guid );
if( tk->i_cat == AUDIO_ES ) /* Error correction data field */
if( tk->b_audio_correction ) /* Error correction data field */
bo_addle_u64( &bo, 78 + tk->i_extra + 8 );
else
bo_addle_u64( &bo, 78 + tk->i_extra );
......@@ -957,7 +963,10 @@ static block_t *asf_header_create( sout_mux_t *p_mux, vlc_bool_t b_broadcast )
if( tk->i_cat == AUDIO_ES )
{
bo_add_guid( &bo, &asf_object_stream_type_audio );
if( tk->b_audio_correction )
bo_add_guid( &bo, &asf_guid_audio_conceal_spread );
else
bo_add_guid( &bo, &asf_guid_audio_conceal_none );
}
else if( tk->i_cat == VIDEO_ES )
{
......@@ -966,16 +975,14 @@ static block_t *asf_header_create( sout_mux_t *p_mux, vlc_bool_t b_broadcast )
}
bo_addle_u64( &bo, 0 ); /* time offset */
bo_addle_u32( &bo, tk->i_extra );
if( tk->i_cat == AUDIO_ES )
bo_addle_u32( &bo, 8 ); /* correction data length */
else
bo_addle_u32( &bo, 0 ); /* correction data length */
/* correction data length */
bo_addle_u32( &bo, tk->b_audio_correction ? 8 : 0 );
bo_addle_u16( &bo, tk->i_id ); /* stream number */
bo_addle_u32( &bo, 0 );
bo_add_mem ( &bo, tk->p_extra, tk->i_extra );
/* Error correction data field */
if( tk->i_cat == AUDIO_ES )
if( tk->b_audio_correction )
{
bo_add_u8( &bo, 0x1 ); /* span */
bo_addle_u16( &bo, tk->i_blockalign ); /* virtual packet length */
......
......@@ -296,11 +296,15 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
case VLC_FOURCC( 'w', 'm', 'a', '1' ):
p_wf->wFormatTag = WAVE_FORMAT_WMA1;
break;
case VLC_FOURCC( 'w', 'm', 'a', ' ' ):
case VLC_FOURCC( 'w', 'm', 'a', '2' ):
p_wf->wFormatTag = WAVE_FORMAT_WMA2;
break;
case VLC_FOURCC( 'w', 'm', 'a', '3' ):
p_wf->wFormatTag = WAVE_FORMAT_WMA3;
case VLC_FOURCC( 'w', 'm', 'a', 'p' ):
p_wf->wFormatTag = WAVE_FORMAT_WMAP;
break;
case VLC_FOURCC( 'w', 'm', 'a', 'l' ):
p_wf->wFormatTag = WAVE_FORMAT_WMAL;
break;
/* raw codec */
case VLC_FOURCC( 'u', '8', ' ', ' ' ):
......
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