- /*Input lipsync and drop check */
- if( p_sys->b_master_sync )
- {
- /* How much audio has drifted */
- mtime_t i_master_drift = p_sys->i_master_drift;
-
- /* This is the pts input should have now with constant frame rate */
- mtime_t i_pts = date_Get( &id->interpolated_pts );
-
- /* How much input pts has drifted */
- mtime_t i_video_drift = p_pic->date - i_pts;
-
- /* Check that we are having lipsync with input here */
- if( unlikely ( ( (i_video_drift - i_master_drift ) > MASTER_SYNC_MAX_DRIFT
- || (i_video_drift + i_master_drift ) < -MASTER_SYNC_MAX_DRIFT ) ) )
- {
- msg_Warn( p_stream,
- "video drift too big, resetting sync %"PRId64" to %"PRId64,
- (i_video_drift + i_master_drift),
- p_pic->date
- );
- date_Set( &id->interpolated_pts, p_pic->date );
- date_Set( &id->next_output_pts, p_pic->date );
- i_pts = date_Get( &id->interpolated_pts );
- }
-
- /* Set the pts of the frame being encoded */
- p_pic->date = i_pts;
-
- /* now take next input pts, pts dates are only enabled if p_module is set*/
- date_Increment( &id->interpolated_pts, id->p_decoder->fmt_out.video.i_frame_rate_base );
-
-
- /* If input pts + input_frame_interval is lower than next_output_pts - output_frame_interval
- * Then the future input frame should fit better and we can drop this one
- *
- * Duplication need is checked in OutputFrame */
- if( ( p_pic->date + (mtime_t)id->i_input_frame_interval ) <
- ( date_Get( &id->next_output_pts ) ) )
- {
-#if 0
- msg_Dbg( p_stream, "dropping frame (%"PRId64" + %"PRId64" vs %"PRId64")",
- p_pic->date, id->i_input_frame_interval, date_Get(&id->next_output_pts) );
-#endif
- picture_Release( p_pic );
- continue;
- }
-#if 0
- msg_Dbg( p_stream, "not dropping frame");
-#endif
-
- /* input calculated pts isn't necessary what pts output should be, so use output pts*/
- p_pic->date = date_Get( &id->next_output_pts );
-
-
- }
-