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 *****************************************************************************/
38 /*****************************************************************************
39 * video_synchro_t and video_synchro_tab_s : timers for the video synchro
40 *****************************************************************************/
42 typedef struct video_synchro_tab_s
47 } video_synchro_tab_t;
49 typedef struct video_synchro_fifo_s
51 /* type of image to be decoded, and decoding date */
53 mtime_t i_decode_date;
56 } video_synchro_fifo_t;
58 typedef struct video_synchro_s
60 /* fifo containing decoding dates */
61 video_synchro_fifo_t fifo[16];
62 unsigned int i_fifo_start;
63 unsigned int i_fifo_stop;
65 /* mean decoding time */
66 mtime_t i_mean_decode_time;
68 mtime_t i_last_display_pts; /* pts of the last displayed image */
69 mtime_t i_last_decode_pts; /* pts of the last decoded image */
70 mtime_t i_last_i_pts; /* pts of the last I image */
71 mtime_t i_last_nondropped_i_pts; /* pts of last non-dropped I image */
72 unsigned int i_images_since_pts;
74 /* il manquait un compteur */
77 /* P images since the last I */
78 unsigned int current_p_count;
79 unsigned int nondropped_p_count;
80 double p_count_predict;
81 /* B images since the last I */
82 unsigned int current_b_count;
83 unsigned int nondropped_b_count;
84 double b_count_predict;
86 /* can we display pictures ? */
87 unsigned int can_display_i;
88 unsigned int can_display_p;
90 unsigned int can_display_b;
93 /* 1 for linear count, 2 for binary count, 3 for ternary count */
94 video_synchro_tab_t tab_p[6];
95 video_synchro_tab_t tab_b[6];
104 typedef struct video_synchro_s
106 int kludge_level, kludge_p, kludge_b, kludge_nbp, kludge_nbb;
108 mtime_t kludge_date, kludge_prevdate;
112 #define SYNC_TOLERATE ((int)(0.010*CLOCK_FREQ)) /* 10 ms */
113 #define SYNC_DELAY ((int)(0.500*CLOCK_FREQ)) /* 500 ms */
118 #define SYNC_AVERAGE_COUNT 10
120 typedef struct video_synchro_s
124 /* Dates needed to compute the date of the current frame
125 * We also use the stream frame rate (sequence.r_frame_rate) */
126 mtime_t i_current_frame_date;
127 mtime_t i_backward_frame_date;
129 /* Frame Trashing Section */
131 int i_b_nb, i_p_nb; /* number of decoded P and B between two I */
132 float r_b_average, r_p_average;
133 int i_b_count, i_p_count, i_i_count;
134 int i_b_trasher; /* used for brensenham algorithm */
140 /*****************************************************************************
142 *****************************************************************************/
143 boolean_t vpar_SynchroChoose( struct vpar_thread_s * p_vpar, int i_coding_type,
145 void vpar_SynchroTrash( struct vpar_thread_s * p_vpar, int i_coding_type,
147 void vpar_SynchroDecode( struct vpar_thread_s * p_vpar, int i_coding_type,
149 void vpar_SynchroEnd( struct vpar_thread_s * p_vpar );
150 mtime_t vpar_SynchroDate( struct vpar_thread_s * p_vpar );
153 void vpar_SynchroKludge( struct vpar_thread_s *, mtime_t );