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

avcodec: zero copy audio decoding

parent 78f1c31a
......@@ -353,31 +353,37 @@ block_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
p_dec->fmt_out.audio.i_format );
if( ctx->channels > AV_NUM_DATA_POINTERS )
free( frame.extended_data );
block_Release( p_block );
p_block = p_buffer;
}
else /* TODO: zero copy... need to replace decoder_NewAudioBuffer() */
memcpy( p_buffer->p_buffer, p_block->p_buffer, p_block->i_buffer );
else /* FIXME: improve decoder_NewAudioBuffer(), avoid useless buffer... */
block_Release( p_buffer );
if (p_sys->b_extract)
{ /* TODO: do not drop channels... at least not here */
aout_ChannelExtract( p_block->p_buffer,
p_buffer = block_Alloc( p_dec->fmt_out.audio.i_bytes_per_frame
* frame.nb_samples );
if( unlikely(p_buffer == NULL) )
{
block_Release( p_block );
return NULL;
}
aout_ChannelExtract( p_buffer->p_buffer,
p_dec->fmt_out.audio.i_channels,
p_buffer->p_buffer, ctx->channels,
p_block->p_buffer, ctx->channels,
frame.nb_samples, p_sys->pi_extraction,
p_dec->fmt_out.audio.i_bitspersample );
block_Release( p_buffer );
p_buffer = p_block;
}
else
block_Release( p_block );
p_block = p_buffer;
}
p_buffer->i_nb_samples = frame.nb_samples;
p_buffer->i_buffer = frame.nb_samples
* p_dec->fmt_out.audio.i_bytes_per_frame;
p_buffer->i_pts = date_Get( &p_sys->end_date );
p_buffer->i_length = date_Increment( &p_sys->end_date, frame.nb_samples )
- p_buffer->i_pts;
return p_buffer;
p_block->i_nb_samples = frame.nb_samples;
p_block->i_buffer = frame.nb_samples
* p_dec->fmt_out.audio.i_bytes_per_frame;
p_block->i_pts = date_Get( &p_sys->end_date );
p_block->i_length = date_Increment( &p_sys->end_date, frame.nb_samples )
- p_block->i_pts;
return p_block;
end:
block_Release(p_block);
......
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