Commit b759e185 authored by Gildas Bazin's avatar Gildas Bazin

* ALL: backport of the ffmpeg real audio support (13650, 13651, 13655, 13658).

parent 0081a1d0
...@@ -897,7 +897,7 @@ static struct ...@@ -897,7 +897,7 @@ static struct
VIDEO_ES, "PAM Image" }, VIDEO_ES, "PAM Image" },
#endif #endif
#if LIBAVCODEC_BUILD > ((50<<16)+(1<<8)+0) #if LIBAVCODEC_BUILD >= ((51<<16)+(0<<8)+0)
{ VLC_FOURCC('b','m','p',' '), CODEC_ID_BMP, { VLC_FOURCC('b','m','p',' '), CODEC_ID_BMP,
VIDEO_ES, "BMP Image" }, VIDEO_ES, "BMP Image" },
#endif #endif
...@@ -1017,7 +1017,13 @@ static struct ...@@ -1017,7 +1017,13 @@ static struct
#if LIBAVCODEC_BUILD >= ((50<<16)+(0<<8)+1) #if LIBAVCODEC_BUILD >= ((50<<16)+(0<<8)+1)
/* QDM2 */ /* QDM2 */
{ VLC_FOURCC('Q','D','M','2'), CODEC_ID_QDM2, { VLC_FOURCC('Q','D','M','2'), CODEC_ID_QDM2,
AUDIO_ES, "QDM2" }, AUDIO_ES, "QDM2 Audio" },
#endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(0<<8)+0)
/* COOK */
{ VLC_FOURCC('c','o','o','k'), CODEC_ID_COOK,
AUDIO_ES, "Cook Audio" },
#endif #endif
/* PCM */ /* PCM */
......
...@@ -79,26 +79,13 @@ struct decoder_sys_t ...@@ -79,26 +79,13 @@ struct decoder_sys_t
{ {
audio_date_t end_date; audio_date_t end_date;
/* Frame buffer for data reordering */
int i_subpacket;
mtime_t i_packet_pts;
int i_frame_size;
char *p_frame;
int i_frame;
/* Output buffer */ /* Output buffer */
char *p_out_buffer;
char *p_out; char *p_out;
unsigned int i_out; unsigned int i_out;
/* Codec params */ /* Codec params */
void *context; void *context;
int i_subpacket_size;
int i_subpacket_h;
int i_codec_flavor; int i_codec_flavor;
int i_coded_frame_size;
int i_extra;
uint8_t *p_extra;
void *dll; void *dll;
unsigned long (*raCloseCodec)(void*); unsigned long (*raCloseCodec)(void*);
...@@ -201,14 +188,17 @@ static int Open( vlc_object_t *p_this ) ...@@ -201,14 +188,17 @@ 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) );
if( p_dec->fmt_in.i_extra >= 10 ) p_sys->i_codec_flavor = -1;
if( p_dec->fmt_in.i_codec == VLC_FOURCC('s','i','p','r') )
{ {
p_sys->i_subpacket_size = ((short *)(p_dec->fmt_in.p_extra))[0]; if( p_dec->fmt_in.audio.i_bitspersample > 1531 )
p_sys->i_subpacket_h = ((short *)(p_dec->fmt_in.p_extra))[1]; p_sys->i_codec_flavor = 3;
p_sys->i_codec_flavor = ((short *)(p_dec->fmt_in.p_extra))[2]; else if( p_dec->fmt_in.audio.i_bitspersample > 937 )
p_sys->i_coded_frame_size = ((short *)(p_dec->fmt_in.p_extra))[3]; p_sys->i_codec_flavor = 1;
p_sys->i_extra = ((short*)(p_dec->fmt_in.p_extra))[4]; else if( p_dec->fmt_in.audio.i_bitspersample > 719 )
p_sys->p_extra = p_dec->fmt_in.p_extra + 10; p_sys->i_codec_flavor = 0;
else
p_sys->i_codec_flavor = 2;
} }
if( OpenDll( p_dec ) != VLC_SUCCESS ) if( OpenDll( p_dec ) != VLC_SUCCESS )
...@@ -235,15 +225,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -235,15 +225,7 @@ static int Open( vlc_object_t *p_this )
p_dec->pf_decode_audio = Decode; p_dec->pf_decode_audio = Decode;
p_sys->i_frame_size = p_sys->p_out = malloc( 4096 * 10 );
p_dec->fmt_in.audio.i_blockalign * p_sys->i_subpacket_h;
p_sys->p_frame = malloc( p_sys->i_frame_size );
p_sys->i_packet_pts = 0;
p_sys->i_subpacket = 0;
p_sys->i_frame = 0;
p_sys->p_out_buffer = malloc( 4096 * 10 );
p_sys->p_out = 0;
p_sys->i_out = 0; p_sys->i_out = 0;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -257,8 +239,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -257,8 +239,7 @@ static void Close( vlc_object_t *p_this )
decoder_t *p_dec = (decoder_t*)p_this; decoder_t *p_dec = (decoder_t*)p_this;
CloseDll( p_dec ); CloseDll( p_dec );
if( p_dec->p_sys->p_frame ) free( p_dec->p_sys->p_frame ); if( p_dec->p_sys->p_out ) free( p_dec->p_sys->p_out );
if( p_dec->p_sys->p_out_buffer ) free( p_dec->p_sys->p_out_buffer );
free( p_dec->p_sys ); free( p_dec->p_sys );
} }
...@@ -379,9 +360,9 @@ static int OpenNativeDll( decoder_t *p_dec, char *psz_path, char *psz_dll ) ...@@ -379,9 +360,9 @@ static int OpenNativeDll( decoder_t *p_dec, char *psz_path, char *psz_dll )
p_dec->fmt_in.audio.i_bitspersample, p_dec->fmt_in.audio.i_bitspersample,
p_dec->fmt_in.audio.i_channels, p_dec->fmt_in.audio.i_channels,
100, /* quality */ 100, /* quality */
p_sys->i_subpacket_size, p_dec->fmt_in.audio.i_blockalign, /* subpacket size */
p_sys->i_coded_frame_size, p_dec->fmt_in.audio.i_blockalign, /* coded frame size */
p_sys->i_extra, p_sys->p_extra p_dec->fmt_in.i_extra, p_dec->fmt_in.p_extra
}; };
msg_Dbg( p_dec, "opening library '%s'", psz_dll ); msg_Dbg( p_dec, "opening library '%s'", psz_dll );
...@@ -431,26 +412,29 @@ static int OpenNativeDll( decoder_t *p_dec, char *psz_path, char *psz_dll ) ...@@ -431,26 +412,29 @@ static int OpenNativeDll( decoder_t *p_dec, char *psz_path, char *psz_dll )
goto error_native; goto error_native;
} }
i_result = p_sys->raSetFlavor( context, p_sys->i_codec_flavor ); if( p_sys->i_codec_flavor >= 0 )
if( i_result )
{ {
msg_Err( p_dec, "decoder flavor setup failed, error code: 0x%x", i_result = p_sys->raSetFlavor( context, p_sys->i_codec_flavor );
i_result ); if( i_result )
goto error_native; {
} msg_Err( p_dec, "decoder flavor setup failed, error code: 0x%x",
i_result );
goto error_native;
}
p_prop = p_sys->raGetFlavorProperty( context, p_sys->i_codec_flavor, p_prop = p_sys->raGetFlavorProperty( context, p_sys->i_codec_flavor,
0, &i_prop ); 0, &i_prop );
msg_Dbg( p_dec, "audio codec: [%d] %s", msg_Dbg( p_dec, "audio codec: [%d] %s",
p_sys->i_codec_flavor, (char *)p_prop ); p_sys->i_codec_flavor, (char *)p_prop );
p_prop = p_sys->raGetFlavorProperty( context, p_sys->i_codec_flavor, p_prop = p_sys->raGetFlavorProperty( context, p_sys->i_codec_flavor,
1, &i_prop ); 1, &i_prop );
if( p_prop ) if( p_prop )
{ {
int i_bps = ((*((int*)p_prop))+4)/8; int i_bps = ((*((int*)p_prop))+4)/8;
msg_Dbg( p_dec, "audio bitrate: %5.3f kbit/s (%d bps)", msg_Dbg( p_dec, "audio bitrate: %5.3f kbit/s (%d bps)",
(*((int*)p_prop))*0.001f, i_bps ); (*((int*)p_prop))*0.001f, i_bps );
}
} }
p_sys->context = context; p_sys->context = context;
...@@ -481,9 +465,9 @@ static int OpenWin32Dll( decoder_t *p_dec, char *psz_path, char *psz_dll ) ...@@ -481,9 +465,9 @@ static int OpenWin32Dll( decoder_t *p_dec, char *psz_path, char *psz_dll )
p_dec->fmt_in.audio.i_bitspersample, p_dec->fmt_in.audio.i_bitspersample,
p_dec->fmt_in.audio.i_channels, p_dec->fmt_in.audio.i_channels,
100, /* quality */ 100, /* quality */
p_sys->i_subpacket_size, p_dec->fmt_in.audio.i_blockalign, /* subpacket size */
p_sys->i_coded_frame_size, p_dec->fmt_in.audio.i_blockalign, /* coded frame size */
p_sys->i_extra, p_sys->p_extra p_dec->fmt_in.i_extra, p_dec->fmt_in.p_extra
}; };
msg_Dbg( p_dec, "opening win32 dll '%s'", psz_dll ); msg_Dbg( p_dec, "opening win32 dll '%s'", psz_dll );
...@@ -540,26 +524,29 @@ static int OpenWin32Dll( decoder_t *p_dec, char *psz_path, char *psz_dll ) ...@@ -540,26 +524,29 @@ static int OpenWin32Dll( decoder_t *p_dec, char *psz_path, char *psz_dll )
goto error_win32; goto error_win32;
} }
i_result = p_sys->wraSetFlavor( context, p_sys->i_codec_flavor ); if( p_sys->i_codec_flavor >= 0 )
if( i_result )
{ {
msg_Err( p_dec, "decoder flavor setup failed, error code: 0x%x", i_result = p_sys->wraSetFlavor( context, p_sys->i_codec_flavor );
i_result ); if( i_result )
goto error_win32; {
} msg_Err( p_dec, "decoder flavor setup failed, error code: 0x%x",
i_result );
goto error_win32;
}
p_prop = p_sys->wraGetFlavorProperty( context, p_sys->i_codec_flavor, p_prop = p_sys->wraGetFlavorProperty( context, p_sys->i_codec_flavor,
0, &i_prop ); 0, &i_prop );
msg_Dbg( p_dec, "audio codec: [%d] %s", msg_Dbg( p_dec, "audio codec: [%d] %s",
p_sys->i_codec_flavor, (char *)p_prop ); p_sys->i_codec_flavor, (char *)p_prop );
p_prop = p_sys->wraGetFlavorProperty( context, p_sys->i_codec_flavor, p_prop = p_sys->wraGetFlavorProperty( context, p_sys->i_codec_flavor,
1, &i_prop ); 1, &i_prop );
if( p_prop ) if( p_prop )
{ {
int i_bps = ((*((int*)p_prop))+4)/8; int i_bps = ((*((int*)p_prop))+4)/8;
msg_Dbg( p_dec, "audio bitrate: %5.3f kbit/s (%d bps)", msg_Dbg( p_dec, "audio bitrate: %5.3f kbit/s (%d bps)",
(*((int*)p_prop))*0.001f, i_bps ); (*((int*)p_prop))*0.001f, i_bps );
}
} }
p_sys->context = context; p_sys->context = context;
...@@ -619,6 +606,8 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block ) ...@@ -619,6 +606,8 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block )
{ {
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
aout_buffer_t *p_aout_buffer = 0; aout_buffer_t *p_aout_buffer = 0;
unsigned int i_result;
int i_samples;
block_t *p_block; block_t *p_block;
#ifdef LOADER #ifdef LOADER
...@@ -635,123 +624,51 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block ) ...@@ -635,123 +624,51 @@ static aout_buffer_t *Decode( decoder_t *p_dec, block_t **pp_block )
} }
#endif #endif
/* Output 1024 samples at a time
* (the audio output doesn't like big audio packets) */
if( p_sys->i_out )
{
int i_out;
int i_samples = p_sys->i_out * 8 /
p_dec->fmt_out.audio.i_bitspersample /
p_dec->fmt_out.audio.i_channels;
i_samples = __MIN( i_samples, 1024 );
i_out = i_samples * p_dec->fmt_out.audio.i_bitspersample *
p_dec->fmt_out.audio.i_channels / 8;
p_aout_buffer = p_dec->pf_aout_buffer_new( p_dec, i_samples );
if( p_aout_buffer == NULL ) return NULL;
memcpy( p_aout_buffer->p_buffer, p_sys->p_out, i_out );
p_sys->i_out -= i_out;
p_sys->p_out += i_out;
/* Date management */
p_aout_buffer->start_date = aout_DateGet( &p_sys->end_date );
p_aout_buffer->end_date =
aout_DateIncrement( &p_sys->end_date, i_samples );
return p_aout_buffer;
}
/* If we have a full frame ready then we can start decoding */
if( p_sys->i_frame )
{
unsigned int i_result;
p_sys->p_out = p_sys->p_out_buffer;
if( p_sys->dll )
i_result = p_sys->raDecode( p_sys->context, p_sys->p_frame +
p_sys->i_frame_size - p_sys->i_frame,
p_dec->fmt_in.audio.i_blockalign,
p_sys->p_out, &p_sys->i_out, -1 );
else
i_result = p_sys->wraDecode( p_sys->context, p_sys->p_frame +
p_sys->i_frame_size - p_sys->i_frame,
p_dec->fmt_in.audio.i_blockalign,
p_sys->p_out, &p_sys->i_out, -1 );
#if 0
msg_Err( p_dec, "decoded: %i samples (%i)",
p_sys->i_out * 8 / p_dec->fmt_out.audio.i_bitspersample /
p_dec->fmt_out.audio.i_channels, i_result );
#endif
p_sys->i_frame -= p_dec->fmt_in.audio.i_blockalign;
return Decode( p_dec, pp_block );
}
if( pp_block == NULL || *pp_block == NULL ) return NULL; if( pp_block == NULL || *pp_block == NULL ) return NULL;
p_block = *pp_block; p_block = *pp_block;
//msg_Err( p_dec, "Decode: "I64Fd", %i", p_block->i_pts, p_block->i_buffer ); if( p_sys->dll )
i_result = p_sys->raDecode( p_sys->context, (char *)p_block->p_buffer,
(unsigned long)p_block->i_buffer,
p_sys->p_out, &p_sys->i_out, -1 );
else
i_result = p_sys->wraDecode( p_sys->context, (char *)p_block->p_buffer,
(unsigned long)p_block->i_buffer,
p_sys->p_out, &p_sys->i_out, -1 );
/* Detect missing subpackets */ #if 0
if( p_sys->i_subpacket && p_block->i_pts > 0 && msg_Err( p_dec, "decoded: %i samples (%i)",
p_block->i_pts != p_sys->i_packet_pts ) p_sys->i_out * 8 / p_dec->fmt_out.audio.i_bitspersample /
{ p_dec->fmt_out.audio.i_channels, i_result );
/* All subpackets in a packet should have the same pts so we must #endif
* have dropped some. Clear current frame buffer. */
p_sys->i_subpacket = 0;
msg_Dbg( p_dec, "detected dropped subpackets" );
}
if( p_block->i_pts > 0 ) p_sys->i_packet_pts = p_block->i_pts;
/* Date management */ /* Date management */
if( /* !p_sys->i_subpacket && */ p_block && p_block->i_pts > 0 && if( p_block->i_pts > 0 &&
p_block->i_pts != aout_DateGet( &p_sys->end_date ) ) p_block->i_pts != aout_DateGet( &p_sys->end_date ) )
{ {
aout_DateSet( &p_sys->end_date, p_block->i_pts ); aout_DateSet( &p_sys->end_date, p_block->i_pts );
} }
#if 0
if( !aout_DateGet( &p_sys->end_date ) ) if( !aout_DateGet( &p_sys->end_date ) )
{ {
/* We've just started the stream, wait for the first PTS. */ /* We've just started the stream, wait for the first PTS. */
if( p_block ) block_Release( p_block ); if( p_block ) block_Release( p_block );
return NULL; return NULL;
} }
#endif
if( p_sys->i_subpacket_size )
{
/* 'cook' way */
int sps = p_sys->i_subpacket_size;
int w = p_dec->fmt_in.audio.i_blockalign;
int h = p_sys->i_subpacket_h;
/* int cfs = p_sys->i_coded_frame_size; */
int x, y;
w /= sps;
y = p_sys->i_subpacket;
for( x = 0; x < w; x++ ) i_samples = p_sys->i_out * 8 /
{ p_dec->fmt_out.audio.i_bitspersample /p_dec->fmt_out.audio.i_channels;
memcpy( p_sys->p_frame + sps * (h*x+((h+1)/2)*(y&1)+(y>>1)),
p_block->p_buffer, sps );
p_block->p_buffer += sps;
}
p_sys->i_subpacket = (p_sys->i_subpacket + 1) % p_sys->i_subpacket_h; p_aout_buffer =
p_dec->pf_aout_buffer_new( p_dec, i_samples );
if( p_aout_buffer )
{
memcpy( p_aout_buffer->p_buffer, p_sys->p_out, p_sys->i_out );
if( !p_sys->i_subpacket ) /* Date management */
{ p_aout_buffer->start_date = aout_DateGet( &p_sys->end_date );
/* We have a complete frame */ p_aout_buffer->end_date =
p_sys->i_frame = p_sys->i_frame_size; aout_DateIncrement( &p_sys->end_date, i_samples );
p_aout_buffer = Decode( p_dec, pp_block );
}
} }
block_Release( p_block ); block_Release( p_block );
......
...@@ -59,6 +59,16 @@ typedef struct ...@@ -59,6 +59,16 @@ typedef struct
int i_frame; int i_frame;
block_t *p_frame; block_t *p_frame;
int i_subpacket_h;
int i_subpacket_size;
int i_coded_frame_size;
int i_frame_size;
int i_subpacket;
int i_subpackets;
block_t **p_subpackets;
int i_out_subpacket;
} real_track_t; } real_track_t;
struct demux_sys_t struct demux_sys_t
...@@ -148,6 +158,14 @@ static void Close( vlc_object_t *p_this ) ...@@ -148,6 +158,14 @@ static void Close( vlc_object_t *p_this )
if( tk->p_frame ) block_Release( tk->p_frame ); if( tk->p_frame ) block_Release( tk->p_frame );
es_format_Clean( &tk->fmt ); es_format_Clean( &tk->fmt );
while( tk->i_subpackets-- )
{
if( tk->p_subpackets[tk->i_subpackets] )
block_Release( tk->p_subpackets[tk->i_subpackets] );
if( !tk->i_subpackets ) free( tk->p_subpackets );
}
free( tk ); free( tk );
} }
...@@ -163,10 +181,8 @@ static int Demux( demux_t *p_demux ) ...@@ -163,10 +181,8 @@ static int Demux( demux_t *p_demux )
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
uint8_t header[18]; uint8_t header[18];
int i_size; int i_size, i_id, i_flags, i;
int i_id;
int64_t i_pts; int64_t i_pts;
int i;
real_track_t *tk = NULL; real_track_t *tk = NULL;
vlc_bool_t b_selected; vlc_bool_t b_selected;
...@@ -198,8 +214,7 @@ static int Demux( demux_t *p_demux ) ...@@ -198,8 +214,7 @@ static int Demux( demux_t *p_demux )
i_id = GetWBE( &header[4] ); i_id = GetWBE( &header[4] );
i_pts = 1000 * GetDWBE( &header[6] ); i_pts = 1000 * GetDWBE( &header[6] );
i_pts += 1000; /* Avoid 0 pts */ i_pts += 1000; /* Avoid 0 pts */
i_flags= header[11]; /* flags 0x02 -> keyframe */
/* header[11] -> flags 0x02 -> keyframe */
#if 0 #if 0
msg_Dbg( p_demux, "packet %d size=%d id=%d pts=%u", msg_Dbg( p_demux, "packet %d size=%d id=%d pts=%u",
...@@ -473,6 +488,71 @@ static int Demux( demux_t *p_demux ) ...@@ -473,6 +488,71 @@ static int Demux( demux_t *p_demux )
} }
} }
} }
else if( tk->fmt.i_codec == VLC_FOURCC( 'c', 'o', 'o', 'k' ) ||
tk->fmt.i_codec == VLC_FOURCC('2','8','_','8') )
{
uint8_t *p_buf = p_sys->buffer;
int y = tk->i_subpacket / (tk->i_frame_size /tk->i_subpacket_size);
int i_index, i;
/* Sanity check */
if( i_flags & 2 ) y = tk->i_subpacket = 0;
if( tk->fmt.i_codec == VLC_FOURCC( 'c', 'o', 'o', 'k' ) )
for( i = 0; i < tk->i_frame_size / tk->i_subpacket_size; i++ )
{
block_t *p_block = block_New( p_demux, tk->i_subpacket_size );
memcpy( p_block->p_buffer, p_buf, tk->i_subpacket_size );
p_buf += tk->i_subpacket_size;
i_index = tk->i_subpacket_h * i +
((tk->i_subpacket_h + 1) / 2) * (y&1) + (y>>1);
p_block->i_dts = p_block->i_pts = i_pts;
tk->p_subpackets[i_index] = p_block;
tk->i_subpacket++;
}
if( tk->fmt.i_codec == VLC_FOURCC('2','8','_','8') )
for( i = 0; i < tk->i_subpacket_h / 2; i++ )
{
block_t *p_block = block_New( p_demux, tk->i_coded_frame_size);
memcpy( p_block->p_buffer, p_buf, tk->i_coded_frame_size );
p_buf += tk->i_coded_frame_size;
i_index = (i * 2 * tk->i_frame_size) /
tk->i_coded_frame_size + y;
p_block->i_dts = p_block->i_pts = i_pts;
tk->p_subpackets[i_index] = p_block;
tk->i_subpacket++;
}
while( tk->i_out_subpacket != tk->i_subpackets &&
tk->p_subpackets[tk->i_out_subpacket] )
{
block_t *p_block = tk->p_subpackets[tk->i_out_subpacket];
tk->p_subpackets[tk->i_out_subpacket] = 0;
if( tk->i_out_subpacket ) p_block->i_dts = p_block->i_pts = 0;
es_out_Send( p_demux->out, tk->p_es, p_block );
tk->i_out_subpacket++;
}
if( tk->i_subpacket == tk->i_subpackets &&
tk->i_out_subpacket != tk->i_subpackets )
{
msg_Warn( p_demux, "i_subpacket != i_out_subpacket, "
"this shouldn't happen" );
}
if( tk->i_subpacket == tk->i_subpackets )
{
tk->i_subpacket = 0;
tk->i_out_subpacket = 0;
}
}
else else
{ {
block_t *p_block = block_New( p_demux, i_size ); block_t *p_block = block_New( p_demux, i_size );
...@@ -495,9 +575,7 @@ static int Demux( demux_t *p_demux ) ...@@ -495,9 +575,7 @@ static int Demux( demux_t *p_demux )
{ {
memcpy( p_block->p_buffer, p_sys->buffer, i_size ); memcpy( p_block->p_buffer, p_sys->buffer, i_size );
} }
p_block->i_dts = p_block->i_dts = p_block->i_pts = i_pts;
p_block->i_pts = i_pts;
es_out_Send( p_demux->out, tk->p_es, p_block ); es_out_Send( p_demux->out, tk->p_es, p_block );
} }
} }
...@@ -898,16 +976,14 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -898,16 +976,14 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
break; break;
case VLC_FOURCC('c','o','o','k'): case VLC_FOURCC('c','o','o','k'):
fmt.i_extra = GetDWBE( p_peek ); p_peek += 4; fmt.audio.i_blockalign = i_subpacket_size;
fmt.p_extra = malloc( fmt.i_extra + 10 ); if( !(fmt.i_extra = GetDWBE( p_peek )) ) break;
fmt.p_extra = malloc( fmt.i_extra );
((short*)(fmt.p_extra))[0] = i_subpacket_size; memcpy( fmt.p_extra, p_peek + 4, fmt.i_extra );
((short*)(fmt.p_extra))[1] = i_subpacket_h; break;
((short*)(fmt.p_extra))[2] = i_flavor;
((short*)(fmt.p_extra))[3] = i_coded_frame_size; case VLC_FOURCC('2','8','_','8'):
((short*)(fmt.p_extra))[4] = fmt.i_extra; fmt.audio.i_blockalign = i_coded_frame_size;
if( fmt.i_extra ) memcpy( fmt.p_extra + 10, p_peek, fmt.i_extra );
fmt.i_extra += 10;
break; break;
default: default:
...@@ -918,6 +994,8 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -918,6 +994,8 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
if( fmt.i_codec != 0 ) if( fmt.i_codec != 0 )
{ {
int i;
msg_Dbg( p_demux, " - extra data=%d", fmt.i_extra ); msg_Dbg( p_demux, " - extra data=%d", fmt.i_extra );
tk = malloc( sizeof( real_track_t ) ); tk = malloc( sizeof( real_track_t ) );
...@@ -925,6 +1003,33 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -925,6 +1003,33 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
tk->fmt = fmt; tk->fmt = fmt;
tk->i_frame = 0; tk->i_frame = 0;
tk->p_frame = NULL; tk->p_frame = NULL;
tk->i_subpacket_h = i_subpacket_h;
tk->i_subpacket_size = i_subpacket_size;
tk->i_coded_frame_size = i_coded_frame_size;
tk->i_frame_size = i_frame_size;
tk->i_out_subpacket = 0;
tk->i_subpacket = 0;
tk->i_subpackets = 0;
tk->p_subpackets = NULL;
if( fmt.i_codec == VLC_FOURCC('c','o','o','k') )
{
tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_subpacket_size;
tk->p_subpackets =
malloc( tk->i_subpackets * sizeof(block_t *) );
}
else if( fmt.i_codec == VLC_FOURCC('2','8','_','8') )
{
tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_coded_frame_size;
tk->p_subpackets =
malloc( tk->i_subpackets * sizeof(block_t *) );
}
for( i = 0; i < tk->i_subpackets; i++ ) tk->p_subpackets[i] = NULL;
tk->p_es = es_out_Add( p_demux->out, &fmt ); tk->p_es = es_out_Add( p_demux->out, &fmt );
TAB_APPEND( p_sys->i_track, p_sys->track, tk ); TAB_APPEND( p_sys->i_track, p_sys->track, tk );
......
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