]> git.sesse.net Git - vlc/blob - src/video_parser/vpar_synchro.c
46f98edccc8ca5330c7cea63ac512e1fa94d336d
[vlc] / src / video_parser / vpar_synchro.c
1 /*****************************************************************************
2  * vpar_synchro.c : frame dropping routines
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: vpar_synchro.c,v 1.85 2001/02/12 18:18:18 massiot Exp $
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  *          Samuel Hocevar <sam@via.ecp.fr>
9  *          Jean-Marc Dressler <polux@via.ecp.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /*
27  * DISCUSSION : How to Write an efficient Frame-Dropping Algorithm
28  * ==========
29  *
30  * This implementation is based on mathematical and statistical
31  * developments. Older implementations used an enslavement, considering
32  * that if we're late when reading an I picture, we will decode one frame
33  * less. It had a tendancy to derive, and wasn't responsive enough, which
34  * would have caused trouble with the stream control stuff.
35  *
36  * 1. Structure of a picture stream
37  *    =============================
38  * Between 2 I's, we have for instance :
39  *    I   B   P   B   P   B   P   B   P   B   P   B   I
40  *    t0  t1  t2  t3  t4  t5  t6  t7  t8  t9  t10 t11 t12
41  * Please bear in mind that B's and IP's will be inverted when displaying
42  * (decoding order != presentation order). Thus, t1 < t0.
43  *
44  * 2. Definitions
45  *    ===========
46  * t[0..12]     : Presentation timestamps of pictures 0..12.
47  * t            : Current timestamp, at the moment of the decoding.
48  * T            : Picture period, T = 1/frame_rate.
49  * tau[I,P,B]   : Mean time to decode an [I,P,B] picture.
50  * tauYUV       : Mean time to render a picture (given by the video_output).
51  * tau´[I,P,B] = 2 * tau[I,P,B] + tauYUV
52  *              : Mean time + typical difference (estimated to tau/2, that
53  *                needs to be confirmed) + render time.
54  * DELTA        : A given error margin.
55  *
56  * 3. General considerations
57  *    ======================
58  * We define three types of machines :
59  *      14T > tauI : machines capable of decoding all I pictures
60  *      2T > tauP  : machines capable of decoding all P pictures
61  *      T > tauB   : machines capable of decoding all B pictures
62  *
63  * 4. Decoding of an I picture
64  *    ========================
65  * On fast machines, we decode all I's.
66  * Otherwise :
67  * We can decode an I picture if we simply have enough time to decode it 
68  * before displaying :
69  *      t0 - t > tau´I + DELTA
70  *
71  * 5. Decoding of a P picture
72  *    =======================
73  * On fast machines, we decode all P's.
74  * Otherwise :
75  * First criterion : have time to decode it.
76  *      t2 - t > tau´P + DELTA
77  *
78  * Second criterion : it shouldn't prevent us from displaying the forthcoming
79  * I picture, which is more important.
80  *      t12 - t > tau´P + tau´I + DELTA
81  *
82  * 6. Decoding of a B picture
83  *    =======================
84  * On fast machines, we decode all B's. Otherwise :
85  *      t1 - t > tau´B + DELTA
86  * Since the next displayed I or P is already decoded, we don't have to
87  * worry about it.
88  *
89  * I hope you will have a pleasant flight and do not forget your life
90  * jacket.
91  *                                                  --Meuuh (2000-12-29)
92  */
93
94 /*****************************************************************************
95  * Preamble
96  *****************************************************************************/
97 #include "defs.h"
98
99 #include "config.h"
100 #include "common.h"
101 #include "threads.h"
102 #include "mtime.h"
103
104 #include "intf_msg.h"
105
106 #include "stream_control.h"
107 #include "input_ext-dec.h"
108
109 #include "video.h"
110 #include "video_output.h"
111
112 #include "video_decoder.h"
113 #include "vdec_motion.h"
114 #include "../video_decoder/vdec_idct.h"
115
116 #include "vpar_blocks.h"
117 #include "../video_decoder/vpar_headers.h"
118 #include "../video_decoder/vpar_synchro.h"
119 #include "../video_decoder/video_parser.h"
120
121 #include "main.h"
122
123 /*
124  * Local prototypes
125  */
126 static int  SynchroType( void );
127
128 /* Error margins */
129 #define DELTA                   (int)(0.040*CLOCK_FREQ)
130
131 #define DEFAULT_NB_P            5
132 #define DEFAULT_NB_B            1
133
134 /*****************************************************************************
135  * vpar_SynchroInit : You know what ?
136  *****************************************************************************/
137 void vpar_SynchroInit( vpar_thread_t * p_vpar )
138 {
139     p_vpar->synchro.i_type = SynchroType();
140     p_vpar->synchro.i_start = p_vpar->synchro.i_end = 0;
141     vlc_mutex_init( &p_vpar->synchro.fifo_lock );
142
143     /* We use a fake stream pattern, which is often right. */
144     p_vpar->synchro.i_n_p = p_vpar->synchro.i_eta_p = DEFAULT_NB_P;
145     p_vpar->synchro.i_n_b = p_vpar->synchro.i_eta_b = DEFAULT_NB_B;
146     memset( p_vpar->synchro.p_tau, 0, 4 * sizeof(mtime_t) );
147     memset( p_vpar->synchro.pi_meaningful, 0, 4 * sizeof(unsigned int) );
148     p_vpar->synchro.b_dropped_last = 0;
149     p_vpar->synchro.current_pts = mdate() + DEFAULT_PTS_DELAY;
150     p_vpar->synchro.backward_pts = 0;
151     p_vpar->synchro.i_current_period = p_vpar->synchro.i_backward_period = 0;
152 #ifdef STATS
153     p_vpar->synchro.i_trashed_pic = p_vpar->synchro.i_not_chosen_pic = 
154         p_vpar->synchro.i_pic = 0;
155 #endif
156 }
157
158 /*****************************************************************************
159  * vpar_SynchroChoose : Decide whether we will decode a picture or not
160  *****************************************************************************/
161 boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
162                               int i_structure )
163 {
164     /* For clarity reasons, we separated the special synchros code from the
165      * mathematical synchro */
166
167     if( p_vpar->synchro.i_type != VPAR_SYNCHRO_DEFAULT )
168     {
169         switch( i_coding_type )
170         {
171         case I_CODING_TYPE:
172             /* I, IP, IP+, IPB */
173             if( p_vpar->synchro.i_type == VPAR_SYNCHRO_Iplus )
174             {
175                 p_vpar->synchro.b_dropped_last = 1;
176             }
177             return( 1 );
178
179         case P_CODING_TYPE:
180             if( p_vpar->synchro.i_type == VPAR_SYNCHRO_I ) /* I */
181             {
182                 return( 0 );
183             }
184
185             if( p_vpar->synchro.i_type == VPAR_SYNCHRO_Iplus ) /* I+ */
186             {
187                 if( p_vpar->synchro.b_dropped_last )
188                 {
189                     p_vpar->synchro.b_dropped_last = 0;
190                     return( 1 );
191                 }
192                 else
193                 {
194                     return( 0 );
195                 }
196             }
197
198             return( 1 ); /* IP, IP+, IPB */
199
200         case B_CODING_TYPE:
201             if( p_vpar->synchro.i_type <= VPAR_SYNCHRO_IP ) /* I, IP */
202             {
203                 return( 0 );
204             }
205             else if( p_vpar->synchro.i_type == VPAR_SYNCHRO_IPB ) /* IPB */
206             {
207                 return( 1 );
208             }
209
210             p_vpar->synchro.b_dropped_last ^= 1; /* IP+ */
211             return( !p_vpar->synchro.b_dropped_last );
212         }
213         return( 0 ); /* never reached but gcc yells at me */
214     }
215     else
216     {
217 #define TAU_PRIME( coding_type )    (p_vpar->synchro.p_tau[(coding_type)] \
218                                  + (p_vpar->synchro.p_tau[(coding_type)] >> 1) \
219                                             + tau_yuv)
220 #define S                           p_vpar->synchro
221         /* VPAR_SYNCHRO_DEFAULT */
222         mtime_t         now, period, tau_yuv;
223         mtime_t         pts = 0;
224         boolean_t       b_decode = 0;
225 #ifdef DEBUG_VPAR
226         char            p_date[MSTRTIME_MAX_SIZE];
227 #endif
228
229         now = mdate();
230         period = 1000000 * 1001 / p_vpar->sequence.i_frame_rate
231                     * p_vpar->sequence.i_current_rate / DEFAULT_RATE;
232
233         vlc_mutex_lock( &p_vpar->p_vout->change_lock );
234         tau_yuv = p_vpar->p_vout->render_time;
235         vlc_mutex_unlock( &p_vpar->p_vout->change_lock );
236 #ifdef VDEC_SMP
237         vlc_mutex_lock( &p_vpar->synchro.fifo_lock );
238 #endif
239
240         switch( i_coding_type )
241         {
242         case I_CODING_TYPE:
243             if( S.backward_pts )
244             {
245                 pts = S.backward_pts;
246             }
247             else
248             {
249                 /* displaying order : B B P B B I
250                  *                      ^       ^
251                  *                      |       +- current picture
252                  *                      +- current PTS
253                  */
254                 pts = S.current_pts + period * (S.i_n_b + 2);
255             }
256
257             if( (1 + S.i_n_p * (S.i_n_b + 1)) * period >
258                     S.p_tau[I_CODING_TYPE] )
259             {
260                 b_decode = 1;
261             }
262             else
263             {
264                 b_decode = (pts - now) > (TAU_PRIME(I_CODING_TYPE) + DELTA);
265             }
266             if( !b_decode )
267                 intf_WarnMsg( 3, "vpar synchro warning: trashing I (%lld)",
268                              pts - now);
269             break;
270
271         case P_CODING_TYPE:
272             if( S.backward_pts )
273             {
274                 pts = S.backward_pts;
275             }
276             else
277             {
278                 pts = S.current_pts + period * (S.i_n_b + 1);
279             }
280
281             if( (1 + S.i_n_p * (S.i_n_b + 1)) * period >
282                     S.p_tau[I_CODING_TYPE] )
283             {
284                 if( (S.i_n_b + 1) * period > S.p_tau[P_CODING_TYPE] )
285                 {
286                     /* Security in case we're _really_ late */
287                     b_decode = (pts - now > 0);
288                 }
289                 else
290                 {
291                     b_decode = (pts - now) > (TAU_PRIME(P_CODING_TYPE) + DELTA);
292                     /* next I */
293                     b_decode &= (pts - now
294                                   + period
295                               * ( (S.i_n_p - S.i_eta_p) * (1 + S.i_n_b) - 1 ))
296                                 > (TAU_PRIME(P_CODING_TYPE)
297                                     + TAU_PRIME(I_CODING_TYPE) + DELTA);
298                 }
299             }
300             else
301             {
302                 b_decode = 0;
303             }
304             break;
305
306         case B_CODING_TYPE:
307             pts = S.current_pts;
308
309             if( (S.i_n_b + 1) * period > S.p_tau[P_CODING_TYPE] )
310             {
311                 b_decode = (pts - now) > (TAU_PRIME(B_CODING_TYPE) + DELTA);
312             }
313             else
314             {
315                 b_decode = 0;
316             }
317         }
318
319 #ifdef VDEC_SMP
320         vlc_mutex_unlock( &p_vpar->synchro.fifo_lock );
321 #endif
322 #ifdef DEBUG_VPAR
323         intf_DbgMsg("vpar synchro debug: %s picture scheduled for %s, %s (%lld)",
324                     i_coding_type == B_CODING_TYPE ? "B" :
325                     (i_coding_type == P_CODING_TYPE ? "P" : "I"),
326                     mstrtime(p_date, pts), b_decode ? "decoding" : "trashed",
327                     S.p_tau[i_coding_type]);
328 #endif
329 #ifdef STATS
330         if( !b_decode )
331         {
332             S.i_not_chosen_pic++;
333         }
334 #endif
335         return( b_decode );
336 #undef S
337 #undef TAU_PRIME
338     }
339 }
340
341 /*****************************************************************************
342  * vpar_SynchroTrash : Update counters when we trash a picture
343  *****************************************************************************/
344 void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
345                         int i_structure )
346 {
347 #ifdef STATS
348     p_vpar->synchro.i_trashed_pic++;
349 #endif
350 }
351
352 /*****************************************************************************
353  * vpar_SynchroDecode : Update timers when we decide to decode a picture
354  *****************************************************************************/
355 void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
356                          int i_structure )
357 {
358 #ifdef VDEC_SMP
359     vlc_mutex_lock( &p_vpar->synchro.fifo_lock );
360 #endif
361
362     if( ((p_vpar->synchro.i_end + 1 - p_vpar->synchro.i_start)
363             % MAX_DECODING_PIC) )
364     {
365         p_vpar->synchro.p_date_fifo[p_vpar->synchro.i_end] = mdate();
366         p_vpar->synchro.pi_coding_types[p_vpar->synchro.i_end] = i_coding_type;
367
368         FIFO_INCREMENT( i_end );
369     }
370     else
371     {
372         /* FIFO full, panic() */
373         intf_ErrMsg("vpar error: synchro fifo full, estimations will be biased");
374     }
375 #ifdef VDEC_SMP
376     vlc_mutex_unlock( &p_vpar->synchro.fifo_lock );
377 #endif
378 }
379
380 /*****************************************************************************
381  * vpar_SynchroEnd : Called when the image is totally decoded
382  *****************************************************************************/
383 void vpar_SynchroEnd( vpar_thread_t * p_vpar, int i_garbage )
384 {
385     mtime_t     tau;
386     int         i_coding_type;
387
388 #ifdef VDEC_SMP
389     vlc_mutex_lock( &p_vpar->synchro.fifo_lock );
390 #endif
391
392     if( !i_garbage )
393     {
394         tau = mdate() - p_vpar->synchro.p_date_fifo[p_vpar->synchro.i_start];
395         i_coding_type = p_vpar->synchro.pi_coding_types[p_vpar->synchro.i_start];
396
397         /* If duration too high, something happened (pause ?), so don't
398          * take it into account. */
399         if( tau < 3 * p_vpar->synchro.p_tau[i_coding_type]
400              || !p_vpar->synchro.pi_meaningful[i_coding_type] )
401         {
402             /* Mean with average tau, to ensure stability. */
403             p_vpar->synchro.p_tau[i_coding_type] =
404                 (p_vpar->synchro.pi_meaningful[i_coding_type]
405                  * p_vpar->synchro.p_tau[i_coding_type] + tau)
406                 / (p_vpar->synchro.pi_meaningful[i_coding_type] + 1);
407             if( p_vpar->synchro.pi_meaningful[i_coding_type] < MAX_PIC_AVERAGE )
408             {
409                 p_vpar->synchro.pi_meaningful[i_coding_type]++;
410             }
411         }
412
413 #ifdef DEBUG_VPAR
414         intf_DbgMsg("vpar synchro debug: finished decoding %s (%lld)",
415                     i_coding_type == B_CODING_TYPE ? "B" :
416                     (i_coding_type == P_CODING_TYPE ? "P" : "I"), tau);
417 #endif
418     }
419
420     FIFO_INCREMENT( i_start );
421
422 #ifdef VDEC_SMP
423     vlc_mutex_unlock( &p_vpar->synchro.fifo_lock );
424 #endif
425 }
426
427 /*****************************************************************************
428  * vpar_SynchroDate : When an image has been decoded, ask for its date
429  *****************************************************************************/
430 mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
431 {
432     /* No need to lock, since PTS are only used by the video parser. */
433     return( p_vpar->synchro.current_pts );
434 }
435
436 /*****************************************************************************
437  * vpar_SynchroNewPicture: Update stream structure and PTS
438  *****************************************************************************/
439 void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type,
440                              int i_repeat_field )
441 {
442     mtime_t         period = 1000000 * 1001 / p_vpar->sequence.i_frame_rate
443                               * p_vpar->sequence.i_current_rate / DEFAULT_RATE;
444 #if 0
445     mtime_t         now = mdate(); 
446 #endif
447
448     switch( i_coding_type )
449     {
450     case I_CODING_TYPE:
451         if( p_vpar->synchro.i_eta_p
452                 && p_vpar->synchro.i_eta_p != p_vpar->synchro.i_n_p )
453         {
454             intf_WarnMsg( 1, "Stream periodicity changed from P[%d] to P[%d]",
455                           p_vpar->synchro.i_n_p, p_vpar->synchro.i_eta_p );
456             p_vpar->synchro.i_n_p = p_vpar->synchro.i_eta_p;
457         }
458         p_vpar->synchro.i_eta_p = p_vpar->synchro.i_eta_b = 0;
459 #ifdef STATS
460         if( p_vpar->synchro.i_type == VPAR_SYNCHRO_DEFAULT )
461         {
462             intf_Msg( "vpar synchro stats: I(%lld) P(%lld)[%d] B(%lld)[%d] YUV(%lld) : trashed %d:%d/%d",
463                   p_vpar->synchro.p_tau[I_CODING_TYPE],
464                   p_vpar->synchro.p_tau[P_CODING_TYPE],
465                   p_vpar->synchro.i_n_p,
466                   p_vpar->synchro.p_tau[B_CODING_TYPE],
467                   p_vpar->synchro.i_n_b,
468                   p_vpar->p_vout->render_time,
469                   p_vpar->synchro.i_not_chosen_pic,
470                   p_vpar->synchro.i_trashed_pic -
471                   p_vpar->synchro.i_not_chosen_pic,
472                   p_vpar->synchro.i_pic );
473             p_vpar->synchro.i_trashed_pic = p_vpar->synchro.i_not_chosen_pic
474                 = p_vpar->synchro.i_pic = 0;
475         }
476 #endif
477         break;
478     case P_CODING_TYPE:
479         p_vpar->synchro.i_eta_p++;
480         if( p_vpar->synchro.i_eta_b
481                 && p_vpar->synchro.i_eta_b != p_vpar->synchro.i_n_b )
482         {
483             intf_WarnMsg( 1, "Stream periodicity changed from B[%d] to B[%d]",
484                           p_vpar->synchro.i_n_b, p_vpar->synchro.i_eta_b );
485             p_vpar->synchro.i_n_b = p_vpar->synchro.i_eta_b;
486         }
487         p_vpar->synchro.i_eta_b = 0;
488         break;
489     case B_CODING_TYPE:
490         p_vpar->synchro.i_eta_b++;
491         break;
492     }
493
494     p_vpar->synchro.current_pts += p_vpar->synchro.i_current_period
495                                         * (period >> 1);
496  
497 #define PTS_THRESHOLD   (period >> 2)
498     if( i_coding_type == B_CODING_TYPE )
499     {
500         /* A video frame can be displayed 1, 2 or 3 times, according to
501          * repeat_first_field, top_field_first, progressive_sequence and
502          * progressive_frame. */
503         p_vpar->synchro.i_current_period = i_repeat_field;
504
505         if( p_vpar->sequence.next_pts )
506         {
507             if( p_vpar->sequence.next_pts - p_vpar->synchro.current_pts
508                     > PTS_THRESHOLD
509                  || p_vpar->synchro.current_pts - p_vpar->sequence.next_pts
510                     > PTS_THRESHOLD )
511             {
512                 intf_WarnMsg( 2,
513                         "vpar synchro warning: pts != current_date (%lld)",
514                         p_vpar->synchro.current_pts
515                             - p_vpar->sequence.next_pts );
516             }
517             p_vpar->synchro.current_pts = p_vpar->sequence.next_pts;
518             p_vpar->sequence.next_pts = 0;
519         }
520     }
521     else
522     {
523         p_vpar->synchro.i_current_period = p_vpar->synchro.i_backward_period;
524         p_vpar->synchro.i_backward_period = i_repeat_field;
525
526         if( p_vpar->synchro.backward_pts )
527         {
528             if( p_vpar->sequence.next_dts && 
529                 (p_vpar->sequence.next_dts - p_vpar->synchro.backward_pts
530                     > PTS_THRESHOLD
531               || p_vpar->synchro.backward_pts - p_vpar->sequence.next_dts
532                     > PTS_THRESHOLD) )
533             {
534                 intf_WarnMsg( 2,
535                         "vpar synchro warning: backward_pts != dts (%lld)",
536                         p_vpar->sequence.next_dts
537                             - p_vpar->synchro.backward_pts );
538             }
539             if( p_vpar->synchro.backward_pts - p_vpar->synchro.current_pts
540                     > PTS_THRESHOLD
541                  || p_vpar->synchro.current_pts - p_vpar->synchro.backward_pts
542                     > PTS_THRESHOLD )
543             {
544                 intf_WarnMsg( 2,
545                    "vpar synchro warning: backward_pts != current_pts (%lld)",
546                    p_vpar->synchro.current_pts - p_vpar->synchro.backward_pts );
547             }
548             p_vpar->synchro.current_pts = p_vpar->synchro.backward_pts;
549             p_vpar->synchro.backward_pts = 0;
550         }
551         else if( p_vpar->sequence.next_dts )
552         {
553             if( p_vpar->sequence.next_dts - p_vpar->synchro.current_pts
554                     > PTS_THRESHOLD
555                  || p_vpar->synchro.current_pts - p_vpar->sequence.next_dts
556                     > PTS_THRESHOLD )
557             {
558                 intf_WarnMsg( 2,
559                         "vpar synchro warning: dts != current_pts (%lld)",
560                         p_vpar->synchro.current_pts
561                             - p_vpar->sequence.next_dts );
562             }
563             /* By definition of a DTS. */
564             p_vpar->synchro.current_pts = p_vpar->sequence.next_dts;
565             p_vpar->sequence.next_dts = 0;
566         }
567
568         if( p_vpar->sequence.next_pts )
569         {
570             /* Store the PTS for the next time we have to date an I picture. */
571             p_vpar->synchro.backward_pts = p_vpar->sequence.next_pts;
572             p_vpar->sequence.next_pts = 0;
573         }
574     }
575 #undef PTS_THRESHOLD
576
577 #if 0
578     /* Removed for incompatibility with slow motion */
579     if( p_vpar->synchro.current_pts + DEFAULT_PTS_DELAY < now )
580     {
581         /* We cannot be _that_ late, something must have happened, reinit
582          * the dates. */
583         intf_WarnMsg( 2, "PTS << now (%lld), resetting",
584                       now - p_vpar->synchro.current_pts - DEFAULT_PTS_DELAY );
585         p_vpar->synchro.current_pts = now + DEFAULT_PTS_DELAY;
586     }
587     if( p_vpar->synchro.backward_pts
588          && p_vpar->synchro.backward_pts + DEFAULT_PTS_DELAY < now )
589     {
590         /* The same. */
591         p_vpar->synchro.backward_pts = 0;
592     }
593 #endif
594
595 #ifdef STATS
596     p_vpar->synchro.i_pic++;
597 #endif
598 }
599
600 /*****************************************************************************
601  * SynchroType: Get the user's synchro type
602  *****************************************************************************
603  * This function is called at initialization.
604  *****************************************************************************/
605 static int SynchroType( void )
606 {
607     char * psz_synchro = main_GetPszVariable( VPAR_SYNCHRO_VAR, NULL );
608
609     if( psz_synchro == NULL )
610     {
611         return VPAR_SYNCHRO_DEFAULT;
612     }
613
614     switch( *psz_synchro++ )
615     {
616       case 'i':
617       case 'I':
618         switch( *psz_synchro++ )
619         {
620           case '\0':
621             return VPAR_SYNCHRO_I;
622
623           case '+':
624             if( *psz_synchro ) return 0;
625             return VPAR_SYNCHRO_Iplus;
626
627           case 'p':
628           case 'P':
629             switch( *psz_synchro++ )
630             {
631               case '\0':
632                 return VPAR_SYNCHRO_IP;
633
634               case '+':
635                 if( *psz_synchro ) return 0;
636                 return VPAR_SYNCHRO_IPplus;
637
638               case 'b':
639               case 'B':
640                 if( *psz_synchro ) return 0;
641                 return VPAR_SYNCHRO_IPB;
642
643               default:
644                 return VPAR_SYNCHRO_DEFAULT;
645                 
646             }
647
648           default:
649             return VPAR_SYNCHRO_DEFAULT;
650         }
651     }
652
653     return VPAR_SYNCHRO_DEFAULT;
654 }
655