diff options
Diffstat (limited to 'src/libreal')
-rw-r--r-- | src/libreal/.hgignore (renamed from src/libreal/.cvsignore) | 0 | ||||
-rw-r--r-- | src/libreal/Makefile.am | 15 | ||||
-rw-r--r-- | src/libreal/audio_decoder.c | 179 | ||||
-rw-r--r-- | src/libreal/real_common.c | 158 | ||||
-rw-r--r-- | src/libreal/real_common.h | 86 | ||||
-rw-r--r-- | src/libreal/xine_decoder.c | 228 |
6 files changed, 322 insertions, 344 deletions
diff --git a/src/libreal/.cvsignore b/src/libreal/.hgignore index 7d926a554..7d926a554 100644 --- a/src/libreal/.cvsignore +++ b/src/libreal/.hgignore diff --git a/src/libreal/Makefile.am b/src/libreal/Makefile.am index 72dac45a1..114a473a7 100644 --- a/src/libreal/Makefile.am +++ b/src/libreal/Makefile.am @@ -1,15 +1,12 @@ include $(top_srcdir)/misc/Makefile.common -libdir = $(XINE_PLUGINDIR) +if ENABLE_REAL +xineplug_LTLIBRARIES = xineplug_decode_real.la +endif -lib_LTLIBRARIES = xineplug_decode_real.la xineplug_decode_real_audio.la - -xineplug_decode_real_la_SOURCES = xine_decoder.c +xineplug_decode_real_la_SOURCES = xine_decoder.c real_common.c audio_decoder.c xineplug_decode_real_la_LIBADD = $(XINE_LIB) $(DYNAMIC_LD_LIBS) xineplug_decode_real_la_CFLAGS = $(VISIBILITY_FLAG) -xineplug_decode_real_la_LDFLAGS = -avoid-version -module +xineplug_decode_real_la_LDFLAGS = $(xineplug_ldflags) -xineplug_decode_real_audio_la_SOURCES = audio_decoder.c -xineplug_decode_real_audio_la_LIBADD = $(XINE_LIB) $(DYNAMIC_LD_LIBS) -xineplug_decode_real_audio_la_CFLAGS = $(VISIBILITY_FLAG) -xineplug_decode_real_audio_la_LDFLAGS = -avoid-version -module +noinst_HEADERS = real_common.h diff --git a/src/libreal/audio_decoder.c b/src/libreal/audio_decoder.c index d5b2b2d26..d1bb94230 100644 --- a/src/libreal/audio_decoder.c +++ b/src/libreal/audio_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_decoder.c,v 1.49 2006/07/10 22:08:30 dgp85 Exp $ + * $Id: audio_decoder.c,v 1.59 2007/03/17 15:45:41 dgp85 Exp $ * * thin layer to use real binary-only codecs in xine * @@ -32,9 +32,6 @@ #include <fcntl.h> #include <unistd.h> #include <dlfcn.h> -#ifdef __x86_64__ - #include <elf.h> -#endif #define LOG_MODULE "real_audio_decoder" #define LOG_VERBOSE @@ -48,6 +45,8 @@ #include "buffer.h" #include "xineutils.h" +#include "real_common.h" + typedef struct { audio_decoder_class_t decoder_class; @@ -105,94 +104,14 @@ typedef struct { void *extras; } ra_init_t; -void *__builtin_new(unsigned long size); -void __builtin_delete (void *foo); -void *__builtin_vec_new(unsigned long size); -void __builtin_vec_delete(void *mem); -void __pure_virtual(void); - - -void *__builtin_new(unsigned long size) { - return malloc(size); -} - -void __builtin_delete (void *foo) { - /* printf ("libareal: __builtin_delete called\n"); */ - free (foo); -} - -#ifdef __x86_64__ -/* (gb) quick-n-dirty check to be run natively */ -static int is_x86_64_object_(FILE *f) -{ - Elf64_Ehdr *hdr = malloc(sizeof(Elf64_Ehdr)); - if (hdr == NULL) - return 0; - - if (fseek(f, 0, SEEK_SET) != 0) { - free(hdr); - return 0; - } - - if (fread(hdr, sizeof(Elf64_Ehdr), 1, f) != 1) { - free(hdr); - return 0; - } - - if (hdr->e_ident[EI_MAG0] != ELFMAG0 || - hdr->e_ident[EI_MAG1] != ELFMAG1 || - hdr->e_ident[EI_MAG2] != ELFMAG2 || - hdr->e_ident[EI_MAG3] != ELFMAG3) { - free(hdr); - return 0; - } - - return hdr->e_machine == EM_X86_64; -} - -static inline int is_x86_64_object(const char *filename) -{ - FILE *f; - int ret; - - if ((f = fopen(filename, "r")) == NULL) - return 0; - - ret = is_x86_64_object_(f); - fclose(f); - return ret; -} -#endif - -static int load_syms_linux (realdec_decoder_t *this, char *codec_name, - const char *alt_codec_name) { - - cfg_entry_t* entry = this->stream->xine->config->lookup_entry( - this->stream->xine->config, "decoder.external.real_codecs_path"); - char path[1024]; - struct stat sb; +static int load_syms_linux (realdec_decoder_t *this, const char *const codec_name, const char *const codec_alternate) { + cfg_entry_t* entry = + this->stream->xine->config->lookup_entry(this->stream->xine->config, + "decoder.external.real_codecs_path"); - snprintf (path, sizeof(path), "%s/%s", entry->str_value, codec_name); - if (stat(path, &sb)) - snprintf (path, sizeof(path), "%s/%s", entry->str_value, alt_codec_name); - -#ifdef __x86_64__ - /* check whether it's a real x86-64 library */ - if (!is_x86_64_object(path)) - return 0; -#endif - - lprintf ("(audio) opening shared obj '%s'\n", path); - - this->ra_handle = dlopen (path, RTLD_LAZY); - - if (!this->ra_handle) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "libareal: error: %s\n", dlerror()); - _x_message(this->stream, XINE_MSG_LIBRARY_LOAD_ERROR, - codec_name, NULL); + if ( (this->ra_handle = _x_real_codec_open(this->stream, entry->str_value, codec_name, codec_alternate)) == NULL ) return 0; - } - + this->raCloseCodec = dlsym (this->ra_handle, "RACloseCodec"); this->raDecode = dlsym (this->ra_handle, "RADecode"); this->raFlush = dlsym (this->ra_handle, "RAFlush"); @@ -208,7 +127,7 @@ static int load_syms_linux (realdec_decoder_t *this, char *codec_name, !this->raGetFlavorProperty || !this->raOpenCodec2 || !this->raSetFlavor || /*!raSetDLLAccessPath ||*/ !this->raInitDecoder){ xprintf (this->stream->xine, XINE_VERBOSITY_LOG, - _("libareal: (audio) Cannot resolve symbols - incompatible dll: %s\n"), path); + _("libareal: (audio) Cannot resolve symbols - incompatible dll: %s\n"), codec_name); return 0; } @@ -443,7 +362,7 @@ static unsigned char sipr_swaps[38][2]={ static void realdec_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { realdec_decoder_t *this = (realdec_decoder_t *) this_gen; - lprintf ("decode_data %d bytes, flags=0x%08x, pts=%lld ...\n", + lprintf ("decode_data %d bytes, flags=0x%08x, pts=%"PRId64" ...\n", buf->size, buf->decoder_flags, buf->pts); if (buf->decoder_flags & BUF_FLAG_PREVIEW) { @@ -678,35 +597,10 @@ static void dispose_class (audio_decoder_class_t *this) { free (this); } -/* - * some fake functions to make real codecs happy - */ -void *__builtin_vec_new(unsigned long size) EXPORTED; -void __builtin_vec_delete(void *mem) EXPORTED; -void __pure_virtual(void) EXPORTED; - -void *__builtin_vec_new(unsigned long size) { - return malloc(size); -} -void __builtin_vec_delete(void *mem) { - free(mem); -} -void __pure_virtual(void) { - lprintf("libareal: FATAL: __pure_virtual() called!\n"); - /* exit(1); */ -} - -/* - * real audio codec loader - */ - -static void *init_class (xine_t *xine, void *data) { +void *init_realadec (xine_t *xine, void *data) { real_class_t *this; config_values_t *config = xine->config; - char *real_codec_path; - char *default_real_codec_path = ""; - struct stat s; this = (real_class_t *) xine_xmalloc (sizeof (real_class_t)); @@ -715,44 +609,7 @@ static void *init_class (xine_t *xine, void *data) { this->decoder_class.get_description = get_description; this->decoder_class.dispose = dispose_class; - /* try some auto-detection */ - - if (!stat ("/usr/local/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/local/RealPlayer8/Codecs"; - if (!stat ("/usr/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/RealPlayer8/Codecs"; - if (!stat ("/usr/lib/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib/RealPlayer8/Codecs"; - if (!stat ("/opt/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/opt/RealPlayer8/Codecs"; - if (!stat ("/usr/lib/RealPlayer9/users/Real/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib/RealPlayer9/users/Real/Codecs"; - if (!stat ("/usr/lib/RealPlayer10/codecs/drvc.so", &s)) - default_real_codec_path = "/usr/lib/RealPlayer10/codecs"; - if (!stat ("/usr/lib64/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib64/RealPlayer8/Codecs"; - if (!stat ("/usr/lib64/RealPlayer9/users/Real/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib64/RealPlayer9/users/Real/Codecs"; - if (!stat ("/usr/lib64/RealPlayer10/codecs/drvc.so", &s)) - default_real_codec_path = "/usr/lib64/RealPlayer10/codecs"; - if (!stat ("/usr/lib/codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib/codecs"; - if (!stat ("/usr/lib/win32/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib/win32"; - - real_codec_path = config->register_string (config, "decoder.external.real_codecs_path", - default_real_codec_path, - _("path to RealPlayer codecs"), - _("If you have RealPlayer installed, specify the path " - "to its codec directory here. You can easily find " - "the codec directory by looking for a file named " - "\"drv3.so.6.0\" in it. If xine can find the RealPlayer " - "codecs, it will use them to decode RealPlayer content " - "for you. Consult the xine FAQ for more information on " - "how to install the codecs."), - 10, NULL, this); - - lprintf ("real codec path : %s\n", real_codec_path); + _x_real_codecs_init(xine); return this; } @@ -765,13 +622,7 @@ static uint32_t audio_types[] = { BUF_AUDIO_COOK, BUF_AUDIO_ATRK, /* BUF_AUDIO_14_4, BUF_AUDIO_28_8, */ BUF_AUDIO_SIPRO, 0 }; -static const decoder_info_t dec_info_audio = { +const decoder_info_t dec_info_realaudio = { audio_types, /* supported types */ - 5 /* priority */ -}; - -const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ - { PLUGIN_AUDIO_DECODER | PLUGIN_MUST_PRELOAD, 15, "realadec", XINE_VERSION_CODE, &dec_info_audio, init_class }, - { PLUGIN_NONE, 0, "", 0, NULL, NULL } + 7 /* priority */ }; diff --git a/src/libreal/real_common.c b/src/libreal/real_common.c new file mode 100644 index 000000000..925a5cc71 --- /dev/null +++ b/src/libreal/real_common.c @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2000-2007 the xine project + * + * This file is part of xine, a free video player. + * + * xine 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. + * + * xine 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-1307, USA + * + * $Id: real_common.c,v 1.12 2007/03/17 15:45:41 dgp85 Exp $ + * + * Common function for the thin layer to use Real binary-only codecs in xine + */ + +#define LOG_MODULE "real_common" +#define LOG_VERBOSE +/* +#define LOG +*/ + +#include "config.h" + +#include <sys/stat.h> +#include <string.h> +#include <dlfcn.h> + +#include "real_common.h" + +#ifdef __alpha__ + +void *__builtin_new(size_t size) { + return malloc(size); +} + +void __builtin_delete (void *foo) { + /* printf ("libareal: __builtin_delete called\n"); */ + free (foo); +} + +void *__builtin_vec_new(size_t size) { + return malloc(size); +} + +void __builtin_vec_delete(void *mem) { + free(mem); +} + +void __pure_virtual(void) { + lprintf("libreal: FATAL: __pure_virtual() called!\n"); + /* exit(1); */ +} + +#endif + +#ifndef HAVE____BRK_ADDR +void ___brk_addr(void) { exit(0); } +#endif + +#ifndef HAVE___CTYPE_B +void __ctype_b(void) { exit(0); } +#endif + +void _x_real_codecs_init(xine_t *const xine) { + const char *real_codecs_path = NULL; +#ifdef REAL_CODEC_PATH + const char *const default_real_codecs_path = REAL_CODEC_PATH; +#else + const char *default_real_codecs_path = ""; + struct stat s; + +#define try_real_path(path) \ + if (!stat (path "/dvrc.so", &s)) \ + default_real_codecs_path = path; +#define try_real_subpath(path) \ + try_real_path("/usr/" path) \ + else try_real_path("/usr/local" path) \ + else try_real_path("/opt" path) + + /* The priority is for the first found */ + try_real_subpath("lib/win32") + else try_real_subpath("lib/codecs") + else try_real_subpath("lib64/RealPlayer10/codecs") + else try_real_subpath("lib/RealPlayer10/codecs") + else try_real_subpath("lib64/RealPlayer9/users/Real/Codecs") + else try_real_subpath("lib/RealPlayer9/users/Real/Codecs") + else try_real_subpath("lib/RealPlayer8/Codecs") + else try_real_subpath("RealPlayer8/Codecs"); + +#undef try_real_path +#undef try_real_subpath +#endif + + real_codecs_path = + xine->config->register_filename (xine->config, "decoder.external.real_codecs_path", + default_real_codecs_path, + XINE_CONFIG_STRING_IS_DIRECTORY_NAME, + _("path to RealPlayer codecs"), + _("If you have RealPlayer installed, specify the path " + "to its codec directory here. You can easily find " + "the codec directory by looking for a file named " + "\"drvc.so\" in it. If xine can find the RealPlayer " + "codecs, it will use them to decode RealPlayer content " + "for you. Consult the xine FAQ for more information on " + "how to install the codecs."), + 10, NULL, NULL); + + lprintf ("real codecs path : %s\n", real_codec_path); +} + +void *_x_real_codec_open(xine_stream_t *const stream, const char *const path, + const char *const codec_name, + const char *const codec_alternate) { + char *codecpath = NULL; + void *codecmodule = NULL; + + asprintf(&codecpath, "%s/%s", path, codec_name); + if ( (codecmodule = dlopen(codecpath, RTLD_NOW)) ) { + free(codecpath); + return codecmodule; + } + + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, + LOG_MODULE ": error loading %s: %s\n", codecpath, dlerror()); + + free(codecpath); + + if ( codec_alternate ) { + asprintf(&codecpath, "%s/%s", path, codec_alternate); + if ( (codecmodule = dlopen(codecpath, RTLD_NOW)) ) { + free(codecpath); + return codecmodule; + } + + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, + LOG_MODULE ": error loading %s: %s\n", codecpath, dlerror()); + } + + _x_message(stream, XINE_MSG_LIBRARY_LOAD_ERROR, codec_name, NULL); + + return NULL; +} + +const plugin_info_t xine_plugin_info[] EXPORTED = { + /* type, API, "name", version, special_info, init_function */ + { PLUGIN_VIDEO_DECODER | PLUGIN_MUST_PRELOAD, 18, "realvdec", XINE_VERSION_CODE, &dec_info_realvideo, init_realvdec }, + { PLUGIN_AUDIO_DECODER | PLUGIN_MUST_PRELOAD, 15, "realadec", XINE_VERSION_CODE, &dec_info_realaudio, init_realadec }, + { PLUGIN_NONE, 0, "", 0, NULL, NULL } +}; diff --git a/src/libreal/real_common.h b/src/libreal/real_common.h new file mode 100644 index 000000000..232bf2a4d --- /dev/null +++ b/src/libreal/real_common.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2000-2007 the xine project + * + * This file is part of xine, a free video player. + * + * xine 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. + * + * xine 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-1307, USA + * + * $Id: real_common.h,v 1.7 2007/03/17 15:45:41 dgp85 Exp $ + * + * Common function for the thin layer to use Real binary-only codecs in xine + */ + +#ifndef __REAL_COMMON_H__ +#define __REAL_COMMON_H__ + +#include "xine_internal.h" + +/* + * some fake functions to make real codecs happy + * These are, on current date (20070316) needed only for Alpha + * codecs. + * As they are far from being proper replacements, define them only there + * until new codecs are available there too. + */ +#ifdef __alpha__ + +void *__builtin_new(size_t size); +void __builtin_delete (void *foo); +void *__builtin_vec_new(size_t size) EXPORTED; +void __builtin_vec_delete(void *mem) EXPORTED; +void __pure_virtual(void) EXPORTED; + +#endif + +#ifndef HAVE___ENVIRON +# ifdef HAVE__ENVIRON + char **__environ __attribute__((weak, alias("_environ"))); +# elif defined(HAVE_ENVIRON) + char **__environ __attribute__((weak, alias("environ"))); +# else + char **fake__environ = { NULL }; + char **__environ __attribute__((weak, alias("fake__environ"))); +# endif +#endif + +#ifndef HAVE_STDERR +# ifdef HAVE___STDERRP +# undef stderr +FILE *stderr __attribute__((weak, alias("__stderrp"))); +# else +# error Your stderr alias is not supported, please report to xine developers. +# endif +#endif + +#ifndef HAVE____BRK_ADDR +void ___brk_addr(void) EXPORTED; +#endif + +#ifndef HAVE___CTYPE_B +void __ctype_b(void) EXPORTED; +#endif + +void _x_real_codecs_init(xine_t *const xine); +void *_x_real_codec_open(xine_stream_t *const stream, const char *const path, + const char *const codec_name, + const char *const codec_alternate); + +const decoder_info_t dec_info_realvideo; +void *init_realvdec (xine_t *xine, void *data); + +const decoder_info_t dec_info_realaudio; +void *init_realadec (xine_t *xine, void *data); + +#endif diff --git a/src/libreal/xine_decoder.c b/src/libreal/xine_decoder.c index 0ed7f12d8..ea1fc8c54 100644 --- a/src/libreal/xine_decoder.c +++ b/src/libreal/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.83 2006/07/10 22:08:30 dgp85 Exp $ + * $Id: xine_decoder.c,v 1.93 2007/03/17 15:45:41 dgp85 Exp $ * * thin layer to use real binary-only codecs in xine * @@ -32,9 +32,6 @@ #include <fcntl.h> #include <unistd.h> #include <dlfcn.h> -#ifdef __x86_64__ - #include <elf.h> -#endif #define LOG_MODULE "real_decoder" #define LOG_VERBOSE @@ -47,6 +44,8 @@ #include "buffer.h" #include "xineutils.h" +#include "real_common.h" + typedef struct { video_decoder_class_t decoder_class; @@ -64,11 +63,11 @@ typedef struct realdec_decoder_s { void *rv_handle; - uint32_t (*rvyuv_custom_message)(uint32_t*, void*); + uint32_t (*rvyuv_custom_message)(void*, void*); uint32_t (*rvyuv_free)(void*); uint32_t (*rvyuv_hive_message)(uint32_t, uint32_t); uint32_t (*rvyuv_init)(void*, void*); /* initdata,context */ - uint32_t (*rvyuv_transform)(char*, char*, uint32_t*, uint32_t*,void*); + uint32_t (*rvyuv_transform)(char*, char*, void*, uint32_t*,void*); void *context; @@ -101,87 +100,40 @@ typedef struct { int32_t format; } rv_init_t; - -void *__builtin_vec_new(uint32_t size); -void __builtin_vec_delete(void *mem); -void __pure_virtual(void); - -#ifdef __x86_64__ -/* (gb) quick-n-dirty check to be run natively */ -static int is_x86_64_object_(FILE *f) -{ - Elf64_Ehdr *hdr = malloc(sizeof(Elf64_Ehdr)); - if (hdr == NULL) - return 0; - - if (fseek(f, 0, SEEK_SET) != 0) { - free(hdr); - return 0; - } - - if (fread(hdr, sizeof(Elf64_Ehdr), 1, f) != 1) { - free(hdr); - return 0; - } - - if (hdr->e_ident[EI_MAG0] != ELFMAG0 || - hdr->e_ident[EI_MAG1] != ELFMAG1 || - hdr->e_ident[EI_MAG2] != ELFMAG2 || - hdr->e_ident[EI_MAG3] != ELFMAG3) { - free(hdr); - return 0; - } - - return hdr->e_machine == EM_X86_64; -} - -static inline int is_x86_64_object(const char *filename) -{ - FILE *f; - int ret; - - if ((f = fopen(filename, "r")) == NULL) - return 0; - - ret = is_x86_64_object_(f); - fclose(f); - return ret; -} -#endif +/* + * Structures for data packets. These used to be tables of unsigned ints, but + * that does not work on 64 bit platforms (e.g. Alpha). The entries that are + * pointers get truncated. Pointers on 64 bit platforms are 8 byte longs. + * So we have to use structures so the compiler will assign the proper space + * for the pointer. + */ +typedef 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; /* * real codec loader */ -static int load_syms_linux (realdec_decoder_t *this, char *codec_name, - const char *alt_codec_name) { - - cfg_entry_t* entry = this->stream->xine->config->lookup_entry( - this->stream->xine->config, "decoder.external.real_codecs_path"); - char path[1024]; - struct stat sb; - - snprintf (path, sizeof(path), "%s/%s", entry->str_value, codec_name); - if (stat(path, &sb)) - snprintf (path, sizeof(path), "%s/%s", entry->str_value, alt_codec_name); +static int load_syms_linux (realdec_decoder_t *this, const char *codec_name, const char *const codec_alternate) { + cfg_entry_t* entry = + this->stream->xine->config->lookup_entry(this->stream->xine->config, + "decoder.external.real_codecs_path"); -#ifdef __x86_64__ - /* check whether it's a real x86-64 library */ - if (!is_x86_64_object(path)) - return 0; -#endif - - lprintf ("opening shared obj '%s'\n", path); - - this->rv_handle = dlopen (path, RTLD_LAZY); - - if (!this->rv_handle) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "libreal: error: %s\n", dlerror()); - _x_message(this->stream, XINE_MSG_LIBRARY_LOAD_ERROR, - codec_name, NULL); + if ( (this->rv_handle = _x_real_codec_open(this->stream, entry->str_value, codec_name, codec_alternate)) == NULL ) return 0; - } - + this->rvyuv_custom_message = dlsym (this->rv_handle, "RV20toYUV420CustomMessage"); this->rvyuv_free = dlsym (this->rv_handle, "RV20toYUV420Free"); this->rvyuv_hive_message = dlsym (this->rv_handle, "RV20toYUV420HiveMessage"); @@ -233,7 +185,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) { break; case BUF_VIDEO_RV40: _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Real Video 4.0"); - if (!load_syms_linux(this, "drvc.so", "drv4.so.6.0")) + if (!load_syms_linux(this, "drvc.so", "drv3.so.6.0")) return 0; break; default: @@ -262,7 +214,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) { this->duration = 90000.0 / this->fps; #endif - lprintf("this->ratio=%d\n", this->ratio); + lprintf("this->ratio=%f\n", this->ratio); lprintf ("init_data.w=%d(0x%x), init_data.h=%d(0x%x)," "this->width=%d(0x%x), this->height=%d(0x%x)\n", @@ -298,20 +250,14 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) { /* setup rv30 codec (codec sub-type and image dimensions): */ if ((init_data.format>=0x20200002) && (buf->type != BUF_VIDEO_RV40)) { int i, j; - uint32_t *cmsg24; - uint32_t cmsg_data[9]; + uint32_t cmsg24[(buf->size - 34 + 2) * sizeof(uint32_t)]; + cmsg_data_t cmsg_data = { 0x24, 1 + ((init_data.subformat >> 16) & 7), &cmsg24[0] }; - cmsg24 = xine_xmalloc((buf->size - 34 + 2) * sizeof(uint32_t)); - cmsg24[0] = this->width; cmsg24[1] = this->height; for(i = 2, j = 34; j < buf->size; i++, j++) cmsg24[i] = 4 * buf->content[j]; - cmsg_data[0] = 0x24; - cmsg_data[1] = 1 + ((init_data.subformat >> 16) & 7); - cmsg_data[2] = (uint32_t) cmsg24; - #ifdef LOG printf ("libreal: CustomMessage cmsg_data:\n"); xine_hexdump ((uint8_t *) cmsg_data, sizeof (cmsg_data)); @@ -319,9 +265,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) { xine_hexdump ((uint8_t *) cmsg24, (buf->size - 34 + 2) * sizeof(uint32_t)); #endif - this->rvyuv_custom_message (cmsg_data, this->context); - - free(cmsg24); + this->rvyuv_custom_message (&cmsg_data, this->context); } this->stream->video_out->open(this->stream->video_out, this->stream); @@ -338,7 +282,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) { static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { realdec_decoder_t *this = (realdec_decoder_t *) this_gen; - lprintf ("decode_data, flags=0x%08x, len=%d, pts=%lld ...\n", + lprintf ("decode_data, flags=0x%08x, len=%d, pts=%"PRId64" ...\n", buf->decoder_flags, buf->size, buf->pts); if (buf->decoder_flags & BUF_FLAG_PREVIEW) { @@ -374,7 +318,7 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) this->chunk_buffer_size = 0; this->pts = buf->pts; - lprintf ("new frame starting, pts=%lld\n", this->pts); + lprintf ("new frame starting, pts=%"PRId64"\n", this->pts); } if ((this->chunk_buffer_size + buf->size) > this->chunk_buffer_max) { @@ -401,16 +345,23 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) vo_frame_t *img; uint32_t transform_out[5]; - uint32_t transform_in[6]; + transform_in_t transform_in = { + this->chunk_buffer_size, + /* length of the packet (sub-packets appended) */ + 0, + /* unknown, seems to be unused */ + buf->decoder_info[2], + /* number of sub-packets - 1 */ + buf->decoder_info_ptr[2], + /* table of sub-packet offsets */ + 0, + /* unknown, seems to be unused */ + this->pts / 90 + /* timestamp (the integer value from the stream) */ + }; lprintf ("chunk table\n"); - transform_in[0] = this->chunk_buffer_size; /* length of the packet (sub-packets appended) */ - transform_in[1] = 0; /* unknown, seems to be unused */ - transform_in[2] = buf->decoder_info[2]; /* number of sub-packets - 1 */ - transform_in[3] = (uint32_t) buf->decoder_info_ptr[2]; /* table of sub-packet offsets */ - transform_in[4] = 0; /* unknown, seems to be unused */ - transform_in[5] = this->pts / 90; /* timestamp (the integer value from the stream) */ #ifdef LOG printf ("libreal: got %d chunks\n", @@ -429,7 +380,7 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) result = this->rvyuv_transform (this->chunk_buffer, this->frame_buffer, - transform_in, + &transform_in, transform_out, this->context); @@ -574,32 +525,10 @@ static void dispose_class (video_decoder_class_t *this) { free (this); } -/* - * some fake functions to make real codecs happy - */ -void *__builtin_vec_new(uint32_t size) EXPORTED; -void __builtin_vec_delete(void *mem) EXPORTED; -void __pure_virtual(void) EXPORTED; - -void *__builtin_vec_new(uint32_t size) { - return malloc(size); -} -void __builtin_vec_delete(void *mem) { - free(mem); -} -void __pure_virtual(void) { - lprintf("libreal: FATAL: __pure_virtual() called!\n"); - /* exit(1); */ -} - - -static void *init_class (xine_t *xine, void *data) { +void *init_realvdec (xine_t *xine, void *data) { real_class_t *this; config_values_t *config = xine->config; - char *real_codec_path; - char *default_real_codec_path = ""; - struct stat s; this = (real_class_t *) xine_xmalloc (sizeof (real_class_t)); @@ -608,44 +537,7 @@ static void *init_class (xine_t *xine, void *data) { this->decoder_class.get_description = get_description; this->decoder_class.dispose = dispose_class; - /* try some auto-detection */ - - if (!stat ("/usr/local/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/local/RealPlayer8/Codecs"; - if (!stat ("/usr/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/RealPlayer8/Codecs"; - if (!stat ("/usr/lib/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib/RealPlayer8/Codecs"; - if (!stat ("/opt/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/opt/RealPlayer8/Codecs"; - if (!stat ("/usr/lib/RealPlayer9/users/Real/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib/RealPlayer9/users/Real/Codecs"; - if (!stat ("/usr/lib/RealPlayer10/codecs/drvc.so", &s)) - default_real_codec_path = "/usr/lib/RealPlayer10/codecs"; - if (!stat ("/usr/lib64/RealPlayer8/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib64/RealPlayer8/Codecs"; - if (!stat ("/usr/lib64/RealPlayer9/users/Real/Codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib64/RealPlayer9/users/Real/Codecs"; - if (!stat ("/usr/lib64/RealPlayer10/codecs/drvc.so", &s)) - default_real_codec_path = "/usr/lib64/RealPlayer10/codecs"; - if (!stat ("/usr/lib/codecs/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib/codecs"; - if (!stat ("/usr/lib/win32/drv3.so.6.0", &s)) - default_real_codec_path = "/usr/lib/win32"; - - real_codec_path = config->register_string (config, "decoder.external.real_codecs_path", - default_real_codec_path, - _("path to RealPlayer codecs"), - _("If you have RealPlayer installed, specify the path " - "to its codec directory here. You can easily find " - "the codec directory by looking for a file named " - "\"drv3.so.6.0\" in it. If xine can find the RealPlayer " - "codecs, it will use them to decode RealPlayer content " - "for you. Consult the xine FAQ for more information on " - "how to install the codecs."), - 10, NULL, this); - - lprintf ("real codec path : %s\n", real_codec_path); + _x_real_codecs_init(xine); return this; } @@ -659,13 +551,7 @@ static uint32_t supported_types[] = { BUF_VIDEO_RV20, BUF_VIDEO_RV40, 0 }; -static const decoder_info_t dec_info_real = { +const decoder_info_t dec_info_realvideo = { supported_types, /* supported types */ 7 /* priority */ }; - -const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ - { PLUGIN_VIDEO_DECODER | PLUGIN_MUST_PRELOAD, 18, "real", XINE_VERSION_CODE, &dec_info_real, init_class }, - { PLUGIN_NONE, 0, "", 0, NULL, NULL } -}; |