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 GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 *****************************************************************************/
24 /*****************************************************************************
35 *****************************************************************************/
39 /*****************************************************************************
40 * video_synchro_t and video_synchro_tab_s : timers for the video synchro
41 *****************************************************************************/
43 typedef struct video_synchro_tab_s
48 } video_synchro_tab_t;
50 typedef struct video_synchro_fifo_s
52 /* type of image to be decoded, and decoding date */
54 mtime_t i_decode_date;
57 } video_synchro_fifo_t;
59 typedef struct video_synchro_s
61 /* fifo containing decoding dates */
62 video_synchro_fifo_t fifo[16];
63 unsigned int i_fifo_start;
64 unsigned int i_fifo_stop;
66 /* mean decoding time */
67 mtime_t i_mean_decode_time;
69 mtime_t i_last_display_pts; /* pts of the last displayed image */
70 mtime_t i_last_decode_pts; /* pts of the last decoded image */
71 mtime_t i_last_i_pts; /* pts of the last I image */
72 mtime_t i_last_nondropped_i_pts; /* pts of last non-dropped I image */
73 unsigned int i_images_since_pts;
75 /* il manquait un compteur */
78 /* P images since the last I */
79 unsigned int current_p_count;
80 unsigned int nondropped_p_count;
81 double p_count_predict;
82 /* B images since the last I */
83 unsigned int current_b_count;
84 unsigned int nondropped_b_count;
85 double b_count_predict;
87 /* can we display pictures ? */
88 unsigned int can_display_i;
89 unsigned int can_display_p;
91 unsigned int can_display_b;
94 /* 1 for linear count, 2 for binary count, 3 for ternary count */
95 video_synchro_tab_t tab_p[6];
96 video_synchro_tab_t tab_b[6];
105 typedef struct video_synchro_s
107 int kludge_level, kludge_p, kludge_b, kludge_nbp, kludge_nbb;
109 mtime_t kludge_date, kludge_prevdate;
113 #define SYNC_TOLERATE ((int)(0.010*CLOCK_FREQ)) /* 10 ms */
114 #define SYNC_DELAY ((int)(0.500*CLOCK_FREQ)) /* 500 ms */
119 #define SYNC_AVERAGE_COUNT 10
121 typedef struct video_synchro_s
125 /* Dates needed to compute the date of the current frame
126 * We also use the stream frame rate (sequence.r_frame_rate) */
127 mtime_t i_current_frame_date;
128 mtime_t i_backward_frame_date;
130 /* Frame Trashing Section */
132 int i_b_nb, i_p_nb; /* number of decoded P and B between two I */
133 float r_b_average, r_p_average;
134 int i_b_count, i_p_count, i_i_count;
135 int i_b_trasher; /* used for brensenham algorithm */
141 /*****************************************************************************
143 *****************************************************************************/
144 boolean_t vpar_SynchroChoose( struct vpar_thread_s * p_vpar, int i_coding_type,
146 void vpar_SynchroTrash( struct vpar_thread_s * p_vpar, int i_coding_type,
148 void vpar_SynchroDecode( struct vpar_thread_s * p_vpar, int i_coding_type,
150 void vpar_SynchroEnd( struct vpar_thread_s * p_vpar );
151 mtime_t vpar_SynchroDate( struct vpar_thread_s * p_vpar );
154 void vpar_SynchroKludge( struct vpar_thread_s *, mtime_t );