vpar_synchro.c 19.8 KB
Newer Older
1 2
/*****************************************************************************
 * vpar_motion.c : motion vectors parsing
3 4 5 6 7 8 9 10 11
 *****************************************************************************
 * Copyright (C) 1999, 2000 VideoLAN
 *
 * Authors:
 *
 * 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.
12
 * 
13 14
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
17
 *
18 19 20
 * 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.
21 22 23 24 25
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
26 27
#include "defs.h"

28 29 30
#include <stdlib.h>                                                /* free() */
#include <sys/types.h>                        /* on BSD, uio.h needs types.h */
#include <sys/uio.h>                                            /* "input.h" */
31 32 33

#include "config.h"
#include "common.h"
34
#include "threads.h"
35
#include "mtime.h"
36
#include "plugins.h"
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

#include "intf_msg.h"

#include "input.h"
#include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"

#include "vdec_idct.h"
#include "video_decoder.h"
#include "vdec_motion.h"

#include "vpar_blocks.h"
#include "vpar_headers.h"
#include "vpar_synchro.h"
#include "video_parser.h"

54 55
#define MAX_COUNT 3

56 57 58 59
/*
 * Local prototypes
 */

60
#ifdef SAM_SYNCHRO
61 62 63 64

/*****************************************************************************
 * vpar_SynchroUpdateStructures : Update the synchro structures
 *****************************************************************************/
65
void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
66
                                   int i_coding_type, boolean_t b_kept )
67
{
Sam Hocevar's avatar
Sam Hocevar committed
68
    int             i_can_display;
69
    mtime_t         i_pts;
70
    pes_packet_t *  p_pes = p_vpar->bit_stream.p_decoder_fifo->buffer[
71 72 73 74
                               p_vpar->bit_stream.p_decoder_fifo->i_start ];

    /* try to guess the current DTS and PTS */
    if( p_pes->b_has_pts )
75
    {
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
        i_pts = p_pes->i_pts;

        /* if the image is I type, then the presentation timestamp is
         * the PTS of the PES. Otherwise, we calculate it with the
         * theorical framerate value */
        if( i_coding_type == I_CODING_TYPE )
        {
            p_vpar->synchro.i_last_pts = p_pes->i_pts;
        }
        else
        {
            p_vpar->synchro.i_last_pts += p_vpar->synchro.i_theorical_delay;
        }

        p_pes->b_has_pts = 0;
91
    }
92
    else
93
    {
94 95
        p_vpar->synchro.i_last_pts += p_vpar->synchro.i_theorical_delay;
        i_pts = p_vpar->synchro.i_last_pts;
96
    }
97

98
    /* update structures */
99 100 101
    switch(i_coding_type)
    {
        case P_CODING_TYPE:
102

Sam Hocevar's avatar
Sam Hocevar committed
103 104
            p_vpar->synchro.i_P_seen += 1024;
            if( b_kept ) p_vpar->synchro.i_P_kept += 1024;
105
            break;
106

107
        case B_CODING_TYPE:
Sam Hocevar's avatar
Sam Hocevar committed
108 109
            p_vpar->synchro.i_B_seen += 1024;
            if( b_kept ) p_vpar->synchro.i_B_kept += 1024;
110
            break;
111

112 113
        case I_CODING_TYPE:

114 115 116
            /* update the last I PTS we have, we need it to
             * calculate the theorical framerate */
            if (i_pts != p_vpar->synchro.i_last_seen_I_pts)
117
            {
118
                if ( p_vpar->synchro.i_last_seen_I_pts )
119
                {
120
                    p_vpar->synchro.i_theorical_delay =
Sam Hocevar's avatar
Sam Hocevar committed
121 122
                      1024 * ( i_pts - p_vpar->synchro.i_last_seen_I_pts )
                          / ( 1024 + p_vpar->synchro.i_B_seen
123
                                + p_vpar->synchro.i_P_seen);
124
                }
125
                p_vpar->synchro.i_last_seen_I_pts = i_pts;
126
            }
127

128
            /* now we calculated all statistics, it's time to
129
             * decide what we have the time to display */
Sam Hocevar's avatar
Sam Hocevar committed
130 131
            i_can_display = 
                ( (i_pts - p_vpar->synchro.i_last_kept_I_pts) << 10 )
132
                                / p_vpar->synchro.i_delay;
133

134 135 136 137 138
            p_vpar->synchro.b_all_I = 0;
            p_vpar->synchro.b_all_B = 0;
            p_vpar->synchro.b_all_P = 0;
            p_vpar->synchro.displayable_p = 0;
            p_vpar->synchro.displayable_b = 0;
139

Sam Hocevar's avatar
Sam Hocevar committed
140
            if( ( p_vpar->synchro.b_all_I = ( i_can_display >= 1024 ) ) )
141
            {
Sam Hocevar's avatar
Sam Hocevar committed
142
                i_can_display -= 1024;
143

144 145
                if( !( p_vpar->synchro.b_all_P
                        = ( i_can_display > p_vpar->synchro.i_P_seen ) ) )
146
                {
147
                    p_vpar->synchro.displayable_p = i_can_display;
148 149 150
                }
                else
                {
151 152 153 154 155 156 157
                    i_can_display -= p_vpar->synchro.i_P_seen;

                    if( !( p_vpar->synchro.b_all_B
                            = ( i_can_display > p_vpar->synchro.i_B_seen ) ) )
                    {
                        p_vpar->synchro.displayable_b = i_can_display;
                    }
158
                }
159 160
            }

161 162
#if 1
            if( p_vpar->synchro.b_all_I )
Sam Hocevar's avatar
Sam Hocevar committed
163 164
                intf_ErrMsg( "  I: 1024/1024  " );

165
            if( p_vpar->synchro.b_all_P )
166 167
                intf_ErrMsg( "P: %i/%i  ", p_vpar->synchro.i_P_seen,
                                           p_vpar->synchro.i_P_seen );
168
            else if( p_vpar->synchro.displayable_p > 0 )
Sam Hocevar's avatar
Sam Hocevar committed
169
                intf_ErrMsg( "P: %i/%i  ", p_vpar->synchro.displayable_p,
170
                                             p_vpar->synchro.i_P_seen );
Sam Hocevar's avatar
Sam Hocevar committed
171 172 173
            else
                intf_ErrMsg( "                " );

174
            if( p_vpar->synchro.b_all_B )
Sam Hocevar's avatar
Sam Hocevar committed
175 176
                intf_ErrMsg( "B: %i/%i", p_vpar->synchro.i_B_seen,
                                         p_vpar->synchro.i_B_seen );
177
            else if( p_vpar->synchro.displayable_b > 0 )
Sam Hocevar's avatar
Sam Hocevar committed
178
                intf_ErrMsg( "B: %i/%i", p_vpar->synchro.displayable_b,
179
                                           p_vpar->synchro.i_B_seen );
Sam Hocevar's avatar
Sam Hocevar committed
180 181 182 183 184
            else
                intf_ErrMsg( "                " );

            intf_ErrMsg( "
Decoding: " );
            /*intf_ErrMsg( "\n" );*/
185
#endif
186 187
            p_vpar->synchro.i_P_seen = 0;
            p_vpar->synchro.i_B_seen = 0;
188 189

            /* update some values */
190
            if( b_kept )
191
            {
192 193 194
                p_vpar->synchro.i_last_kept_I_pts = i_pts;
                p_vpar->synchro.i_P_kept = 0;
                p_vpar->synchro.i_B_kept = 0;
195 196
            }

197 198 199 200
            break;
    }
}

201 202 203
/*****************************************************************************
 * vpar_SynchroChoose : Decide whether we will decode a picture or not
 *****************************************************************************/
Jean-Marc Dressler's avatar
 
Jean-Marc Dressler committed
204 205
boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
                              int i_structure )
206
{
207
    mtime_t i_delay = p_vpar->synchro.i_last_pts - mdate();
208

209
    switch( i_coding_type )
210
    {
211 212
        case I_CODING_TYPE:

213 214 215 216 217 218
            if( p_vpar->synchro.i_type != VPAR_SYNCHRO_DEFAULT )
            {
                /* I, IP, IP+, IPB */
                return( 1 );
            }

219
            return( p_vpar->synchro.b_all_I );
220 221 222

        case P_CODING_TYPE:

223 224 225 226 227 228 229 230 231 232
            if( p_vpar->synchro.i_type == VPAR_SYNCHRO_I ) /* I */
            {
                return( 0 );
            }

            if( p_vpar->synchro.i_type >= VPAR_SYNCHRO_IP ) /* IP, IP+, IPB */
            {
                return( 1 );
            }

233 234
            if( p_vpar->synchro.b_all_P )
            {
235
                return( 1 );
236
            }
237 238

            if( p_vpar->synchro.displayable_p * i_delay
239
                < p_vpar->synchro.i_delay )
240 241 242 243
            {
                return( 0 );
            }

244 245
            p_vpar->synchro.displayable_p -= 1024;

246
            return( 1 );
247

248 249
        case B_CODING_TYPE:

250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
            if( p_vpar->synchro.i_type != VPAR_SYNCHRO_DEFAULT )
            {
                if( p_vpar->synchro.i_type <= VPAR_SYNCHRO_IP ) /* I, IP */
                {
                    return( 0 );
                }
                else if( p_vpar->synchro.i_type == VPAR_SYNCHRO_IPB ) /* IPB */
                {
                    return( 1 );
                }

                if( p_vpar->synchro.b_dropped_last_B ) /* IP+ */
                {
                    p_vpar->synchro.b_dropped_last_B = 0;
                    return( 1 );
                }

                p_vpar->synchro.b_dropped_last_B = 1;
                return( 0 );
            }

271 272
            if( p_vpar->synchro.b_all_B )
            {
273
                return( 1 );
274
            }
275

276
            if( p_vpar->synchro.displayable_b <= 0 )
277 278 279
            {
                return( 0 );
            }
280

281 282
            if( i_delay < 0 )
            {
283
                p_vpar->synchro.displayable_b -= 512;
284
                return( 0 );
285
            }
286

287
            p_vpar->synchro.displayable_b -= 1024;
288 289
            return( 1 );
    }
290

291
    return( 0 );
292

293 294 295 296 297 298 299 300
}

/*****************************************************************************
 * vpar_SynchroTrash : Update timers when we trash a picture
 *****************************************************************************/
void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
                        int i_structure )
{
301
    vpar_SynchroUpdateStructures (p_vpar, i_coding_type, 0);
302 303 304 305 306 307

}

/*****************************************************************************
 * vpar_SynchroDecode : Update timers when we decide to decode a picture
 *****************************************************************************/
308
void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
309 310
                            int i_structure )
{
311
    vpar_SynchroUpdateStructures (p_vpar, i_coding_type, 1);
312

313
    p_vpar->synchro.i_date_fifo[p_vpar->synchro.i_stop] = mdate();
314

315
    FIFO_INCREMENT( i_stop );
316

317
}
Jean-Marc Dressler's avatar
 
Jean-Marc Dressler committed
318 319 320 321

/*****************************************************************************
 * vpar_SynchroEnd : Called when the image is totally decoded
 *****************************************************************************/
322
void vpar_SynchroEnd( vpar_thread_t * p_vpar )
Jean-Marc Dressler's avatar
 
Jean-Marc Dressler committed
323
{
324 325 326
    if( p_vpar->synchro.i_stop != p_vpar->synchro.i_start )
    {
        mtime_t i_delay;
327

328 329 330
        i_delay = ( mdate() -
            p_vpar->synchro.i_date_fifo[p_vpar->synchro.i_start] )
              / ( (p_vpar->synchro.i_stop - p_vpar->synchro.i_start) & 0x0f );
331

332 333
        p_vpar->synchro.i_delay =
            ( 7 * p_vpar->synchro.i_delay + i_delay ) >> 3;
334

335 336 337 338 339 340 341 342 343 344
#if 0
        intf_ErrMsg( "decode %lli (mean %lli, theorical %lli)\n",
                     i_delay, p_vpar->synchro.i_delay,
                     p_vpar->synchro.i_theorical_delay );
#endif
    }
    else
    {
        intf_ErrMsg( "vpar error: critical ! fifo full\n" );
    }
345

346
    FIFO_INCREMENT( i_start );
347 348
}

349 350 351
/*****************************************************************************
 * vpar_SynchroDate : When an image has been decoded, ask for its date
 *****************************************************************************/
352 353
mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
{
354
#if 0
355 356 357

    mtime_t i_displaydate = p_vpar->synchro.i_last_pts;

358 359
    static mtime_t i_delta = 0;

360
    intf_ErrMsg( "displaying image with delay %lli and delta %lli\n",
361 362 363
        i_displaydate - mdate(),
        i_displaydate - i_delta );

364
    intf_ErrMsg ( "theorical fps: %f - actual fps: %f \n",
365
        1000000.0 / p_vpar->synchro.i_theorical_delay, 1000000.0 / p_vpar->synchro.i_delay );
366

367
    i_delta = i_displaydate;
368

369
    return i_displaydate;
370 371 372 373 374
#else

    return p_vpar->synchro.i_last_pts;

#endif
Jean-Marc Dressler's avatar
 
Jean-Marc Dressler committed
375 376
}

377 378 379
#endif

#ifdef MEUUH_SYNCHRO
Christophe Massiot's avatar
Christophe Massiot committed
380 381 382 383 384 385 386

/* synchro a deux balles backportee du decodeur de reference. NE MARCHE PAS
AVEC LES IMAGES MONOTRAMES */

boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
                              int i_structure )
{
387
    switch (i_coding_type)
Christophe Massiot's avatar
Christophe Massiot committed
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
    {
    case B_CODING_TYPE:
        if ((p_vpar->synchro.kludge_level <= p_vpar->synchro.kludge_nbp))
        {
            p_vpar->synchro.kludge_b++;
            return( 0 );
        }
        if (p_vpar->synchro.kludge_b %
             (p_vpar->synchro.kludge_nbb /
                (p_vpar->synchro.kludge_level - p_vpar->synchro.kludge_nbp)))
        {
            p_vpar->synchro.kludge_b++;
            return( 0 );
        }
        p_vpar->synchro.kludge_b++;
        return( 1 );

    case P_CODING_TYPE:
406
        if (p_vpar->synchro.kludge_p++ >= p_vpar->synchro.kludge_level)
Christophe Massiot's avatar
Christophe Massiot committed
407 408 409 410 411 412 413 414 415 416 417 418 419
        {
            return( 0 );
        }
        return( 1 );

    default:
        return( 1 );
    }
}

void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
                        int i_structure )
{
420
    if (DECODER_FIFO_START(p_vpar->fifo)->b_has_pts && i_coding_type == I_CODING_TYPE)
Christophe Massiot's avatar
Christophe Massiot committed
421 422 423 424 425 426
    {
        p_vpar->synchro.kludge_nbframes = 0;
        p_vpar->synchro.kludge_date = DECODER_FIFO_START(p_vpar->fifo)->i_pts;
    }
    else
        p_vpar->synchro.kludge_nbframes++;
427
    DECODER_FIFO_START(p_vpar->fifo)->b_has_pts = 0;
Christophe Massiot's avatar
Christophe Massiot committed
428 429 430 431 432
}

void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
                            int i_structure )
{
433
    if (DECODER_FIFO_START(p_vpar->fifo)->b_has_pts && i_coding_type == I_CODING_TYPE)
Christophe Massiot's avatar
Christophe Massiot committed
434 435 436 437 438 439 440 441 442 443 444 445
    {
        p_vpar->synchro.kludge_nbframes = 0;
        p_vpar->synchro.kludge_date = DECODER_FIFO_START(p_vpar->fifo)->i_pts;
        DECODER_FIFO_START(p_vpar->fifo)->b_has_pts = 0;
    }
    else
        p_vpar->synchro.kludge_nbframes++;
}

mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
{
    return( p_vpar->synchro.kludge_date
Sam Hocevar's avatar
Sam Hocevar committed
446 447
            + p_vpar->synchro.kludge_nbframes * 1000000
                / (p_vpar->sequence.i_frame_rate ) * 1001 );
Christophe Massiot's avatar
Christophe Massiot committed
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
}

void vpar_SynchroEnd( vpar_thread_t * p_vpar )
{
}

void vpar_SynchroKludge( vpar_thread_t * p_vpar, mtime_t date )
{
    mtime_t     show_date;
    int         temp = p_vpar->synchro.kludge_level;

    p_vpar->synchro.kludge_nbp = p_vpar->synchro.kludge_p ? p_vpar->synchro.kludge_p : 5;
    p_vpar->synchro.kludge_nbb = p_vpar->synchro.kludge_b ? p_vpar->synchro.kludge_b : 6;
    show_date = date - mdate();
    p_vpar->synchro.kludge_p = 0;
    p_vpar->synchro.kludge_b = 0;

    if (show_date < (SYNC_DELAY - SYNC_TOLERATE) && show_date <= p_vpar->synchro.kludge_prevdate)
    {
        p_vpar->synchro.kludge_level--;
        if (p_vpar->synchro.kludge_level < 0)
            p_vpar->synchro.kludge_level = 0;
        else if (p_vpar->synchro.kludge_level >
                     p_vpar->synchro.kludge_nbp + p_vpar->synchro.kludge_nbb)
            p_vpar->synchro.kludge_level = p_vpar->synchro.kludge_nbp + p_vpar->synchro.kludge_nbb;
#ifdef DEBUG
        if (temp != p_vpar->synchro.kludge_level)
            intf_DbgMsg("vdec debug: Level changed from %d to %d (%Ld)\n",
                        temp, p_vpar->synchro.kludge_level, show_date );
#endif
    }
    else if (show_date > (SYNC_DELAY + SYNC_TOLERATE) && show_date >= p_vpar->synchro.kludge_prevdate)
    {
        p_vpar->synchro.kludge_level++;
        if (p_vpar->synchro.kludge_level > p_vpar->synchro.kludge_nbp + p_vpar->synchro.kludge_nbb)
            p_vpar->synchro.kludge_level = p_vpar->synchro.kludge_nbp + p_vpar->synchro.kludge_nbb;
#ifdef DEBUG
        if (temp != p_vpar->synchro.kludge_level)
            intf_DbgMsg("vdec debug: Level changed from %d to %d (%Ld)\n",
                        temp, p_vpar->synchro.kludge_level, show_date );
#endif
    }

    p_vpar->synchro.kludge_prevdate = show_date;
    if ((p_vpar->synchro.kludge_level - p_vpar->synchro.kludge_nbp) > p_vpar->synchro.kludge_nbb)
        p_vpar->synchro.kludge_level = p_vpar->synchro.kludge_nbb + p_vpar->synchro.kludge_nbp;
}

496
#endif
497 498 499 500 501 502


#ifdef POLUX_SYNCHRO

void vpar_SynchroSetCurrentDate( vpar_thread_t * p_vpar, int i_coding_type )
{
503 504 505
    pes_packet_t * p_pes =
        p_vpar->bit_stream.p_decoder_fifo->buffer[p_vpar->bit_stream.p_decoder_fifo->i_start];

506 507 508 509 510 511 512 513

    switch( i_coding_type )
    {
    case B_CODING_TYPE:
        if( p_pes->b_has_pts )
        {
            if( p_pes->i_pts < p_vpar->synchro.i_current_frame_date )
            {
514
                intf_ErrMsg( "vpar warning: pts_date < current_date\n" );
515 516 517 518 519 520
            }
            p_vpar->synchro.i_current_frame_date = p_pes->i_pts;
            p_pes->b_has_pts = 0;
        }
        else
        {
Sam Hocevar's avatar
Sam Hocevar committed
521
            p_vpar->synchro.i_current_frame_date += 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
522 523
        }
        break;
524

525 526 527 528
    default:

        if( p_vpar->synchro.i_backward_frame_date == 0 )
        {
Sam Hocevar's avatar
Sam Hocevar committed
529
            p_vpar->synchro.i_current_frame_date += 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
530 531 532 533 534
        }
        else
        {
            if( p_vpar->synchro.i_backward_frame_date < p_vpar->synchro.i_current_frame_date )
            {
535
                intf_ErrMsg( "vpar warning: backward_date < current_date (%Ld)\n",
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
                         p_vpar->synchro.i_backward_frame_date - p_vpar->synchro.i_current_frame_date );
            }
            p_vpar->synchro.i_current_frame_date = p_vpar->synchro.i_backward_frame_date;
            p_vpar->synchro.i_backward_frame_date = 0;
        }

        if( p_pes->b_has_pts )
        {
            p_vpar->synchro.i_backward_frame_date = p_pes->i_pts;
            p_pes->b_has_pts = 0;
        }
       break;
    }
}

boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
                              int i_structure )
{
    boolean_t b_result = 1;
    int i_synchro_level = p_vpar->p_vout->i_synchro_level;
556

557 558
    vpar_SynchroSetCurrentDate( p_vpar, i_coding_type );

559
    /*
560 561 562
     * The synchro level is updated by the video input (see SynchroLevelUpdate)
     * so we just use the synchro_level to decide which frame to trash
     */
563

564 565 566
    switch( i_coding_type )
    {
    case I_CODING_TYPE:
567 568 569 570 571

        p_vpar->synchro.r_p_average =
            (p_vpar->synchro.r_p_average*(SYNC_AVERAGE_COUNT-1)+p_vpar->synchro.i_p_count)/SYNC_AVERAGE_COUNT;
        p_vpar->synchro.r_b_average =
            (p_vpar->synchro.r_b_average*(SYNC_AVERAGE_COUNT-1)+p_vpar->synchro.i_b_count)/SYNC_AVERAGE_COUNT;
572

573 574 575
        p_vpar->synchro.i_p_nb = (int)(p_vpar->synchro.r_p_average+0.5);
        p_vpar->synchro.i_b_nb = (int)(p_vpar->synchro.r_b_average+0.5);

576 577 578
        p_vpar->synchro.i_p_count = p_vpar->synchro.i_b_count = 0;
        p_vpar->synchro.i_b_trasher = p_vpar->synchro.i_b_nb / 2;
        p_vpar->synchro.i_i_count++;
579
       break;
580 581 582 583 584 585 586 587

    case P_CODING_TYPE:
        p_vpar->synchro.i_p_count++;
        if( p_vpar->synchro.i_p_count > i_synchro_level )
        {
            b_result = 0;
        }
        break;
588

589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
    case B_CODING_TYPE:
        p_vpar->synchro.i_b_count++;
        if( p_vpar->synchro.i_p_nb >= i_synchro_level )
        {
            /* We must trash all the B */
            b_result = 0;
        }
        else
        {
            /* We use the brensenham algorithm to decide which B to trash */
            p_vpar->synchro.i_b_trasher +=
                p_vpar->synchro.i_b_nb - (i_synchro_level-p_vpar->synchro.i_p_nb);
            if( p_vpar->synchro.i_b_trasher >= p_vpar->synchro.i_b_nb )
            {
                b_result = 0;
                p_vpar->synchro.i_b_trasher -= p_vpar->synchro.i_b_nb;
            }
        }
        break;
    }
609

610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
    return( b_result );
}

void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
                        int i_structure )
{
    vpar_SynchroChoose( p_vpar, i_coding_type, i_structure );
}

void vpar_SynchroUpdateLevel()
{
    //vlc_mutex_lock( &level_lock );
    //vlc_mutex_unlock( &level_lock );
}

mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
{
    return( p_vpar->synchro.i_current_frame_date );
}

/* functions with no use */

void vpar_SynchroEnd( vpar_thread_t * p_vpar )
{
}

void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
                            int i_structure )
{
}

#endif