]> git.sesse.net Git - vlc/blob - include/vpar_synchro.h
6f7bdfc441088c77b606df7a9ebb420872569f86
[vlc] / include / vpar_synchro.h
1 /*****************************************************************************
2  * vpar_synchro.h : video parser blocks management
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  *
6  * Authors:
7  *
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.
12  * 
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.
17  *
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  *****************************************************************************/
22
23 /*****************************************************************************
24  * Requires:
25  *  "config.h"
26  *  "common.h"
27  *  "mtime.h"
28  *  "threads.h"
29  *  "input.h"
30  *  "video.h"
31  *  "video_output.h"
32  *  "decoder_fifo.h"
33  *  "video_fifo.h"
34  *****************************************************************************/
35
36 #define SAM_SYNCHRO
37 //#define POLUX_SYNCHRO
38 //#define MEUUH_SYNCHRO
39
40 /*****************************************************************************
41  * video_synchro_t and video_synchro_tab_s : timers for the video synchro
42  *****************************************************************************/
43 #ifdef SAM_SYNCHRO
44 typedef struct video_synchro_s
45 {
46     /* fifo containing decoding dates */
47     mtime_t      i_date_fifo[16];
48     unsigned int i_start;
49     unsigned int i_stop;
50
51     /* mean decoding time */
52     mtime_t i_delay;
53     mtime_t i_theorical_delay;
54
55     /* dates */
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 */
59
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;
66
67     /* can we display pictures ? */
68     boolean_t     b_all_I;
69     boolean_t     b_all_P;
70     double        displayable_p;
71     boolean_t     b_all_B;
72     double        displayable_b;
73
74 } video_synchro_t;
75
76 #define FIFO_INCREMENT( i_counter ) \
77     p_vpar->synchro.i_counter = (p_vpar->synchro.i_counter + 1) & 0xf;
78
79 #endif
80
81 #ifdef MEUUH_SYNCHRO
82 typedef struct video_synchro_s
83 {
84     int         kludge_level, kludge_p, kludge_b, kludge_nbp, kludge_nbb;
85     int         kludge_nbframes;
86     mtime_t     kludge_date, kludge_prevdate;
87     int         i_coding_type;
88 } video_synchro_t;
89
90 #define SYNC_TOLERATE   ((int)(0.010*CLOCK_FREQ))                   /* 10 ms */
91 #define SYNC_DELAY      ((int)(0.500*CLOCK_FREQ))                  /* 500 ms */
92 #endif
93
94 #ifdef POLUX_SYNCHRO
95
96 #define SYNC_AVERAGE_COUNT 10
97
98 typedef struct video_synchro_s
99 {
100     /* Date Section */
101
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;
106
107     /* Frame Trashing Section */
108
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 */
113
114 } video_synchro_t;
115
116 #endif
117
118 /*****************************************************************************
119  * Prototypes
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 );
129
130 #ifndef SAM_SYNCHRO
131 void vpar_SynchroKludge         ( struct vpar_thread_s *, mtime_t );
132 #endif