Commit fb38d422 authored by Gildas Bazin's avatar Gildas Bazin

* modules/demux/rawdv.c: added support for DV audio now that ffmpeg can
   decode this.
* modules/codec/ffmpeg/ffmpeg.h, modules/codec/ffmpeg/ffmpeg.c: added the
   necessary fourcc for DV audio.
parent 9f975d14
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library * ffmpeg.c: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.23 2003/02/08 19:10:21 massiot Exp $ * $Id: ffmpeg.c,v 1.24 2003/02/18 19:42:57 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -513,11 +513,21 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc, ...@@ -513,11 +513,21 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
case FOURCC_dvsd: case FOURCC_dvsd:
case FOURCC_DVSD: case FOURCC_DVSD:
case FOURCC_dvhd: case FOURCC_dvhd:
case FOURCC_dvc:
case FOURCC_dvp:
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec = CODEC_ID_DVVIDEO; i_codec = CODEC_ID_DVVIDEO;
psz_name = "DV video"; psz_name = "DV video";
break; break;
#if LIBAVCODEC_BUILD >= 4655
case FOURCC_dvau:
i_cat = AUDIO_ES;
i_codec = CODEC_ID_DVAUDIO;
psz_name = "DV audio";
break;
#endif
#if LIBAVCODEC_BUILD >= 4632 #if LIBAVCODEC_BUILD >= 4632
case FOURCC_WMA1: case FOURCC_WMA1:
case FOURCC_wma1: case FOURCC_wma1:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg_vdec.h: video decoder using ffmpeg library * ffmpeg_vdec.h: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: ffmpeg.h,v 1.11 2002/12/10 10:22:04 fenrir Exp $ * $Id: ffmpeg.h,v 1.12 2003/02/18 19:42:57 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -142,6 +142,8 @@ int E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes ); ...@@ -142,6 +142,8 @@ int E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes );
#define FOURCC_dvsd VLC_FOURCC('d','v','s','d') #define FOURCC_dvsd VLC_FOURCC('d','v','s','d')
#define FOURCC_DVSD VLC_FOURCC('D','V','S','D') #define FOURCC_DVSD VLC_FOURCC('D','V','S','D')
#define FOURCC_dvhd VLC_FOURCC('d','v','h','d') #define FOURCC_dvhd VLC_FOURCC('d','v','h','d')
#define FOURCC_dvc VLC_FOURCC('d','v','c',' ')
#define FOURCC_dvp VLC_FOURCC('d','v','p',' ')
/***************************************************************************** /*****************************************************************************
* Audio codec fourcc * Audio codec fourcc
...@@ -150,4 +152,5 @@ int E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes ); ...@@ -150,4 +152,5 @@ int E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes );
#define FOURCC_wma1 VLC_FOURCC('w','m','a','1') #define FOURCC_wma1 VLC_FOURCC('w','m','a','1')
#define FOURCC_WMA2 VLC_FOURCC('W','M','A','2') #define FOURCC_WMA2 VLC_FOURCC('W','M','A','2')
#define FOURCC_wma2 VLC_FOURCC('w','m','a','2') #define FOURCC_wma2 VLC_FOURCC('w','m','a','2')
#define FOURCC_dvau VLC_FOURCC('d','v','a','u')
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* rawdv.c : raw dv input module for vlc * rawdv.c : raw dv input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: rawdv.c,v 1.3 2003/01/23 09:00:36 fenrir Exp $ * $Id: rawdv.c,v 1.4 2003/02/18 19:42:57 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -86,6 +86,7 @@ struct demux_sys_t ...@@ -86,6 +86,7 @@ struct demux_sys_t
/* codec specific stuff */ /* codec specific stuff */
BITMAPINFOHEADER *p_bih; BITMAPINFOHEADER *p_bih;
WAVEFORMATEX *p_wf;
double f_rate; double f_rate;
int i_bitrate; int i_bitrate;
...@@ -123,7 +124,7 @@ vlc_module_end(); ...@@ -123,7 +124,7 @@ vlc_module_end();
static int Activate( vlc_object_t * p_this ) static int Activate( vlc_object_t * p_this )
{ {
input_thread_t *p_input = (input_thread_t *)p_this; input_thread_t *p_input = (input_thread_t *)p_this;
byte_t *p_peek; byte_t *p_peek, *p_peek_backup;
uint32_t i_dword; uint32_t i_dword;
demux_sys_t *p_rawdv; demux_sys_t *p_rawdv;
dv_header_t dv_header; dv_header_t dv_header;
...@@ -152,6 +153,7 @@ static int Activate( vlc_object_t * p_this ) ...@@ -152,6 +153,7 @@ static int Activate( vlc_object_t * p_this )
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return -1; return -1;
} }
p_peek_backup = p_peek;
/* fill in the dv_id_t structure */ /* fill in the dv_id_t structure */
i_dword = GetDWBE( p_peek ); p_peek += 4; i_dword = GetDWBE( p_peek ); p_peek += 4;
...@@ -206,6 +208,7 @@ static int Activate( vlc_object_t * p_this ) ...@@ -206,6 +208,7 @@ static int Activate( vlc_object_t * p_this )
} }
memset( p_rawdv, 0, sizeof( demux_sys_t ) ); memset( p_rawdv, 0, sizeof( demux_sys_t ) );
p_rawdv->p_bih = NULL; p_rawdv->p_bih = NULL;
p_rawdv->p_wf = NULL;
p_input->p_demux_data = p_rawdv; p_input->p_demux_data = p_rawdv;
p_rawdv->p_bih = (BITMAPINFOHEADER *) malloc( sizeof(BITMAPINFOHEADER) ); p_rawdv->p_bih = (BITMAPINFOHEADER *) malloc( sizeof(BITMAPINFOHEADER) );
...@@ -237,6 +240,32 @@ static int Activate( vlc_object_t * p_this ) ...@@ -237,6 +240,32 @@ static int Activate( vlc_object_t * p_this )
p_rawdv->f_rate = 29.97; p_rawdv->f_rate = 29.97;
} }
/* Audio stuff */
#if 0
p_peek = p_peek_backup + 80*6+80*16*3 + 3; /* beginning of AAUX pack */
if( *p_peek != 0x50 || *p_peek != 0x51 )
{
msg_Err( p_input, "AAUX should begin with 0x50" );
}
#endif
p_rawdv->p_wf = (WAVEFORMATEX *)malloc( sizeof(WAVEFORMATEX) );
if( !p_rawdv->p_wf )
{
msg_Err( p_input, "out of memory" );
goto error;
}
p_rawdv->p_wf->wFormatTag = 0;
p_rawdv->p_wf->nChannels = 2;
p_rawdv->p_wf->nSamplesPerSec = 44100; /* FIXME */
p_rawdv->p_wf->nAvgBytesPerSec = p_rawdv->f_rate * p_rawdv->frame_size;
p_rawdv->p_wf->nBlockAlign = p_rawdv->frame_size;
p_rawdv->p_wf->wBitsPerSample = 16;
p_rawdv->p_wf->cbSize = 0;
/* necessary because input_SplitBuffer() will only get /* necessary because input_SplitBuffer() will only get
* INPUT_DEFAULT_BUFSIZE bytes at a time. */ * INPUT_DEFAULT_BUFSIZE bytes at a time. */
p_input->i_bufsize = p_rawdv->frame_size; p_input->i_bufsize = p_rawdv->frame_size;
...@@ -271,6 +300,18 @@ static int Activate( vlc_object_t * p_this ) ...@@ -271,6 +300,18 @@ static int Activate( vlc_object_t * p_this )
input_SelectES( p_input, p_rawdv->p_video_es ); input_SelectES( p_input, p_rawdv->p_video_es );
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
/* Add audio stream */
vlc_mutex_lock( &p_input->stream.stream_lock );
p_rawdv->p_audio_es = input_AddES( p_input,
p_input->stream.p_selected_program,
2, 0 );
p_rawdv->p_audio_es->i_stream_id = 1;
p_rawdv->p_audio_es->i_fourcc = VLC_FOURCC( 'd','v','a','u' );
p_rawdv->p_audio_es->i_cat = AUDIO_ES;
p_rawdv->p_audio_es->p_waveformatex = (void *)p_rawdv->p_wf;
input_SelectES( p_input, p_rawdv->p_audio_es );
vlc_mutex_unlock( &p_input->stream.stream_lock );
/* Init pcr */ /* Init pcr */
p_rawdv->i_pcr = 0; p_rawdv->i_pcr = 0;
...@@ -278,6 +319,7 @@ static int Activate( vlc_object_t * p_this ) ...@@ -278,6 +319,7 @@ static int Activate( vlc_object_t * p_this )
error: error:
if( p_rawdv->p_bih ) free( p_rawdv->p_bih ); if( p_rawdv->p_bih ) free( p_rawdv->p_bih );
if( p_rawdv->p_wf ) free( p_rawdv->p_wf );
Deactivate( (vlc_object_t *)p_input ); Deactivate( (vlc_object_t *)p_input );
return -1; return -1;
} }
...@@ -301,17 +343,11 @@ static void Deactivate( vlc_object_t *p_this ) ...@@ -301,17 +343,11 @@ static void Deactivate( vlc_object_t *p_this )
static int Demux( input_thread_t * p_input ) static int Demux( input_thread_t * p_input )
{ {
demux_sys_t *p_rawdv = (demux_sys_t *)p_input->p_demux_data; demux_sys_t *p_rawdv = (demux_sys_t *)p_input->p_demux_data;
decoder_fifo_t *p_fifo =
p_input->stream.p_selected_program->pp_es[0]->p_decoder_fifo;
pes_packet_t *p_pes; pes_packet_t *p_pes;
pes_packet_t *p_audio_pes;
data_packet_t *p_data; data_packet_t *p_data;
ssize_t i_read; ssize_t i_read;
if( p_fifo == NULL )
{
return -1;
}
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT ) if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{ {
off_t i_pos; off_t i_pos;
...@@ -344,6 +380,7 @@ static int Demux( input_thread_t * p_input ) ...@@ -344,6 +380,7 @@ static int Demux( input_thread_t * p_input )
return i_read; return i_read;
} }
/* Build video PES packet */
p_pes = input_NewPES( p_input->p_method_data ); p_pes = input_NewPES( p_input->p_method_data );
if( p_pes == NULL ) if( p_pes == NULL )
{ {
...@@ -360,7 +397,27 @@ static int Demux( input_thread_t * p_input ) ...@@ -360,7 +397,27 @@ static int Demux( input_thread_t * p_input )
input_ClockGetTS( p_input, p_input->stream.p_selected_program, input_ClockGetTS( p_input, p_input->stream.p_selected_program,
p_rawdv->i_pcr ); p_rawdv->i_pcr );
input_DecodePES( p_fifo, p_pes ); /* Do the same for audio */
p_audio_pes = input_NewPES( p_input->p_method_data );
if( p_pes == NULL )
{
msg_Err( p_input, "out of memory" );
input_DeletePacket( p_input->p_method_data, p_data );
return -1;
}
p_audio_pes->i_rate = p_input->stream.control.i_rate;
p_audio_pes->p_first = p_audio_pes->p_last =
input_ShareBuffer( p_input->p_method_data, p_data->p_buffer );
p_audio_pes->p_first->p_next = p_data->p_next;
p_audio_pes->p_first->p_payload_start = p_data->p_payload_start;
p_audio_pes->p_first->p_payload_end = p_data->p_payload_end;
p_audio_pes->i_pes_size = i_read;
p_audio_pes->i_nb_data = 1;
p_audio_pes->i_pts = p_pes->i_pts;
/* Decode PES packets */
input_DecodePES( p_rawdv->p_video_es->p_decoder_fifo, p_pes );
input_DecodePES( p_rawdv->p_audio_es->p_decoder_fifo, p_audio_pes );
p_rawdv->i_pcr += ( 90000 / p_rawdv->f_rate ); p_rawdv->i_pcr += ( 90000 / p_rawdv->f_rate );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment