Commit 85d35a75 authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/quicktime.c, configure.ac: ported the audio part of the quicktime module to win32.
parent 543f828d
dnl Autoconf settings for vlc dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.38 2003/07/20 22:06:02 hartman Exp $ dnl $Id: configure.ac,v 1.39 2003/07/21 17:48:31 gbazin Exp $
AC_INIT(vlc,0.6.1-test1) AC_INIT(vlc,0.6.1-test1)
...@@ -1695,10 +1695,14 @@ AC_ARG_ENABLE(quicktime, ...@@ -1695,10 +1695,14 @@ AC_ARG_ENABLE(quicktime,
if test "${enable_quicktime}" != "no" && if test "${enable_quicktime}" != "no" &&
(test "${SYS}" = "darwin" || test "${enable_quicktime}" = "yes") (test "${SYS}" = "darwin" || test "${enable_quicktime}" = "yes")
then then
if test "${SYS}" = "mingw32"; then
AX_ADD_BUILTINS([quicktime])
else
AC_CHECK_HEADERS(QuickTime/QuickTime.h, AC_CHECK_HEADERS(QuickTime/QuickTime.h,
[ AX_ADD_BUILTINS([quicktime]) [ AX_ADD_BUILTINS([quicktime])
AX_ADD_LDFLAGS([quicktime],[-framework QuickTime -framework Carbon]) AX_ADD_LDFLAGS([quicktime],[-framework QuickTime -framework Carbon])
], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ]) ], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
fi
fi fi
dnl dnl
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* quicktime.c: a quicktime decoder that uses the QT library/dll * quicktime.c: a quicktime decoder that uses the QT library/dll
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: quicktime.c,v 1.8 2003/06/17 14:43:21 hartman Exp $ * $Id: quicktime.c,v 1.9 2003/07/21 17:48:31 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir at via.ecp.fr> * Authors: Laurent Aimar <fenrir at via.ecp.fr>
* Derk-Jan Hartman <thedj at users.sf.net> * Derk-Jan Hartman <thedj at users.sf.net>
...@@ -47,6 +47,11 @@ ...@@ -47,6 +47,11 @@
#include "w32dll/loader/qtx/qtxsdk/components.h" #include "w32dll/loader/qtx/qtxsdk/components.h"
#include "w32dll/loader/wine/windef.h" #include "w32dll/loader/wine/windef.h"
#include "w32dll/loader/ldt_keeper.h" #include "w32dll/loader/ldt_keeper.h"
HMODULE WINAPI LoadLibraryA(LPCSTR);
FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR);
int WINAPI FreeLibrary(HMODULE);
#endif #endif
/***************************************************************************** /*****************************************************************************
...@@ -70,15 +75,16 @@ vlc_module_begin(); ...@@ -70,15 +75,16 @@ vlc_module_begin();
var_Create( p_module->p_libvlc, "qt_mutex", VLC_VAR_MUTEX ); var_Create( p_module->p_libvlc, "qt_mutex", VLC_VAR_MUTEX );
vlc_module_end(); vlc_module_end();
#define FCC( a, b , c, d ) \ #define FCC( a, b , c, d ) \
((uint32_t)( ((a)<<24)|((b)<<16)|((c)<<8)|(d))) ((uint32_t)( ((a)<<24)|((b)<<16)|((c)<<8)|(d)))
#ifndef SYS_DARWIN #ifndef SYS_DARWIN
typedef struct OpaqueSoundConverter* SoundConverter; typedef struct OpaqueSoundConverter* SoundConverter;
typedef long OSType;
typedef int OSErr;
typedef unsigned long UnsignedFixed; typedef unsigned long UnsignedFixed;
typedef uint8_t Byte; typedef uint8_t Byte;
typedef struct SoundComponentData { typedef struct SoundComponentData {
long flags; long flags;
OSType format; OSType format;
...@@ -89,6 +95,7 @@ typedef struct SoundComponentData { ...@@ -89,6 +95,7 @@ typedef struct SoundComponentData {
Byte * buffer; Byte * buffer;
long reserved; long reserved;
} SoundComponentData; } SoundComponentData;
#endif /* SYS_DARWIN */ #endif /* SYS_DARWIN */
typedef struct typedef struct
...@@ -100,20 +107,27 @@ typedef struct ...@@ -100,20 +107,27 @@ typedef struct
#ifndef SYS_DARWIN #ifndef SYS_DARWIN
#ifdef LOADER #ifdef LOADER
ldt_fs_t *ldt_fs; ldt_fs_t *ldt_fs;
#endif /* LOADER */ #endif /* LOADER */
HMODULE qtml; HMODULE qtml;
OSErr (*InitializeQTML) ( long flags ); OSErr (*InitializeQTML) ( long flags );
OSErr (*TerminateQTML) ( void );
#endif /* SYS_DARWIN */ #endif /* SYS_DARWIN */
int (*SoundConverterOpen) ( const SoundComponentData *, int (*SoundConverterOpen) ( const SoundComponentData *,
const SoundComponentData *, SoundConverter* ); const SoundComponentData *,
SoundConverter* );
int (*SoundConverterClose) ( SoundConverter ); int (*SoundConverterClose) ( SoundConverter );
int (*SoundConverterSetInfo) ( SoundConverter , OSType ,void * ); int (*SoundConverterSetInfo) ( SoundConverter , OSType, void * );
int (*SoundConverterGetBufferSizes) ( SoundConverter, unsigned long, int (*SoundConverterGetBufferSizes) ( SoundConverter, unsigned long,
unsigned long*, unsigned long*, unsigned long* ); unsigned long*, unsigned long*,
unsigned long* );
int (*SoundConverterBeginConversion)( SoundConverter ); int (*SoundConverterBeginConversion)( SoundConverter );
int (*SoundConverterEndConversion) ( SoundConverter, void *, unsigned long *, unsigned long *); int (*SoundConverterEndConversion) ( SoundConverter, void *,
int (*SoundConverterConvertBuffer) ( SoundConverter, const void *, unsigned long, void *, unsigned long *, unsigned long *);
unsigned long *,unsigned long * ); int (*SoundConverterConvertBuffer) ( SoundConverter, const void *,
unsigned long, void *,
unsigned long *, unsigned long * );
SoundConverter myConverter; SoundConverter myConverter;
SoundComponentData InputFormatInfo, OutputFormatInfo; SoundComponentData InputFormatInfo, OutputFormatInfo;
...@@ -135,8 +149,10 @@ typedef struct ...@@ -135,8 +149,10 @@ typedef struct
uint8_t *p_buffer; uint8_t *p_buffer;
uint8_t buffer_out[1000000]; /* FIXME */ uint8_t buffer_out[1000000]; /* FIXME */
} adec_thread_t; } adec_thread_t;
#ifndef WIN32
typedef struct typedef struct
{ {
/* Input properties */ /* Input properties */
...@@ -149,26 +165,36 @@ typedef struct ...@@ -149,26 +165,36 @@ typedef struct
#endif /* LOADER */ #endif /* LOADER */
HMODULE qtml; HMODULE qtml;
OSErr (*InitializeQTML) ( long flags ); OSErr (*InitializeQTML) ( long flags );
#endif /* SYS_DARWIN */ #endif /* SYS_DARWIN */
Component (*FindNextComponent) ( Component prev, ComponentDescription* desc ); Component (*FindNextComponent)
ComponentInstance (*OpenComponent) ( Component c ); ( Component prev, ComponentDescription* desc );
ComponentResult (*ImageCodecInitialize) ( ComponentInstance ci, ImageSubCodecDecompressCapabilities * cap);
ComponentResult (*ImageCodecGetCodecInfo) ( ComponentInstance ci, ComponentInstance (*OpenComponent)
CodecInfo *info ); ( Component c );
ComponentResult (*ImageCodecPreDecompress)( ComponentInstance ci,
CodecDecompressParams * params ); ComponentResult (*ImageCodecInitialize)
ComponentResult (*ImageCodecBandDecompress)( ComponentInstance ci, ( ComponentInstance ci, ImageSubCodecDecompressCapabilities * cap);
CodecDecompressParams * params );
PixMapHandle (*GetGWorldPixMap) ( GWorldPtr offscreenGWorld ); ComponentResult (*ImageCodecGetCodecInfo)
OSErr (*QTNewGWorldFromPtr) ( GWorldPtr *gw, ( ComponentInstance ci, CodecInfo *info );
OSType pixelFormat,
const Rect *boundsRect, ComponentResult (*ImageCodecPreDecompress)
CTabHandle cTable, ( ComponentInstance ci, CodecDecompressParams * params );
/*GDHandle*/ void *aGDevice, /*unused*/
GWorldFlags flags, ComponentResult (*ImageCodecBandDecompress)
void *baseAddr, ( ComponentInstance ci, CodecDecompressParams * params );
long rowBytes );
OSErr (*NewHandleClear) ( Size byteCount ); PixMapHandle (*GetGWorldPixMap)
( GWorldPtr offscreenGWorld );
OSErr (*QTNewGWorldFromPtr)
( GWorldPtr *gw, OSType pixelFormat, const Rect *boundsRect,
CTabHandle cTable, /*GDHandle*/ void *aGDevice, /*unused*/
GWorldFlags flags, void *baseAddr, long rowBytes );
OSErr (*NewHandleClear)
( Size byteCount );
ComponentInstance ci; ComponentInstance ci;
Rect OutBufferRect; /* the dimensions of our GWorld */ Rect OutBufferRect; /* the dimensions of our GWorld */
...@@ -177,7 +203,7 @@ typedef struct ...@@ -177,7 +203,7 @@ typedef struct
environment */ environment */
ImageDescriptionHandle framedescHandle; ImageDescriptionHandle framedescHandle;
CodecDecompressParams decpar; /* for ImageCodecPreDecompress() */ CodecDecompressParams decpar; /* for ImageCodecPreDecompress()*/
CodecCapabilities codeccap; /* for decpar */ CodecCapabilities codeccap; /* for decpar */
...@@ -191,6 +217,7 @@ typedef struct ...@@ -191,6 +217,7 @@ typedef struct
uint8_t *p_buffer; uint8_t *p_buffer;
} vdec_thread_t; } vdec_thread_t;
#endif
static int pi_channels_maps[6] = static int pi_channels_maps[6] =
{ {
...@@ -273,6 +300,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -273,6 +300,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_fifo->pf_run = RunDecoderVideo; p_fifo->pf_run = RunDecoderVideo;
return VLC_SUCCESS; return VLC_SUCCESS;
case VLC_FOURCC('m','p','4','a'): /* MPEG-4 audio */
case VLC_FOURCC('Q','D','M','C'): /* QDesign */ case VLC_FOURCC('Q','D','M','C'): /* QDesign */
case VLC_FOURCC('Q','D','M','2'): /* QDesign* 2 */ case VLC_FOURCC('Q','D','M','2'): /* QDesign* 2 */
case VLC_FOURCC('Q','c','l','p'): /* Qualcomm Purevoice Codec */ case VLC_FOURCC('Q','c','l','p'): /* Qualcomm Purevoice Codec */
...@@ -300,12 +328,6 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -300,12 +328,6 @@ static int OpenDecoder( vlc_object_t *p_this )
} }
} }
#ifdef LOADER
HMODULE WINAPI LoadLibraryA(LPCSTR);
FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR);
int WINAPI FreeLibrary(HMODULE);
#endif
/**************************************************************************** /****************************************************************************
**************************************************************************** ****************************************************************************
** **
...@@ -313,10 +335,10 @@ int WINAPI FreeLibrary(HMODULE); ...@@ -313,10 +335,10 @@ int WINAPI FreeLibrary(HMODULE);
** **
**************************************************************************** ****************************************************************************
****************************************************************************/ ****************************************************************************/
static int InitThreadAudio ( adec_thread_t * ); static int InitThreadAudio ( adec_thread_t * );
static void DecodeThreadAudio ( adec_thread_t * ); static void DecodeThreadAudio ( adec_thread_t * );
static void EndThreadAudio ( adec_thread_t * ); static void EndThreadAudio ( adec_thread_t * );
static int QTAudioInit ( adec_thread_t * );
static int RunDecoderAudio( decoder_fifo_t *p_fifo ) static int RunDecoderAudio( decoder_fifo_t *p_fifo )
{ {
...@@ -379,43 +401,18 @@ static int InitThreadAudio( adec_thread_t *p_dec ) ...@@ -379,43 +401,18 @@ static int InitThreadAudio( adec_thread_t *p_dec )
/* get lock, avoid segfault */ /* get lock, avoid segfault */
var_Get( p_dec->p_fifo->p_libvlc, "qt_mutex", &lockval ); var_Get( p_dec->p_fifo->p_libvlc, "qt_mutex", &lockval );
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
#ifdef SYS_DARWIN #ifdef SYS_DARWIN
EnterMovies(); EnterMovies();
#else #endif
#ifdef LOADER
p_dec->ldt_fs = Setup_LDT_Keeper();
#endif /* LOADER */
msg_Dbg( p_dec->p_fifo, "trying to load `qtmlClient.dll'" );
if( !( p_dec->qtml = LoadLibraryA("qtmlClient.dll") ) )
{
msg_Err( p_dec->p_fifo, "cannot load qtmlClient.dll");
goto exit_error;
}
msg_Dbg( p_dec->p_fifo, "qtmlClient.dll loaded" );
/* (void*) to shut up gcc */
p_dec->InitializeQTML = (void*)InitializeQTML;
#endif /* SYS_DARWIN */
p_dec->SoundConverterOpen = (void*)SoundConverterOpen;
p_dec->SoundConverterClose = (void*)SoundConverterClose;
p_dec->SoundConverterSetInfo = (void*)SoundConverterSetInfo;
p_dec->SoundConverterGetBufferSizes = (void*)SoundConverterGetBufferSizes;
p_dec->SoundConverterConvertBuffer = (void*)SoundConverterConvertBuffer;
p_dec->SoundConverterBeginConversion= (void*)SoundConverterBeginConversion;
p_dec->SoundConverterEndConversion = (void*)SoundConverterEndConversion;
#ifndef SYS_DARWIN if( QTAudioInit( p_dec ) != VLC_SUCCESS )
if( !p_dec->InitializeQTML ||
!p_dec->SoundConverterOpen || !p_dec->SoundConverterClose ||
!p_dec->SoundConverterSetInfo || !p_dec->SoundConverterGetBufferSizes ||
!p_dec->SoundConverterConvertBuffer ||
!p_dec->SoundConverterBeginConversion || !p_dec->SoundConverterEndConversion )
{ {
msg_Err( p_dec->p_fifo, "error getting qtmlClient.dll symbols"); msg_Err( p_dec->p_fifo, "cannot initialize QT");
goto exit_error; goto exit_error;
} }
#ifndef SYS_DARWIN
if( ( i_error = p_dec->InitializeQTML( 6 + 16 ) ) ) if( ( i_error = p_dec->InitializeQTML( 6 + 16 ) ) )
{ {
msg_Dbg( p_dec->p_fifo, "error while InitializeQTML = %d", i_error ); msg_Dbg( p_dec->p_fifo, "error while InitializeQTML = %d", i_error );
...@@ -453,36 +450,51 @@ static int InitThreadAudio( adec_thread_t *p_dec ) ...@@ -453,36 +450,51 @@ static int InitThreadAudio( adec_thread_t *p_dec )
&p_dec->myConverter ); &p_dec->myConverter );
if( i_error ) if( i_error )
{ {
msg_Err( p_dec->p_fifo, "error while SoundConverterOpen = %d", i_error ); msg_Err( p_dec->p_fifo,
"error while SoundConverterOpen = %d", i_error );
goto exit_error; goto exit_error;
} }
#if 0
/* tell the sound converter we accept VBR formats */
i_error = SoundConverterSetInfo( p_dec->myConverter, siClientAcceptsVBR,
(void *)true );
#endif
if( p_wf->cbSize > 36 + 8 ) if( p_wf->cbSize > 36 + 8 )
{ {
i_error = p_dec->SoundConverterSetInfo( p_dec->myConverter, i_error =
p_dec->SoundConverterSetInfo( p_dec->myConverter,
FCC( 'w', 'a', 'v', 'e' ), FCC( 'w', 'a', 'v', 'e' ),
((uint8_t*)&p_wf[1]) + 36 + 8 ); ((uint8_t*)&p_wf[1]) + 36 + 8 );
msg_Dbg( p_dec->p_fifo, "error while SoundConverterSetInfo = %d", i_error ); msg_Dbg( p_dec->p_fifo,
"error while SoundConverterSetInfo = %d", i_error );
} }
WantedBufferSize = p_dec->OutputFormatInfo.numChannels * p_dec->OutputFormatInfo.sampleRate * 2; WantedBufferSize = p_dec->OutputFormatInfo.numChannels *
p_dec->OutputFormatInfo.sampleRate * 2;
p_dec->FramesToGet = 0; p_dec->FramesToGet = 0;
i_error = p_dec->SoundConverterGetBufferSizes( p_dec->myConverter, i_error = p_dec->SoundConverterGetBufferSizes( p_dec->myConverter,
WantedBufferSize, &p_dec->FramesToGet, WantedBufferSize, &p_dec->FramesToGet,
&InputBufferSize, &OutputBufferSize ); &InputBufferSize, &OutputBufferSize );
msg_Dbg( p_dec->p_fifo, "WantedBufferSize=%li InputBufferSize=%li OutputBufferSize=%li FramesToGet=%li", msg_Dbg( p_dec->p_fifo, "WantedBufferSize=%li InputBufferSize=%li "
WantedBufferSize, InputBufferSize, OutputBufferSize, p_dec->FramesToGet ); "OutputBufferSize=%li FramesToGet=%li", WantedBufferSize,
InputBufferSize, OutputBufferSize, p_dec->FramesToGet );
p_dec->InFrameSize = (InputBufferSize + p_dec->FramesToGet - 1 ) / p_dec->FramesToGet; p_dec->InFrameSize = (InputBufferSize + p_dec->FramesToGet - 1 ) /
p_dec->FramesToGet;
p_dec->OutFrameSize = OutputBufferSize / p_dec->FramesToGet; p_dec->OutFrameSize = OutputBufferSize / p_dec->FramesToGet;
msg_Dbg( p_dec->p_fifo, "frame size %d -> %d", p_dec->InFrameSize, p_dec->OutFrameSize ); msg_Dbg( p_dec->p_fifo, "frame size %d -> %d",
p_dec->InFrameSize, p_dec->OutFrameSize );
i_error = p_dec->SoundConverterBeginConversion( p_dec->myConverter ); i_error = p_dec->SoundConverterBeginConversion( p_dec->myConverter );
if( i_error ) if( i_error )
{ {
msg_Err( p_dec->p_fifo, "error while SoundConverterBeginConversion = %d", i_error ); msg_Err( p_dec->p_fifo,
"error while SoundConverterBeginConversion = %d", i_error );
goto exit_error; goto exit_error;
} }
...@@ -520,9 +532,9 @@ exit_error: ...@@ -520,9 +532,9 @@ exit_error:
#endif #endif
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( lockval.p_address );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
static void DecodeThreadAudio ( adec_thread_t *p_dec )
static void DecodeThreadAudio( adec_thread_t *p_dec )
{ {
pes_packet_t *p_pes; pes_packet_t *p_pes;
vlc_value_t lockval; vlc_value_t lockval;
...@@ -567,13 +579,19 @@ static void DecodeThreadAudio ( adec_thread_t *p_dec ) ...@@ -567,13 +579,19 @@ static void DecodeThreadAudio ( adec_thread_t *p_dec )
p_dec->p_buffer, p_dec->p_buffer,
i_frames, i_frames,
p_dec->buffer_out, p_dec->buffer_out,
&i_out_frames, &i_out_bytes ); &i_out_frames,
&i_out_bytes );
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( lockval.p_address );
/*msg_Dbg( p_dec->p_fifo, "decoded %d frames -> %ld frames (error=%d)", /*
msg_Dbg( p_dec->p_fifo,
"decoded %d frames -> %ld frames (error=%d)",
i_frames, i_out_frames, i_error ); i_frames, i_out_frames, i_error );
msg_Dbg( p_dec->p_fifo, "decoded %ld frames = %ld bytes", i_out_frames, i_out_bytes );*/ msg_Dbg( p_dec->p_fifo, "decoded %ld frames = %ld bytes",
i_out_frames, i_out_bytes );
*/
p_dec->i_buffer -= i_frames * p_dec->InFrameSize; p_dec->i_buffer -= i_frames * p_dec->InFrameSize;
if( p_dec->i_buffer > 0 ) if( p_dec->i_buffer > 0 )
{ {
...@@ -582,7 +600,7 @@ static void DecodeThreadAudio ( adec_thread_t *p_dec ) ...@@ -582,7 +600,7 @@ static void DecodeThreadAudio ( adec_thread_t *p_dec )
p_dec->i_buffer ); p_dec->i_buffer );
} }
if( i_out_frames > 0 ) if( !i_error && i_out_frames > 0 )
{ {
aout_buffer_t *p_aout_buffer; aout_buffer_t *p_aout_buffer;
uint8_t *p_buff = p_dec->buffer_out; uint8_t *p_buff = p_dec->buffer_out;
...@@ -590,7 +608,8 @@ static void DecodeThreadAudio ( adec_thread_t *p_dec ) ...@@ -590,7 +608,8 @@ static void DecodeThreadAudio ( adec_thread_t *p_dec )
/*msg_Dbg( p_dec->p_fifo, "pts=%lld date=%lld dateget=%lld", /*msg_Dbg( p_dec->p_fifo, "pts=%lld date=%lld dateget=%lld",
p_dec->pts, mdate(), aout_DateGet( &p_dec->date ) );*/ p_dec->pts, mdate(), aout_DateGet( &p_dec->date ) );*/
if( p_dec->pts != 0 && p_dec->pts != aout_DateGet( &p_dec->date ) ) if( p_dec->pts != 0 &&
p_dec->pts != aout_DateGet( &p_dec->date ) )
{ {
aout_DateSet( &p_dec->date, p_dec->pts ); aout_DateSet( &p_dec->date, p_dec->pts );
} }
...@@ -622,12 +641,25 @@ static void DecodeThreadAudio ( adec_thread_t *p_dec ) ...@@ -622,12 +641,25 @@ static void DecodeThreadAudio ( adec_thread_t *p_dec )
p_buff, p_buff,
p_aout_buffer->i_nb_bytes ); p_aout_buffer->i_nb_bytes );
/*msg_Dbg( p_dec->p_fifo, "==> start=%lld end=%lld date=%lld", /*
p_aout_buffer->start_date, p_aout_buffer->end_date, mdate() );*/ msg_Dbg( p_dec->p_fifo,
aout_DecPlay( p_dec->p_aout, p_dec->p_aout_input, p_aout_buffer ); "==> start=%lld end=%lld date=%lld",
/*msg_Dbg( p_dec->p_fifo, "s1=%d s2=%d", i_framesperchannels, p_aout_buffer->i_nb_samples ); p_aout_buffer->start_date,
p_aout_buffer->end_date, mdate() );
*/
aout_DecPlay( p_dec->p_aout, p_dec->p_aout_input,
p_aout_buffer );
/*
msg_Dbg( p_dec->p_fifo, "s1=%d s2=%d", i_framesperchannels,
p_aout_buffer->i_nb_samples );
msg_Dbg( p_dec->p_fifo, "i_nb_bytes=%d i_nb_samples*4=%d",
p_aout_buffer->i_nb_bytes,
p_aout_buffer->i_nb_samples * 4 );
*/
msg_Dbg( p_dec->p_fifo, "i_nb_bytes=%d i_nb_samples*4=%d", p_aout_buffer->i_nb_bytes, p_aout_buffer->i_nb_samples * 4 );*/
p_buff += i_frames * 4; p_buff += i_frames * 4;
i_out_frames -= i_frames; i_out_frames -= i_frames;
} }
...@@ -651,7 +683,9 @@ static void EndThreadAudio( adec_thread_t *p_dec ) ...@@ -651,7 +683,9 @@ static void EndThreadAudio( adec_thread_t *p_dec )
var_Get( p_dec->p_fifo->p_libvlc, "qt_mutex", &lockval ); var_Get( p_dec->p_fifo->p_libvlc, "qt_mutex", &lockval );
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
i_error = p_dec->SoundConverterEndConversion( p_dec->myConverter, NULL, &ConvertedFrames, &ConvertedBytes ); i_error = p_dec->SoundConverterEndConversion( p_dec->myConverter, NULL,
&ConvertedFrames,
&ConvertedBytes );
msg_Dbg( p_dec->p_fifo, "SoundConverterEndConversion => %d", i_error ); msg_Dbg( p_dec->p_fifo, "SoundConverterEndConversion => %d", i_error );
i_error = p_dec->SoundConverterClose( p_dec->myConverter ); i_error = p_dec->SoundConverterClose( p_dec->myConverter );
...@@ -659,13 +693,13 @@ static void EndThreadAudio( adec_thread_t *p_dec ) ...@@ -659,13 +693,13 @@ static void EndThreadAudio( adec_thread_t *p_dec )
#ifndef SYS_DARWIN #ifndef SYS_DARWIN
FreeLibrary( p_dec->qtml ); FreeLibrary( p_dec->qtml );
msg_Dbg( p_dec->p_fifo, "FreeLibrary ok." ); */ msg_Dbg( p_dec->p_fifo, "FreeLibrary ok." );
#endif #endif
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( lockval.p_address );
#ifdef LOADER #ifdef LOADER
Restore_LDT_Keeper( p_dec->ldt_fs ); Restore_LDT_Keeper( p_dec->ldt_fs );
msg_Dbg( p_dec->p_fifo, "Restore_LDT_Keeper" ); */ msg_Dbg( p_dec->p_fifo, "Restore_LDT_Keeper" );
#endif #endif
#ifdef SYS_DARWIN #ifdef SYS_DARWIN
ExitMovies(); ExitMovies();
...@@ -673,6 +707,115 @@ static void EndThreadAudio( adec_thread_t *p_dec ) ...@@ -673,6 +707,115 @@ static void EndThreadAudio( adec_thread_t *p_dec )
aout_DecDelete( p_dec->p_aout, p_dec->p_aout_input ); aout_DecDelete( p_dec->p_aout, p_dec->p_aout_input );
} }
static int QTAudioInit( adec_thread_t *p_dec )
{
#ifdef SYS_DARWIN
p_dec->SoundConverterOpen = (void*)SoundConverterOpen;
p_dec->SoundConverterClose = (void*)SoundConverterClose;
p_dec->SoundConverterSetInfo = (void*)SoundConverterSetInfo;
p_dec->SoundConverterGetBufferSizes = (void*)SoundConverterGetBufferSizes;
p_dec->SoundConverterConvertBuffer = (void*)SoundConverterConvertBuffer;
p_dec->SoundConverterBeginConversion= (void*)SoundConverterBeginConversion;
p_dec->SoundConverterEndConversion = (void*)SoundConverterEndConversion;
#else
#ifdef LOADER
p_dec->ldt_fs = Setup_LDT_Keeper();
#endif /* LOADER */
p_dec->qtml = LoadLibraryA( "qtmlClient.dll" );
if( p_dec->qtml == NULL )
{
msg_Dbg( p_dec->p_fifo, "failed loading qtmlClient.dll" );
return VLC_EGENERIC;
}
p_dec->InitializeQTML =
(void *)GetProcAddress( p_dec->qtml, "InitializeQTML" );
if( p_dec->InitializeQTML == NULL )
{
msg_Dbg( p_dec->p_fifo, "failed geting proc address InitializeQTML" );
return VLC_EGENERIC;
}
p_dec->SoundConverterOpen =
(void *)GetProcAddress( p_dec->qtml, "SoundConverterOpen" );
if( p_dec->SoundConverterOpen == NULL )
{
msg_Dbg( p_dec->p_fifo,
"failed getting proc address SoundConverterOpen");
return VLC_EGENERIC;
}
p_dec->SoundConverterClose =
(void *)GetProcAddress( p_dec->qtml, "SoundConverterClose" );
if( p_dec->SoundConverterClose == NULL )
{
msg_Dbg( p_dec->p_fifo,
"failed getting proc address SoundConverterClose");
return VLC_EGENERIC;
}
p_dec->TerminateQTML =
(void *)GetProcAddress( p_dec->qtml, "TerminateQTML" );
if( p_dec->TerminateQTML == NULL )
{
msg_Dbg( p_dec->p_fifo, "failed getting proc address TerminateQTML");
return VLC_EGENERIC;
}
p_dec->SoundConverterSetInfo =
(void *)GetProcAddress( p_dec->qtml, "SoundConverterSetInfo" );
if( p_dec->SoundConverterSetInfo == NULL )
{
msg_Dbg( p_dec->p_fifo,
"failed getting proc address SoundConverterSetInfo");
return VLC_EGENERIC;
}
p_dec->SoundConverterGetBufferSizes =
(void *)GetProcAddress( p_dec->qtml, "SoundConverterGetBufferSizes" );
if( p_dec->SoundConverterGetBufferSizes == NULL )
{
msg_Dbg( p_dec->p_fifo,
"failed getting proc address SoundConverterGetBufferSizes");
return VLC_EGENERIC;
}
p_dec->SoundConverterConvertBuffer =
(void *)GetProcAddress( p_dec->qtml, "SoundConverterConvertBuffer" );
if( p_dec->SoundConverterConvertBuffer == NULL )
{
msg_Dbg( p_dec->p_fifo,
"failed getting proc address SoundConverterConvertBuffer" );
return VLC_EGENERIC;
}
p_dec->SoundConverterEndConversion =
(void *)GetProcAddress( p_dec->qtml, "SoundConverterEndConversion" );
if( p_dec->SoundConverterEndConversion == NULL )
{
msg_Dbg( p_dec->p_fifo,
"failed getting proc address SoundConverterEndConversion" );
return VLC_EGENERIC;
}
p_dec->SoundConverterBeginConversion =
(void *)GetProcAddress( p_dec->qtml, "SoundConverterBeginConversion");
if( p_dec->SoundConverterBeginConversion == NULL )
{
msg_Dbg( p_dec->p_fifo,
"failed getting proc address SoundConverterBeginConversion" );
return VLC_EGENERIC;
}
msg_Dbg( p_dec->p_fifo,
"Standard init done you may now call supported functions" );
#endif /* else SYS_DARWIN */
return VLC_SUCCESS;
}
/**************************************************************************** /****************************************************************************
**************************************************************************** ****************************************************************************
...@@ -682,6 +825,10 @@ static void EndThreadAudio( adec_thread_t *p_dec ) ...@@ -682,6 +825,10 @@ static void EndThreadAudio( adec_thread_t *p_dec )
**************************************************************************** ****************************************************************************
****************************************************************************/ ****************************************************************************/
#ifdef WIN32
static int RunDecoderVideo( decoder_fifo_t *p_fifo ){ return VLC_EGENERIC; }
#else
static int InitThreadVideo ( vdec_thread_t * ); static int InitThreadVideo ( vdec_thread_t * );
static void DecodeThreadVideo ( vdec_thread_t * ); static void DecodeThreadVideo ( vdec_thread_t * );
static void EndThreadVideo ( vdec_thread_t * ); static void EndThreadVideo ( vdec_thread_t * );
...@@ -759,7 +906,8 @@ static int InitThreadVideo( vdec_thread_t *p_dec ) ...@@ -759,7 +906,8 @@ static int InitThreadVideo( vdec_thread_t *p_dec )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
memcpy( fcc, &p_dec->p_fifo->i_fourcc, 4 ); memcpy( fcc, &p_dec->p_fifo->i_fourcc, 4 );
msg_Dbg( p_dec->p_fifo, "quicktime_video %4.4s %dx%d", fcc, p_bih->biWidth, p_bih->biHeight ); msg_Dbg( p_dec->p_fifo, "quicktime_video %4.4s %dx%d", fcc,
p_bih->biWidth, p_bih->biHeight );
/* get lock, avoid segfault */ /* get lock, avoid segfault */
var_Get( p_dec->p_fifo->p_libvlc, "qt_mutex", &lockval ); var_Get( p_dec->p_fifo->p_libvlc, "qt_mutex", &lockval );
...@@ -835,10 +983,12 @@ static int InitThreadVideo( vdec_thread_t *p_dec ) ...@@ -835,10 +983,12 @@ static int InitThreadVideo( vdec_thread_t *p_dec )
memset( &cinfo, 0, sizeof( CodecInfo ) ); memset( &cinfo, 0, sizeof( CodecInfo ) );
cres = p_dec->ImageCodecGetCodecInfo( p_dec->ci, &cinfo ); cres = p_dec->ImageCodecGetCodecInfo( p_dec->ci, &cinfo );
msg_Dbg( p_dec->p_fifo, "Flags: compr: 0x%lx decomp: 0x%lx format: 0x%lx\n", msg_Dbg( p_dec->p_fifo,
cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags); "Flags: compr: 0x%lx decomp: 0x%lx format: 0x%lx\n",
msg_Dbg( p_dec->p_fifo, "quicktime_video: Codec name: %.*s\n", ((unsigned char*)&cinfo.typeName)[0], cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags );
((unsigned char*)&cinfo.typeName)+1); msg_Dbg( p_dec->p_fifo, "quicktime_video: Codec name: %.*s\n",
((unsigned char*)&cinfo.typeName)[0],
((unsigned char*)&cinfo.typeName)+1 );
/* make a yuy2 gworld */ /* make a yuy2 gworld */
p_dec->OutBufferRect.top = 0; p_dec->OutBufferRect.top = 0;
...@@ -871,7 +1021,8 @@ static int InitThreadVideo( vdec_thread_t *p_dec ) ...@@ -871,7 +1021,8 @@ static int InitThreadVideo( vdec_thread_t *p_dec )
memcpy( ((char*)&id->clutID) + 2, p_vide + 70, i_vide - 70 ); memcpy( ((char*)&id->clutID) + 2, p_vide + 70, i_vide - 70 );
} }
msg_Dbg( p_dec->p_fifo, "idSize=%ld ver=%d rev=%d vendor=%ld tempQ=%d spaQ=%d w=%d h=%d dpi=%d%d dataSize=%d frameCount=%d clutID=%d", msg_Dbg( p_dec->p_fifo, "idSize=%ld ver=%d rev=%d vendor=%ld tempQ=%d "
"spaQ=%d w=%d h=%d dpi=%d%d dataSize=%d frameCount=%d clutID=%d",
id->idSize, id->version, id->revisionLevel, id->vendor, id->idSize, id->version, id->revisionLevel, id->vendor,
(int)id->temporalQuality, (int)id->spatialQuality, (int)id->temporalQuality, (int)id->spatialQuality,
id->width, id->height, id->width, id->height,
...@@ -880,19 +1031,24 @@ static int InitThreadVideo( vdec_thread_t *p_dec ) ...@@ -880,19 +1031,24 @@ static int InitThreadVideo( vdec_thread_t *p_dec )
id->frameCount, id->frameCount,
id->clutID ); id->clutID );
p_dec->framedescHandle = (ImageDescriptionHandle) p_dec->NewHandleClear( id->idSize ); p_dec->framedescHandle =
(ImageDescriptionHandle) p_dec->NewHandleClear( id->idSize );
memcpy( *p_dec->framedescHandle, id, id->idSize ); memcpy( *p_dec->framedescHandle, id, id->idSize );
p_dec->plane = malloc( p_bih->biWidth * p_bih->biHeight * 3 ); p_dec->plane = malloc( p_bih->biWidth * p_bih->biHeight * 3 );
i_result = p_dec->QTNewGWorldFromPtr( &p_dec->OutBufferGWorld, i_result = p_dec->QTNewGWorldFromPtr( &p_dec->OutBufferGWorld,
kYUVSPixelFormat, /*pixel format of new GWorld==YUY2 */ /*pixel format of new GWorld==YUY2 */
&p_dec->OutBufferRect, /*we should benchmark if yvu9 is faster for svq3, too */ kYUVSPixelFormat,
/* we should benchmark if yvu9 is
* faster for svq3, too */
&p_dec->OutBufferRect,
0, 0, 0, 0, 0, 0,
p_dec->plane, p_dec->plane,
p_bih->biWidth * 2 ); p_bih->biWidth * 2 );
msg_Dbg( p_dec->p_fifo, "NewGWorldFromPtr returned:%ld\n", 65536-( i_result&0xffff ) ); msg_Dbg( p_dec->p_fifo, "NewGWorldFromPtr returned:%ld\n",
65536 - ( i_result&0xffff ) );
memset( &p_dec->decpar, 0, sizeof( CodecDecompressParams ) ); memset( &p_dec->decpar, 0, sizeof( CodecDecompressParams ) );
p_dec->decpar.imageDescription = p_dec->framedescHandle; p_dec->decpar.imageDescription = p_dec->framedescHandle;
...@@ -909,12 +1065,15 @@ static int InitThreadVideo( vdec_thread_t *p_dec ) ...@@ -909,12 +1065,15 @@ static int InitThreadVideo( vdec_thread_t *p_dec )
p_dec->decpar.dstPixMap = **p_dec->GetGWorldPixMap( p_dec->OutBufferGWorld );/*destPixmap; */ p_dec->decpar.dstPixMap = **p_dec->GetGWorldPixMap( p_dec->OutBufferGWorld );/*destPixmap; */
cres = p_dec->ImageCodecPreDecompress( p_dec->ci, &p_dec->decpar ); cres = p_dec->ImageCodecPreDecompress( p_dec->ci, &p_dec->decpar );
msg_Dbg( p_dec->p_fifo, "quicktime_video: ImageCodecPreDecompress cres=0x%X\n", (int)cres ); msg_Dbg( p_dec->p_fifo,
"quicktime_video: ImageCodecPreDecompress cres=0x%X\n",
(int)cres );
p_dec->p_vout = vout_Request( p_dec->p_fifo, NULL, p_dec->p_vout = vout_Request( p_dec->p_fifo, NULL,
p_bih->biWidth, p_bih->biHeight, p_bih->biWidth, p_bih->biHeight,
VLC_FOURCC( 'Y', 'U', 'Y', '2' ), VLC_FOURCC( 'Y', 'U', 'Y', '2' ),
VOUT_ASPECT_FACTOR * p_bih->biWidth / p_bih->biHeight ); VOUT_ASPECT_FACTOR * p_bih->biWidth /
p_bih->biHeight );
if( !p_dec->p_vout ) if( !p_dec->p_vout )
{ {
...@@ -939,7 +1098,9 @@ exit_error: ...@@ -939,7 +1098,9 @@ exit_error:
static void DecodeThreadVideo( vdec_thread_t *p_dec ) static void DecodeThreadVideo( vdec_thread_t *p_dec )
{ {
BITMAPINFOHEADER *p_bih = (BITMAPINFOHEADER*)p_dec->p_fifo->p_bitmapinfoheader; BITMAPINFOHEADER *p_bih =
(BITMAPINFOHEADER*)p_dec->p_fifo->p_bitmapinfoheader;
pes_packet_t *p_pes; pes_packet_t *p_pes;
vlc_value_t lockval; vlc_value_t lockval;
picture_t *p_pic; picture_t *p_pic;
...@@ -987,8 +1148,8 @@ static void DecodeThreadVideo( vdec_thread_t *p_dec ) ...@@ -987,8 +1148,8 @@ static void DecodeThreadVideo( vdec_thread_t *p_dec )
if( cres &0xFFFF ) if( cres &0xFFFF )
{ {
msg_Dbg( p_dec->p_fifo, msg_Dbg( p_dec->p_fifo, "quicktime_video: ImageCodecBandDecompress"
"quicktime_video: ImageCodecBandDecompress cres=0x%X (-0x%X) %d :(\n", " cres=0x%X (-0x%X) %d :(\n",
(int)cres,(int)-cres, (int)cres ); (int)cres,(int)-cres, (int)cres );
} }
...@@ -1022,3 +1183,4 @@ static void EndThreadVideo( vdec_thread_t *p_dec ) ...@@ -1022,3 +1183,4 @@ static void EndThreadVideo( vdec_thread_t *p_dec )
ExitMovies(); ExitMovies();
#endif #endif
} }
#endif
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