1 /*****************************************************************************
2 * vpar_synchro.h : video parser blocks management
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21 *****************************************************************************/
23 /*****************************************************************************
34 *****************************************************************************/
37 //#define POLUX_SYNCHRO
38 //#define MEUUH_SYNCHRO
40 /*****************************************************************************
41 * video_synchro_t and video_synchro_tab_s : timers for the video synchro
42 *****************************************************************************/
44 typedef struct video_synchro_s
46 /* fifo containing decoding dates */
47 mtime_t i_date_fifo[16];
51 /* mean decoding time */
53 mtime_t i_theorical_delay;
56 mtime_t i_last_pts; /* pts of the last displayed image */
57 mtime_t i_last_seen_I_pts; /* date of the last I we decoded */
58 mtime_t i_last_kept_I_pts; /* pts of last non-dropped I image */
60 /* P images since the last I */
61 unsigned int i_P_seen;
62 unsigned int i_P_kept;
63 /* B images since the last I */
64 unsigned int i_B_seen;
65 unsigned int i_B_kept;
67 /* can we display pictures ? */
76 #define FIFO_INCREMENT( i_counter ) \
77 p_vpar->synchro.i_counter = (p_vpar->synchro.i_counter + 1) & 0xf;
82 typedef struct video_synchro_s
84 int kludge_level, kludge_p, kludge_b, kludge_nbp, kludge_nbb;
86 mtime_t kludge_date, kludge_prevdate;
90 #define SYNC_TOLERATE ((int)(0.010*CLOCK_FREQ)) /* 10 ms */
91 #define SYNC_DELAY ((int)(0.500*CLOCK_FREQ)) /* 500 ms */
96 #define SYNC_AVERAGE_COUNT 10
98 typedef struct video_synchro_s
102 /* Dates needed to compute the date of the current frame
103 * We also use the stream frame rate (sequence.r_frame_rate) */
104 mtime_t i_current_frame_date;
105 mtime_t i_backward_frame_date;
107 /* Frame Trashing Section */
109 int i_b_nb, i_p_nb; /* number of decoded P and B between two I */
110 float r_b_average, r_p_average;
111 int i_b_count, i_p_count, i_i_count;
112 int i_b_trasher; /* used for brensenham algorithm */
118 /*****************************************************************************
120 *****************************************************************************/
121 boolean_t vpar_SynchroChoose ( struct vpar_thread_s * p_vpar,
122 int i_coding_type, int i_structure );
123 void vpar_SynchroTrash ( struct vpar_thread_s * p_vpar,
124 int i_coding_type, int i_structure );
125 void vpar_SynchroDecode ( struct vpar_thread_s * p_vpar,
126 int i_coding_type, int i_structure );
127 void vpar_SynchroEnd ( struct vpar_thread_s * p_vpar );
128 mtime_t vpar_SynchroDate ( struct vpar_thread_s * p_vpar );
131 void vpar_SynchroKludge ( struct vpar_thread_s *, mtime_t );