Commit 75f2ed95 authored by Gildas Bazin's avatar Gildas Bazin

* modules/demux/real.c: re-order cook subpackets and send them 1 at a time to...

* modules/demux/real.c: re-order cook subpackets and send them 1 at a time to the decoder. This is required by the new ffmpeg cook codec (It also breaks our binary realaudio codec but I'll repair that later on).
parent b8f9e25f
...@@ -902,7 +902,7 @@ static struct ...@@ -902,7 +902,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
...@@ -1022,13 +1022,13 @@ static struct ...@@ -1022,13 +1022,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 #endif
#if LIBAVCODEC_BUILD >= ((51<<16)+(0<<8)+0) #if LIBAVCODEC_BUILD >= ((51<<16)+(0<<8)+0)
/* COOK */ /* COOK */
{ VLC_FOURCC('c','o','o','k'), CODEC_ID_COOK, { VLC_FOURCC('c','o','o','k'), CODEC_ID_COOK,
AUDIO_ES, "COOK" }, AUDIO_ES, "Cook Audio" },
#endif #endif
/* PCM */ /* PCM */
......
...@@ -59,6 +59,15 @@ typedef struct ...@@ -59,6 +59,15 @@ 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;
} real_track_t; } real_track_t;
struct demux_sys_t struct demux_sys_t
...@@ -148,6 +157,14 @@ static void Close( vlc_object_t *p_this ) ...@@ -148,6 +157,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 );
} }
...@@ -473,6 +490,38 @@ static int Demux( demux_t *p_demux ) ...@@ -473,6 +490,38 @@ static int Demux( demux_t *p_demux )
} }
} }
} }
else if( tk->fmt.i_codec == VLC_FOURCC( 'c', 'o', 'o', 'k' ) )
{
uint8_t *p_buf = p_sys->buffer;
int h = tk->i_subpacket_h;
int y = tk->i_subpacket / (tk->i_frame_size /tk->i_subpacket_size);
int i;
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;
p_block->i_dts = p_block->i_pts = i_pts;
tk->p_subpackets[(h*i+((h+1)/2)*(y&1)+(y>>1))] = p_block;
tk->i_subpacket++;
}
if( tk->i_subpacket == tk->i_subpackets )
{
for( i = 0; i < tk->i_subpackets; i++ )
{
block_t *p_block = tk->p_subpackets[i];
tk->p_subpackets[i] = 0;
if( i ) p_block->i_dts = p_block->i_pts = 0;
es_out_Send( p_demux->out, tk->p_es, p_block );
}
tk->i_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 +544,7 @@ static int Demux( demux_t *p_demux ) ...@@ -495,9 +544,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 );
} }
} }
...@@ -912,16 +959,10 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -912,16 +959,10 @@ 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;
((short*)(fmt.p_extra))[2] = i_flavor;
((short*)(fmt.p_extra))[3] = i_coded_frame_size;
((short*)(fmt.p_extra))[4] = fmt.i_extra;
if( fmt.i_extra ) memcpy( fmt.p_extra + 10, p_peek, fmt.i_extra );
fmt.i_extra += 10;
break; break;
default: default:
...@@ -939,6 +980,28 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num ) ...@@ -939,6 +980,28 @@ 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_subpacket = 0;
tk->i_subpackets = 0;
tk->p_subpackets = NULL;
if( fmt.i_codec == VLC_FOURCC('c','o','o','k') )
{
int i;
tk->i_subpackets =
i_subpacket_h * i_frame_size / tk->i_subpacket_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