Commit 5ac16455 authored by Christophe Massiot's avatar Christophe Massiot

PTS calculation fix for the mad plug-in, courtesy of KKI_ on IRC.

parent 621ed463
......@@ -44,7 +44,7 @@ static void PrintFrameInfo(struct mad_header *Header);
enum mad_flow libmad_input( void *p_data, struct mad_stream *p_stream )
{
mad_adec_thread_t * p_dec = (mad_adec_thread_t *) p_data;
size_t i_wanted, i_left;
size_t i_wanted, i_left, i_current;
if ( p_dec->p_fifo->b_die )
{
......@@ -74,6 +74,7 @@ enum mad_flow libmad_input( void *p_data, struct mad_stream *p_stream )
if( p_stream->next_frame )
{
i_left = p_stream->bufend - p_stream->next_frame;
i_current = p_stream->next_frame - p_dec->buffer;
if( p_dec->buffer != p_stream->next_frame )
{
memcpy( p_dec->buffer, p_stream->next_frame, i_left );
......@@ -81,9 +82,19 @@ enum mad_flow libmad_input( void *p_data, struct mad_stream *p_stream )
i_wanted = MAD_BUFFER_MDLEN - i_left;
/* Store timestamp for next frame */
if ( ( p_stream->next_frame == p_dec->buffer ) ||
( i_current >= i_left * ( ( i_current / ( MAD_BUFFER_MDLEN - i_current ) ) + 1 ) )
)
{
p_dec->i_next_pts = p_dec->bit_stream.p_pes->i_pts;
}
else
{
/* p_dec->bit_stream.p_pes->i_pts != p_dec->i_next_pts */
p_dec->i_next_pts = 0;
}
}
else
{
i_wanted = MAD_BUFFER_MDLEN;
i_left = 0;
......
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