summaryrefslogtreecommitdiff
path: root/src/libreal
diff options
context:
space:
mode:
Diffstat (limited to 'src/libreal')
-rw-r--r--src/libreal/audio_decoder.c76
-rw-r--r--src/libreal/xine_decoder.c43
2 files changed, 60 insertions, 59 deletions
diff --git a/src/libreal/audio_decoder.c b/src/libreal/audio_decoder.c
index c0df8c72f..8bf3afaaa 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.4 2002/11/25 02:06:28 guenter Exp $
+ * $Id: audio_decoder.c,v 1.5 2002/11/26 00:37:29 guenter Exp $
*
* thin layer to use real binary-only codecs in xine
*
@@ -38,10 +38,9 @@
#include "video_out.h"
#include "buffer.h"
-
+/*
#define LOG
-
-
+*/
typedef struct {
video_decoder_class_t decoder_class;
@@ -95,6 +94,7 @@ typedef struct {
void *extras;
} ra_init_t;
+#ifdef LOG
static void hexdump (char *buf, int length) {
int i;
@@ -125,6 +125,7 @@ static void hexdump (char *buf, int length) {
}
printf ("\n");
}
+#endif
void *__builtin_new(unsigned long size) {
return malloc(size);
@@ -136,7 +137,11 @@ static int load_syms_linux (realdec_decoder_t *this, char *codec_name) {
sprintf (path, "%s/%s", this->cls->real_codec_path, codec_name);
+#ifdef LOG
printf ("libareal: (audio) opening shared obj '%s'\n", path);
+
+#endif
+
this->ra_handle = dlopen (path, RTLD_LAZY);
if (!this->ra_handle) {
@@ -155,8 +160,6 @@ static int load_syms_linux (realdec_decoder_t *this, char *codec_name) {
this->raSetDLLAccessPath = dlsym (this->ra_handle, "SetDLLAccessPath");
this->raSetPwd = dlsym (this->ra_handle, "RASetPwd"); /* optional, used by SIPR */
- printf ("libareal: codec loaded, symbols resolved\n");
-
if (!this->raCloseCodec || !this->raDecode || !this->raFlush || !this->raFreeDecoder ||
!this->raGetFlavorProperty || !this->raOpenCodec2 || !this->raSetFlavor ||
/*!raSetDLLAccessPath ||*/ !this->raInitDecoder){
@@ -165,8 +168,6 @@ static int load_syms_linux (realdec_decoder_t *this, char *codec_name) {
return 0;
}
- printf ("libareal: raSetDLLAccessPath\n");
-
if (this->raSetDLLAccessPath){
char path[1024];
@@ -178,12 +179,12 @@ static int load_syms_linux (realdec_decoder_t *this, char *codec_name) {
}
path[strlen(path)+1]=0;
- printf ("libareal: path=%s\n", path);
-
this->raSetDLLAccessPath(path);
}
+#ifdef LOG
printf ("libareal: audio decoder loaded successfully\n");
+#endif
return 1;
}
@@ -203,9 +204,10 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
version = BE_16 (buf->content);
+#ifdef LOG
printf ("libareal: header buffer detected, header version %d\n", version);
-
hexdump (buf->content, buf->size);
+#endif
flavor = BE_16 (buf->content+18);
coded_frame_size = BE_32 (buf->content+20);
@@ -241,18 +243,16 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
this->block_align= coded_frame_size2;
+#ifdef LOG
printf ("libareal: 0x%04x 0x%04x 0x%04x 0x%04x data_len 0x%04x\n",
subpacket_size, coded_frame_size, codec_data_length,
coded_frame_size2, data_len);
-
-
printf ("libareal: %d samples/sec, %d bits/sample, %d channels\n",
samples_per_sec, bits_per_sample, num_channels);
+#endif
/* load codec, resolv symbols */
- printf ("libareal: loading codec...\n");
-
switch (buf->type) {
case BUF_AUDIO_COOK:
if (!load_syms_linux (this, "cook.so.6.0"))
@@ -311,11 +311,12 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
};
+#ifdef LOG
printf ("libareal: init_data:\n");
hexdump (&init_data, sizeof (ra_init_t));
printf ("libareal: extras :\n");
hexdump (init_data.extras, data_len);
-
+#endif
result = this->raInitDecoder (this->context, &init_data);
if(result){
@@ -325,16 +326,12 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
}
}
- printf ("libareal: raInitDecoder done.\n");
-
if (this->raSetPwd){
/* used by 'SIPR' */
this->raSetPwd (this->context, "Ardubancel Quazanga"); /* set password... lol. */
printf ("libareal: password set\n");
}
- printf ("libareal: set flavor %d\n", flavor);
-
result = this->raSetFlavor (this->context, flavor);
if (result){
printf ("libareal: decoder flavor setup failed, error code: 0x%x\n",
@@ -342,26 +339,6 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
return 0;
}
- printf ("libareal: set flavor %d done\n", flavor);
-
-
-#if 0
-
- prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0,&len);
- mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio codec: [%d] %s\n",((short*)(sh->wf+1))[2],prop);
-
- prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],1,&len);
- sh->i_bps=((*((int*)prop))+4)/8;
- mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Audio bitrate: %5.3f kbit/s (%d bps) \n",(*((int*)prop))*0.001f,sh->i_bps);
-
-// prop=raGetFlavorProperty(sh->context,((short*)(sh->wf+1))[2],0x13,&len);
-// mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Samples/block?: %d \n",(*((int*)prop)));
-
- sh->audio_out_minsize=128000; // no idea how to get... :(
- sh->audio_in_minsize=((short*)(sh->wf+1))[1]*sh->wf->nBlockAlign;
-
-#endif
-
/*
* alloc buffers for data reordering
*/
@@ -380,7 +357,6 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
this->frame_reordered = this->frame_buffer;
this->frame_num_bytes = 0;
- printf ("libareal: frame size is %d\n", this->frame_size);
}
/*
@@ -406,7 +382,6 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
mode) ;
this->sample_size = num_channels * (bits_per_sample>>3);
- printf ("libareal: 1 sample is %d bytes\n", this->sample_size);
return 1;
}
@@ -437,7 +412,9 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
int size;
+#ifdef LOG
printf ("libareal: content buffer detected, %d bytes\n", buf->size);
+#endif
size = buf->size;
@@ -452,7 +429,9 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
memcpy (this->frame_buffer+this->frame_num_bytes, buf->content, size);
this->frame_num_bytes += size;
+#ifdef LOG
printf ("libareal: buffering %d/%d bytes\n", this->frame_num_bytes, this->frame_size);
+#endif
size = 0;
@@ -466,16 +445,19 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
int h = this->h;
audio_buffer_t *audio_buffer;
+#ifdef LOG
printf ("libareal: buffering %d bytes\n", needed);
+#endif
memcpy (this->frame_buffer+this->frame_num_bytes, buf->content, needed);
size -= needed;
this->frame_num_bytes = 0;
+#ifdef LOG
printf ("libareal: frame completed. reordering...\n");
-
printf ("libareal: bs=%d sps=%d w=%d h=%d \n",/*sh->wf->nBlockAlign*/-1,sps,w,h);
+#endif
if (!sps) {
@@ -523,8 +505,10 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
for (x=0; x<w; x++) {
+#ifdef LOG
printf ("libareal: x=%d, y=%d, off %d\n",
x, y, sps*(h*x+((h+1)/2)*(y&1)+(y>>1)));
+#endif
memcpy (this->frame_reordered+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)),
s, sps);
@@ -540,7 +524,9 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
*/
}
+#ifdef LOG
hexdump (this->frame_reordered, buf->size);
+#endif
n = 0;
while (n<this->frame_size) {
@@ -552,7 +538,9 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
this->block_align,
audio_buffer->mem, &len, -1);
+#ifdef LOG
printf ("libareal: raDecode result %d, len=%d\n", result, len);
+#endif
audio_buffer->vpts = 0; /* FIXME */
audio_buffer->num_frames = len/this->sample_size;;
@@ -698,7 +686,9 @@ static void *init_class (xine_t *xine, void *data) {
"/opt/RealPlayer8/Codecs");
}
+#ifdef LOG
printf ("libareal: real codec path : %s\n", this->real_codec_path);
+#endif
return this;
}
diff --git a/src/libreal/xine_decoder.c b/src/libreal/xine_decoder.c
index 935492c7a..49b86600b 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.7 2002/11/25 02:26:51 guenter Exp $
+ * $Id: xine_decoder.c,v 1.8 2002/11/26 00:37:29 guenter Exp $
*
* thin layer to use real binary-only codecs in xine
*
@@ -38,9 +38,9 @@
#include "video_out.h"
#include "buffer.h"
-
+/*
#define LOG
-
+*/
typedef struct {
@@ -101,6 +101,7 @@ typedef struct {
int format;
} rv_init_t;
+#ifdef LOG
static void hexdump (char *buf, int length) {
int i;
@@ -131,7 +132,7 @@ static void hexdump (char *buf, int length) {
}
printf ("\n");
}
-
+#endif
/*
* real codec loader
@@ -143,7 +144,9 @@ static int load_syms_linux (realdec_decoder_t *this, char *codec_name) {
sprintf (path, "%s/%s", this->cls->real_codec_path, codec_name);
+#ifdef LOG
printf ("libreal: opening shared obj '%s'\n", path);
+#endif
this->rv_handle = dlopen (path, RTLD_LAZY);
if (!this->rv_handle) {
@@ -176,8 +179,6 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
0, 1, 0}; /* rv30 */
- printf ("libareal: loading codec...\n");
-
switch (buf->type) {
case BUF_VIDEO_RV20:
if (!load_syms_linux (this, "drv2.so.6.0"))
@@ -202,21 +203,21 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
init_data.subformat = BE_32(&buf->content[26]);
init_data.format = BE_32(&buf->content[30]);
+#ifdef LOG
hexdump (&init_data, sizeof (init_data));
hexdump (buf->content, 32);
hexdump (extrahdr, 10);
-
+
printf ("libreal: init codec %dx%d... %x %x\n",
init_data.w, init_data.h,
init_data.subformat, init_data.format );
-
+#endif
+
this->context = NULL;
result = this->rvyuv_init (&init_data, &this->context);
- printf ("libreal: ... done %d\n", result);
-
/* setup rv30 codec (codec sub-type and image dimensions): */
if (init_data.format>=0x20200002){
unsigned long cmsg24[4]={this->width,this->height,
@@ -224,15 +225,14 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
unsigned long cmsg_data[3]={0x24,1+((init_data.subformat>>16)&7),
(unsigned long) &cmsg24};
+#ifdef LOG
printf ("libreal: cmsg24:\n");
hexdump (cmsg24, sizeof (cmsg24));
printf ("libreal: cmsg_data:\n");
hexdump (cmsg_data, sizeof (cmsg_data));
+#endif
this->rvyuv_custom_message (cmsg_data, this->context);
-
- printf ("libreal: special setup for rv30 done\n");
-
}
this->stream->video_out->open(this->stream->video_out, this->stream);
@@ -247,7 +247,8 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
realdec_decoder_t *this = (realdec_decoder_t *) this_gen;
#ifdef LOG
- printf ("libreal: decode_data, flags=0x%08x ...\n", buf->decoder_flags);
+ printf ("libreal: decode_data, flags=0x%08x, len=%d ...\n",
+ buf->decoder_flags, buf->size);
#endif
if (buf->decoder_flags & BUF_FLAG_PREVIEW) {
@@ -275,8 +276,10 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
this->pts /* timestamp (the integer value from the stream) */
};
+#ifdef LOG
printf ("libreal: got %d chunks in buffer and new frame is starting\n",
this->num_chunks);
+#endif
img = this->stream->video_out->get_frame (this->stream->video_out,
/* this->av_picture.linesize[0], */
@@ -301,6 +304,7 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
img->duration = this->duration;
img->bad_frame = 0;
+#ifdef LOG
printf ("libreal: pts %lld %lld diff %lld # %d est. duration %lld\n",
this->pts*90,
buf->pts*90,
@@ -316,6 +320,7 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
printf ("libreal: chunk_table:\n");
hexdump (this->chunk_tab, this->num_chunks*8+8);
+#endif
result = this->rvyuv_transform (this->chunk_buffer,
this->frame_buffer,
@@ -323,14 +328,14 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
transform_out,
this->context);
- printf ("libreal: decoding result: %d\n", result);
-
xine_fast_memcpy (img->base[0], this->frame_buffer, this->frame_size);
xine_fast_memcpy (img->base[1], this->frame_buffer+this->frame_size,
this->frame_size/4);
xine_fast_memcpy (img->base[2], this->frame_buffer+this->frame_size*5/4,
this->frame_size/4);
+ /* FIXME: call copy on slices */
+
img->draw(img, this->stream);
img->free(img);
@@ -338,7 +343,9 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
/* new frame starting */
+#ifdef LOG
printf ("libreal: new frame starting (%d bytes)\n", buf->size);
+#endif
memcpy (this->chunk_buffer, buf->content, buf->size);
@@ -355,8 +362,10 @@ static void realdec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
/* buffer another fragment */
+#ifdef LOG
printf ("libreal: another fragment (%d chunks in buffer)\n",
this->num_chunks);
+#endif
memcpy (this->chunk_buffer+this->chunk_buffer_size, buf->content, buf->size);
@@ -503,7 +512,9 @@ static void *init_class (xine_t *xine, void *data) {
"/opt/RealPlayer8/Codecs");
}
+#ifdef LOG
printf ("libareal: real codec path : %s\n", this->real_codec_path);
+#endif
return this;
}