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}