summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/video_out.h11
-rw-r--r--src/libmpeg2/Makefile.am15
-rw-r--r--src/libmpeg2/decode.c357
-rw-r--r--src/libmpeg2/mpeg2.h10
-rw-r--r--src/libmpeg2/mpeg2_internal.h1
-rw-r--r--src/libmpeg2/xine_decoder.c91
-rw-r--r--src/xine-engine/video_decoder.c10
-rw-r--r--src/xine-engine/xine.c49
-rw-r--r--src/xine-engine/xine_internal.h14
9 files changed, 346 insertions, 212 deletions
diff --git a/include/video_out.h b/include/video_out.h
index cf7a9f6d6..1f3c10285 100644
--- a/include/video_out.h
+++ b/include/video_out.h
@@ -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: video_out.h,v 1.4 2001/04/20 18:01:55 guenter Exp $
+ * $Id: video_out.h,v 1.5 2001/04/23 00:34:59 guenter Exp $
*
*
* xine version of video_out.h
@@ -269,12 +269,3 @@ vo_instance_t *vo_init (char *driver_name);
char *vo_get_available_drivers ();
#endif
-
-
-
-
-
-
-
-
-
diff --git a/src/libmpeg2/Makefile.am b/src/libmpeg2/Makefile.am
index a7031295c..c6c6a1391 100644
--- a/src/libmpeg2/Makefile.am
+++ b/src/libmpeg2/Makefile.am
@@ -1,13 +1,20 @@
-CFLAGS = @BUILD_LIB_STATIC@ @LIBMPEG2_CFLAGS@ @GLOBAL_CFLAGS@
+CFLAGS = @LIBMPEG2_CFLAGS@ @GLOBAL_CFLAGS@
EXTRA_DIST = idct_mlib.c idct_mlib.h motion_comp_mlib.c
-noinst_LTLIBRARIES = libmpeg2.la
+LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic
+
+libdir = $(XINE_PLUGINDIR)
+
+lib_LTLIBRARIES = xineplug_decode_mpeg2.la
#libmpeg2_la_SOURCES = slice.c header.c stats.c idct.c motion_comp.c\
# decode.c idct_mmx.c motion_comp_mmx.c
-libmpeg2_la_SOURCES = slice.c header.c stats.c idct.c motion_comp.c\
- decode.c idct_mmx.c motion_comp_mmx.c
+
+xineplug_decode_mpeg2_la_SOURCES = slice.c header.c stats.c idct.c motion_comp.c\
+ decode.c idct_mmx.c motion_comp_mmx.c xine_decoder.c
+xineplug_decode_mpeg2_la_LDFLAGS = -avoid-version -module
+
noinst_HEADERS = vlc.h mpeg2.h mpeg2_internal.h
diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c
index 010eed0f5..c4d456fa1 100644
--- a/src/libmpeg2/decode.c
+++ b/src/libmpeg2/decode.c
@@ -26,51 +26,37 @@
#include <stdlib.h>
#include <inttypes.h>
-/* Xine specific */
-#include "buffer.h"
-#include "xine_internal.h"
-
#include "video_out.h"
#include "mpeg2.h"
#include "mpeg2_internal.h"
#include "cpu_accel.h"
-#include "attributes.h"
-
-#ifdef HAVE_MEMALIGN
-/* some systems have memalign() but no declaration for it */
-void * memalign (size_t align, size_t size);
-#else
-/* assume malloc alignment is sufficient */
-#define memalign(align,size) malloc (size)
-#endif
-
-#define BUFFER_SIZE (224 * 1024)
+#include "utils.h"
mpeg2_config_t config;
-void mpeg2_init (mpeg2dec_t * mpeg2dec, uint32_t mm_accel,
- vo_instance_t * output)
+void mpeg2_init (mpeg2dec_t * mpeg2dec,
+ vo_instance_t * output)
{
static int do_init = 1;
if (do_init) {
do_init = 0;
- config.flags = mm_accel;
+ config.flags = mm_accel();
idct_init ();
motion_comp_init ();
}
- mpeg2dec->chunk_buffer = memalign (16, BUFFER_SIZE + 4);
- mpeg2dec->picture = memalign (16, sizeof (picture_t));
+ mpeg2dec->chunk_buffer = xmalloc_aligned (16, 224 * 1024 + 4);
+ mpeg2dec->picture = xmalloc_aligned (16, sizeof (picture_t));
- mpeg2dec->shift = 0xffffff00;
+ mpeg2dec->shift = 0;
mpeg2dec->is_sequence_needed = 1;
- mpeg2dec->drop_flag = 0;
- mpeg2dec->drop_frame = 0;
+ mpeg2dec->frames_to_drop = 0;
+ mpeg2dec->skip_slices = 0;
mpeg2dec->in_slice = 0;
- mpeg2dec->output = output;
mpeg2dec->chunk_ptr = mpeg2dec->chunk_buffer;
- mpeg2dec->code = 0xb4;
+ mpeg2dec->code = 0xff;
+ mpeg2dec->output = output;
memset (mpeg2dec->picture, 0, sizeof (picture_t));
@@ -78,11 +64,91 @@ void mpeg2_init (mpeg2dec_t * mpeg2dec, uint32_t mm_accel,
header_state_init (mpeg2dec->picture);
}
-static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
- uint8_t * buffer, uint32_t pts)
+void decode_free_image_buffers (mpeg2dec_t * mpeg2dec) {
+
+ picture_t *picture = mpeg2dec->picture;
+
+ if (picture->forward_reference_frame) {
+ picture->forward_reference_frame->free (picture->forward_reference_frame);
+ picture->forward_reference_frame = NULL;
+ }
+
+ if (picture->backward_reference_frame) {
+ picture->backward_reference_frame->free (picture->backward_reference_frame);
+ picture->backward_reference_frame = NULL;
+ }
+
+ if (picture->throwaway_frame) {
+ picture->throwaway_frame->free (picture->throwaway_frame);
+ picture->throwaway_frame = NULL;
+ }
+}
+
+static void decode_reorder_frames (mpeg2dec_t * mpeg2dec)
+{
+ picture_t *picture = mpeg2dec->picture;
+
+ if (picture->picture_coding_type != B_TYPE) {
+
+ if (picture->forward_reference_frame)
+ picture->forward_reference_frame->free (picture->forward_reference_frame);
+
+ /*
+ * make the backward reference frame the new forward reference frame
+ */
+
+ picture->forward_reference_frame = picture->backward_reference_frame;
+
+ /*
+ * allocate new backward reference frame
+ */
+
+
+ picture->backward_reference_frame = mpeg2dec->output->get_frame (mpeg2dec->output,
+ picture->coded_picture_width,
+ picture->coded_picture_height,
+ picture->aspect_ratio_information,
+ IMGFMT_YV12,
+ picture->frame_duration);;
+ picture->backward_reference_frame->PTS = 0;
+ picture->backward_reference_frame->bFrameBad = 1;
+
+ /*
+ * make it the current frame
+ */
+
+ picture->current_frame = picture->backward_reference_frame;
+
+ } else {
+
+ /*
+ * allocate new throwaway frame
+ */
+
+ picture->throwaway_frame = mpeg2dec->output->get_frame (mpeg2dec->output,
+ picture->coded_picture_width,
+ picture->coded_picture_height,
+ picture->aspect_ratio_information,
+ IMGFMT_YV12,
+ picture->frame_duration);;
+ picture->throwaway_frame->PTS = 0;
+ picture->throwaway_frame->bFrameBad = 1;
+
+ /*
+ * make it the current frame
+ */
+
+ picture->current_frame = picture->throwaway_frame;
+ }
+}
+
+
+
+static int parse_chunk (mpeg2dec_t * mpeg2dec, int code, uint8_t * buffer, uint32_t pts)
{
picture_t * picture;
int is_frame_done;
+ int bFlipPage;
/* wait for sequence_header_code */
if (mpeg2dec->is_sequence_needed && (code != 0xb3))
@@ -96,18 +162,17 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
if (is_frame_done) {
mpeg2dec->in_slice = 0;
- if (((picture->picture_structure == FRAME_PICTURE) ||
- (picture->second_field)) &&
- (!(mpeg2dec->drop_frame))) {
- if (picture->picture_coding_type == B_TYPE)
- picture->current_frame->draw (picture->current_frame);
- else
+ if ((picture->picture_structure == FRAME_PICTURE) ||
+ (picture->second_field)) {
+ if (picture->picture_coding_type == B_TYPE) {
+ picture->throwaway_frame->draw (picture->throwaway_frame);
+ picture->throwaway_frame->free (picture->throwaway_frame);
+ } else {
picture->forward_reference_frame->draw (picture->forward_reference_frame);
-#ifdef ARCH_X86
- if (config.flags & MM_ACCEL_X86_MMX)
- emms ();
-#endif
- }
+ }
+ bFlipPage = 1;
+ } else
+ bFlipPage = 0;
}
switch (code) {
@@ -117,13 +182,60 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
exit (1);
}
+ if (bFlipPage)
+ decode_reorder_frames (mpeg2dec);
+
if (mpeg2dec->pts) {
picture->current_frame->PTS = mpeg2dec->pts;
mpeg2dec->pts = 0;
}
- mpeg2dec->drop_frame =
- mpeg2dec->drop_flag && (picture->picture_coding_type == B_TYPE);
+
+ /*
+ * find out if we want to skip this frame
+ */
+
+ mpeg2dec->drop_frame = 0;
+ switch (picture->picture_coding_type) {
+ case B_TYPE:
+
+ if (mpeg2dec->frames_to_drop) {
+ mpeg2dec->drop_frame = 1;
+ mpeg2dec->frames_to_drop--;
+ }
+ if (!picture->forward_reference_frame
+ || !picture->backward_reference_frame
+ || picture->forward_reference_frame->bFrameBad
+ || picture->backward_reference_frame->bFrameBad) {
+ mpeg2dec->drop_frame = 1;
+ mpeg2dec->frames_to_drop--;
+ }
+
+ break;
+ case P_TYPE:
+
+ if (mpeg2dec->frames_to_drop>2) {
+ mpeg2dec->drop_frame = 1;
+ mpeg2dec->frames_to_drop--;
+ }
+
+ if (!picture->forward_reference_frame
+ || picture->forward_reference_frame->bFrameBad) {
+ mpeg2dec->drop_frame = 1;
+ mpeg2dec->frames_to_drop--;
+ }
+
+ break;
+ case I_TYPE:
+
+ if (mpeg2dec->frames_to_drop>4) {
+ mpeg2dec->drop_frame = 1;
+ mpeg2dec->frames_to_drop--;
+ }
+
+ break;
+ }
+
break;
case 0xb3: /* sequence_header_code */
@@ -131,20 +243,9 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
fprintf (stderr, "bad sequence header\n");
exit (1);
}
- if (mpeg2dec->is_sequence_needed) {
+ if (mpeg2dec->is_sequence_needed)
mpeg2dec->is_sequence_needed = 0;
- picture->forward_reference_frame =
- mpeg2dec->output->get_frame (mpeg2dec->output,picture->coded_picture_width,
- picture->coded_picture_height,
- picture->aspect_ratio_information, IMGFMT_YV12,
- picture->frame_duration);
- picture->backward_reference_frame =
- mpeg2dec->output->get_frame (mpeg2dec->output,picture->coded_picture_width,
- picture->coded_picture_height,
- picture->aspect_ratio_information, IMGFMT_YV12,
- picture->frame_duration);
- }
break;
case 0xb5: /* extension_start_code */
@@ -165,102 +266,83 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
mpeg2dec->in_slice = 1;
if (picture->second_field)
- picture->current_frame->field (picture->current_frame, picture->picture_structure);
+ picture->current_frame->field (picture->current_frame,
+ picture->picture_structure);
+ /*
else {
if (picture->picture_coding_type == B_TYPE)
picture->current_frame =
- mpeg2dec->output->get_frame (mpeg2dec->output,picture->coded_picture_width,
- picture->coded_picture_height,
- picture->aspect_ratio_information, IMGFMT_YV12,
- picture->frame_duration);
- /* vo_get_frame (mpeg2dec->output,
- picture->picture_structure); */
+ vo_get_frame (mpeg2dec->output,
+ picture->picture_structure);
else {
picture->current_frame =
- mpeg2dec->output->get_frame (mpeg2dec->output,picture->coded_picture_width,
- picture->coded_picture_height,
- picture->aspect_ratio_information, IMGFMT_YV12,
- picture->frame_duration);
- /*
vo_get_frame (mpeg2dec->output,
(VO_PREDICTION_FLAG |
picture->picture_structure));
- */
picture->forward_reference_frame =
picture->backward_reference_frame;
picture->backward_reference_frame = picture->current_frame;
}
}
+ */
}
if (!(mpeg2dec->drop_frame)) {
slice_process (picture, code, buffer);
-
-#ifdef ARCH_X86
- if (config.flags & MM_ACCEL_X86_MMX)
- emms ();
-#endif
}
}
return is_frame_done;
}
-static inline uint8_t * copy_chunk (mpeg2dec_t * mpeg2dec,
- uint8_t * current, uint8_t * end)
+int mpeg2_decode_data (mpeg2dec_t * mpeg2dec, uint8_t * current, uint8_t * end,
+ uint32_t pts)
{
uint32_t shift;
uint8_t * chunk_ptr;
- uint8_t * limit;
uint8_t byte;
+ int ret = 0;
shift = mpeg2dec->shift;
chunk_ptr = mpeg2dec->chunk_ptr;
- limit = current + (mpeg2dec->chunk_buffer + BUFFER_SIZE - chunk_ptr);
- if (limit > end)
- limit = end;
-
- while (1) {
- byte = *current++;
- if (shift != 0x00000100) {
- shift = (shift | byte) << 8;
- *chunk_ptr++ = byte;
- if (current < limit)
- continue;
- if (current == end) {
+ mpeg2dec->pts = pts;
+
+ while (current != end) {
+ while (1) {
+ byte = *current++;
+ if (shift != 0x00000100) {
+ *chunk_ptr++ = byte;
+ shift = (shift | byte) << 8;
+ if (current != end)
+ continue;
mpeg2dec->chunk_ptr = chunk_ptr;
mpeg2dec->shift = shift;
- return NULL;
- } else {
- /* we filled the chunk buffer without finding a start code */
- mpeg2dec->code = 0xb4; /* sequence_error_code */
- mpeg2dec->chunk_ptr = mpeg2dec->chunk_buffer;
- return current;
+#ifdef ARCH_X86
+ if (config.flags & MM_ACCEL_X86_MMX)
+ emms();
+#endif
+
+ return ret;
}
+ break;
}
- mpeg2dec->code = byte;
- mpeg2dec->chunk_ptr = mpeg2dec->chunk_buffer;
- mpeg2dec->shift = 0xffffff00;
- return current;
- }
-}
-int mpeg2_decode_data (mpeg2dec_t * mpeg2dec, uint8_t * current,
- uint8_t * end, uint32_t pts)
-{
- int ret;
- uint8_t code;
+ /* found start_code following chunk */
- ret = 0;
+ ret += parse_chunk (mpeg2dec, mpeg2dec->code, mpeg2dec->chunk_buffer, pts);
- mpeg2dec->pts = pts;
- while (current != end) {
- code = mpeg2dec->code;
- current = copy_chunk (mpeg2dec, current, end);
- if (current == NULL)
- return ret;
- ret += parse_chunk (mpeg2dec, code, mpeg2dec->chunk_buffer, pts);
+ /* done with header or slice, prepare for next one */
+
+ mpeg2dec->code = byte;
+ chunk_ptr = mpeg2dec->chunk_buffer;
+ shift = 0xffffff00;
}
+ mpeg2dec->chunk_ptr = chunk_ptr;
+ mpeg2dec->shift = shift;
+#ifdef ARCH_X86
+ if (config.flags & MM_ACCEL_X86_MMX)
+ emms();
+#endif
return ret;
}
@@ -268,63 +350,20 @@ void mpeg2_close (mpeg2dec_t * mpeg2dec)
{
static uint8_t finalizer[] = {0,0,1,0};
- mpeg2_decode_data (mpeg2dec, finalizer, finalizer+4, mpeg2dec->pts);
+ mpeg2_decode_data (mpeg2dec, finalizer, finalizer+4, 0);
if (! (mpeg2dec->is_sequence_needed))
- mpeg2dec->picture->backward_reference_frame->draw (mpeg2dec->picture->backward_reference_frame);
+ mpeg2dec->picture->backward_reference_frame->draw (mpeg2dec->picture->backward_reference_frame);
+
+ mpeg2dec->output->close (mpeg2dec->output);
free (mpeg2dec->chunk_buffer);
free (mpeg2dec->picture);
}
-void mpeg2_drop (mpeg2dec_t * mpeg2dec, int flag)
+void mpeg2_skip_frames (mpeg2dec_t * mpeg2dec, int num_frames)
{
- mpeg2dec->drop_flag = flag;
-}
-
-/*
- * xine specific stuff
- */
-
-int mpeg2dec_get_version () {
- return 1;
-}
-
-int mpeg2dec_can_handle (int buf_type) {
- return (buf_type == BUF_VIDEO_MPEG) ;
-}
-
-
-static mpeg2dec_t gMpeg2;
-
-void mpeg2dec_init (vo_instance_t *video_out) {
- uint32_t mmacc = mm_accel();
-
- mpeg2_init (&gMpeg2, mmacc, video_out);
-}
-
-void mpeg2dec_decode_data (buf_element_t *buf) {
- mpeg2_decode_data (&gMpeg2, buf->content, buf->content + buf->size,
- buf->PTS);
+ mpeg2dec->frames_to_drop = num_frames;
}
-void mpeg2dec_release_img_buffers () {
- // decode_free_image_buffers (&gMpeg2);
-}
-void mpeg2dec_close () {
- mpeg2_close (&gMpeg2);
-}
-
-static video_decoder_t vd_mpeg2dec = {
- mpeg2dec_get_version,
- mpeg2dec_can_handle,
- mpeg2dec_init,
- mpeg2dec_decode_data,
- mpeg2dec_release_img_buffers,
- mpeg2dec_close
-};
-
-video_decoder_t *init_video_decoder_mpeg2dec () {
- return &vd_mpeg2dec;
-}
diff --git a/src/libmpeg2/mpeg2.h b/src/libmpeg2/mpeg2.h
index c83a61e7e..3b51fba22 100644
--- a/src/libmpeg2/mpeg2.h
+++ b/src/libmpeg2/mpeg2.h
@@ -30,8 +30,8 @@ typedef struct mpeg2dec_s {
uint32_t shift;
int is_display_initialized;
int is_sequence_needed;
- int drop_flag;
- int drop_frame;
+ int frames_to_drop, drop_frame;
+ int skip_slices;
int in_slice;
/* the maximum chunk size is determined by vbv_buffer_size */
@@ -46,8 +46,6 @@ typedef struct mpeg2dec_s {
uint32_t pts;
- /* ONLY for 0.2.0 release - will not stay there later */
- int frame_rate_code;
} mpeg2dec_t ;
@@ -55,7 +53,7 @@ typedef struct mpeg2dec_s {
/* initialize mpegdec with a opaque user pointer */
-void mpeg2_init (mpeg2dec_t * mpeg2dec, uint32_t mm_accel,
+void mpeg2_init (mpeg2dec_t * mpeg2dec,
vo_instance_t * output);
/* destroy everything which was allocated, shutdown the output */
@@ -64,4 +62,6 @@ void mpeg2_close (mpeg2dec_t * mpeg2dec);
int mpeg2_decode_data (mpeg2dec_t * mpeg2dec,
uint8_t * data_start, uint8_t * data_end, uint32_t pts);
+void decode_free_image_buffers (mpeg2dec_t * mpeg2dec) ;
+
void mpeg2_drop (mpeg2dec_t * mpeg2dec, int flag);
diff --git a/src/libmpeg2/mpeg2_internal.h b/src/libmpeg2/mpeg2_internal.h
index e2f2111d5..a5d76dc7c 100644
--- a/src/libmpeg2/mpeg2_internal.h
+++ b/src/libmpeg2/mpeg2_internal.h
@@ -118,6 +118,7 @@ typedef struct picture_s {
struct vo_frame_s * current_frame;
struct vo_frame_s * forward_reference_frame;
struct vo_frame_s * backward_reference_frame;
+ struct vo_frame_s * throwaway_frame;
int second_field;
diff --git a/src/libmpeg2/xine_decoder.c b/src/libmpeg2/xine_decoder.c
new file mode 100644
index 000000000..a2f358b6d
--- /dev/null
+++ b/src/libmpeg2/xine_decoder.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2000-2001 the xine project
+ *
+ * This file is part of xine, a unix 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: xine_decoder.c,v 1.1 2001/04/23 00:34:59 guenter Exp $
+ *
+ * stuff needed to turn libmpeg2 into a xine decoder plugin
+ */
+
+
+#include <stdlib.h>
+
+#include "video_out.h"
+#include "mpeg2.h"
+#include "mpeg2_internal.h"
+#include "buffer.h"
+#include "xine_internal.h"
+
+
+typedef struct mpeg2dec_decoder_s {
+ video_decoder_t video_decoder;
+ mpeg2dec_t mpeg2;
+} mpeg2dec_decoder_t;
+
+int mpeg2dec_can_handle (video_decoder_t *this_gen, int buf_type) {
+ return ((buf_type & 0xFFFF0000) == BUF_VIDEO_MPEG) ;
+}
+
+
+void mpeg2dec_init (video_decoder_t *this_gen, vo_instance_t *video_out) {
+
+ mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+
+ mpeg2_init (&this->mpeg2, video_out);
+}
+
+void mpeg2dec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
+ mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+
+ mpeg2_decode_data (&this->mpeg2, buf->content, buf->content + buf->size,
+ buf->PTS);
+}
+
+void mpeg2dec_release_img_buffers (video_decoder_t *this_gen) {
+
+ mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+
+ decode_free_image_buffers (&this->mpeg2);
+}
+
+void mpeg2dec_close (video_decoder_t *this_gen) {
+
+ mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+
+ mpeg2_close (&this->mpeg2);
+}
+
+video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *cfg) {
+
+ mpeg2dec_decoder_t *this ;
+
+ if (iface_version != 1)
+ return NULL;
+
+ this = (mpeg2dec_decoder_t *) malloc (sizeof (mpeg2dec_decoder_t));
+
+ this->video_decoder.interface_version = 1;
+ this->video_decoder.can_handle = mpeg2dec_can_handle;
+ this->video_decoder.init = mpeg2dec_init;
+ this->video_decoder.decode_data = mpeg2dec_decode_data;
+ this->video_decoder.release_img_buffers = mpeg2dec_release_img_buffers;
+ this->video_decoder.close = mpeg2dec_close;
+
+ return (video_decoder_t *) this;
+}
+
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index dab46d628..3d3632b1e 100644
--- a/src/xine-engine/video_decoder.c
+++ b/src/xine-engine/video_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: video_decoder.c,v 1.4 2001/04/22 02:42:49 guenter Exp $
+ * $Id: video_decoder.c,v 1.5 2001/04/23 00:34:59 guenter Exp $
*
*/
@@ -43,7 +43,7 @@ void *video_decoder_loop (void *this_gen) {
switch (buf->type) {
case BUF_CONTROL_START:
if (this->video_cur_decoder) {
- this->video_cur_decoder->close ();
+ this->video_cur_decoder->close (this->video_cur_decoder);
this->video_cur_decoder = NULL;
}
@@ -62,7 +62,7 @@ void *video_decoder_loop (void *this_gen) {
if (this->video_cur_decoder != decoder) {
if (this->video_cur_decoder)
- this->video_cur_decoder->close ();
+ this->video_cur_decoder->close (this->video_cur_decoder);
this->video_cur_decoder = decoder;
this->video_cur_decoder->init (this->video_cur_decoder, this->video_out);
@@ -76,7 +76,7 @@ void *video_decoder_loop (void *this_gen) {
case BUF_CONTROL_END:
if (this->video_cur_decoder) {
- this->video_cur_decoder->close ();
+ this->video_cur_decoder->close (this->video_cur_decoder);
this->video_cur_decoder = NULL;
}
@@ -94,7 +94,7 @@ void *video_decoder_loop (void *this_gen) {
case BUF_CONTROL_QUIT:
if (this->video_cur_decoder) {
- this->video_cur_decoder->close ();
+ this->video_cur_decoder->close (this->video_cur_decoder);
this->video_cur_decoder = NULL;
}
running = 0;
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 6e6b25496..63cdd01f0 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.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.c,v 1.4 2001/04/22 00:31:44 guenter Exp $
+ * $Id: xine.c,v 1.5 2001/04/23 00:34:59 guenter Exp $
*
* top-level xine functions
*
@@ -412,17 +412,17 @@ static void xine_pause (xine_t *this) {
/*
*
*/
-xine_t *xine_init (vo_instance_t *vo,
+xine_t *xine_init (vo_driver_t *vo,
ao_functions_t *ao,
gui_status_callback_func_t gui_status_callback,
- config_values_t *config, int demux_strategy, uint32_t debug_lvl) {
+ config_values_t *config) {
xine_t *this = xmalloc (sizeof (xine_t));
int err;
this->status_callback = gui_status_callback;
- this->demux_strategy = demux_strategy;
- xine_debug = debug_lvl;
+ this->config = config;
+ xine_debug = config->lookup_int (config, "xine_debug", 0);
#ifdef TEST_FILE
gTestFile = open ("/tmp/test.mp3", O_WRONLY | O_CREAT, 0644);
@@ -441,23 +441,38 @@ xine_t *xine_init (vo_instance_t *vo,
buffer_pool_init (2000, 4096);
/*
- * init demuxer
+ * create a metronom
*/
+
+ this->metronom = metronom_init ();
+
+ /*
+ * load input and demuxer plugins
+ */
+
+ load_input_plugins (this, config, INPUT_PLUGIN_IFACE_VERSION);
+ printf ("xine_init: input plugins loaded\n");
+
+ this->demux_strategy = config->lookup_int (config, "demux_strategy", 0);
+
load_demux_plugins(this, config, DEMUXER_PLUGIN_IFACE_VERSION);
this->audio_channel = 0;
this->spu_channel = -1;
this->cur_input_pos = 0;
- printf ("xine_init: demuxer initialized\n");
+ printf ("xine_init: demuxer plugins loaded\n");
/*
* init and start decoder threads
*/
+ this->video_out = vo_new_instance (vo, this->metronom);
video_decoder_init (this);
- this->mBufAudio = audio_decoder_init (ao);
+
+ this->audio_out = ao;
+ audio_decoder_init (this);
/*
* init SPU decoder
@@ -466,14 +481,6 @@ xine_t *xine_init (vo_instance_t *vo,
this->spu_fifo = fifo_buffer_new ();
spudec_init(NULL);
- /*
- * load input plugins
- */
-
- load_input_plugins (this, config, INPUT_PLUGIN_IFACE_VERSION);
-
- printf ("xine_init: plugins loaded\n");
-
return this;
}
@@ -527,15 +534,6 @@ void xine_select_spu_channel (xine_t *this, int nChannel) {
/*
*
*/
-input_plugin_t* xine_get_input_plugin_list (xine_t *this, int *nInputPlugins) {
-
- *nInputPlugins = this->num_input_plugins;
- return this->input_plugins;
-}
-
-/*
- *
- */
int xine_get_current_position (xine_t *this) {
off_t len;
@@ -566,3 +564,4 @@ int xine_get_status(xine_t *this) {
return this->status;
}
+
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 36c04b108..681e12bc9 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.h
@@ -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_internal.h,v 1.6 2001/04/22 02:42:49 guenter Exp $
+ * $Id: xine_internal.h,v 1.7 2001/04/23 00:34:59 guenter Exp $
*
*/
@@ -44,6 +44,10 @@
/*
* generic xine video decoder plugin interface
+ *
+ * for a dynamic plugin make sure you provide this function call:
+ * video_decoder_t *init_video_decoder_plugin (int iface_version,
+ * config_values_t *cfg);
*/
typedef struct video_decoder_s video_decoder_t;
@@ -60,7 +64,7 @@ struct video_decoder_s {
void (*release_img_buffers) (video_decoder_t *this);
- void (*close) (void);
+ void (*close) (video_decoder_t *this);
};
@@ -105,6 +109,8 @@ typedef struct xine_s {
/* private : */
metronom_t *metronom;
+
+ config_values_t *config;
input_plugin_t input_plugins[INPUT_PLUGIN_MAX];
int num_input_plugins;
@@ -165,10 +171,10 @@ config_values_t *config_file_init (char *filename);
*
*/
-xine_t *xine_init (vo_instance_t *vo,
+xine_t *xine_init (vo_driver_t *vo,
ao_functions_t *ao,
gui_status_callback_func_t gui_status_callback,
- config_values_t *config, int demux_strategy, uint32_t debug_lvl) ;
+ config_values_t *config);
/*
* open a stream and play it