Commit 46f782a9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

araw: zero copy for native audio sample formats

parent 492dfdd5
......@@ -297,10 +297,13 @@ static int DecoderOpen( vlc_object_t *p_this )
static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
if( !pp_block || !*pp_block ) return NULL;
if( pp_block == NULL )
return NULL;
block_t *p_block = *pp_block;
if( p_block == NULL )
return NULL;
*pp_block = NULL;
if( p_block->i_pts > VLC_TS_INVALID &&
p_block->i_pts != date_Get( &p_sys->end_date ) )
......@@ -308,47 +311,37 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
date_Set( &p_sys->end_date, p_block->i_pts );
}
else if( !date_Get( &p_sys->end_date ) )
{
/* We've just started the stream, wait for the first PTS. */
block_Release( p_block );
return NULL;
}
/* Don't re-use the same pts twice */
p_block->i_pts = VLC_TS_INVALID;
goto skip;
unsigned samples = (8 * p_block->i_buffer) / p_sys->framebits;
if( samples == 0 )
{
block_Release( p_block );
return NULL;
}
goto skip;
/* Create chunks of max 1024 samples */
if( samples > 1024 ) samples = 1024;
block_t *p_out = decoder_NewAudioBuffer( p_dec, samples );
if( p_out == NULL )
if( p_sys->decode != NULL )
{
block_Release( p_block );
return NULL;
}
p_out->i_pts = date_Get( &p_sys->end_date );
p_out->i_length = date_Increment( &p_sys->end_date, samples )
- p_out->i_pts;
block_t *p_out = decoder_NewAudioBuffer( p_dec, samples );
if( p_out == NULL )
goto skip;
if( p_sys->decode != NULL )
p_sys->decode( p_out->p_buffer, p_block->p_buffer,
samples * p_dec->fmt_in.audio.i_channels );
block_Release( p_block );
p_block = p_out;
}
else
memcpy( p_out->p_buffer, p_block->p_buffer, p_out->i_buffer );
samples = (samples * p_sys->framebits) / 8;
p_block->p_buffer += samples;
p_block->i_buffer -= samples;
{
decoder_UpdateAudioFormat( p_dec );
p_block->i_buffer = samples * (p_sys->framebits / 8);
}
return p_out;
p_block->i_pts = date_Get( &p_sys->end_date );
p_block->i_length = date_Increment( &p_sys->end_date, samples )
- p_block->i_pts;
return p_block;
skip:
block_Release( p_block );
return NULL;
}
static void S8Decode( void *outp, const uint8_t *in, unsigned samples )
......
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