⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quicktime.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** * quicktime.c: a quicktime decoder that uses the QT library/dll ***************************************************************************** * Copyright (C) 2003 VideoLAN * $Id: quicktime.c 10101 2005-03-02 16:47:31Z robux4 $ * * Authors: Laurent Aimar <fenrir at via.ecp.fr> *          Derk-Jan Hartman <thedj at users.sf.net> * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * 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. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <vlc/vlc.h>#include <vlc/aout.h>#include <vlc/vout.h>#include <vlc/decoder.h>#ifdef SYS_DARWIN#include <QuickTime/QuickTimeComponents.h>#include <QuickTime/Movies.h>#include <QuickTime/ImageCodec.h>#endif/* for windows do we require Quicktime compents header? */#ifdef LOADER#include "w32dll/loader/qtx/qtxsdk/components.h"#include "w32dll/loader/wine/windef.h"#include "w32dll/loader/ldt_keeper.h"HMODULE   WINAPI LoadLibraryA(LPCSTR);FARPROC   WINAPI GetProcAddress(HMODULE,LPCSTR);int       WINAPI FreeLibrary(HMODULE);#endif/***************************************************************************** * Module descriptor *****************************************************************************/static int  Open ( vlc_object_t * );static void Close( vlc_object_t * );vlc_module_begin();    set_description( _("QuickTime library decoder") );    set_capability( "decoder", 10 );    set_category( CAT_INPUT );    set_subcategory( SUBCAT_INPUT_VCODEC );    set_callbacks( Open, Close );    /* create a mutex */    var_Create( p_module->p_libvlc, "qt_mutex", VLC_VAR_MUTEX );vlc_module_end();/***************************************************************************** * Local prototypes *****************************************************************************/static int           OpenAudio( decoder_t * );static int           OpenVideo( decoder_t * );static aout_buffer_t *DecodeAudio( decoder_t *, block_t ** );static picture_t     *DecodeVideo( decoder_t *, block_t ** );#define FCC( a, b , c, d ) \    ((uint32_t)( ((a)<<24)|((b)<<16)|((c)<<8)|(d)))#ifndef SYS_DARWINtypedef struct OpaqueSoundConverter*    SoundConverter;#ifndef LOADERtypedef long                            OSType;typedef int                             OSErr;#endiftypedef unsigned long                   UnsignedFixed;typedef uint8_t                         Byte;typedef struct SoundComponentData {    long                            flags;    OSType                          format;    short                           numChannels;    short                           sampleSize;    UnsignedFixed                   sampleRate;    long                            sampleCount;    Byte *                          buffer;    long                            reserved;} SoundComponentData;#endif /* SYS_DARWIN */struct decoder_sys_t{    /* library */#ifndef SYS_DARWIN#ifdef LOADER    ldt_fs_t    *ldt_fs;#endif /* LOADER */    HMODULE qtml;    OSErr (*InitializeQTML)             ( long flags );    OSErr (*TerminateQTML)              ( void );#endif /* SYS_DARWIN */    /* Audio */    int (*SoundConverterOpen)           ( const SoundComponentData *,                                          const SoundComponentData *,                                          SoundConverter* );    int (*SoundConverterClose)          ( SoundConverter );    int (*SoundConverterSetInfo)        ( SoundConverter , OSType, void * );    int (*SoundConverterGetBufferSizes) ( SoundConverter, unsigned long,                                          unsigned long*, unsigned long*,                                          unsigned long* );    int (*SoundConverterBeginConversion)( SoundConverter );    int (*SoundConverterEndConversion)  ( SoundConverter, void *,                                          unsigned long *, unsigned long *);    int (*SoundConverterConvertBuffer)  ( SoundConverter, const void *,                                          unsigned long, void *,                                          unsigned long *, unsigned long * );    SoundConverter      myConverter;    SoundComponentData  InputFormatInfo, OutputFormatInfo;    long            FramesToGet;    unsigned int    InFrameSize;    unsigned int    OutFrameSize;#ifndef WIN32    /* Video */    Component         (*FindNextComponent)        ( Component prev, ComponentDescription* desc );    ComponentInstance (*OpenComponent)        ( Component c );    ComponentResult   (*ImageCodecInitialize)        ( ComponentInstance ci, ImageSubCodecDecompressCapabilities * cap);    ComponentResult   (*ImageCodecGetCodecInfo)        ( ComponentInstance ci, CodecInfo *info );    ComponentResult   (*ImageCodecPreDecompress)        ( ComponentInstance ci, CodecDecompressParams * params );    ComponentResult   (*ImageCodecBandDecompress)        ( ComponentInstance ci, CodecDecompressParams * params );    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;    Rect                    OutBufferRect;   /* the dimensions of our GWorld */    GWorldPtr               OutBufferGWorld; /* a GWorld is some kind of                                                description for a drawing                                                environment */    ImageDescriptionHandle  framedescHandle;    CodecDecompressParams   decpar;          /* for ImageCodecPreDecompress()*/    CodecCapabilities       codeccap;        /* for decpar */#endif    /* Output properties */    uint8_t *           plane;    mtime_t             pts;    audio_date_t        date;    int                 i_late; /* video */    /* buffer */    unsigned int        i_buffer;    unsigned int        i_buffer_size;    uint8_t             *p_buffer;    /* Audio only */    uint8_t             out_buffer[1000000];    /* FIXME */    int                 i_out_frames;    int                 i_out;};static int pi_channels_maps[6] ={    0,    AOUT_CHAN_CENTER,    AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,    AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER,    AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARLEFT,    AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER     | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARLEFT};static int QTAudioInit( decoder_t * );static int QTVideoInit( decoder_t * );/***************************************************************************** * Open: probe the decoder and return score ***************************************************************************** * Tries to launch a decoder and return score so that the interface is able * to choose. *****************************************************************************/static int Open( vlc_object_t *p_this ){    decoder_t *p_dec = (decoder_t*)p_this;    switch( p_dec->fmt_in.i_codec )    {        case VLC_FOURCC('S','V','Q','3'): /* Sorenson v3 */    /*    case VLC_FOURCC('S','V','Q','1'):  Sorenson v1         case VLC_FOURCC('Z','y','G','o'):        case VLC_FOURCC('V','P','3','1'):        case VLC_FOURCC('3','I','V','1'): */        case VLC_FOURCC('r','l','e',' '): /* QuickTime animation (RLE) */        case VLC_FOURCC('r','p','z','a'): /* QuickTime Apple Video */        case VLC_FOURCC('a','z','p','r'): /* QuickTime animation (RLE) */#ifdef LOADER            p_dec->p_sys = NULL;            p_dec->pf_decode_video = DecodeVideo;            return VLC_SUCCESS;#else            return OpenVideo( p_dec );#endif        case VLC_FOURCC('s','a','m','r'): /* 3GPP AMR audio */        case VLC_FOURCC('m','p','4','a'): /* MPEG-4 audio */        case VLC_FOURCC('Q','D','M','C'): /* QDesign */        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 */        case VLC_FOURCC('M','A','C','3'): /* MACE3 audio decoder */        case VLC_FOURCC('M','A','C','6'): /* MACE6 audio decoder */        case VLC_FOURCC('d','v','c','a'): /* DV Audio */        case VLC_FOURCC('s','o','w','t'): /* 16-bit Little Endian */        case VLC_FOURCC('t','w','o','s'): /* 16-bit Big Endian */        case VLC_FOURCC('a','l','a','w'): /* ALaw 2:1 */        case VLC_FOURCC('u','l','a','w'): /* mu-Law 2:1 */        case VLC_FOURCC('r','a','w',' '): /* 8-bit offset binaries */        case VLC_FOURCC('f','l','3','2'): /* 32-bit Floating Point */        case VLC_FOURCC('f','l','6','4'): /* 64-bit Floating Point */        case VLC_FOURCC('i','n','2','4'): /* 24-bit Interger */        case VLC_FOURCC('i','n','3','2'): /* 32-bit Integer */        case 0x0011:                            /* DVI IMA */        case 0x6D730002:                        /* Microsoft ADPCM-ACM */        case 0x6D730011:                        /* DVI Intel IMAADPCM-ACM */#ifdef LOADER            p_dec->p_sys = NULL;            p_dec->pf_decode_audio = DecodeAudio;            return VLC_SUCCESS;#else            return OpenAudio( p_dec );#endif        default:            return VLC_EGENERIC;    }}/***************************************************************************** * Close: *****************************************************************************/static void Close( vlc_object_t *p_this ){    decoder_t     *p_dec = (decoder_t*)p_this;    decoder_sys_t *p_sys = p_dec->p_sys;    vlc_value_t   lockval;    /* get lock, avoid segfault */    var_Get( p_dec->p_libvlc, "qt_mutex", &lockval );    vlc_mutex_lock( lockval.p_address );#ifdef SYS_DARWIN    /* on OS X QT is not threadsafe */    vlc_mutex_lock( &p_dec->p_vlc->quicktime_lock );#endif    if( p_dec->fmt_out.i_cat == AUDIO_ES )    {        int i_error;        unsigned long ConvertedFrames=0;        unsigned long ConvertedBytes=0;        i_error = p_sys->SoundConverterEndConversion( p_sys->myConverter, NULL,                                                      &ConvertedFrames,                                                      &ConvertedBytes );        msg_Dbg( p_dec, "SoundConverterEndConversion => %d", i_error );        i_error = p_sys->SoundConverterClose( p_sys->myConverter );        msg_Dbg( p_dec, "SoundConverterClose => %d", i_error );        free( p_sys->p_buffer );    }    else if( p_dec->fmt_out.i_cat == VIDEO_ES )    {        free( p_sys->plane );    }#ifndef SYS_DARWIN    FreeLibrary( p_sys->qtml );    msg_Dbg( p_dec, "FreeLibrary ok." );#endif#ifdef SYS_DARWIN    ExitMovies();#endif#if 0    /* Segfault */#ifdef LOADER    Restore_LDT_Keeper( p_sys->ldt_fs );    msg_Dbg( p_dec, "Restore_LDT_Keeper" );#endif#endif#ifdef SYS_DARWIN    vlc_mutex_unlock( &p_dec->p_vlc->quicktime_lock );#endif    vlc_mutex_unlock( lockval.p_address );    free( p_sys );}/***************************************************************************** * OpenAudio: *****************************************************************************/static int OpenAudio( decoder_t *p_dec ){    decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) );    vlc_value_t     lockval;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -