Commit a4c8807e authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Real/Sipr, try to use a correct flavor detection, without using the MPlayer hacks...

parent da58e962
...@@ -95,6 +95,7 @@ struct audio_format_t ...@@ -95,6 +95,7 @@ struct audio_format_t
unsigned i_bitspersample; unsigned i_bitspersample;
unsigned i_blockalign; unsigned i_blockalign;
uint8_t i_channels; /* must be <=32 */ uint8_t i_channels; /* must be <=32 */
uint8_t i_flavor;
}; };
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
......
...@@ -186,6 +186,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -186,6 +186,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Channel detection */
if( p_dec->fmt_in.audio.i_channels <= 0 || if( p_dec->fmt_in.audio.i_channels <= 0 ||
p_dec->fmt_in.audio.i_channels > 6 ) p_dec->fmt_in.audio.i_channels > 6 )
{ {
...@@ -197,19 +198,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -197,19 +198,12 @@ static int Open( vlc_object_t *p_this )
p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) ); p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
memset( p_sys, 0, sizeof(decoder_sys_t) ); memset( p_sys, 0, sizeof(decoder_sys_t) );
/* Flavor for SIPR codecs */
p_sys->i_codec_flavor = -1; p_sys->i_codec_flavor = -1;
if( p_dec->fmt_in.i_codec == VLC_FOURCC('s','i','p','r') ) if( p_dec->fmt_in.i_codec == VLC_FOURCC('s','i','p','r') )
{ {
if( p_dec->fmt_in.audio.i_bitspersample > 1531 ) p_sys->i_codec_flavor = p_dec->fmt_in.audio.i_flavor;
p_sys->i_codec_flavor = 3; msg_Dbg( p_dec, "Got sipr flavor %d", p_sys->i_codec_flavor );
else if( p_dec->fmt_in.audio.i_bitspersample > 937 )
p_sys->i_codec_flavor = 1;
else if( p_dec->fmt_in.audio.i_bitspersample > 719 )
p_sys->i_codec_flavor = 0;
else
p_sys->i_codec_flavor = 2;
msg_Dbg( p_dec, "Got sipr flavor %d from bitrate %d\n",
p_sys->i_codec_flavor, p_dec->fmt_in.audio.i_bitspersample );
} }
if( OpenDll( p_dec ) != VLC_SUCCESS ) if( OpenDll( p_dec ) != VLC_SUCCESS )
......
...@@ -124,9 +124,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args ); ...@@ -124,9 +124,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
static int HeaderRead( demux_t *p_demux ); static int HeaderRead( demux_t *p_demux );
static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ); static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num );
// Map flavour to bytes per second
static int sipr_fl2bps[4] = {813, 1062, 625, 2000}; // 6.5, 8.5, 5, 16 kbit per second
/***************************************************************************** /*****************************************************************************
* Open * Open
*****************************************************************************/ *****************************************************************************/
...@@ -138,6 +135,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -138,6 +135,11 @@ static int Open( vlc_object_t *p_this )
const uint8_t *p_peek; const uint8_t *p_peek;
if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) return VLC_EGENERIC; if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) return VLC_EGENERIC;
if( !memcmp( p_peek, ".ra", 3 ) )
{
msg_Warn( p_demux, ".ra files unsuported" );
return VLC_EGENERIC;
}
if( memcmp( p_peek, ".RMF", 4 ) ) return VLC_EGENERIC; if( memcmp( p_peek, ".RMF", 4 ) ) return VLC_EGENERIC;
/* Fill p_demux field */ /* Fill p_demux field */
...@@ -1011,6 +1013,7 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -1011,6 +1013,7 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
{ {
int i_header_size, i_flavor, i_coded_frame_size, i_subpacket_h; int i_header_size, i_flavor, i_coded_frame_size, i_subpacket_h;
int i_frame_size, i_subpacket_size; int i_frame_size, i_subpacket_size;
char p_genr[4];
int i_version = GetWBE( &p_peek[4] ); /* [0..3] = '.','r','a',0xfd */ int i_version = GetWBE( &p_peek[4] ); /* [0..3] = '.','r','a',0xfd */
msg_Dbg( p_demux, " - audio version=%d", i_version ); msg_Dbg( p_demux, " - audio version=%d", i_version );
...@@ -1099,9 +1102,8 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -1099,9 +1102,8 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
msg_Dbg( p_demux, " - audio codec=%4.4s channels=%d rate=%dHz", msg_Dbg( p_demux, " - audio codec=%4.4s channels=%d rate=%dHz",
(char*)&fmt.i_codec, fmt.audio.i_channels, fmt.audio.i_rate ); (char*)&fmt.i_codec, fmt.audio.i_channels, fmt.audio.i_rate );
} }
else else /* RMF version 4/5 */
{ {
p_peek += 2; /* 00 00 */ p_peek += 2; /* 00 00 */
p_peek += 4; /* .ra4 or .ra5 */ p_peek += 4; /* .ra4 or .ra5 */
p_peek += 4; /* data size */ p_peek += 4; /* data size */
...@@ -1127,7 +1129,7 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -1127,7 +1129,7 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
if( i_version == 5 ) if( i_version == 5 )
{ {
p_peek += 4; /* genr */ memcpy( (char *)p_genr, p_peek, 4 ); p_peek += 4; /* genr */
memcpy( (char *)&fmt.i_codec, p_peek, 4 ); p_peek += 4; memcpy( (char *)&fmt.i_codec, p_peek, 4 ); p_peek += 4;
} }
else else
...@@ -1149,8 +1151,10 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -1149,8 +1151,10 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
switch( fmt.i_codec ) switch( fmt.i_codec )
{ {
case VLC_FOURCC('1','4','_','4'): case VLC_FOURCC('1','4','_','4'):
/* fmt.audio.i_blockalign = 0x14 */
break; break;
case VLC_FOURCC('l','p','c','J'): case VLC_FOURCC('l','p','c','J'):
/* fmt.audio.i_blockalign = 0x14 */
fmt.i_codec = VLC_FOURCC( '1','4','_','4' ); fmt.i_codec = VLC_FOURCC( '1','4','_','4' );
break; break;
...@@ -1175,20 +1179,19 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -1175,20 +1179,19 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
fmt.i_codec = VLC_FOURCC( 'm','p','4','a' ); fmt.i_codec = VLC_FOURCC( 'm','p','4','a' );
break; break;
case VLC_FOURCC('s','i','p','r'):
fmt.audio.i_flavor = i_flavor;
case VLC_FOURCC('c','o','o','k'): case VLC_FOURCC('c','o','o','k'):
case VLC_FOURCC('a','t','r','c'): case VLC_FOURCC('a','t','r','c'):
fmt.audio.i_blockalign = i_subpacket_size; if( !memcmp( p_genr, "genr", 4 ) )
fmt.audio.i_blockalign = i_subpacket_size;
else
fmt.audio.i_blockalign = i_coded_frame_size;
if( !fmt.i_extra ) break; if( !fmt.i_extra ) break;
fmt.p_extra = malloc( fmt.i_extra ); fmt.p_extra = malloc( fmt.i_extra );
memcpy( fmt.p_extra, p_peek, fmt.i_extra ); memcpy( fmt.p_extra, p_peek, fmt.i_extra );
break; break;
case VLC_FOURCC('s','i','p','r'):
fmt.i_extra = 0;
fmt.audio.i_blockalign = i_coded_frame_size;
fmt.audio.i_bitspersample = sipr_fl2bps[ i_flavor ];
break;
case VLC_FOURCC('r','a','l','f'): case VLC_FOURCC('r','a','l','f'):
msg_Dbg( p_demux, " - audio codec not supported=%4.4s", msg_Dbg( p_demux, " - audio codec not supported=%4.4s",
(char*)&fmt.i_codec ); (char*)&fmt.i_codec );
......
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