Changeset 2175bb5b22bd2d67cd6cc63c6e8802f7189cdd85

Show
Ignore:
Timestamp:
24/10/02 11:37:48 (6 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1035452268 +0000
git-parent:

[2a533cead65e40f553aa30a7ca03292ce9fbe281]

git-author:
Gildas Bazin <gbazin@videolan.org> 1035452268 +0000
Message:

* src/input/input_ext-dec.c, include/input_ext-dec.h, modules/codec/araw.c:

renamed input_NextPES into input_ExtractPES and factorised its code.

* modules/codec/ffmpeg/ffmpeg.c, modules/codec/faad/decoder.c,

modules/codec/cinepak/cinepak.c: make use of NextPES and GetPES from
src/input/input_ext-dec.c.

* modules/codec/a52.c: fixed uninitialized variable.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/input_ext-dec.h

    rbfc4f0f r2175bb5  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: input_ext-dec.h,v 1.73 2002/10/23 23:17:45 gbazin Exp $ 
     5 * $Id: input_ext-dec.h,v 1.74 2002/10/24 09:37:48 gbazin Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    219219VLC_EXPORT( void, NextPTS,                 ( bit_stream_t *, mtime_t *, mtime_t * ) ); 
    220220 
    221 VLC_EXPORT( int,  input_NextPES,           ( decoder_fifo_t *, pes_packet_t ** ) ); 
     221VLC_EXPORT( int,  input_ExtractPES,        ( decoder_fifo_t *, pes_packet_t ** ) ); 
    222222 
    223223/***************************************************************************** 
  • modules/codec/a52.c

    r9a6b90b r2175bb5  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2002 VideoLAN 
    5  * $Id: a52.c,v 1.14 2002/09/30 21:32:32 massiot Exp $ 
     5 * $Id: a52.c,v 1.15 2002/10/24 09:37:48 gbazin Exp $ 
    66 * 
    77 * Authors: St�ane Borel <stef@via.ecp.fr> 
     
    128128    p_dec->output_format.i_format = VLC_FOURCC('a','5','2',' '); 
    129129 
     130    aout_DateSet( &end_date, 0 ); 
     131 
    130132    /* Init the bitstream */ 
    131133    InitBitstream( &p_dec->bit_stream, p_dec->p_fifo, 
  • modules/codec/araw.c

    rc0cab76 r2175bb5  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001, 2002 VideoLAN 
    5  * $Id: araw.c,v 1.3 2002/10/21 10:46:34 fenrir Exp $ 
     5 * $Id: araw.c,v 1.4 2002/10/24 09:37:48 gbazin Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    316316 
    317317    /* **** get samples count **** */ 
    318     if( input_NextPES( p_adec->p_fifo, &p_pes ) < 0 ) 
     318    if( input_ExtractPES( p_adec->p_fifo, &p_pes ) < 0 ) 
    319319    { 
    320320        p_adec->p_fifo->b_error = 1; 
  • modules/codec/cinepak/cinepak.c

    rac811ff r2175bb5  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: cinepak.c,v 1.4 2002/10/15 01:50:24 fenrir Exp $ 
     5 * $Id: cinepak.c,v 1.5 2002/10/24 09:37:48 gbazin Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    156156    if( p ) free( p ) 
    157157 
    158 /* get the first pes from fifo */ 
    159 static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo ) 
    160 { 
    161     pes_packet_t *p_pes; 
    162  
    163     vlc_mutex_lock( &p_fifo->data_lock ); 
    164  
    165     /* if fifo is emty wait */ 
    166     while( !p_fifo->p_first ) 
    167     { 
    168         if( p_fifo->b_die ) 
    169         { 
    170             vlc_mutex_unlock( &p_fifo->data_lock ); 
    171             return( NULL ); 
    172         } 
    173         vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); 
    174     } 
    175     p_pes = p_fifo->p_first; 
    176  
    177     vlc_mutex_unlock( &p_fifo->data_lock ); 
    178  
    179     return( p_pes ); 
    180 } 
    181  
    182 /* free the first pes and go to next */ 
    183 static void __PES_NEXT( decoder_fifo_t *p_fifo ) 
    184 { 
    185     pes_packet_t *p_next; 
    186  
    187     vlc_mutex_lock( &p_fifo->data_lock ); 
    188      
    189     p_next = p_fifo->p_first->p_next; 
    190     p_fifo->p_first->p_next = NULL; 
    191     input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first ); 
    192     p_fifo->p_first = p_next; 
    193     p_fifo->i_depth--; 
    194  
    195     if( !p_fifo->p_first ) 
    196     { 
    197         /* No PES in the fifo */ 
    198         /* pp_last no longer valid */ 
    199         p_fifo->pp_last = &p_fifo->p_first; 
    200         while( !p_fifo->p_first ) 
    201         { 
    202             vlc_cond_signal( &p_fifo->data_wait ); 
    203             vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); 
    204         } 
    205     } 
    206     vlc_mutex_unlock( &p_fifo->data_lock ); 
    207 } 
    208158 
    209159static inline void __GetFrame( videodec_thread_t *p_vdec ) 
     
    213163    byte_t        *p_buffer; 
    214164 
    215     p_pes = __PES_GET( p_vdec->p_fifo ); 
     165    p_pes = GetPES( p_vdec->p_fifo ); 
    216166    p_vdec->i_pts = p_pes->i_pts; 
    217167 
    218168    while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) ) 
    219169    { 
    220         __PES_NEXT( p_vdec->p_fifo ); 
    221         p_pes = __PES_GET( p_vdec->p_fifo ); 
     170        p_pes = NextPES( p_vdec->p_fifo ); 
    222171    } 
    223172    p_vdec->i_framesize = p_pes->i_pes_size; 
     
    243192    pes_packet_t  *p_pes; 
    244193 
    245     p_pes = __PES_GET( p_vdec->p_fifo ); 
     194    p_pes = GetPES( p_vdec->p_fifo ); 
    246195    if( p_pes->i_nb_data != 1 ) 
    247196    { 
    248197        free( p_vdec->p_framedata ); /* FIXME keep this buffer */ 
    249198    } 
    250     __PES_NEXT( p_vdec->p_fifo ); 
     199    NextPES( p_vdec->p_fifo ); 
    251200} 
    252201 
  • modules/codec/faad/decoder.c

    r5f3c2d3 r2175bb5  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001, 2002 VideoLAN 
    5  * $Id: decoder.c,v 1.6 2002/10/20 17:44:17 fenrir Exp $ 
     5 * $Id: decoder.c,v 1.7 2002/10/24 09:37:47 gbazin Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    149149} 
    150150 
    151 /* get the first pes from fifo */ 
    152 static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo ) 
    153 { 
    154     pes_packet_t *p_pes; 
    155  
    156     vlc_mutex_lock( &p_fifo->data_lock ); 
    157  
    158     /* if fifo is emty wait */ 
    159     while( !p_fifo->p_first ) 
    160     { 
    161         if( p_fifo->b_die ) 
    162         { 
    163             vlc_mutex_unlock( &p_fifo->data_lock ); 
    164             return( NULL ); 
    165         } 
    166         vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); 
    167     } 
    168     p_pes = p_fifo->p_first; 
    169  
    170     vlc_mutex_unlock( &p_fifo->data_lock ); 
    171  
    172     return( p_pes ); 
    173 } 
    174  
    175 /* free the first pes and go to next */ 
    176 static void __PES_NEXT( decoder_fifo_t *p_fifo ) 
    177 { 
    178     pes_packet_t *p_next; 
    179  
    180     vlc_mutex_lock( &p_fifo->data_lock ); 
    181      
    182     p_next = p_fifo->p_first->p_next; 
    183     p_fifo->p_first->p_next = NULL; 
    184     input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first ); 
    185     p_fifo->p_first = p_next; 
    186     p_fifo->i_depth--; 
    187  
    188     if( !p_fifo->p_first ) 
    189     { 
    190         /* No PES in the fifo */ 
    191         /* pp_last no longer valid */ 
    192         p_fifo->pp_last = &p_fifo->p_first; 
    193         while( !p_fifo->p_first ) 
    194         { 
    195             vlc_cond_signal( &p_fifo->data_wait ); 
    196             vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); 
    197         } 
    198     } 
    199     vlc_mutex_unlock( &p_fifo->data_lock ); 
    200 } 
    201  
    202151static inline void __GetFrame( adec_thread_t *p_adec ) 
    203152{ 
     
    206155    byte_t        *p_buffer; 
    207156 
    208     p_pes = __PES_GET( p_adec->p_fifo ); 
     157    p_pes = GetPES( p_adec->p_fifo ); 
    209158    if( p_pes->i_pts ) 
    210159    { 
     
    214163    while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) ) 
    215164    { 
    216         __PES_NEXT( p_adec->p_fifo ); 
    217         p_pes = __PES_GET( p_adec->p_fifo ); 
     165        p_pes = NextPES( p_adec->p_fifo ); 
    218166    } 
    219167    p_adec->i_framesize = p_pes->i_pes_size; 
     
    251199static inline void __NextFrame( adec_thread_t *p_adec ) 
    252200{ 
    253     __PES_NEXT( p_adec->p_fifo ); 
     201    NextPES( p_adec->p_fifo ); 
    254202} 
    255203 
  • modules/codec/ffmpeg/ffmpeg.c

    rcada6d0 r2175bb5  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: ffmpeg.c,v 1.8 2002/10/20 17:28:01 fenrir Exp $ 
     5 * $Id: ffmpeg.c,v 1.9 2002/10/24 09:37:47 gbazin Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    238238 
    239239} 
    240 /* get the first pes from fifo */ 
    241 static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo ) 
    242 { 
    243     pes_packet_t *p_pes; 
    244  
    245     vlc_mutex_lock( &p_fifo->data_lock ); 
    246  
    247     /* if fifo is emty wait */ 
    248     while( !p_fifo->p_first ) 
    249     { 
    250         if( p_fifo->b_die ) 
    251         { 
    252             vlc_mutex_unlock( &p_fifo->data_lock ); 
    253             return( NULL ); 
    254         } 
    255         vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); 
    256     } 
    257     p_pes = p_fifo->p_first; 
    258  
    259     vlc_mutex_unlock( &p_fifo->data_lock ); 
    260  
    261     return( p_pes ); 
    262 } 
    263  
    264 /* free the first pes and go to next */ 
    265 static void __PES_NEXT( decoder_fifo_t *p_fifo ) 
    266 { 
    267     pes_packet_t *p_next; 
    268  
    269     vlc_mutex_lock( &p_fifo->data_lock ); 
    270      
    271     p_next = p_fifo->p_first->p_next; 
    272     p_fifo->p_first->p_next = NULL; 
    273     input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first ); 
    274     p_fifo->p_first = p_next; 
    275     p_fifo->i_depth--; 
    276  
    277     if( !p_fifo->p_first ) 
    278     { 
    279         /* No PES in the fifo */ 
    280         /* pp_last no longer valid */ 
    281         p_fifo->pp_last = &p_fifo->p_first; 
    282         while( !p_fifo->p_first ) 
    283         { 
    284             vlc_cond_signal( &p_fifo->data_wait ); 
    285             vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); 
    286         } 
    287     } 
    288     vlc_mutex_unlock( &p_fifo->data_lock ); 
    289 } 
    290240 
    291241static void __GetFrame( videodec_thread_t *p_vdec ) 
     
    295245    byte_t        *p_buffer; 
    296246 
    297     p_pes = __PES_GET( p_vdec->p_fifo ); 
     247    p_pes = GetPES( p_vdec->p_fifo ); 
    298248    p_vdec->i_pts = p_pes->i_pts; 
    299249 
    300250    while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) ) 
    301251    { 
    302         __PES_NEXT( p_vdec->p_fifo ); 
    303         p_pes = __PES_GET( p_vdec->p_fifo ); 
     252        p_pes = NextPES( p_vdec->p_fifo ); 
    304253    } 
    305254    p_vdec->i_framesize = p_pes->i_pes_size; 
     
    337286static void __NextFrame( videodec_thread_t *p_vdec ) 
    338287{ 
    339     __PES_NEXT( p_vdec->p_fifo ); 
     288    NextPES( p_vdec->p_fifo ); 
    340289} 
    341290 
     
    841790               but break picture until a new I, and for mpeg4 ...*/ 
    842791            p_vdec->i_frame_late--; /* needed else it will never be decrease */ 
    843             __PES_NEXT( p_vdec->p_fifo ); 
     792            NextPES( p_vdec->p_fifo ); 
    844793            return; 
    845794        } 
     
    854803               but break picture until a new I, and for mpeg4 ...*/ 
    855804            p_vdec->i_frame_late--; /* needed else it will never be decrease */ 
    856             __PES_NEXT( p_vdec->p_fifo ); 
     805            NextPES( p_vdec->p_fifo ); 
    857806            return; 
    858807        } 
  • src/input/input_ext-dec.c

    rbfc4f0f r2175bb5  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998-2001 VideoLAN 
    5  * $Id: input_ext-dec.c,v 1.36 2002/10/23 23:17:44 gbazin Exp $ 
     5 * $Id: input_ext-dec.c,v 1.37 2002/10/24 09:37:47 gbazin Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    132132 
    133133        /* Signal the input thread we're waiting. This is only 
    134          * needed in case of slave clock (ES plug-in) but it won't 
     134         * needed in case of slave clock (ES plug-in) but it won't 
    135135         * harm. */ 
    136136        vlc_cond_signal( &p_fifo->data_wait ); 
     
    167167    p_fifo->p_first = p_next; 
    168168    p_fifo->i_depth--; 
     169 
     170    if( p_fifo->p_first == NULL ) 
     171    { 
     172        /* No PES in the FIFO. p_last is no longer valid. */ 
     173        p_fifo->pp_last = &p_fifo->p_first; 
     174    } 
    169175 
    170176    vlc_mutex_unlock( &p_fifo->data_lock ); 
     
    513519 
    514520/**************************************************************************** 
    515  * input_NextPES : extract a PES from the fifo. If pp_pes is NULL then this  
     521 * input_ExtractPES : extract a PES from the fifo. If pp_pes is NULL then this 
    516522 * PES is deleted, else pp_pes will be set to this PES 
    517523 ****************************************************************************/ 
    518 int input_NextPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes ) 
    519 
    520     pes_packet_t *p_pes, *p_next; 
     524int input_ExtractPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes ) 
     525
     526    pes_packet_t *p_pes; 
     527 
     528    p_pes = _GetPES( p_fifo ); 
    521529 
    522530    vlc_mutex_lock( &p_fifo->data_lock ); 
    523531 
    524     /* if fifo is emty wait */ 
    525     while( !p_fifo->p_first ) 
    526     { 
    527         if( p_fifo->b_die ) 
    528         { 
    529             vlc_mutex_unlock( &p_fifo->data_lock ); 
    530             if( pp_pes ) 
    531             { 
    532                 *pp_pes = NULL; 
    533             } 
    534             return( -1 ); 
    535         } 
    536         vlc_cond_signal( &p_fifo->data_wait ); 
    537         vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); 
    538     } 
    539     p_pes = p_fifo->p_first; 
    540  
    541     p_next = p_pes->p_next; 
     532    p_fifo->p_first = p_pes->p_next; 
    542533    p_pes->p_next = NULL; 
    543  
    544  
    545     p_fifo->p_first = p_next; 
    546534    p_fifo->i_depth--; 
    547535 
     
    552540        p_fifo->pp_last = &p_fifo->p_first; 
    553541    } 
     542 
    554543    vlc_mutex_unlock( &p_fifo->data_lock ); 
    555544 
     
    564553    return( 0 ); 
    565554} 
    566