vpar_synchro.h 4.88 KB
Newer Older
1 2 3
/*****************************************************************************
 * vpar_synchro.h : video parser blocks management
 *****************************************************************************
4 5
 * Copyright (C) 1999, 2000 VideoLAN
 *
6 7 8
 * Authors: Samuel Hocevar <sam@via.ecp.fr>
 *          Jean-Marc Dressler <polux@via.ecp.fr>
 *          Christophe Massiot <massiot@via.ecp.fr>
9 10 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
14
 * 
15 16
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
19
 *
20 21 22
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23 24 25
 *****************************************************************************/

/*****************************************************************************
26 27 28 29
 * Requires:
 *  "config.h"
 *  "common.h"
 *  "mtime.h"
30
 *  "threads.h"
31 32 33 34 35 36 37
 *  "input.h"
 *  "video.h"
 *  "video_output.h"
 *  "decoder_fifo.h"
 *  "video_fifo.h"
 *****************************************************************************/

38 39 40
#define SAM_SYNCHRO
//#define POLUX_SYNCHRO
//#define MEUUH_SYNCHRO
41

42
/*****************************************************************************
43
 * video_synchro_t and video_synchro_tab_s : timers for the video synchro
44
 *****************************************************************************/
45
#ifdef SAM_SYNCHRO
46 47
typedef struct video_synchro_s
{
48 49 50
    /* synchro algorithm */
    int          i_type;

51
    /* fifo containing decoding dates */
52 53 54
    mtime_t      i_date_fifo[16];
    unsigned int i_start;
    unsigned int i_stop;
55

56
    /* mean decoding time */
57 58
    mtime_t i_delay;
    mtime_t i_theorical_delay;
59

60 61 62 63
    /* dates */
    mtime_t i_last_pts;                   /* pts of the last displayed image */
    mtime_t i_last_seen_I_pts;              /* date of the last I we decoded */
    mtime_t i_last_kept_I_pts;            /* pts of last non-dropped I image */
64 65

    /* P images since the last I */
66 67
    unsigned int i_P_seen;
    unsigned int i_P_kept;
68
    /* B images since the last I */
69 70
    unsigned int i_B_seen;
    unsigned int i_B_kept;
71

72
    /* can we display pictures ? */
73 74
    boolean_t     b_all_I;
    boolean_t     b_all_P;
Sam Hocevar's avatar
Sam Hocevar committed
75
    int           displayable_p;
76
    boolean_t     b_all_B;
Sam Hocevar's avatar
Sam Hocevar committed
77
    int           displayable_b;
78
    boolean_t     b_dropped_last;
79

80
} video_synchro_t;
81

82 83
#define FIFO_INCREMENT( i_counter ) \
    p_vpar->synchro.i_counter = (p_vpar->synchro.i_counter + 1) & 0xf;
84

85 86
#define VPAR_SYNCHRO_DEFAULT   0
#define VPAR_SYNCHRO_I         1
87 88 89 90
#define VPAR_SYNCHRO_Iplus     2
#define VPAR_SYNCHRO_IP        3
#define VPAR_SYNCHRO_IPplus    4
#define VPAR_SYNCHRO_IPB       5
91

92 93 94
#endif

#ifdef MEUUH_SYNCHRO
Christophe Massiot's avatar
Christophe Massiot committed
95 96 97 98 99 100 101 102
typedef struct video_synchro_s
{
    int         kludge_level, kludge_p, kludge_b, kludge_nbp, kludge_nbb;
    int         kludge_nbframes;
    mtime_t     kludge_date, kludge_prevdate;
    int         i_coding_type;
} video_synchro_t;

103 104
#define SYNC_TOLERATE   ((int)(0.010*CLOCK_FREQ))                   /* 10 ms */
#define SYNC_DELAY      ((int)(0.500*CLOCK_FREQ))                  /* 500 ms */
Christophe Massiot's avatar
Christophe Massiot committed
105
#endif
106

107 108
#ifdef POLUX_SYNCHRO

109 110
#define SYNC_AVERAGE_COUNT 10

111 112 113
typedef struct video_synchro_s
{
    /* Date Section */
114 115

    /* Dates needed to compute the date of the current frame
Sam Hocevar's avatar
Sam Hocevar committed
116
     * We also use the stream frame rate (sequence.i_frame_rate) */
117 118 119 120
    mtime_t     i_current_frame_date;
    mtime_t     i_backward_frame_date;

    /* Frame Trashing Section */
121

122
    int         i_b_nb, i_p_nb;   /* number of decoded P and B between two I */
123
    float       r_b_average, r_p_average;
124 125
    int         i_b_count, i_p_count, i_i_count;
    int         i_b_trasher;                /* used for brensenham algorithm */
126

127 128 129 130
} video_synchro_t;

#endif

131 132 133
/*****************************************************************************
 * Prototypes
 *****************************************************************************/
134 135 136 137 138 139 140 141
boolean_t vpar_SynchroChoose    ( struct vpar_thread_s * p_vpar,
                                  int i_coding_type, int i_structure );
void vpar_SynchroTrash          ( struct vpar_thread_s * p_vpar,
                                  int i_coding_type, int i_structure );
void vpar_SynchroDecode         ( struct vpar_thread_s * p_vpar,
                                  int i_coding_type, int i_structure );
void vpar_SynchroEnd            ( struct vpar_thread_s * p_vpar );
mtime_t vpar_SynchroDate        ( struct vpar_thread_s * p_vpar );
Michel Kaempf's avatar
Michel Kaempf committed
142 143

#ifndef SAM_SYNCHRO
144
void vpar_SynchroKludge         ( struct vpar_thread_s *, mtime_t );
Michel Kaempf's avatar
Michel Kaempf committed
145
#endif