Changeset 55320a77c20c9855c67c9f07598daee5804e57d6

Show
Ignore:
Timestamp:
11/13/03 14:31:12 (5 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1068730272 +0000
git-parent:

[3f71e7714a4380254cda040ad67e1fb7c5d7bae4]

git-author:
Laurent Aimar <fenrir@videolan.org> 1068730272 +0000
Message:
  • input: handle also SPU in es_out_Add (and fix a bad lock).
  • sub: use es_out_Add (and that give a proper solution for multiple tracks)

fixed seeking with sub. (pf_demux was called in Seek instead of
pf_seek ...)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/util/sub.c

    re53ac06 r55320a7  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2003 VideoLAN 
    5  * $Id: sub.c,v 1.35 2003/11/05 00:39:16 gbazin Exp $ 
     5 * $Id: sub.c,v 1.36 2003/11/13 13:31:12 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    238238    while (*p_pos) 
    239239    { 
    240    if (toupper(*p_pos) == toupper(*psz_little)) 
    241         { 
    242        char * psz_cur1 = p_pos + 1; 
    243        char * psz_cur2 = psz_little + 1; 
    244        while (*psz_cur1 && *psz_cur2 && toupper(*psz_cur1) == toupper(*psz_cur2)) 
    245             { 
    246        psz_cur1++; 
    247        psz_cur2++; 
    248        } 
    249        if (!*psz_cur2) return p_pos; 
    250    
    251    p_pos++; 
     240        if (toupper(*p_pos) == toupper(*psz_little)) 
     241        { 
     242            char * psz_cur1 = p_pos + 1; 
     243            char * psz_cur2 = psz_little + 1; 
     244            while (*psz_cur1 && *psz_cur2 && toupper(*psz_cur1) == toupper(*psz_cur2)) 
     245            { 
     246                psz_cur1++; 
     247                psz_cur2++; 
     248            } 
     249            if (!*psz_cur2) return p_pos; 
     250       
     251        p_pos++; 
    252252    } 
    253253    return NULL; 
     
    265265    text_t  txt; 
    266266    vlc_value_t val; 
     267    es_format_t  fmt; 
    267268 
    268269    int     i; 
     
    470471 
    471472    /* *** add subtitle ES *** */ 
    472     vlc_mutex_lock( &p_input->stream.stream_lock ); 
    473     p_sub->p_es = input_AddES( p_input, p_input->stream.p_selected_program, 
    474                                0xff - i_track_id,    /* FIXME */ 
    475                                SPU_ES, NULL, 0 ); 
    476     vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    477  
    478     p_sub->p_es->i_stream_id = 0xff - i_track_id;    /* FIXME */ 
    479      
    480     if( p_sub->psz_header != NULL ) 
    481     { 
    482         p_sub->p_es->p_demux_data = malloc( sizeof( subtitle_data_t ) ); 
    483         p_sub->p_es->p_demux_data->psz_header = strdup( p_sub->psz_header ); 
    484         free( p_sub->psz_header ); 
    485     } 
    486  
    487473    if( p_sub->i_sub_type == SUB_TYPE_VOBSUB ) 
    488474    { 
    489         p_sub->p_es->i_fourcc    = VLC_FOURCC( 's','p','u',' ' ); 
    490         /* open vobsub file */ 
     475        es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','p','u',' ' ) ); 
    491476    } 
    492477    else if( p_sub->i_sub_type == SUB_TYPE_SSA1 || 
    493478             p_sub->i_sub_type == SUB_TYPE_SSA2_4 ) 
    494479    { 
    495         p_sub->p_es->i_fourcc    = VLC_FOURCC( 's','s','a',' ' ); 
     480        es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','s','a',' ' ) ); 
    496481    } 
    497482    else 
    498483    { 
    499         p_sub->p_es->i_fourcc    = VLC_FOURCC( 's','u','b','t' ); 
    500     } 
     484        es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','u','b','t' ) ); 
     485    } 
     486    if( p_sub->psz_header != NULL ) 
     487    { 
     488        fmt.i_extra_type = ES_EXTRA_TYPE_SUBHEADER; 
     489        fmt.i_extra = strlen( p_sub->psz_header ) + 1; 
     490        fmt.p_extra = strdup( p_sub->psz_header ); 
     491    } 
     492    p_sub->p_es = es_out_Add( p_input->p_es_out, &fmt ); 
    501493 
    502494    p_sub->i_previously_selected = 0; 
     
    509501static int  sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate ) 
    510502{ 
    511     if( p_sub->p_es->p_decoder_fifo && !p_sub->i_previously_selected ) 
     503    input_thread_t *p_input = p_sub->p_input; 
     504    vlc_bool_t     b; 
     505 
     506    es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, p_sub->p_es, &b ); 
     507    if( b && !p_sub->i_previously_selected ) 
    512508    { 
    513509        p_sub->i_previously_selected = 1; 
     
    515511        return VLC_SUCCESS; 
    516512    } 
    517     else if( !p_sub->p_es->p_decoder_fifo && p_sub->i_previously_selected ) 
     513    else if( !b && p_sub->i_previously_selected ) 
    518514    { 
    519515        p_sub->i_previously_selected = 0; 
     
    573569        p_pes->i_nb_data = 1; 
    574570        p_pes->p_first = 
    575             p_pes->p_last = p_data; 
     571        p_pes->p_last = p_data; 
    576572        p_pes->i_pes_size = i_len; 
    577573 
     
    579575                p_sub->subtitle[p_sub->i_subtitle].psz_text, 
    580576                i_len ); 
    581         if( p_sub->p_es->p_decoder_fifo && p_pes->i_pts > 0 ) 
    582         { 
    583  
    584             input_DecodePES( p_sub->p_es->p_decoder_fifo, p_pes ); 
     577 
     578        if( p_pes->i_pts > 0 ) 
     579        { 
     580            es_out_Send( p_input->p_es_out, p_sub->p_es, p_pes ); 
    585581        } 
    586582        else 
     
    591587        p_sub->i_subtitle++; 
    592588    } 
    593     return( 0 )
     589    return VLC_SUCCESS
    594590} 
    595591 
     
    606602        p_sub->i_subtitle++; 
    607603    } 
    608  
    609604    return( 0 ); 
    610605} 
  • modules/demux/util/sub.h

    r354c7ab r55320a7  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2003 VideoLAN 
    5  * $Id: sub.h,v 1.10 2003/11/05 00:17:50 hartman Exp $ 
     5 * $Id: sub.h,v 1.11 2003/11/13 13:31:12 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    8  *  
     8 * 
    99 * This program is free software; you can redistribute it and/or modify 
    1010 * it under the terms of the GNU General Public License as published by 
    1111 * the Free Software Foundation; either version 2 of the License, or 
    1212 * (at your option) any later version. 
    13  *  
     13 * 
    1414 * This program is distributed in the hope that it will be useful, 
    1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     
    4141} subtitle_t; 
    4242 
    43 typedef struct subtitle_track_s 
     43#if 0 
     44typedef struct 
    4445{ 
    4546    int             i_track_id; 
     
    5253    int             i_previously_selected; /* to make pf_seek */ 
    5354    es_descriptor_t *p_es; 
    54      
     55 
    5556} subtitle_track_t; 
     57#endif 
    5658 
    5759typedef struct subtitle_demux_s 
    5860{ 
    5961    VLC_COMMON_MEMBERS 
    60      
     62 
    6163    module_t        *p_module; 
    62      
    63     int     (*pf_open) ( struct subtitle_demux_s *p_sub,  
    64                          input_thread_t*p_input,  
     64 
     65    int     (*pf_open) ( struct subtitle_demux_s *p_sub, 
     66                         input_thread_t*p_input, 
    6567                         char *psz_name, 
    6668                         mtime_t i_microsecperframe, 
     
    6971    int     (*pf_seek) ( struct subtitle_demux_s *p_sub, mtime_t i_date ); 
    7072    void    (*pf_close)( struct subtitle_demux_s *p_sub ); 
    71      
    7273 
    7374    /* *** private *** */ 
     
    7980    int                 i_subtitles; 
    8081    subtitle_t          *subtitle; 
    81     es_descriptor_t     *p_es; 
     82    es_out_id_t         *p_es; 
    8283    int                 i_previously_selected; /* to make pf_seek */ 
    8384 
    84     /*unsigned int i_tracks; 
    85     subtitle_track_t   *p_tracks 
     85    /*unsigned int i_tracks; 
     86    subtitle_track_t *p_tracks 
    8687    */ 
    87      
    8888 
    8989} subtitle_demux_t; 
    9090 
    9191/***************************************************************************** 
    92  * 
    93  * I made somes wrappers : So use them ! 
    94  *  I think you shouldn't need access to subtitle_demux_t members else said 
    95  *  it to me. 
    96  * 
    97  *****************************************************************************/ 
    98  
    99  
    100 /***************************************************************************** 
    101  * subtitle_New: Start a new subtitle demux instance (but subtitle ES isn't  
     92 * subtitle_New: Start a new subtitle demux instance (but subtitle ES isn't 
    10293 *               selected by default. 
    10394 ***************************************************************************** 
     
    113104                                              char *psz_name, 
    114105                                              mtime_t i_microsecperframe, 
    115                                               int i_track_id ); 
    116 /***************************************************************************** 
    117  * subtitle_Select: Select the related subtitle ES. 
    118  *****************************************************************************/ 
    119 static inline void subtitle_Select( subtitle_demux_t *p_sub ); 
    120  
    121 /***************************************************************************** 
    122  * subtitle_Unselect: Unselect the related subtitle ES. 
    123  *****************************************************************************/ 
    124 static inline void subtitle_Unselect( subtitle_demux_t *p_sub ); 
    125  
    126 /***************************************************************************** 
    127  * subtitle_Demux: send subtitle to decoder from last date to i_max 
    128  *****************************************************************************/ 
    129 static inline int  subtitle_Demux( subtitle_demux_t *p_sub, mtime_t i_max ); 
    130  
    131 /***************************************************************************** 
    132  * subtitle_Seek: Seek to i_date 
    133  *****************************************************************************/ 
    134 static inline int  subtitle_Seek( subtitle_demux_t *p_sub, mtime_t i_date ); 
    135  
    136 /***************************************************************************** 
    137  * subtitle_Close: Stop ES decoder and free all memory included p_sub. 
    138  *****************************************************************************/ 
    139 static inline void subtitle_Close( subtitle_demux_t *p_sub ); 
    140  
    141  
    142  
    143  
    144  
    145 /*****************************************************************************/ 
    146 /*****************************************************************************/ 
    147 /*****************************************************************************/ 
    148  
    149  
    150 static inline  
    151     subtitle_demux_t *subtitle_New( input_thread_t *p_input, 
    152                                     char *psz_name, 
    153                                     mtime_t i_microsecperframe, 
    154                                     int i_track_id ) 
     106                                              int i_track_id ) 
    155107{ 
    156108    subtitle_demux_t *p_sub; 
     
    186138} 
    187139 
    188 static inline void subtitle_Select( subtitle_demux_t *p_sub ) 
    189 
    190     if( p_sub && p_sub->p_es ) 
    191     { 
    192         vlc_mutex_lock( &p_sub->p_input->stream.stream_lock ); 
    193         input_SelectES( p_sub->p_input, p_sub->p_es ); 
    194         vlc_mutex_unlock( &p_sub->p_input->stream.stream_lock ); 
    195         p_sub->i_previously_selected = 0; 
    196     } 
    197 
    198 static inline void subtitle_Unselect( subtitle_demux_t *p_sub ) 
    199 
    200     if( p_sub && p_sub->p_es ) 
    201     { 
    202         vlc_mutex_lock( &p_sub->p_input->stream.stream_lock ); 
    203         input_UnselectES( p_sub->p_input, p_sub->p_es ); 
    204         vlc_mutex_unlock( &p_sub->p_input->stream.stream_lock ); 
    205         p_sub->i_previously_selected = 0; 
    206     } 
    207 
    208  
     140/***************************************************************************** 
     141 * subtitle_Demux: send subtitle to decoder from last date to i_max 
     142 *****************************************************************************/ 
    209143static inline int subtitle_Demux( subtitle_demux_t *p_sub, mtime_t i_max ) 
    210144{ 
     
    212146} 
    213147 
     148/***************************************************************************** 
     149 * subtitle_Seek: Seek to i_date 
     150 *****************************************************************************/ 
    214151static inline int subtitle_Seek( subtitle_demux_t *p_sub, mtime_t i_date ) 
    215152{ 
    216     return( p_sub->pf_demux( p_sub, i_date ) ); 
     153    return( p_sub->pf_seek( p_sub, i_date ) ); 
    217154} 
    218155 
     156/***************************************************************************** 
     157 * subtitle_Close: Stop ES decoder and free all memory included p_sub. 
     158 *****************************************************************************/ 
    219159static inline void subtitle_Close( subtitle_demux_t *p_sub ) 
    220160{ 
     
    230170    } 
    231171} 
     172 
  • src/input/input.c

    r3f71e77 r55320a7  
    55 ***************************************************************************** 
    66 * Copyright (C) 1998-2002 VideoLAN 
    7  * $Id: input.c,v 1.253 2003/11/13 12:28:34 fenrir Exp $ 
     7 * $Id: input.c,v 1.254 2003/11/13 13:31:12 fenrir Exp $ 
    88 * 
    99 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    746746        if( ( p_sub = subtitle_New( p_input, strdup(val.psz_string), i_microsecondperframe, 0 ) ) ) 
    747747        { 
     748            /* Select this ES by default */ 
     749            es_out_Control( p_input->p_es_out, ES_OUT_SET_SELECT, p_sub->p_es, VLC_TRUE ); 
     750 
    748751            TAB_APPEND( p_input->p_sys->i_sub, p_input->p_sys->sub, p_sub ); 
    749             subtitle_Select( p_sub ); 
    750752        } 
    751753    } 
    752754    if( val.psz_string ) free( val.psz_string ); 
    753      
     755 
    754756    var_Get( p_input, "sub-autodetect-file", &val ); 
    755757    if( val.b_bool ) 
     
    11101112            } 
    11111113            id->p_es->p_bitmapinfoheader = p_bih; 
     1114            break; 
     1115        } 
     1116        case SPU_ES: 
     1117        { 
     1118            subtitle_data_t *p_sub = malloc( sizeof( subtitle_data_t ) ); 
     1119            memset( p_sub, 0, sizeof( subtitle_data_t ) ); 
     1120            if( fmt->i_extra > 0 ) 
     1121            { 
     1122                if( fmt->i_extra_type == ES_EXTRA_TYPE_SUBHEADER ) 
     1123                { 
     1124                    p_sub->psz_header = malloc( fmt->i_extra  ); 
     1125                    memcpy( p_sub->psz_header, fmt->p_extra , fmt->i_extra ); 
     1126                } 
     1127            } 
     1128            /* FIXME beuuuuuurk */ 
     1129            id->p_es->p_demux_data = p_sub; 
    11121130            break; 
    11131131        } 
     
    12391257    { 
    12401258        case ES_OUT_SET_SELECT: 
     1259            vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); 
    12411260            id = (es_out_id_t*) va_arg( args, es_out_id_t * ); 
    12421261            b = (vlc_bool_t) va_arg( args, vlc_bool_t ); 
     
    12441263            { 
    12451264                input_SelectES( p_sys->p_input, id->p_es ); 
     1265                vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 
    12461266                return id->p_es->p_decoder_fifo ? VLC_SUCCESS : VLC_EGENERIC; 
    12471267            } 
     
    12491269            { 
    12501270                input_UnselectES( p_sys->p_input, id->p_es ); 
    1251             } 
    1252             return VLC_SUCCESS; 
    1253  
     1271                vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 
     1272                return VLC_SUCCESS; 
     1273            } 
    12541274        case ES_OUT_GET_SELECT: 
    12551275            id = (es_out_id_t*) va_arg( args, es_out_id_t * );