Commit c3bd897e authored by David Robison's avatar David Robison Committed by Rémi Denis-Courmont

input: improved buffering accuracy and no rebuffering on ignored

To test this change, I used a MiniMaxwell which allows me to introduce
jitter, delay, and packet re-ordering in the video stream. I ran for
over 12 hours with no effect on the video and no increase in buffer
size. I'm reattaching the final patch here. I've made 2 basic changes
to the buffering strategy:

1) I now check to see if I and done buffering on both the
ES_OUT_SET_PCR and ES_OUT_SET_GROUP_PCR calls. This causes the buffered
amount to be checked more frequently and prevents over buffering which
I have seen in some instances
2) When ignoring the jitter, I do not flush the buffer and rebuffer,
since I am not increasing the buffer size anyway. Instead I just reset
the PCR and continue on.
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 407651b1
...@@ -2309,14 +2309,14 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args ) ...@@ -2309,14 +2309,14 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
EsOutIsExtraBufferingAllowed( out ), EsOutIsExtraBufferingAllowed( out ),
i_pcr, mdate() ); i_pcr, mdate() );
if( p_pgrm == p_sys->p_pgrm ) if( p_sys->b_buffering )
{ {
if( p_sys->b_buffering ) /* Check buffering state on master clock update */
{ EsOutDecodersStopBuffering( out, false );
/* Check buffering state on master clock update */ }
EsOutDecodersStopBuffering( out, false ); else if( p_pgrm == p_sys->p_pgrm )
} {
else if( b_late && ( !p_sys->p_input->p->p_sout || if( b_late && ( !p_sys->p_input->p->p_sout ||
!p_sys->p_input->p->b_out_pace_control ) ) !p_sys->p_input->p->b_out_pace_control ) )
{ {
const mtime_t i_pts_delay_base = p_sys->i_pts_delay - p_sys->i_pts_jitter; const mtime_t i_pts_delay_base = p_sys->i_pts_delay - p_sys->i_pts_jitter;
...@@ -2330,19 +2330,23 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args ) ...@@ -2330,19 +2330,23 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
"ES_OUT_SET_(GROUP_)PCR is called too late (jitter of %d ms ignored)", "ES_OUT_SET_(GROUP_)PCR is called too late (jitter of %d ms ignored)",
(int)(i_pts_delay - i_pts_delay_base) / 1000 ); (int)(i_pts_delay - i_pts_delay_base) / 1000 );
i_pts_delay = p_sys->i_pts_delay; i_pts_delay = p_sys->i_pts_delay;
/* reset clock */
for( int i = 0; i < p_sys->i_pgrm; i++ )
input_clock_Reset( p_sys->pgrm[i]->p_clock );
} }
else else
{ {
msg_Err( p_sys->p_input, msg_Err( p_sys->p_input,
"ES_OUT_SET_(GROUP_)PCR is called too late (pts_delay increased to %d ms)", "ES_OUT_SET_(GROUP_)PCR is called too late (pts_delay increased to %d ms)",
(int)(i_pts_delay/1000) ); (int)(i_pts_delay/1000) );
}
/* Force a rebufferization when we are too late */ /* Force a rebufferization when we are too late */
/* It is not really good, as we throw away already buffered data /* It is not really good, as we throw away already buffered data
* TODO have a mean to correctly reenter bufferization */ * TODO have a mean to correctly reenter bufferization */
es_out_Control( out, ES_OUT_RESET_PCR ); es_out_Control( out, ES_OUT_RESET_PCR );
}
es_out_SetJitter( out, i_pts_delay_base, i_pts_delay - i_pts_delay_base, p_sys->i_cr_average ); es_out_SetJitter( out, i_pts_delay_base, i_pts_delay - i_pts_delay_base, p_sys->i_cr_average );
} }
......
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