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

📄 realvideo.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * realvideo.c: a realvideo decoder that uses the real's dll ***************************************************************************** * Copyright (C) 2005 the VideoLAN team * Copyright (C) 2008 Wang Bo * * 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_vout.h>#include <vlc_codec.h>#ifdef LOADER/* Need the w32dll loader from mplayer */#   include <wine/winerror.h>#   include <ldt_keeper.h>#   include <wine/windef.h>void *WINAPI LoadLibraryA( char *name );void *WINAPI GetProcAddress( void *handle, char *func );int WINAPI FreeLibrary( void *handle );#endif#ifndef WINAPI#   define WINAPI#endif#if defined(HAVE_DL_DLOPEN)#   if defined(HAVE_DLFCN_H) /* Linux, BSD, Hurd */#       include <dlfcn.h>#   endif#   if defined(HAVE_SYS_DL_H)#       include <sys/dl.h>#   endif#endiftypedef struct cmsg_data_s{    uint32_t data1;    uint32_t data2;    uint32_t* dimensions;} cmsg_data_t;typedef struct transform_in_s{    uint32_t len;    uint32_t unknown1;    uint32_t chunks;    uint32_t* extra;    uint32_t unknown2;    uint32_t timestamp;} transform_in_t;// copypaste from demux_real.c - it should match to get it working!typedef struct dp_hdr_s{    uint32_t chunks;    // number of chunks    uint32_t timestamp;    // timestamp from packet header    uint32_t len;    // length of actual data    uint32_t chunktab;    // offset to chunk offset array} dp_hdr_t;/* we need exact positions */struct rv_init_t{    short unk1;    short w;    short h;    short unk3;    int unk2;    unsigned int * subformat;    int unk5;    unsigned int * format;} rv_init_t;struct decoder_sys_t{    /* library */#ifdef LOADER    ldt_fs_t    *ldt_fs;#endif    void        *handle;    void         *rv_handle;    int          inited;    char         *plane;};int dll_type = 1;static unsigned long (*rvyuv_custom_message)(cmsg_data_t* ,void*);static unsigned long (*rvyuv_free)(void*);static unsigned long (*rvyuv_init)(void*, void*); // initdata,contextstatic unsigned long (*rvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);#ifdef WIN32static unsigned long WINAPI (*wrvyuv_custom_message)(cmsg_data_t* ,void*);static unsigned long WINAPI (*wrvyuv_free)(void*);static unsigned long WINAPI (*wrvyuv_init)(void*, void*); // initdata,contextstatic unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);#endif/***************************************************************************** * Module descriptor *****************************************************************************/static int  Open ( vlc_object_t * );static void Close( vlc_object_t * );//static int  OpenPacketizer( vlc_object_t * );static picture_t *DecodeVideo( decoder_t *, block_t ** );vlc_module_begin();    set_description( N_("RealVideo library decoder") );    set_capability( "decoder", 10 );    set_category( CAT_INPUT );    set_subcategory( SUBCAT_INPUT_VCODEC );    set_callbacks( Open, Close );vlc_module_end();/***************************************************************************** * Local prototypes *****************************************************************************/#ifdef WIN32static void * load_syms(decoder_t *p_dec, const char *path) {    void *handle;    msg_Dbg( p_dec, "opening win32 dll '%s'\n", path);#ifdef LOADER    Setup_LDT_Keeper();#endif    handle = LoadLibraryA(path);    msg_Dbg( p_dec, "win32 real codec handle=%p  \n",handle);    if (!handle)    {        msg_Err( p_dec, "Error loading dll\n");        return NULL;    }    wrvyuv_custom_message = GetProcAddress(handle, "RV20toYUV420CustomMessage");    wrvyuv_free = GetProcAddress(handle, "RV20toYUV420Free");    wrvyuv_init = GetProcAddress(handle, "RV20toYUV420Init");    wrvyuv_transform = GetProcAddress(handle, "RV20toYUV420Transform");    if (wrvyuv_custom_message && wrvyuv_free && wrvyuv_init && wrvyuv_transform)    {        dll_type = 1;        return handle;    }    msg_Err( p_dec, "Error resolving symbols! (version incompatibility?)\n");    FreeLibrary(handle);    return NULL; // error}#elsestatic void * load_syms_linux(decoder_t *p_dec, const char *path) {    void *handle;    msg_Dbg( p_dec, "opening shared obj '%s'\n", path);    handle = dlopen (path, RTLD_LAZY);    if (!handle)     {        msg_Err( p_dec,"Error: %s\n",dlerror());        return NULL;    }    rvyuv_custom_message = dlsym(handle, "RV20toYUV420CustomMessage");    rvyuv_free = dlsym(handle, "RV20toYUV420Free");    rvyuv_init = dlsym(handle, "RV20toYUV420Init");    rvyuv_transform = dlsym(handle, "RV20toYUV420Transform");    if(rvyuv_custom_message && rvyuv_free && rvyuv_init && rvyuv_transform)    {        dll_type = 0;        return handle;    }    msg_Err( p_dec,"Error resolving symbols! (version incompatibility?)\n");    dlclose(handle);    return 0;}#endifstatic int InitVideo(decoder_t *p_dec){    int result;    struct rv_init_t init_data;    char fcc[4];    vlc_mutex_t  *lock;    char *g_decode_path;    int  i_vide = p_dec->fmt_in.i_extra;    unsigned int *p_vide = p_dec->fmt_in.p_extra;    decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) );    memset(p_sys,0,sizeof( decoder_sys_t ) );    if( i_vide < 8 )    {            msg_Err( p_dec, "missing extra info" );            free( p_sys );            return VLC_EGENERIC;    }    if (p_sys->plane) free(p_sys->plane);    p_sys->plane = malloc (p_dec->fmt_in.video.i_width*p_dec->fmt_in.video.i_height*3/2 + 1024 );    if (NULL == p_sys->plane)    {        msg_Err( p_dec, "cannot alloc plane buffer" );        free( p_sys );        return VLC_EGENERIC;    }    p_dec->p_sys = p_sys;    p_dec->pf_decode_video = DecodeVideo;    memcpy( fcc, &p_dec->fmt_in.i_codec, 4 );    init_data.unk1 = 11;    init_data.w = p_dec->fmt_in.video.i_width ;    init_data.h = p_dec->fmt_in.video.i_height ;    init_data.unk3 = 0;    init_data.unk2 = 0;    init_data.subformat = (unsigned int*)p_vide[0];    init_data.unk5 = 1;    init_data.format = (unsigned int*)p_vide[1];    /* first try to load linux dlls, if failed and we're supporting win32 dlls,       then try to load the windows ones */    bool b_so_opened = false;#ifdef WIN32    g_decode_path="plugins\\drv43260.dll";    if( (p_sys->rv_handle = load_syms(p_dec, g_decode_path)) )        b_so_opened = true;#else    static const char psz_paths[] =    {        "/usr/lib/win32\0"        "/usr/lib/codecs\0"        "/usr/local/RealPlayer8/Codecs\0"        "/usr/RealPlayer8/Codecs\0"        "/usr/lib/RealPlayer8/Codecs\0"        "/opt/RealPlayer8/Codecs\0"        "/usr/lib/RealPlayer9/users/Real/Codecs\0"        "/usr/lib/RealPlayer10/codecs\0"        "/usr/lib/RealPlayer10GOLD/codecs\0"        "/usr/lib/helix/player/codecs\0"        "/usr/lib64/RealPlayer8/Codecs\0"        "/usr/lib64/RealPlayer9/users/Real/Codecs\0"        "/usr/lib64/RealPlayer10/codecs\0"        "/usr/lib64/RealPlayer10GOLD/codecs\0"        "/usr/local/lib/codecs\0"        "\0"    };    for( size_t i = 0; psz_paths[i]; i += strlen( psz_paths + i ) + 1 )    {        if( asprintf( &g_decode_path, "%s/drv4.so.6.0", psz_paths + i ) != -1 )        {            p_sys->rv_handle = load_syms_linux(p_dec, g_decode_path);            free( g_decode_path );        }        if( p_sys->rv_handle )

⌨️ 快捷键说明

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