Changeset 5bdef1c76ad3d3e6ef9601265362dc49bc05ee0c

Show
Ignore:
Timestamp:
17/10/04 15:38:22 (4 years ago)
Author:
Derk-Jan Hartman <hartman@videolan.org>
git-committer:
Derk-Jan Hartman <hartman@videolan.org> 1098020302 +0000
git-parent:

[a95e32965feec730866b90d0ab544d05a69b1d50]

git-author:
Derk-Jan Hartman <hartman@videolan.org> 1098020302 +0000
Message:

* vobsub.c: implemented vobsub seeking support.

Files:

Legend:

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

    r24b0610 r5bdef1c  
    7070typedef struct 
    7171{ 
    72     mtime_t i_start; 
     72    int64_t i_start; 
    7373    int     i_vobsub_location; 
    7474} subtitle_t; 
     
    166166            { 
    167167                if( p_sys->track[i].p_subtitles[p_sys->track[i].i_subtitles-1].i_start > p_sys->i_length ) 
    168                     p_sys->i_length = (mtime_t) p_sys->track[i].p_subtitles[p_sys->track[i].i_subtitles-1].i_start + 1 * 1000 * 1000
     168                    p_sys->i_length = (int64_t) p_sys->track[i].p_subtitles[p_sys->track[i].i_subtitles-1].i_start + ( 1 *1000 *1000 )
    169169            } 
    170170        } 
     
    215215    demux_sys_t *p_sys = p_demux->p_sys; 
    216216    int64_t *pi64, i64; 
     217    int i; 
    217218    double *pf, f; 
    218219 
     
    221222        case DEMUX_GET_LENGTH: 
    222223            pi64 = (int64_t*)va_arg( args, int64_t * ); 
    223             *pi64 = p_sys->i_length; 
     224            *pi64 = (int64_t) p_sys->i_length; 
    224225            return VLC_SUCCESS; 
    225226 
    226227        case DEMUX_GET_TIME: 
    227228            pi64 = (int64_t*)va_arg( args, int64_t * ); 
    228             /*if( p_sys->i_current_subtitle < p_sys->i_subtitles ) 
    229             { 
    230                 *pi64 = p_sys->subtitle[p_sys->i_current_subtitle].i_start; 
     229            for( i = 0; i < p_sys->i_tracks; i++ ) 
     230            { 
     231                vlc_bool_t b_selected; 
     232                /* Check the ES is selected */ 
     233                es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, 
     234                                p_sys->track[i].p_es, &b_selected ); 
     235                if( b_selected ) break; 
     236            } 
     237            if( i < p_sys->i_tracks && p_sys->track[i].i_current_subtitle < p_sys->track[i].i_subtitles ) 
     238            { 
     239                *pi64 = p_sys->track[i].p_subtitles[p_sys->track[i].i_current_subtitle].i_start; 
    231240                return VLC_SUCCESS; 
    232             }*/ 
     241            } 
    233242            return VLC_EGENERIC; 
    234243 
    235244        case DEMUX_SET_TIME: 
    236245            i64 = (int64_t)va_arg( args, int64_t ); 
    237             /*p_sys->i_current_subtitle = 0; 
    238             while( p_sys->i_current_subtitle < p_sys->i_subtitles && 
    239                    p_sys->subtitle[p_sys->i_current_subtitle].i_start < i64 ) 
    240             { 
    241                 p_sys->i_current_subtitle++; 
    242             } 
    243  
    244             if( p_sys->i_current_subtitle >= p_sys->i_subtitles ) 
    245                 return VLC_EGENERIC;*/ 
     246            for( i = 0; i < p_sys->i_tracks; i++ ) 
     247            { 
     248                p_sys->track[i].i_current_subtitle = 0; 
     249                while( p_sys->track[i].i_current_subtitle < p_sys->track[i].i_subtitles && 
     250                       p_sys->track[i].p_subtitles[p_sys->track[i].i_current_subtitle].i_start < i64 ) 
     251                { 
     252                    p_sys->track[i].i_current_subtitle++; 
     253                } 
     254 
     255                if( p_sys->track[i].i_current_subtitle >= p_sys->track[i].i_subtitles ) 
     256                    return VLC_EGENERIC; 
     257            } 
    246258            return VLC_SUCCESS; 
    247259 
    248260        case DEMUX_GET_POSITION: 
    249261            pf = (double*)va_arg( args, double * ); 
    250             /*if( p_sys->i_current_subtitle >= p_sys->i_subtitles ) 
     262            for( i = 0; i < p_sys->i_tracks; i++ ) 
     263            { 
     264                vlc_bool_t b_selected; 
     265                /* Check the ES is selected */ 
     266                es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, 
     267                                p_sys->track[i].p_es, &b_selected ); 
     268                if( b_selected ) break; 
     269            } 
     270            if( p_sys->track[i].i_current_subtitle >= p_sys->track[i].i_subtitles ) 
    251271            { 
    252272                *pf = 1.0; 
    253273            } 
    254             else if( p_sys->i_subtitles > 0 ) 
    255             { 
    256                 *pf = (double)p_sys->subtitle[p_sys->i_current_subtitle].i_start / 
     274            else if( p_sys->track[i].i_subtitles > 0 ) 
     275            { 
     276                *pf = (double)p_sys->track[i].p_subtitles[p_sys->track[i].i_current_subtitle].i_start / 
    257277                      (double)p_sys->i_length; 
    258278            } 
     
    260280            { 
    261281                *pf = 0.0; 
    262             }*/ 
     282            } 
    263283            return VLC_SUCCESS; 
    264284 
    265285        case DEMUX_SET_POSITION: 
    266286            f = (double)va_arg( args, double ); 
    267             /*i64 = f * p_sys->i_length; 
    268  
    269             p_sys->i_current_subtitle = 0; 
    270             while( p_sys->i_current_subtitle < p_sys->i_subtitles && 
    271                    p_sys->subtitle[p_sys->i_current_subtitle].i_start < i64 ) 
    272             { 
    273                 p_sys->i_current_subtitle++; 
    274             } 
    275             if( p_sys->i_current_subtitle >= p_sys->i_subtitles ) 
    276                 return VLC_EGENERIC;*/ 
     287            i64 = (int64_t) f * p_sys->i_length; 
     288 
     289            for( i = 0; i < p_sys->i_tracks; i++ ) 
     290            { 
     291                p_sys->track[i].i_current_subtitle = 0; 
     292                while( p_sys->track[i].i_current_subtitle < p_sys->track[i].i_subtitles && 
     293                       p_sys->track[i].p_subtitles[p_sys->track[i].i_current_subtitle].i_start < i64 ) 
     294                { 
     295                    p_sys->track[i].i_current_subtitle++; 
     296                } 
     297                if( p_sys->track[i].i_current_subtitle >= p_sys->track[i].i_subtitles ) 
     298                    return VLC_EGENERIC; 
     299            } 
    277300            return VLC_SUCCESS; 
    278301 
     
    305328#define tk p_sys->track[i] 
    306329        if( tk.i_current_subtitle >= tk.i_subtitles ) 
    307             return 0
    308  
    309         i_maxdate = p_sys->i_next_demux_date; 
     330            continue
     331 
     332        i_maxdate = (int64_t) p_sys->i_next_demux_date; 
    310333        if( i_maxdate <= 0 && tk.i_current_subtitle < tk.i_subtitles ) 
    311334        { 
    312335            /* Should not happen */ 
    313             i_maxdate = tk.p_subtitles[tk.i_current_subtitle].i_start + 1; 
     336            i_maxdate = (int64_t) tk.p_subtitles[tk.i_current_subtitle].i_start + 1; 
    314337        } 
    315338 
     
    496519             * 
    497520             */ 
    498             unsigned int h, m, s, ms, loc; 
    499             int i_start, i_location = 0; 
     521            int h, m, s, ms, loc; 
     522            int64_t i_start, i_location = 0; 
    500523             
    501524            vobsub_track_t *current_tk = &p_sys->track[p_sys->i_tracks - 1]; 
     
    506529                subtitle_t *current_sub; 
    507530                 
    508                 i_start = ( (mtime_t)h * 3600*1000 + 
    509                             (mtime_t)m * 60*1000 + 
    510                             (mtime_t)s * 1000 + 
    511                             (mtime_t)ms ) * 1000; 
     531                i_start = (int64_t) ( h * 3600*1000 + 
     532                            m * 60*1000 + 
     533                            s * 1000 + 
     534                            ms ) * 1000; 
    512535                i_location = loc; 
    513536                 
     
    516539                current_sub = &current_tk->p_subtitles[current_tk->i_subtitles - 1]; 
    517540                 
    518                 current_sub->i_start = i_start; 
     541                current_sub->i_start = (int64_t) i_start; 
    519542                current_sub->i_vobsub_location = i_location; 
    520543            } 
     
    550573        if( p[3] != 0xbd ) 
    551574        { 
    552             msg_Dbg( p_demux, "we don't need these ps packets (id=0x1%2.2x)", p[3] ); 
     575            /* msg_Dbg( p_demux, "we don't need these ps packets (id=0x1%2.2x)", p[3] ); */ 
    553576            p += i_size; 
    554577            continue; 
     
    568591        } 
    569592        i_spu = i_id&0x1f; 
    570         msg_Dbg( p_demux, "SPU track %d size %d", i_spu, i_size ); 
    571  
    572         /* FIXME i_spu == determines which of the spu tracks we will show. */ 
     593        /* msg_Dbg( p_demux, "SPU track %d size %d", i_spu, i_size ); */ 
     594 
    573595        for( i = 0; i < p_sys->i_tracks; i++ ) 
    574596        {