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 /* synchro algorithm */
49 /* fifo containing decoding dates */
50 mtime_t i_date_fifo[16];
54 /* mean decoding time */
56 mtime_t i_theorical_delay;
59 mtime_t i_last_pts; /* pts of the last displayed image */
60 mtime_t i_last_seen_I_pts; /* date of the last I we decoded */
61 mtime_t i_last_kept_I_pts; /* pts of last non-dropped I image */
63 /* P images since the last I */
64 unsigned int i_P_seen;
65 unsigned int i_P_kept;
66 /* B images since the last I */
67 unsigned int i_B_seen;
68 unsigned int i_B_kept;
70 /* can we display pictures ? */
76 boolean_t b_dropped_last_B;
80 #define FIFO_INCREMENT( i_counter ) \
81 p_vpar->synchro.i_counter = (p_vpar->synchro.i_counter + 1) & 0xf;
83 #define VPAR_SYNCHRO_DEFAULT 0
84 #define VPAR_SYNCHRO_I 1
85 #define VPAR_SYNCHRO_IP 2
86 #define VPAR_SYNCHRO_IPplus 3
87 #define VPAR_SYNCHRO_IPB 4
92 typedef struct video_synchro_s
94 int kludge_level, kludge_p, kludge_b, kludge_nbp, kludge_nbb;
96 mtime_t kludge_date, kludge_prevdate;
100 #define SYNC_TOLERATE ((int)(0.010*CLOCK_FREQ)) /* 10 ms */
101 #define SYNC_DELAY ((int)(0.500*CLOCK_FREQ)) /* 500 ms */
106 #define SYNC_AVERAGE_COUNT 10
108 typedef struct video_synchro_s
112 /* Dates needed to compute the date of the current frame
113 * We also use the stream frame rate (sequence.i_frame_rate) */
114 mtime_t i_current_frame_date;
115 mtime_t i_backward_frame_date;
117 /* Frame Trashing Section */
119 int i_b_nb, i_p_nb; /* number of decoded P and B between two I */
120 float r_b_average, r_p_average;
121 int i_b_count, i_p_count, i_i_count;
122 int i_b_trasher; /* used for brensenham algorithm */
128 /*****************************************************************************
130 *****************************************************************************/
131 boolean_t vpar_SynchroChoose ( struct vpar_thread_s * p_vpar,
132 int i_coding_type, int i_structure );
133 void vpar_SynchroTrash ( struct vpar_thread_s * p_vpar,
134 int i_coding_type, int i_structure );
135 void vpar_SynchroDecode ( struct vpar_thread_s * p_vpar,
136 int i_coding_type, int i_structure );
137 void vpar_SynchroEnd ( struct vpar_thread_s * p_vpar );
138 mtime_t vpar_SynchroDate ( struct vpar_thread_s * p_vpar );
141 void vpar_SynchroKludge ( struct vpar_thread_s *, mtime_t );