summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dxr3/dxr3_mpeg_encoders.c41
-rw-r--r--src/dxr3/video_out_dxr3.c24
-rw-r--r--src/dxr3/video_out_dxr3.h10
3 files changed, 66 insertions, 9 deletions
diff --git a/src/dxr3/dxr3_mpeg_encoders.c b/src/dxr3/dxr3_mpeg_encoders.c
index 00a1dc2dc..109853c35 100644
--- a/src/dxr3/dxr3_mpeg_encoders.c
+++ b/src/dxr3/dxr3_mpeg_encoders.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2001 the xine project
+ * Copyright (C) 2000-2003 the xine project
*
* This file is part of xine, a unix video player.
*
@@ -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: dxr3_mpeg_encoders.c,v 1.10 2002/10/26 14:35:04 mroi Exp $
+ * $Id: dxr3_mpeg_encoders.c,v 1.11 2003/05/25 18:36:51 mroi Exp $
*/
/* mpeg encoders for the dxr3 video out plugin.
@@ -41,6 +41,7 @@
#include <stdlib.h>
#include <sys/ioctl.h>
#include <string.h>
+#include <dlfcn.h>
#include <fcntl.h>
#include <errno.h>
#include <math.h>
@@ -106,6 +107,12 @@ static int fame_prepare_frame(fame_data_t *this, dxr3_driver_t *drv,
dxr3_frame_t *frame);
#endif
+/* initialization function */
+int dxr3_lavc_init(dxr3_driver_t *drv, plugin_node_t *node);
+
+/* close function from encoder api */
+static int lavc_on_close(dxr3_driver_t *drv);
+
#ifdef HAVE_LIBRTE
int dxr3_rte_init(dxr3_driver_t *drv)
@@ -572,3 +579,33 @@ static int fame_prepare_frame(fame_data_t *this, dxr3_driver_t *drv, dxr3_frame_
return 1;
}
#endif
+
+
+int dxr3_lavc_init(dxr3_driver_t *drv, plugin_node_t *node)
+{
+ void *ffmpeg;
+ int (*init)(dxr3_driver_t *);
+ int result;
+
+ ffmpeg = dlopen(node->filename, RTLD_LAZY);
+ if (!ffmpeg) return 0;
+
+ init = dlsym(ffmpeg, "dxr3_encoder_init");
+ if (!init) return 0;
+
+ result = init(drv);
+ /* the close function is implemented here, because it will call dlclose()
+ * and that should not be done be the library we are closing... */
+ drv->enc->on_close = lavc_on_close;
+ drv->enc->handle = ffmpeg;
+ return result;
+}
+
+static int lavc_on_close(dxr3_driver_t *drv)
+{
+ drv->enc->on_unneeded(drv);
+ dlclose(drv->enc->handle);
+ free(drv->enc);
+ drv->enc = NULL;
+ return 1;
+}
diff --git a/src/dxr3/video_out_dxr3.c b/src/dxr3/video_out_dxr3.c
index 62a14c329..f3389c126 100644
--- a/src/dxr3/video_out_dxr3.c
+++ b/src/dxr3/video_out_dxr3.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_out_dxr3.c,v 1.77 2003/05/06 21:07:38 mroi Exp $
+ * $Id: video_out_dxr3.c,v 1.78 2003/05/25 18:36:51 mroi Exp $
*/
/* mpeg1 encoding video out plugin for the dxr3.
@@ -221,6 +221,7 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v
const char *confstr;
int encoder, confnum;
static char *available_encoders[SUPPORTED_ENCODER_COUNT + 2];
+ plugin_node_t *node;
#ifdef HAVE_X11
static char *videoout_modes[] = { "letterboxed tv", "widescreen tv",
"letterboxed overlay", "widescreen overlay", NULL };
@@ -294,6 +295,17 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v
#if LOG_VID
printf("video_out_dxr3: Supported mpeg encoders: ");
#endif
+ /* check, if ffmpeg plugin is available by looking through plugin
+ * catalog; catalog mutex is already locked here, since this is open_plugin() */
+ for (node = xine_list_first_content(class->xine->plugin_catalog->video); node;
+ node = xine_list_next_content(class->xine->plugin_catalog->video))
+ if (strcasecmp(node->info->id, "ffmpegvideo") == 0) {
+ available_encoders[encoder++] = "libavcodec";
+#if LOG_VID
+ printf("libavcodec, ");
+#endif
+ break;
+ }
#ifdef HAVE_LIBFAME
available_encoders[encoder++] = "fame";
#if LOG_VID
@@ -316,6 +328,10 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v
available_encoders, _("the encoder for non mpeg content"),
_("Content other than mpeg has to pass an additional reencoding stage, "
"because the dxr3 handles mpeg only."), 10, NULL, NULL);
+ if ((strcmp(available_encoders[encoder], "libavcodec") == 0) && !dxr3_lavc_init(this, node)) {
+ printf("video_out_dxr3: Mpeg encoder libavcodec failed to init.\n");
+ return 0;
+ }
#ifdef HAVE_LIBRTE
if ((strcmp(available_encoders[encoder], "rte") == 0) && !dxr3_rte_init(this)) {
printf("video_out_dxr3: Mpeg encoder rte failed to init.\n");
@@ -652,7 +668,7 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge
/* planar format, only base[0] */
/* add one extra line for field swap stuff */
- frame->real_base[0] = xine_xmalloc_aligned(16, image_size + frame->vo_frame.pitches[0],
+ frame->real_base[0] = xine_xmalloc_aligned(16, (image_size + frame->vo_frame.pitches[0]) * 4,
(void**)&frame->mem);
/* don't use first line */
@@ -680,8 +696,8 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge
image_size_v = frame->vo_frame.pitches[2] * ((oheight + 1) / 2);
/* add one extra line for field swap stuff */
- frame->real_base[0] = xine_xmalloc_aligned(16, image_size_y + frame->vo_frame.pitches[0] +
- image_size_u + image_size_v, (void**)&frame->mem);
+ frame->real_base[0] = xine_xmalloc_aligned(16, (image_size_y + frame->vo_frame.pitches[0] +
+ image_size_u + image_size_v) * 4, (void**)&frame->mem);
/* don't use first line */
frame->real_base[0] += frame->vo_frame.pitches[0];
diff --git a/src/dxr3/video_out_dxr3.h b/src/dxr3/video_out_dxr3.h
index fd0fac039..64ea4a22c 100644
--- a/src/dxr3/video_out_dxr3.h
+++ b/src/dxr3/video_out_dxr3.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_dxr3.h,v 1.15 2003/02/13 14:32:18 mroi Exp $
+ * $Id: video_out_dxr3.h,v 1.16 2003/05/25 18:36:51 mroi Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -37,14 +37,14 @@
#define CLOSED_FOR_ENCODER -2
/* the number of supported encoders */
-#define SUPPORTED_ENCODER_COUNT 2
+#define SUPPORTED_ENCODER_COUNT 3
/* plugin structures */
typedef struct encoder_data_s encoder_data_t;
typedef struct spu_encoder_s spu_encoder_t;
-typedef enum { ENC_FAME, ENC_RTE } encoder_type;
+typedef enum { ENC_FAME, ENC_RTE, ENC_LAVC } encoder_type;
struct coeff {
@@ -142,6 +142,9 @@ struct encoder_data_s {
int (*on_display_frame)(dxr3_driver_t *, dxr3_frame_t *);
int (*on_unneeded)(dxr3_driver_t *);
int (*on_close)(dxr3_driver_t *);
+
+ /* this is only used by the libavcodec encoder */
+ void *handle;
};
struct spu_encoder_s {
@@ -165,6 +168,7 @@ int dxr3_rte_init(dxr3_driver_t *);
#ifdef HAVE_LIBFAME
int dxr3_fame_init(dxr3_driver_t *);
#endif
+int dxr3_lavc_init(dxr3_driver_t *, plugin_node_t *);
/* spu encoder functions */
spu_encoder_t *dxr3_spu_encoder_init(void);