summaryrefslogtreecommitdiff
path: root/src/libreal
diff options
context:
space:
mode:
Diffstat (limited to 'src/libreal')
-rw-r--r--src/libreal/Makefile.am1
-rw-r--r--src/libreal/real_common.c22
-rw-r--r--src/libreal/real_common.h10
-rw-r--r--src/libreal/xine_real_audio_decoder.c241
-rw-r--r--src/libreal/xine_real_video_decoder.c153
5 files changed, 176 insertions, 251 deletions
diff --git a/src/libreal/Makefile.am b/src/libreal/Makefile.am
index 6e76d6279..90e47a63c 100644
--- a/src/libreal/Makefile.am
+++ b/src/libreal/Makefile.am
@@ -1,3 +1,4 @@
+include $(top_builddir)/misc/Makefile.plugins
include $(top_srcdir)/misc/Makefile.common
if ENABLE_REAL
diff --git a/src/libreal/real_common.c b/src/libreal/real_common.c
index fcd0fac8f..6eedb009a 100644
--- a/src/libreal/real_common.c
+++ b/src/libreal/real_common.c
@@ -1,18 +1,18 @@
/*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
@@ -77,8 +77,8 @@ void _x_real_codecs_init(xine_t *const xine) {
default_real_codecs_path[0] = 0;
-#define UL64 0x05 /* /usr/{,local/}lib64 */
-#define UL 0x0A /* /usr/{,local/}lib */
+#define UL64 0x03 /* /usr/{,local/}lib64 */
+#define UL 0x0C /* /usr/{,local/}lib */
#define O 0x10 /* /opt */
#define OL64 0x20 /* /opt/lib64 */
#define OL 0x40 /* /opt/lib */
@@ -132,8 +132,8 @@ void _x_real_codecs_init(xine_t *const xine) {
#endif
- real_codecs_path =
- xine->config->register_filename (xine->config, "decoder.external.real_codecs_path",
+ 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"),
@@ -154,7 +154,7 @@ void *_x_real_codec_open(xine_stream_t *const stream, const char *const path,
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);
@@ -178,12 +178,12 @@ void *_x_real_codec_open(xine_stream_t *const stream, const char *const path,
}
_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 */
+ /* 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
index 1e3d8c264..3c77eda5f 100644
--- a/src/libreal/real_common.h
+++ b/src/libreal/real_common.h
@@ -1,18 +1,18 @@
/*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
@@ -26,7 +26,7 @@
#include "xine_internal.h"
/*
- * some fake functions to make real codecs happy
+ * 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
diff --git a/src/libreal/xine_real_audio_decoder.c b/src/libreal/xine_real_audio_decoder.c
index 1b21de2d0..aa53bbb8d 100644
--- a/src/libreal/xine_real_audio_decoder.c
+++ b/src/libreal/xine_real_audio_decoder.c
@@ -1,27 +1,31 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
+/*
+ * Copyright (C) 2000-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* thin layer to use real binary-only codecs in xine
*
- * code inspired by work from Florian Schneider for the MPlayer Project
+ * code inspired by work from Florian Schneider for the MPlayer Project
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
@@ -51,6 +55,8 @@ typedef struct {
/* empty so far */
} real_class_t;
+typedef void * ra_codec_t;
+
typedef struct realdec_decoder_s {
audio_decoder_t audio_decoder;
@@ -60,18 +66,18 @@ typedef struct realdec_decoder_s {
void *ra_handle;
- unsigned long (*raCloseCodec)(void*);
- unsigned long (*raDecode)(void*, char*,unsigned long,char*,unsigned int*,long);
- unsigned long (*raFlush)(unsigned long,unsigned long,unsigned long);
- unsigned long (*raFreeDecoder)(void*);
- void* (*raGetFlavorProperty)(void*,unsigned long,unsigned long,int*);
- unsigned long (*raInitDecoder)(void*, void*);
- unsigned long (*raOpenCodec2)(void*);
- unsigned long (*raSetFlavor)(void*,unsigned long);
- void (*raSetDLLAccessPath)(char*);
- void (*raSetPwd)(char*,char*);
+ uint32_t (*raCloseCodec)(ra_codec_t);
+ uint32_t (*raDecode)(ra_codec_t, char *, uint32_t, char *, uint32_t *, uint32_t);
+ uint32_t (*raFlush)(ra_codec_t, char *, uint32_t *);
+ uint32_t (*raFreeDecoder)(ra_codec_t);
+ void * (*raGetFlavorProperty)(ra_codec_t, uint16_t, uint16_t, uint16_t *);
+ uint32_t (*raInitDecoder)(ra_codec_t, void *);
+ uint32_t (*raOpenCodec2)(ra_codec_t *, const char *);
+ uint32_t (*raSetFlavor)(ra_codec_t, uint16_t);
+ void (*raSetDLLAccessPath)(char *);
+ void (*raSetPwd)(ra_codec_t, char *);
- void *context;
+ ra_codec_t context;
int sps, w, h;
int block_align;
@@ -86,20 +92,20 @@ typedef struct realdec_decoder_s {
uint64_t pts;
int output_open;
-
+
int decoder_ok;
} realdec_decoder_t;
typedef struct {
- int samplerate;
- short bits;
- short channels;
- int unk1;
- int subpacket_size;
- int coded_frame_size;
- int codec_data_length;
- void *extras;
+ uint32_t samplerate;
+ uint16_t bits;
+ uint16_t channels;
+ uint16_t quality;
+ uint32_t subpacket_size;
+ uint32_t coded_frame_size;
+ uint32_t codec_data_length;
+ void *extras;
} ra_init_t;
static int load_syms_linux (realdec_decoder_t *this, const char *const codec_name, const char *const codec_alternate) {
@@ -124,7 +130,7 @@ static int load_syms_linux (realdec_decoder_t *this, const char *const codec_nam
if (!this->raCloseCodec || !this->raDecode || !this->raFlush || !this->raFreeDecoder ||
!this->raGetFlavorProperty || !this->raOpenCodec2 || !this->raSetFlavor ||
/*!raSetDLLAccessPath ||*/ !this->raInitDecoder){
- xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
_("libareal: (audio) Cannot resolve symbols - incompatible dll: %s\n"), codec_name);
return 0;
}
@@ -156,7 +162,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
int coded_frame_size2, data_len, flavor;
int mode;
void *extras;
-
+
/*
* extract header data
*/
@@ -167,13 +173,13 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
#ifdef LOG
xine_hexdump (buf->content, buf->size);
#endif
-
+
flavor = _X_BE_16 (buf->content+22);
coded_frame_size = _X_BE_32 (buf->content+24);
codec_data_length= _X_BE_16 (buf->content+40);
coded_frame_size2= _X_BE_16 (buf->content+42);
subpacket_size = _X_BE_16 (buf->content+44);
-
+
this->sps = subpacket_size;
this->w = coded_frame_size2;
this->h = codec_data_length;
@@ -185,8 +191,8 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
/* FIXME: */
if (buf->type==BUF_AUDIO_COOK) {
-
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"libareal: audio header version 4 for COOK audio not supported.\n");
return 0;
}
@@ -204,7 +210,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
this->block_align= coded_frame_size2;
lprintf ("0x%04x 0x%04x 0x%04x 0x%04x data_len 0x%04x\n",
- subpacket_size, coded_frame_size, codec_data_length,
+ subpacket_size, coded_frame_size, codec_data_length,
coded_frame_size2, data_len);
lprintf ("%d samples/sec, %d bits/sample, %d channels\n",
samples_per_sec, bits_per_sample, num_channels);
@@ -216,13 +222,14 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
_x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Cook");
if (!load_syms_linux (this, "cook.so", "cook.so.6.0"))
return 0;
+ this->block_align = subpacket_size;
break;
-
+
case BUF_AUDIO_ATRK:
_x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Atrac");
if (!load_syms_linux (this, "atrc.so", "atrc.so.6.0"))
return 0;
- this->block_align = 384;
+ this->block_align = subpacket_size;
break;
case BUF_AUDIO_14_4:
@@ -245,7 +252,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
break;
default:
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"libareal: error, i don't handle buf type 0x%08x\n", buf->type);
return 0;
}
@@ -254,19 +261,19 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
* init codec
*/
- result = this->raOpenCodec2 (&this->context);
+ result = this->raOpenCodec2 (&this->context, NULL);
if (result) {
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "libareal: error in raOpenCodec2: %d\n", result);
return 0;
}
- {
+ {
ra_init_t init_data;
init_data.samplerate = samples_per_sec;
init_data.bits = bits_per_sample;
init_data.channels = num_channels;
- init_data.unk1 = 100; /* ??? */
+ init_data.quality = 100; /* ??? */
init_data.subpacket_size = subpacket_size; /* subpacket size */
init_data.coded_frame_size = coded_frame_size; /* coded frame size */
init_data.codec_data_length = data_len; /* codec data length */
@@ -278,10 +285,10 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
printf ("libareal: extras :\n");
xine_hexdump (init_data.extras, data_len);
#endif
-
+
result = this->raInitDecoder (this->context, &init_data);
if(result){
- xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
_("libareal: decoder init failed, error code: 0x%x\n"), result);
return 0;
}
@@ -307,14 +314,14 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
if (this->sps) {
this->frame_size = this->w/this->sps*this->h*this->sps;
- this->frame_buffer = xine_xmalloc (this->frame_size);
- this->frame_reordered = xine_xmalloc (this->frame_size);
+ this->frame_buffer = calloc (1, this->frame_size);
+ this->frame_reordered = calloc (1, this->frame_size);
this->frame_num_bytes = 0;
} else {
this->frame_size = this->w*this->h;
- this->frame_buffer = xine_xmalloc (this->frame_size);
+ this->frame_buffer = calloc (this->w, this->h);
this->frame_reordered = this->frame_buffer;
this->frame_num_bytes = 0;
@@ -337,7 +344,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
return 0;
}
- (this->stream->audio_out->open) (this->stream->audio_out,
+ (this->stream->audio_out->open) (this->stream->audio_out,
this->stream,
bits_per_sample,
samples_per_sec,
@@ -350,17 +357,10 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
return 1;
}
-static unsigned char sipr_swaps[38][2]={
- {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
- {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
- {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},
- {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},
- {77,80} };
-
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=%"PRId64" ...\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) {
@@ -383,130 +383,46 @@ static void realdec_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
this->pts = buf->pts;
size = buf->size;
-
while (size) {
+ int need;
- int needed;
-
- needed = this->frame_size - this->frame_num_bytes;
-
- if (needed>size) {
-
- memcpy (this->frame_buffer+this->frame_num_bytes, buf->content, size);
+ need = this->frame_size - this->frame_num_bytes;
+ if (size < need) {
+ memcpy (this->frame_buffer + this->frame_num_bytes,
+ buf->content + buf->size - size, size);
this->frame_num_bytes += size;
-
- lprintf ("buffering %d/%d bytes\n", this->frame_num_bytes, this->frame_size);
-
size = 0;
-
} else {
-
- int result;
- int len =-1;
- int n;
- int sps = this->sps;
- int w = this->w;
- int h = this->h;
audio_buffer_t *audio_buffer;
+ int n, len;
+ int result;
- lprintf ("buffering %d bytes\n", needed);
-
- memcpy (this->frame_buffer+this->frame_num_bytes, buf->content, needed);
-
- size -= needed;
+ memcpy (this->frame_buffer + this->frame_num_bytes,
+ buf->content + buf->size - size, need);
+ size -= need;
this->frame_num_bytes = 0;
- lprintf ("frame completed. reordering...\n");
- lprintf ("bs=%d sps=%d w=%d h=%d \n",/*sh->wf->nBlockAlign*/-1,sps,w,h);
-
- if (!sps) {
-
- int j,n;
- int bs=h*w*2/96; /* nibbles per subpacket */
- unsigned char *p=this->frame_buffer;
-
- /* 'sipr' way */
- /* demux_read_data(sh->ds, p, h*w); */
- for (n=0;n<38;n++){
- int i=bs*sipr_swaps[n][0];
- int o=bs*sipr_swaps[n][1];
- /* swap nibbles of block 'i' with 'o' TODO: optimize */
- for (j=0;j<bs;j++) {
- int x=(i&1) ? (p[(i>>1)]>>4) : (p[(i>>1)]&15);
- int y=(o&1) ? (p[(o>>1)]>>4) : (p[(o>>1)]&15);
- if (o&1)
- p[(o>>1)]=(p[(o>>1)]&0x0F)|(x<<4);
- else
- p[(o>>1)]=(p[(o>>1)]&0xF0)|x;
-
- if (i&1)
- p[(i>>1)]=(p[(i>>1)]&0x0F)|(y<<4);
- else
- p[(i>>1)]=(p[(i>>1)]&0xF0)|y;
-
- ++i;
- ++o;
- }
- }
- /*
- sh->a_in_buffer_size=
- sh->a_in_buffer_len=w*h;
- */
-
- } else {
- int x, y;
- uint8_t *s;
-
- /* 'cook' way */
-
- w /= sps; s = this->frame_buffer;
-
- for (y=0; y<h; y++)
-
- for (x=0; x<w; x++) {
-
- lprintf ("x=%d, y=%d, off %d\n",
- x, y, sps*(h*x+((h+1)/2)*(y&1)+(y>>1)));
-
- memcpy (this->frame_reordered+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)),
- s, sps);
- s+=sps;
-
- /* demux_read_data(sh->ds, sh->a_in_buffer+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)),
- sps); */
-
- }
- /*
- sh->a_in_buffer_size=
- sh->a_in_buffer_len=w*h*sps;
- */
- }
-
-#ifdef LOG
- xine_hexdump (this->frame_reordered, buf->size);
-#endif
-
n = 0;
- while (n<this->frame_size) {
+ while (n < this->frame_size) {
audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- result = this->raDecode (this->context,
- this->frame_reordered+n,
+ result = this->raDecode (this->context,
+ this->frame_buffer + n,
this->block_align,
(char *) audio_buffer->mem, &len, -1);
lprintf ("raDecode result %d, len=%d\n", result, len);
- audio_buffer->vpts = this->pts;
+ audio_buffer->vpts = this->pts;
this->pts = 0;
audio_buffer->num_frames = len/this->sample_size;;
-
- this->stream->audio_out->put_buffer (this->stream->audio_out,
+
+ this->stream->audio_out->put_buffer (this->stream->audio_out,
audio_buffer, this->stream);
- n+=this->block_align;
+ n += this->block_align;
}
}
}
@@ -517,13 +433,13 @@ static void realdec_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
static void realdec_reset (audio_decoder_t *this_gen) {
realdec_decoder_t *this = (realdec_decoder_t *) this_gen;
-
+
this->frame_num_bytes = 0;
}
static void realdec_discontinuity (audio_decoder_t *this_gen) {
realdec_decoder_t *this = (realdec_decoder_t *) this_gen;
-
+
this->pts = 0;
}
@@ -559,13 +475,13 @@ static void realdec_dispose (audio_decoder_t *this_gen) {
lprintf ("dispose done\n");
}
-static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen,
+static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen,
xine_stream_t *stream) {
real_class_t *cls = (real_class_t *) class_gen;
realdec_decoder_t *this ;
- this = (realdec_decoder_t *) xine_xmalloc (sizeof (realdec_decoder_t));
+ this = (realdec_decoder_t *) calloc(1, sizeof(realdec_decoder_t));
this->audio_decoder.decode_data = realdec_decode_data;
this->audio_decoder.reset = realdec_reset;
@@ -598,9 +514,8 @@ static void dispose_class (audio_decoder_class_t *this) {
void *init_realadec (xine_t *xine, void *data) {
real_class_t *this;
- config_values_t *config = xine->config;
- this = (real_class_t *) xine_xmalloc (sizeof (real_class_t));
+ this = (real_class_t *) calloc(1, sizeof(real_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.get_identifier = get_identifier;
@@ -616,11 +531,11 @@ void *init_realadec (xine_t *xine, void *data) {
* exported plugin catalog entry
*/
-static uint32_t audio_types[] = {
+static uint32_t audio_types[] = {
BUF_AUDIO_COOK, BUF_AUDIO_ATRK, /* BUF_AUDIO_14_4, BUF_AUDIO_28_8, */ BUF_AUDIO_SIPRO, 0
};
const decoder_info_t dec_info_realaudio = {
audio_types, /* supported types */
- 7 /* priority */
+ 6 /* priority */
};
diff --git a/src/libreal/xine_real_video_decoder.c b/src/libreal/xine_real_video_decoder.c
index d68c7390e..4977ee889 100644
--- a/src/libreal/xine_real_video_decoder.c
+++ b/src/libreal/xine_real_video_decoder.c
@@ -1,27 +1,31 @@
/*
- * Copyright (C) 2000-2004 the xine project
- *
+ * Copyright (C) 2000-2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* thin layer to use real binary-only codecs in xine
*
- * code inspired by work from Florian Schneider for the MPlayer Project
+ * code inspired by work from Florian Schneider for the MPlayer Project
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
@@ -63,9 +67,9 @@ typedef struct realdec_decoder_s {
uint32_t (*rvyuv_custom_message)(void*, void*);
uint32_t (*rvyuv_free)(void*);
- uint32_t (*rvyuv_hive_message)(uint32_t, uint32_t);
+ uint32_t (*rvyuv_hive_message)(uint32_t, void*);
uint32_t (*rvyuv_init)(void*, void*); /* initdata,context */
- uint32_t (*rvyuv_transform)(char*, char*, void*, uint32_t*,void*);
+ uint32_t (*rvyuv_transform)(char*, char*, void*, void*, void*);
void *context;
@@ -113,13 +117,21 @@ typedef struct cmsg_data_s {
typedef struct transform_in_s {
uint32_t len;
- uint32_t unknown1;
- uint32_t chunks;
- uint32_t* extra;
- uint32_t unknown2;
+ uint32_t interpolate;
+ uint32_t nsegments;
+ void *segments;
+ uint32_t flags;
uint32_t timestamp;
} transform_in_t;
+typedef struct {
+ uint32_t frames;
+ uint32_t notes;
+ uint32_t timestamp;
+ uint32_t width;
+ uint32_t height;
+} transform_out_t;
+
/*
* real codec loader
*/
@@ -137,12 +149,12 @@ static int load_syms_linux (realdec_decoder_t *this, const char *codec_name, con
this->rvyuv_hive_message = dlsym (this->rv_handle, "RV20toYUV420HiveMessage");
this->rvyuv_init = dlsym (this->rv_handle, "RV20toYUV420Init");
this->rvyuv_transform = dlsym (this->rv_handle, "RV20toYUV420Transform");
-
+
if (this->rvyuv_custom_message &&
this->rvyuv_free &&
this->rvyuv_hive_message &&
this->rvyuv_init &&
- this->rvyuv_transform)
+ this->rvyuv_transform)
return 1;
this->rvyuv_custom_message = dlsym (this->rv_handle, "RV40toYUV420CustomMessage");
@@ -150,15 +162,15 @@ static int load_syms_linux (realdec_decoder_t *this, const char *codec_name, con
this->rvyuv_hive_message = dlsym (this->rv_handle, "RV40toYUV420HiveMessage");
this->rvyuv_init = dlsym (this->rv_handle, "RV40toYUV420Init");
this->rvyuv_transform = dlsym (this->rv_handle, "RV40toYUV420Transform");
-
+
if (this->rvyuv_custom_message &&
this->rvyuv_free &&
this->rvyuv_hive_message &&
this->rvyuv_init &&
- this->rvyuv_transform)
+ this->rvyuv_transform)
return 1;
- xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG,
_("libreal: Error resolving symbols! (version incompatibility?)\n"));
return 0;
}
@@ -169,7 +181,6 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
int result;
rv_init_t init_data = {11, 0, 0, 0, 0, 0, 1, 0}; /* rv30 */
-
switch (buf->type) {
case BUF_VIDEO_RV20:
_x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Real Video 2.0");
@@ -187,17 +198,17 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
return 0;
break;
default:
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
"libreal: error, i don't handle buf type 0x%08x\n", buf->type);
_x_abort();
}
init_data.w = _X_BE_16(&buf->content[12]);
init_data.h = _X_BE_16(&buf->content[14]);
-
+
this->width = (init_data.w + 1) & (~1);
this->height = (init_data.h + 1) & (~1);
-
+
if(buf->decoder_flags & BUF_FLAG_ASPECT)
this->ratio = (double)buf->decoder_info[1] / (double)buf->decoder_info[2];
else
@@ -205,15 +216,15 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
/* While the framerate is stored in the header it sometimes doesn't bear
* much resemblence to the actual frequency of frames in the file. Hence
- * it's better to just let the engine estimate the frame duration for us */
+ * it's better to just let the engine estimate the frame duration for us */
#if 0
- this->fps = (double) _X_BE_16(&buf->content[22]) +
+ this->fps = (double) _X_BE_16(&buf->content[22]) +
((double) _X_BE_16(&buf->content[24]) / 65536.0);
this->duration = 90000.0 / this->fps;
#endif
-
+
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",
init_data.w, init_data.w,
@@ -227,22 +238,22 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
init_data.subformat = _X_BE_32(&buf->content[26]);
init_data.format = _X_BE_32(&buf->content[30]);
-
+
#ifdef LOG
printf ("libreal: init_data for rvyuv_init:\n");
xine_hexdump ((char *) &init_data, sizeof (init_data));
-
+
printf ("libreal: buf->content\n");
xine_hexdump (buf->content, buf->size);
-#endif
- lprintf ("init codec %dx%d... %x %x\n",
+#endif
+ lprintf ("init codec %dx%d... %x %x\n",
init_data.w, init_data.h,
init_data.subformat, init_data.format );
-
+
this->context = NULL;
-
- result = this->rvyuv_init (&init_data, &this->context);
-
+
+ result = this->rvyuv_init (&init_data, &this->context);
+
lprintf ("init result: %d\n", result);
/* setup rv30 codec (codec sub-type and image dimensions): */
@@ -255,42 +266,42 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
cmsg24[1] = this->height;
for(i = 2, j = 34; j < buf->size; i++, j++)
cmsg24[i] = 4 * buf->content[j];
-
+
#ifdef LOG
printf ("libreal: CustomMessage cmsg_data:\n");
- xine_hexdump ((uint8_t *) cmsg_data, sizeof (cmsg_data));
+ xine_hexdump ((uint8_t *) &cmsg_data, sizeof (cmsg_data));
printf ("libreal: cmsg24:\n");
xine_hexdump ((uint8_t *) cmsg24, (buf->size - 34 + 2) * sizeof(uint32_t));
#endif
-
+
this->rvyuv_custom_message (&cmsg_data, this->context);
}
-
+
(this->stream->video_out->open) (this->stream->video_out, this->stream);
-
+
this->frame_size = this->width * this->height;
this->frame_buffer = xine_xmalloc (this->width * this->height * 3 / 2);
-
- this->chunk_buffer = xine_xmalloc (BUF_SIZE);
+
+ this->chunk_buffer = calloc(1, BUF_SIZE);
this->chunk_buffer_max = BUF_SIZE;
-
+
return 1;
}
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=%"PRId64" ...\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) {
/* real_find_sequence_header (&this->real, buf->content, buf->content + buf->size);*/
return;
}
-
+
if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
this->duration = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION,
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION,
this->duration);
}
@@ -301,14 +312,14 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
_x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
} else if (this->decoder_ok && this->context) {
-
+
/* Each frame starts with BUF_FLAG_FRAME_START and ends with
* BUF_FLAG_FRAME_END.
* The last buffer contains the chunk offset table.
*/
if (!(buf->decoder_flags & BUF_FLAG_SPECIAL)) {
-
+
lprintf ("buffer (%d bytes)\n", buf->size);
if (buf->decoder_flags & BUF_FLAG_FRAME_START) {
@@ -318,10 +329,10 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
this->pts = buf->pts;
lprintf ("new frame starting, pts=%"PRId64"\n", this->pts);
}
-
+
if ((this->chunk_buffer_size + buf->size) > this->chunk_buffer_max) {
lprintf("increasing chunk buffer size\n");
-
+
this->chunk_buffer_max *= 2;
this->chunk_buffer = realloc(this->chunk_buffer, this->chunk_buffer_max);
}
@@ -334,15 +345,15 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
} else {
/* end of frame, chunk table */
-
+
lprintf ("special buffer (%d bytes)\n", buf->size);
-
+
if (buf->decoder_info[1] == BUF_SPECIAL_RV_CHUNK_TABLE) {
int result;
vo_frame_t *img;
- uint32_t transform_out[5];
+ transform_out_t transform_out;
transform_in_t transform_in = {
this->chunk_buffer_size,
/* length of the packet (sub-packets appended) */
@@ -369,31 +380,31 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
xine_hexdump (this->chunk_buffer, this->chunk_buffer_size);
printf ("libreal: transform_in:\n");
- xine_hexdump ((uint8_t *) transform_in, 6 * 4);
+ xine_hexdump ((uint8_t *) &transform_in, sizeof(rv_xform_in_t));
printf ("libreal: chunk_table:\n");
- xine_hexdump ((uint8_t *) buf->decoder_info_ptr[2],
+ xine_hexdump ((uint8_t *) buf->decoder_info_ptr[2],
2*(buf->decoder_info[2]+1)*sizeof(uint32_t));
#endif
result = this->rvyuv_transform (this->chunk_buffer,
this->frame_buffer,
&transform_in,
- transform_out,
+ &transform_out,
this->context);
lprintf ("transform result: %08x\n", result);
lprintf ("transform_out:\n");
- #ifdef LOG
- xine_hexdump ((uint8_t *) transform_out, 5 * 4);
- #endif
+#ifdef LOG
+ xine_hexdump ((uint8_t *) &transform_out, 5 * 4);
+#endif
/* Sometimes the stream contains video of a different size
* to that specified in the realmedia header */
- if(transform_out[0] && ((transform_out[3] != this->width) ||
- (transform_out[4] != this->height))) {
- this->width = transform_out[3];
- this->height = transform_out[4];
+ if(transform_out.frames && ((transform_out.width != this->width) ||
+ (transform_out.height != this->height))) {
+ this->width = transform_out.width;
+ this->height = transform_out.height;
this->frame_size = this->width * this->height;
@@ -447,13 +458,13 @@ static void realdec_flush (video_decoder_t *this_gen) {
static void realdec_reset (video_decoder_t *this_gen) {
realdec_decoder_t *this = (realdec_decoder_t *) this_gen;
-
+
this->chunk_buffer_size = 0;
}
static void realdec_discontinuity (video_decoder_t *this_gen) {
realdec_decoder_t *this = (realdec_decoder_t *) this_gen;
-
+
this->pts = 0;
}
@@ -469,27 +480,27 @@ static void realdec_dispose (video_decoder_t *this_gen) {
if (this->rvyuv_free && this->context)
this->rvyuv_free (this->context);
- if (this->rv_handle)
+ if (this->rv_handle)
dlclose (this->rv_handle);
if (this->frame_buffer)
free (this->frame_buffer);
-
+
if (this->chunk_buffer)
free (this->chunk_buffer);
-
+
free (this);
lprintf ("dispose done\n");
}
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen,
+static video_decoder_t *open_plugin (video_decoder_class_t *class_gen,
xine_stream_t *stream) {
real_class_t *cls = (real_class_t *) class_gen;
realdec_decoder_t *this ;
- this = (realdec_decoder_t *) xine_xmalloc (sizeof (realdec_decoder_t));
+ this = (realdec_decoder_t *) calloc(1, sizeof(realdec_decoder_t));
this->video_decoder.decode_data = realdec_decode_data;
this->video_decoder.flush = realdec_flush;
@@ -526,9 +537,8 @@ static void dispose_class (video_decoder_class_t *this) {
void *init_realvdec (xine_t *xine, void *data) {
real_class_t *this;
- config_values_t *config = xine->config;
- this = (real_class_t *) xine_xmalloc (sizeof (real_class_t));
+ this = (real_class_t *) calloc(1, sizeof(real_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.get_identifier = get_identifier;
@@ -544,8 +554,7 @@ void *init_realvdec (xine_t *xine, void *data) {
* exported plugin catalog entry
*/
-static uint32_t supported_types[] = { BUF_VIDEO_RV20,
- BUF_VIDEO_RV30,
+static uint32_t supported_types[] = { BUF_VIDEO_RV30,
BUF_VIDEO_RV40,
0 };