X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Frawdv.c;h=527056d7daaeacd36c1d176d6928cf8087e587dd;hb=0ce4275a7ebf06fa68187161eb581f8993e0060d;hp=5ddd56096a847528692877f6fc4e98fc0bc51c3c;hpb=fe087a38282e93addb25fa9598393e40ea233b09;p=vlc diff --git a/modules/demux/rawdv.c b/modules/demux/rawdv.c index 5ddd56096a..527056d7da 100644 --- a/modules/demux/rawdv.c +++ b/modules/demux/rawdv.c @@ -1,10 +1,11 @@ /***************************************************************************** * rawdv.c : raw DV input module for vlc ***************************************************************************** - * Copyright (C) 2001-2004 the VideoLAN team + * Copyright (C) 2001-2007 the VideoLAN team * $Id$ * * Authors: Gildas Bazin + * Paul Corke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,31 +19,41 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include /***************************************************************************** * Module descriptor *****************************************************************************/ +#define HURRYUP_TEXT N_( "Hurry up" ) +#define HURRYUP_LONGTEXT N_( "The demuxer will advance timestamps if the " \ + "input can't keep up with the rate." ) + static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); -vlc_module_begin(); - set_description( _("raw DV demuxer") ); - set_capability( "demux2", 2 ); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_DEMUX ); - set_callbacks( Open, Close ); - add_shortcut( "rawdv" ); -vlc_module_end(); +vlc_module_begin () + set_shortname( "DV" ) + set_description( N_("DV (Digital Video) demuxer") ) + set_capability( "demux", 3 ) + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_DEMUX ) + add_bool( "rawdv-hurry-up", 0, NULL, HURRYUP_TEXT, HURRYUP_LONGTEXT, false ) + set_callbacks( Open, Close ) + add_shortcut( "rawdv" ) +vlc_module_end () /***************************************************************************** @@ -103,6 +114,7 @@ struct demux_sys_t /* program clock reference (in units of 90kHz) */ mtime_t i_pcr; + bool b_hurry_up; }; /***************************************************************************** @@ -122,12 +134,11 @@ static int Open( vlc_object_t * p_this ) demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; - byte_t *p_peek, *p_peek_backup; + const uint8_t *p_peek, *p_peek_backup; uint32_t i_dword; dv_header_t dv_header; dv_id_t dv_id; - char *psz_ext; /* It isn't easy to recognize a raw DV stream. The chances that we'll * mistake a stream from another type for a raw DV stream are too high, so @@ -135,12 +146,8 @@ static int Open( vlc_object_t * p_this ) * it is possible to force this demux. */ /* Check for DV file extension */ - psz_ext = strrchr( p_demux->psz_path, '.' ); - if( ( !psz_ext || strcasecmp( psz_ext, ".dv") ) && - strcmp(p_demux->psz_demux, "rawdv") ) - { + if( !demux_IsPathExtension( p_demux, ".dv" ) && !p_demux->b_force ) return VLC_EGENERIC; - } if( stream_Peek( p_demux->s, &p_peek, DV_PAL_FRAME_SIZE ) < DV_NTSC_FRAME_SIZE ) @@ -195,11 +202,15 @@ static int Open( vlc_object_t * p_this ) p_peek += 72; /* skip rest of DIF block */ - /* Set p_input field */ p_demux->pf_demux = Demux; p_demux->pf_control = Control; p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); + if( !p_sys ) + return VLC_ENOMEM; + + p_sys->b_hurry_up = var_CreateGetBool( p_demux, "rawdv-hurry-up" ); + msg_Dbg( p_demux, "Realtime DV Source: %s", (p_sys->b_hurry_up)?"Yes":"No" ); p_sys->i_dsf = dv_header.dsf; p_sys->frame_size = dv_header.dsf ? 12 * 150 * 80 : 10 * 150 * 80; @@ -211,7 +222,7 @@ static int Open( vlc_object_t * p_this ) p_sys->i_bitrate = 0; - es_format_Init( &p_sys->fmt_video, VIDEO_ES, VLC_FOURCC('d','v','s','d') ); + es_format_Init( &p_sys->fmt_video, VIDEO_ES, VLC_CODEC_DV ); p_sys->fmt_video.video.i_width = 720; p_sys->fmt_video.video.i_height= dv_header.dsf ? 576 : 480;; @@ -228,9 +239,10 @@ static int Open( vlc_object_t * p_this ) p_peek = p_peek_backup + 80*6+80*16*3 + 3; /* beginning of AAUX pack */ if( *p_peek == 0x50 ) { - es_format_Init( &p_sys->fmt_audio, AUDIO_ES, - VLC_FOURCC('a','r','a','w') ); + /* 12 bits non-linear will be converted to 16 bits linear */ + es_format_Init( &p_sys->fmt_audio, AUDIO_ES, VLC_CODEC_S16L ); + p_sys->fmt_audio.audio.i_bitspersample = 16; p_sys->fmt_audio.audio.i_channels = 2; switch( (p_peek[4] >> 3) & 0x07 ) { @@ -246,9 +258,6 @@ static int Open( vlc_object_t * p_this ) break; } - /* 12 bits non-linear will be converted to 16 bits linear */ - p_sys->fmt_audio.audio.i_bitspersample = 16; - p_sys->p_es_audio = es_out_Add( p_demux->out, &p_sys->fmt_audio ); } @@ -263,6 +272,7 @@ static void Close( vlc_object_t *p_this ) demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys = p_demux->p_sys; + var_Destroy( p_demux, "rawdv-hurry-up"); free( p_sys ); } @@ -275,12 +285,18 @@ static int Demux( demux_t *p_demux ) { demux_sys_t *p_sys = p_demux->p_sys; block_t *p_block; - vlc_bool_t b_audio = VLC_FALSE; + bool b_audio = false; + + if( p_sys->b_hurry_up ) + { + /* 3 frames */ + p_sys->i_pcr = mdate() + (p_sys->i_dsf ? 120000 : 90000); + } /* Call the pace control */ es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pcr ); - - if( ( p_block = stream_Block( p_demux->s, p_sys->frame_size ) ) == NULL ) + p_block = stream_Block( p_demux->s, p_sys->frame_size ); + if( p_block == NULL ) { /* EOF */ return 0; @@ -308,7 +324,10 @@ static int Demux( demux_t *p_demux ) es_out_Send( p_demux->out, p_sys->p_es_video, p_block ); - p_sys->i_pcr += ( I64C(1000000) / p_sys->f_rate ); + if( !p_sys->b_hurry_up ) + { + p_sys->i_pcr += ( INT64_C(1000000) / p_sys->f_rate ); + } return 1; } @@ -321,7 +340,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) demux_sys_t *p_sys = p_demux->p_sys; /* XXX: DEMUX_SET_TIME is precise here */ - return demux2_vaControlHelper( p_demux->s, + return demux_vaControlHelper( p_demux->s, 0, -1, p_sys->frame_size * p_sys->f_rate * 8, p_sys->frame_size, i_query, args ); @@ -395,7 +414,7 @@ static block_t *dv_extract_audio( demux_t *p_demux, i_audio_quant = p_buf[4] & 0x07; /* 0 - 16bit, 1 - 12bit */ if( i_audio_quant > 1 ) { - msg_Dbg( p_demux, "Unsupported quantization for DV audio"); + msg_Dbg( p_demux, "unsupported quantization for DV audio"); return NULL; } @@ -450,7 +469,7 @@ static block_t *dv_extract_audio( demux_t *p_demux, else { /* 12bit quantization */ - lc = ((uint16_t)p_frame[d] << 4) | + lc = ((uint16_t)p_frame[d] << 4) | ((uint16_t)p_frame[d+2] >> 4); lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc)); @@ -471,5 +490,3 @@ static block_t *dv_extract_audio( demux_t *p_demux, return p_block; } - -