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

📄 quicktime.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** * quicktime.c: a quicktime decoder that uses the QT library/dll ***************************************************************************** * Copyright (C) 2003 the VideoLAN team * $Id$ * * Authors: Laurent Aimar <fenrir at via.ecp.fr> *          Derk-Jan Hartman <hartman at videolan.org>> * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <vlc_common.h>#include <vlc_plugin.h>#include <vlc_aout.h>#include <vlc_vout.h>#include <vlc_codec.h>#if !defined (__APPLE__) && !defined(WIN32)# define LOADER 1#endif#ifdef __APPLE__#include <QuickTime/QuickTimeComponents.h>#include <QuickTime/Movies.h>#include <QuickTime/ImageCodec.h>#endif/* for windows do we require Quicktime compents header? */#ifdef LOADER#include "qtx/qtxsdk/components.h"#include "wine/windef.h"#include "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( N_("QuickTime library decoder") );    set_capability( "decoder", 10 );    set_category( CAT_INPUT );    set_subcategory( SUBCAT_INPUT_VCODEC );    set_callbacks( Open, Close );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 __APPLE__typedef 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 /* __APPLE__ */struct decoder_sys_t{    /* library */#ifndef __APPLE__#ifdef LOADER    ldt_fs_t    *ldt_fs;#endif /* LOADER */    HMODULE qtml;    HINSTANCE qts;    OSErr (*InitializeQTML)             ( long flags );    OSErr (*TerminateQTML)              ( void );#endif /* __APPLE__ */    /* 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;    unsigned 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 const 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;#ifdef __APPLE__    OSErr err;    SInt32 qtVersion, macosversion;        err = Gestalt(gestaltQuickTimeVersion, &qtVersion);    err = Gestalt(gestaltSystemVersion, &macosversion);#ifndef NDEBUG    msg_Dbg( p_this, "mac os version is %#lx", macosversion );    msg_Dbg( p_this, "quicktime version is %#lx", qtVersion );#endif#endif    switch( p_dec->fmt_in.i_codec )    {        case VLC_FOURCC('h','2','6','4'): /* H.264 */        case VLC_FOURCC('c','v','i','d'): /* Cinepak */        case VLC_FOURCC('I','V','4','1'): /* Indeo Video IV */        case VLC_FOURCC('i','v','4','1'): /* dto. */#ifdef __APPLE__        case VLC_FOURCC('p','x','l','t'): /* Pixlet */#endif        case VLC_FOURCC('d','v','1','n'): /* DVC Pro 100 NTSC */        case VLC_FOURCC('d','v','1','p'): /* DVC Pro 100 PAL */        case VLC_FOURCC('d','v','h','p'): /* DVC PRO HD 720p */        case VLC_FOURCC('d','v','h','6'): /* DVC PRO HD 1080i 60 */        case VLC_FOURCC('d','v','h','5'): /* DVC PRO HD 1080i 50 */        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#ifdef __APPLE__        case VLC_FOURCC('I','L','B','C'): /* iLBC */            if ((err != noErr) || (qtVersion < 0x07500000))                 return VLC_EGENERIC;        case VLC_FOURCC('i','l','b','c'): /* iLBC */            if ((err != noErr) || (qtVersion < 0x07500000))                 return VLC_EGENERIC;#endif        case VLC_FOURCC('s','a','m','r'): /* 3GPP AMR audio */        case VLC_FOURCC('s','a','m','b'): /* 3GPP AMR-WB 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#ifdef __APPLE__        /* FIXME: right now, we don't support audio decoding on 10.5 and later         because we are still using the hardcore-outdated SoundManager API,         which was removed after 10.4 */        if( macosversion >= 0x1050 || err != noErr )        {            msg_Warn( p_dec, "Your Mac OS version doesn't have SoundManager anymore. "                     "You can't use this plugin for audio." );            return VLC_EGENERIC;        }#endif        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_mutex_t   *lock;    /* get lock, avoid segfault */    lock = var_AcquireMutex( "qt_mutex" );    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 __APPLE__    FreeLibrary( p_sys->qtml );    FreeLibrary( p_sys->qts );

⌨️ 快捷键说明

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