/*****************************************************************************
* vpar_synchro.h : video parser blocks management
- * (c)1999 VideoLAN
- *****************************************************************************
*****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ * $Id: vpar_synchro.h,v 1.33 2001/05/06 04:32:02 sam Exp $
+ *
+ * Author: Christophe Massiot <massiot@via.ecp.fr>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ *****************************************************************************/
+
+/*****************************************************************************
* Requires:
* "config.h"
* "common.h"
* "mtime.h"
- * "vlc_thread.h"
+ * "threads.h"
* "input.h"
* "video.h"
* "video_output.h"
/*****************************************************************************
* video_synchro_t and video_synchro_tab_s : timers for the video synchro
*****************************************************************************/
-typedef struct video_synchro_tab_s
-{
- double mean;
- double deviation;
-
-} video_synchro_tab_t;
-
-typedef struct video_synchro_fifo_s
-{
- /* type of image to be decoded, and decoding date */
- int i_image_type;
- mtime_t i_decode_date;
- mtime_t i_pts;
-
-} video_synchro_fifo_t;
+#define MAX_DECODING_PIC 16
+#define MAX_PIC_AVERAGE 8
+/* Read the discussion on top of vpar_synchro.c for more information. */
typedef struct video_synchro_s
{
+ /* synchro algorithm */
+ int i_type;
+
/* fifo containing decoding dates */
- video_synchro_fifo_t fifo[16];
- unsigned int i_fifo_start;
- unsigned int i_fifo_stop;
+ mtime_t p_date_fifo[MAX_DECODING_PIC];
+ int pi_coding_types[MAX_DECODING_PIC];
+ unsigned int i_start, i_end;
+ vlc_mutex_t fifo_lock;
- /* mean decoding time */
- mtime_t i_mean_decode_time;
- /* dates */
- mtime_t i_last_display_pts; /* pts of the last displayed image */
- mtime_t i_last_decode_pts; /* pts of the last decoded image */
- mtime_t i_last_i_pts; /* pts of the last I image */
- mtime_t i_last_nondropped_i_pts; /* pts of last non-dropped I image */
- unsigned int i_images_since_pts;
-
- /* il manquait un compteur */
- unsigned int modulo;
+ /* stream properties */
+ unsigned int i_n_p, i_n_b;
- /* P images since the last I */
- unsigned int current_p_count;
- unsigned int nondropped_p_count;
- double p_count_predict;
- /* B images since the last I */
- unsigned int current_b_count;
- unsigned int nondropped_b_count;
- double b_count_predict;
+ /* decoding values */
+ mtime_t p_tau[4]; /* average decoding durations */
+ unsigned int pi_meaningful[4]; /* number of durations read */
+ /* and p_vout->render_time (read with p_vout->change_lock) */
- /* can we display pictures ? */
- unsigned int can_display_i;
- unsigned int can_display_p;
- double displayable_p;
- unsigned int can_display_b;
- double displayable_b;
+ /* stream context */
+ unsigned int i_eta_p, i_eta_b;
+ boolean_t b_dropped_last; /* for special synchros below */
+ mtime_t backward_pts, current_pts;
+ int i_current_period; /* period to add to the next picture */
+ int i_backward_period; /* period to add after the next
+ * reference picture
+ * (backward_period * period / 2) */
- /* 1 for linear count, 2 for binary count, 3 for ternary count */
- video_synchro_tab_t tab_p[6];
- video_synchro_tab_t tab_b[6];
+#ifdef STATS
+ unsigned int i_trashed_pic, i_not_chosen_pic, i_pic;
+#endif
+} video_synchro_t;
- double theorical_fps;
- double actual_fps;
+#define FIFO_INCREMENT( i_counter ) \
+ p_vpar->synchro.i_counter = \
+ (p_vpar->synchro.i_counter + 1) % MAX_DECODING_PIC;
-} video_synchro_t;
+/* Synchro algorithms */
+#define VPAR_SYNCHRO_DEFAULT 0
+#define VPAR_SYNCHRO_I 1
+#define VPAR_SYNCHRO_Iplus 2
+#define VPAR_SYNCHRO_IP 3
+#define VPAR_SYNCHRO_IPplus 4
+#define VPAR_SYNCHRO_IPB 5
/*****************************************************************************
* Prototypes
*****************************************************************************/
-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 );
+void vpar_SynchroInit ( struct vpar_thread_s * p_vpar );
+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, int i_garbage );
+mtime_t vpar_SynchroDate ( struct vpar_thread_s * p_vpar );
+void vpar_SynchroNewPicture( struct vpar_thread_s * p_vpar, int i_coding_type,
+ int i_repeat_field );