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 ) ...@@ -297,10 +297,13 @@ static int DecoderOpen( vlc_object_t *p_this )
static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) static block_t *DecodeBlock( 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;
if( pp_block == NULL )
if( !pp_block || !*pp_block ) return NULL; return NULL;
block_t *p_block = *pp_block; block_t *p_block = *pp_block;
if( p_block == NULL )
return NULL;
*pp_block = NULL;
if( p_block->i_pts > VLC_TS_INVALID && if( p_block->i_pts > VLC_TS_INVALID &&
p_block->i_pts != date_Get( &p_sys->end_date ) ) 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 ) ...@@ -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 ); date_Set( &p_sys->end_date, p_block->i_pts );
} }
else if( !date_Get( &p_sys->end_date ) ) else if( !date_Get( &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. */
block_Release( p_block ); goto skip;
return NULL;
}
/* Don't re-use the same pts twice */
p_block->i_pts = VLC_TS_INVALID;
unsigned samples = (8 * p_block->i_buffer) / p_sys->framebits; unsigned samples = (8 * p_block->i_buffer) / p_sys->framebits;
if( samples == 0 ) if( samples == 0 )
{ goto skip;
block_Release( p_block );
return NULL;
}
/* Create chunks of max 1024 samples */
if( samples > 1024 ) samples = 1024;
if( p_sys->decode != NULL )
{
block_t *p_out = decoder_NewAudioBuffer( p_dec, samples ); block_t *p_out = decoder_NewAudioBuffer( p_dec, samples );
if( p_out == NULL ) if( p_out == NULL )
{ goto skip;
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;
if( p_sys->decode != NULL )
p_sys->decode( p_out->p_buffer, p_block->p_buffer, p_sys->decode( p_out->p_buffer, p_block->p_buffer,
samples * p_dec->fmt_in.audio.i_channels ); samples * p_dec->fmt_in.audio.i_channels );
block_Release( p_block );
p_block = p_out;
}
else else
memcpy( p_out->p_buffer, p_block->p_buffer, p_out->i_buffer ); {
decoder_UpdateAudioFormat( p_dec );
samples = (samples * p_sys->framebits) / 8; p_block->i_buffer = samples * (p_sys->framebits / 8);
p_block->p_buffer += samples; }
p_block->i_buffer -= samples;
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 ) 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