Changeset 069f260a8179fa8f3462c121c6ff790300d321b0

Show
Ignore:
Timestamp:
22/08/08 17:57:59 (3 months ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1219420679 +0200
git-parent:

[b1cea0a301d6bc450edc0b8ec03c4af54f5d9e35]

git-author:
Laurent Aimar <fenrir@videolan.org> 1219420679 +0200
Message:

Fixed input slave reading of a52/dts/flac/m4a/mpga (close #1818).

Input slave method needs that PCR of master and slave input use the same origin.

Files:

Legend:

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

    re81f6fc r069f260  
    6767    decoder_t *p_packetizer; 
    6868 
     69    mtime_t i_pts; 
     70    mtime_t i_time_offset; 
     71 
    6972    int i_mux_rate; 
    7073    bool b_big_endian; 
     
    7477 
    7578#define PCM_FRAME_SIZE (1536 * 4) 
    76 #define A52_PACKET_SIZE (4 * PCM_FRAME_SIZE) 
     79#define A52_PACKET_SIZE (1024) 
     80#define A52_PEEK_SIZE (4 * PCM_FRAME_SIZE) 
    7781#define A52_PROBE_SIZE (512*1024) 
    7882#define A52_MAX_HEADER_SIZE 10 
     
    110114        /* Some A52 wav files don't begin with a sync code so we do a more 
    111115         * extensive search */ 
    112         int i_size = stream_Peek( p_demux->s, &p_peek, i_peek + A52_PACKET_SIZE * 2); 
     116        int i_size = stream_Peek( p_demux->s, &p_peek, i_peek + A52_PEEK_SIZE * 2); 
    113117        i_size -= (PCM_FRAME_SIZE + A52_MAX_HEADER_SIZE); 
    114118 
     
    151155    p_sys->i_mux_rate = 0; 
    152156    p_sys->b_big_endian = b_big_endian; 
     157    p_sys->i_pts = 0; 
     158    p_sys->i_time_offset = 0; 
    153159 
    154160    /* Load the A52 packetizer */ 
     
    234240                    p_block_out->i_buffer * INT64_C(1000000)/p_block_out->i_length; 
    235241            } 
     242            p_sys->i_pts = p_block_out->i_pts; 
     243 
     244            /* Correct timestamp */ 
     245            p_block_out->i_pts += p_sys->i_time_offset; 
     246            p_block_out->i_dts += p_sys->i_time_offset; 
    236247 
    237248            /* set PCR */ 
     
    253264{ 
    254265    demux_sys_t *p_sys  = p_demux->p_sys; 
    255     if( i_query == DEMUX_SET_TIME ) 
    256     { 
    257         return VLC_EGENERIC; 
    258     } 
    259     else if( i_query == DEMUX_HAS_UNSUPPORTED_META ) 
    260     { 
    261         bool *pb_bool = (bool*)va_arg( args, bool* ); 
     266    bool *pb_bool; 
     267    int64_t *pi64; 
     268    int i_ret; 
     269 
     270    switch( i_query ) 
     271    { 
     272    case DEMUX_HAS_UNSUPPORTED_META: 
     273        pb_bool = (bool*)va_arg( args, bool* ); 
    262274        *pb_bool = true; 
    263275        return VLC_SUCCESS; 
    264     } 
    265     else 
    266     { 
    267         return demux_vaControlHelper( p_demux->s, 
     276 
     277    case DEMUX_GET_TIME: 
     278        pi64 = (int64_t*)va_arg( args, int64_t * ); 
     279        *pi64 = p_sys->i_pts + p_sys->i_time_offset; 
     280        return VLC_SUCCESS; 
     281 
     282    case DEMUX_SET_TIME: /* TODO implement a high precicsion seek */ 
     283    default: 
     284        i_ret = demux_vaControlHelper( p_demux->s, 
    268285                                       0, -1, 
    269286                                       8*p_sys->i_mux_rate, 1, i_query, args ); 
     287        if( !i_ret && p_sys->i_mux_rate > 0 && 
     288            ( i_query == DEMUX_SET_POSITION || i_query == DEMUX_SET_TIME ) ) 
     289        { 
     290 
     291            const int64_t i_time = INT64_C(1000000) * stream_Tell(p_demux->s) / 
     292                                        p_sys->i_mux_rate; 
     293 
     294            /* Fix time_offset */ 
     295            if( i_time >= 0 ) 
     296                p_sys->i_time_offset = i_time - p_sys->i_pts; 
     297        } 
     298        return i_ret; 
    270299    } 
    271300} 
  • modules/demux/dts.c

    re81f6fc r069f260  
    6363    decoder_t *p_packetizer; 
    6464 
     65    mtime_t i_pts; 
     66    mtime_t i_time_offset; 
     67 
    6568    int i_mux_rate; 
    6669}; 
     
    157160 
    158161    DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys; 
     162    p_sys->i_mux_rate = 0; 
     163    p_sys->i_pts = 0; 
     164    p_sys->i_time_offset = 0; 
    159165  
    160166    INIT_APACKETIZER( p_sys->p_packetizer, 'd','t','s',' ' ); 
     
    215221            } 
    216222 
     223            /* Correct timestamp */ 
     224            p_block_out->i_pts += p_sys->i_time_offset; 
     225            p_block_out->i_dts += p_sys->i_time_offset; 
     226 
    217227            /* set PCR */ 
    218228            es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts ); 
     
    233243{ 
    234244    demux_sys_t *p_sys  = p_demux->p_sys; 
    235     if( i_query == DEMUX_SET_TIME ) 
    236         return VLC_EGENERIC; 
    237     else 
    238         return demux_vaControlHelper( p_demux->s, 
     245    bool *pb_bool; 
     246    int64_t *pi64; 
     247    int i_ret; 
     248 
     249    switch( i_query ) 
     250    { 
     251    case DEMUX_HAS_UNSUPPORTED_META: 
     252        pb_bool = (bool*)va_arg( args, bool* ); 
     253        *pb_bool = true; 
     254        return VLC_SUCCESS; 
     255 
     256    case DEMUX_GET_TIME: 
     257        pi64 = (int64_t*)va_arg( args, int64_t * ); 
     258        *pi64 = p_sys->i_pts + p_sys->i_time_offset; 
     259        return VLC_SUCCESS; 
     260 
     261    case DEMUX_SET_TIME: /* TODO implement a high precicsion seek */ 
     262    default: 
     263        i_ret = demux_vaControlHelper( p_demux->s, 
    239264                                       0, -1, 
    240265                                       8*p_sys->i_mux_rate, 1, i_query, args ); 
     266        if( !i_ret && p_sys->i_mux_rate > 0 && 
     267            ( i_query == DEMUX_SET_POSITION || i_query == DEMUX_SET_TIME ) ) 
     268        { 
     269 
     270            const int64_t i_time = INT64_C(1000000) * stream_Tell(p_demux->s) / 
     271                                        p_sys->i_mux_rate; 
     272 
     273            /* Fix time_offset */ 
     274            if( i_time >= 0 ) 
     275                p_sys->i_time_offset = i_time - p_sys->i_pts; 
     276        } 
     277        return i_ret; 
     278    } 
    241279} 
    242280 
  • modules/demux/flac.c

    r2e4d57c r069f260  
    231231            } 
    232232 
     233            p_sys->i_pts = p_block_out->i_dts; 
     234 
     235            /* Correct timestamp */ 
     236            p_block_out->i_pts += p_sys->i_time_offset; 
     237            p_block_out->i_dts += p_sys->i_time_offset; 
     238 
    233239            /* set PCR */ 
    234             if( p_block_out->i_dts >= p_sys->i_pts_start
     240            if( p_block_out->i_dts >= p_sys->i_pts_start + p_sys->i_time_offset
    235241                es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts ); 
    236242            else 
    237243                es_out_Control( p_demux->out, ES_OUT_RESET_PCR ); 
    238244 
    239             p_sys->i_pts = p_block_out->i_dts; 
    240245            es_out_Send( p_demux->out, p_sys->p_es, p_block_out ); 
    241246 
     
    310315        p_sys->i_time_offset = p_sys->seekpoint[i]->i_time_offset - p_sys->i_pts; 
    311316        p_sys->i_pts_start = p_sys->i_pts+i_delta_time; 
    312         es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, p_sys->p_es, p_sys->i_pts_start ); 
     317        es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, p_sys->p_es, p_sys->i_pts_start + p_sys->i_time_offset ); 
    313318    } 
    314319    else 
  • modules/demux/mpeg/m4a.c

    r3561b9b r069f260  
    161161            } 
    162162 
    163             es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts ); 
    164  
    165             p_block_out->p_next = NULL; 
    166  
    167163            p_sys->i_pts = p_block_out->i_pts; 
    168164            if( p_sys->i_pts > M4A_PTS_START + INT64_C(500000) ) 
     
    171167 
    172168            p_sys->i_bytes += p_block_out->i_buffer; 
     169 
     170            /* Correct timestamp */ 
     171            p_block_out->i_pts += p_sys->i_time_offset; 
     172            p_block_out->i_dts += p_sys->i_time_offset; 
     173 
     174            /* */ 
     175            es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts ); 
     176 
    173177            es_out_Send( p_demux->out, p_sys->p_es, p_block_out ); 
    174178 
  • modules/demux/mpeg/mpga.c

    r1035469 r069f260  
    304304            block_t *p_next = p_block_out->p_next; 
    305305 
     306            p_sys->i_pts = p_block_out->i_pts; 
     307 
     308            /* Correct timestamp */ 
     309            p_block_out->i_pts += p_sys->i_time_offset; 
     310            p_block_out->i_dts += p_sys->i_time_offset; 
     311 
    306312            es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts ); 
    307313 
    308             p_block_out->p_next = NULL; 
    309             p_sys->i_pts = p_block_out->i_pts; 
    310314            es_out_Send( p_demux->out, p_sys->p_es, p_block_out ); 
    311315 
     
    394398 
    395399                /* Fix time_offset */ 
    396                 if( i_time >= 0 ) p_sys->i_time_offset = i_time - p_sys->i_pts; 
     400                if( i_time >= 0 ) 
     401                    p_sys->i_time_offset = i_time - p_sys->i_pts; 
    397402            } 
    398403            return i_ret;