Changeset e695e7d80ebe2420542e14dfd7894222e449d88b

Show
Ignore:
Timestamp:
02/04/04 15:18:32 (5 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1080911912 +0000
git-parent:

[d9259f2f2e86a0338c91c31d35fc0ad6983ca724]

git-author:
Laurent Aimar <fenrir@videolan.org> 1080911912 +0000
Message:
  • rawdv.c: demux -> demux2. (Untested so may be broken)
Files:

Legend:

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

    r070b6a3 re695e7d  
    22 * rawdv.c : raw dv input module for vlc 
    33 ***************************************************************************** 
    4  * Copyright (C) 2001-2003 VideoLAN 
    5  * $Id: rawdv.c,v 1.15 2004/02/29 19:01:22 gbazin Exp
     4 * Copyright (C) 2001-2004 VideoLAN 
     5 * $Id
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    3636static void Close( vlc_object_t * ); 
    3737 
    38 static block_t *dv_extract_audio( input_thread_t * p_input, 
    39                                   block_t* p_frame_block ); 
    40  
    4138vlc_module_begin(); 
    4239    set_description( _("raw dv demuxer") ); 
    43     set_capability( "demux", 2 ); 
     40    set_capability( "demux2", 2 ); 
    4441    set_callbacks( Open, Close ); 
    4542    add_shortcut( "rawdv" ); 
     
    110107 * Local prototypes 
    111108 *****************************************************************************/ 
    112 static int  Demux     ( input_thread_t * ); 
     109static int Demux( demux_t * ); 
     110static int Control( demux_t *, int i_query, va_list args ); 
     111 
     112static block_t *dv_extract_audio( demux_t *p_demux, 
     113                                  block_t* p_frame_block ); 
    113114 
    114115/***************************************************************************** 
     
    117118static int Open( vlc_object_t * p_this ) 
    118119{ 
    119     input_thread_t *p_input = (input_thread_t *)p_this; 
    120     demux_sys_t    *p_sys; 
    121  
    122     byte_t         *p_peek, *p_peek_backup; 
    123  
    124     uint32_t       i_dword; 
    125     dv_header_t    dv_header; 
    126     dv_id_t        dv_id; 
    127     char           *psz_ext; 
     120    demux_t     *p_demux = (demux_t*)p_this; 
     121    demux_sys_t *p_sys; 
     122 
     123    byte_t      *p_peek, *p_peek_backup; 
     124 
     125    uint32_t    i_dword; 
     126    dv_header_t dv_header; 
     127    dv_id_t     dv_id; 
     128    char        *psz_ext; 
    128129 
    129130    /* It isn't easy to recognize a raw dv stream. The chances that we'll 
     
    133134 
    134135    /* Check for dv file extension */ 
    135     psz_ext = strrchr ( p_input->psz_name, '.' ); 
    136     if( ( !psz_ext || strcasecmp( psz_ext, ".dv") )&& 
    137         ( !p_input->psz_demux || strcmp(p_input->psz_demux, "rawdv") ) ) 
     136    psz_ext = strrchr( p_demux->psz_path, '.' ); 
     137    if( ( !psz_ext || strcasecmp( psz_ext, ".dv") ) && 
     138        strcmp(p_demux->psz_demux, "rawdv") ) 
    138139    { 
    139140        return VLC_EGENERIC; 
    140141    } 
    141142 
    142     if( stream_Peek( p_input->s, &p_peek, DV_PAL_FRAME_SIZE ) < 
     143    if( stream_Peek( p_demux->s, &p_peek, DV_PAL_FRAME_SIZE ) < 
    143144        DV_NTSC_FRAME_SIZE ) 
    144145    { 
    145146        /* Stream too short ... */ 
    146         msg_Err( p_input, "cannot peek()" ); 
     147        msg_Err( p_demux, "cannot peek()" ); 
    147148        return VLC_EGENERIC; 
    148149    } 
     
    162163    if( dv_id.sct != 0 ) 
    163164    { 
    164         msg_Warn( p_input, "not a raw dv stream header" ); 
     165        msg_Warn( p_demux, "not a raw dv stream header" ); 
    165166        return VLC_EGENERIC; 
    166167    } 
     
    171172    if( i_dword >> (32 - 1) ) /* incorrect bit */ 
    172173    { 
    173         msg_Warn( p_input, "incorrect bit" ); 
     174        msg_Warn( p_demux, "incorrect bit" ); 
    174175        return VLC_EGENERIC; 
    175176    } 
     
    195196 
    196197    /* Set p_input field */ 
    197     p_input->pf_demux = Demux; 
    198     p_input->pf_demux_control = demux_vaControlDefault
    199     p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) ); 
     198    p_demux->pf_demux  = Demux; 
     199    p_demux->pf_control = Control
     200    p_demux->p_sys      = p_sys = malloc( sizeof( demux_sys_t ) ); 
    200201 
    201202    p_sys->i_dsf = dv_header.dsf; 
     
    213214    p_sys->fmt_video.video.i_height= dv_header.dsf ? 576 : 480;; 
    214215 
     216    /* FIXME FIXME */ 
     217#if 0 
    215218    /* necessary because input_SplitBuffer() will only get 
    216219     * INPUT_DEFAULT_BUFSIZE bytes at a time. */ 
    217220    p_input->i_bufsize = p_sys->frame_size; 
    218  
    219     vlc_mutex_lock( &p_input->stream.stream_lock ); 
    220     if( input_InitStream( p_input, 0 ) == -1) 
    221     { 
    222         vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    223         msg_Err( p_input, "cannot init stream" ); 
    224         free( p_sys ); 
    225         return VLC_EGENERIC; 
    226     } 
    227     p_input->stream.i_mux_rate = p_sys->frame_size * p_sys->f_rate; 
    228     vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    229  
    230     p_sys->p_es_video = es_out_Add( p_input->p_es_out, &p_sys->fmt_video ); 
     221#endif 
     222 
     223    p_sys->p_es_video = es_out_Add( p_demux->out, &p_sys->fmt_video ); 
    231224 
    232225    /* Audio stuff */ 
     
    255248        p_sys->fmt_audio.audio.i_bitspersample = 16; 
    256249 
    257         p_sys->p_es_audio = es_out_Add( p_input->p_es_out, &p_sys->fmt_audio ); 
     250        p_sys->p_es_audio = es_out_Add( p_demux->out, &p_sys->fmt_audio ); 
    258251    } 
    259252 
     
    266259static void Close( vlc_object_t *p_this ) 
    267260{ 
    268     input_thread_t *p_input = (input_thread_t *)p_this; 
    269     demux_sys_t    *p_sys = p_input->p_demux_data
     261    demux_t     *p_demux = (demux_t*)p_this; 
     262    demux_sys_t *p_sys  = p_demux->p_sys
    270263 
    271264    free( p_sys ); 
     
    277270 * Returns -1 in case of error, 0 in case of EOF, 1 otherwise 
    278271 *****************************************************************************/ 
    279 static int Demux( input_thread_t * p_input ) 
    280 
    281     demux_sys_t    *p_sys = p_input->p_demux_data; 
    282     block_t        *p_block; 
    283     vlc_bool_t     b_audio = VLC_FALSE, b_video = VLC_FALSE; 
    284  
    285     if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT ) 
    286     { 
    287         off_t i_pos = stream_Tell( p_input->s ); 
    288  
    289         msg_Warn( p_input, "synchro reinit" ); 
    290  
    291         /* If the user tried to seek in the stream, we need to make sure 
    292          * the new position is at a DIF block boundary. */ 
    293         if( i_pos % p_sys->frame_size > 0 ) 
    294         { 
    295             i_pos += p_sys->frame_size - i_pos % p_sys->frame_size; 
    296  
    297             if( stream_Seek( p_input->s, i_pos ) ) 
    298             { 
    299                 msg_Warn( p_input, "cannot resynch after seek (EOF?)" ); 
    300                 return -1; 
    301             } 
    302         } 
    303     } 
     272static int Demux( demux_t *p_demux ) 
     273
     274    demux_sys_t *p_sys  = p_demux->p_sys; 
     275    block_t     *p_block; 
     276    vlc_bool_t  b_audio = VLC_FALSE; 
    304277 
    305278    /* Call the pace control */ 
    306     input_ClockManageRef( p_input, p_input->stream.p_selected_program, 
    307                           p_sys->i_pcr ); 
    308  
    309     if( ( p_block = stream_Block( p_input->s, p_sys->frame_size ) ) == NULL ) 
     279    es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pcr ); 
     280 
     281    if( ( p_block = stream_Block( p_demux->s, p_sys->frame_size ) ) == NULL ) 
    310282    { 
    311283        /* EOF */ 
     
    313285    } 
    314286 
    315     es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, 
    316                     p_sys->p_es_video, &b_video ); 
    317  
    318287    if( p_sys->p_es_audio ) 
    319288    { 
    320         es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, 
     289        es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE, 
    321290                        p_sys->p_es_audio, &b_audio ); 
    322291    } 
    323292 
    324293    p_block->i_dts = 
    325     p_block->i_pts = input_ClockGetTS( p_input, 
    326                                        p_input->stream.p_selected_program, 
    327                                        p_sys->i_pcr ); 
     294    p_block->i_pts = p_sys->i_pcr; 
     295 
    328296    if( b_audio ) 
    329297    { 
    330         block_t *p_audio_block = dv_extract_audio( p_input, p_block ); 
     298        block_t *p_audio_block = dv_extract_audio( p_demux, p_block ); 
    331299        if( p_audio_block ) 
    332300        { 
    333             p_audio_block->i_pts = p_audio_block->i_dts = p_block->i_dts; 
    334             es_out_Send( p_input->p_es_out, p_sys->p_es_audio, p_audio_block ); 
     301            p_audio_block->i_pts = 
     302            p_audio_block->i_dts = p_sys->i_pcr; 
     303            es_out_Send( p_demux->out, p_sys->p_es_audio, p_audio_block ); 
    335304        } 
    336305    } 
    337306 
    338     if( b_video ) 
    339         es_out_Send( p_input->p_es_out, p_sys->p_es_video, p_block ); 
    340     else 
    341         block_Release( p_block ); 
    342  
    343     p_sys->i_pcr += ( 90000 / p_sys->f_rate ); 
     307    es_out_Send( p_demux->out, p_sys->p_es_video, p_block ); 
     308 
     309    p_sys->i_pcr += ( I64C(1000000) / p_sys->f_rate ); 
    344310 
    345311    return 1; 
     312} 
     313 
     314/***************************************************************************** 
     315 * Control: 
     316 *****************************************************************************/ 
     317static int Control( demux_t *p_demux, int i_query, va_list args ) 
     318{ 
     319    demux_sys_t *p_sys  = p_demux->p_sys; 
     320 
     321    /* XXX: DEMUX_SET_TIME is precise here */ 
     322    return demux2_vaControlHelper( p_demux->s, 
     323                                   0, -1, 
     324                                   p_sys->frame_size * p_sys->f_rate * 8, 
     325                                   p_sys->frame_size, i_query, args ); 
    346326} 
    347327 
     
    352332  { 18, 48, 78,  8, 38, 68, 28, 58, 88 }, 
    353333  { 24, 54, 84, 14, 44, 74,  4, 34, 64 }, 
    354    
     334 
    355335  {  1, 31, 61, 21, 51, 81, 11, 41, 71 }, /* 2nd channel */ 
    356336  {  7, 37, 67, 27, 57, 87, 17, 47, 77 }, 
     
    365345  {  12,  48,  84,   2,  38,  74,  28,  64, 100}, 
    366346  {  18,  54,  90,   8,  44,  80,  34,  70, 106}, 
    367   {  24,  60,  96,  14,  50,  86,   4,  40,  76},   
     347  {  24,  60,  96,  14,  50,  86,   4,  40,  76}, 
    368348  {  30,  66, 102,  20,  56,  92,  10,  46,  82}, 
    369      
     349 
    370350  {   1,  37,  73,  27,  63,  99,  17,  53,  89}, /* 2nd channel */ 
    371351  {   7,  43,  79,  33,  69, 105,  23,  59,  95}, 
    372352  {  13,  49,  85,   3,  39,  75,  29,  65, 101}, 
    373353  {  19,  55,  91,   9,  45,  81,  35,  71, 107}, 
    374   {  25,  61,  97,  15,  51,  87,   5,  41,  77},   
     354  {  25,  61,  97,  15,  51,  87,   5,  41,  77}, 
    375355  {  31,  67, 103,  21,  57,  93,  11,  47,  83}, 
    376356}; 
     
    379359{ 
    380360    uint16_t shift, result; 
    381      
     361 
    382362    sample = (sample < 0x800) ? sample : sample | 0xf000; 
    383363    shift = (sample & 0xf00) >> 8; 
     
    396376} 
    397377 
    398 static block_t *dv_extract_audio( input_thread_t * p_input
     378static block_t *dv_extract_audio( demux_t *p_demux
    399379                                  block_t* p_frame_block ) 
    400380{ 
    401     demux_sys_t *p_sys = p_input->p_demux_data
     381    demux_sys_t *p_sys = p_demux->p_sys
    402382    block_t *p_block; 
    403383    uint8_t *p_frame, *p_buf; 
     
    414394    if( i_audio_quant > 1 ) 
    415395    { 
    416         msg_Dbg( p_input, "Unsupported quantization for DV audio"); 
     396        msg_Dbg( p_demux, "Unsupported quantization for DV audio"); 
    417397        return NULL; 
    418398    } 
     
    434414    i_size = (i_size + i_samples) * 4; /* 2ch, 2bytes */ 
    435415 
    436     p_block = block_New( p_input, i_size ); 
     416    p_block = block_New( p_demux, i_size ); 
    437417 
    438418    /* for each DIF segment */ 
     
    490470    return p_block; 
    491471} 
     472 
     473