]> git.sesse.net Git - vlc/blob - include/vpar_synchro.h
* Totally new frame dropping algorithm.
[vlc] / include / vpar_synchro.h
1 /*****************************************************************************
2  * vpar_synchro.h : video parser blocks management
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  *
6  * Author: Christophe Massiot <massiot@via.ecp.fr>
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 /*****************************************************************************
37  * video_synchro_t and video_synchro_tab_s : timers for the video synchro
38  *****************************************************************************/
39 #define MAX_DECODING_PIC        16
40 #define MAX_PIC_AVERAGE         8
41
42 /* Read the discussion on top of vpar_synchro.c for more information. */
43 typedef struct video_synchro_s
44 {
45     /* synchro algorithm */
46     int             i_type;
47
48     /* fifo containing decoding dates */
49     mtime_t         p_date_fifo[MAX_DECODING_PIC];
50     int             pi_coding_types[MAX_DECODING_PIC];
51     unsigned int    i_start, i_end;
52     vlc_mutex_t     fifo_lock;
53
54     /* stream properties */
55     unsigned int    i_n_p, i_n_b;
56
57     /* decoding values */
58     mtime_t         p_tau[4];                  /* average decoding durations */
59     unsigned int    pi_meaningful[4];            /* number of durations read */
60     /* and p_vout->render_time (read with p_vout->change_lock) */
61
62     /* stream context */
63     unsigned int    i_eta_p, i_eta_b;
64     boolean_t       b_dropped_last;            /* for special synchros below */
65     mtime_t         backward_pts, current_pts;
66
67 #ifdef STATS
68     unsigned int    i_B_self, i_B_next, i_B_last, i_B_I;
69 #endif
70 } video_synchro_t;
71
72 #define FIFO_INCREMENT( i_counter )                                         \
73     p_vpar->synchro.i_counter =                                             \
74         (p_vpar->synchro.i_counter + 1) % MAX_DECODING_PIC;
75
76 /* Synchro algorithms */
77 #define VPAR_SYNCHRO_DEFAULT    0
78 #define VPAR_SYNCHRO_I          1
79 #define VPAR_SYNCHRO_Iplus      2
80 #define VPAR_SYNCHRO_IP         3
81 #define VPAR_SYNCHRO_IPplus     4
82 #define VPAR_SYNCHRO_IPB        5
83
84 /*****************************************************************************
85  * Prototypes
86  *****************************************************************************/
87 void vpar_SynchroInit           ( struct vpar_thread_s * p_vpar );
88 boolean_t vpar_SynchroChoose    ( struct vpar_thread_s * p_vpar,
89                                   int i_coding_type, int i_structure );
90 void vpar_SynchroTrash          ( struct vpar_thread_s * p_vpar,
91                                   int i_coding_type, int i_structure );
92 void vpar_SynchroDecode         ( struct vpar_thread_s * p_vpar,
93                                   int i_coding_type, int i_structure );
94 void vpar_SynchroEnd            ( struct vpar_thread_s * p_vpar );
95 mtime_t vpar_SynchroDate        ( struct vpar_thread_s * p_vpar );