From 12ee56f278ece1d6e2e5a00ccb48ba94abb6addb Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Thu, 28 Mar 2002 12:44:37 +0000 Subject: Ability to change logo at run-time. Fix endianness in xine-logoconv, build and install it by default. CVS patchset: 1642 CVS date: 2002/03/28 12:44:37 --- configure.in | 33 +++++++++--- misc/Makefile.am | 17 ++++-- misc/xine-lib.spec.in | 1 + misc/xine-logoconv.c | 23 +++++--- src/xine-engine/Makefile.am | 2 +- src/xine-engine/video_out.c | 127 ++++++++++++++++++++++++++++++++------------ 6 files changed, 153 insertions(+), 50 deletions(-) diff --git a/configure.in b/configure.in index 1761411bd..669dd24be 100644 --- a/configure.in +++ b/configure.in @@ -245,6 +245,32 @@ fi AM_CONDITIONAL(HAVE_X11, [test x"$no_x" != "xyes"]) +dnl +dnl zlib +dnl +dnl Test for libz +AC_CHECK_LIB(z, gzsetparams, + [ AC_CHECK_HEADER(zlib.h, + have_zlib=yes + ZLIB_LIBS="-lz",)]) + +AM_CONDITIONAL(HAVE_ZLIB, [test x"$have_zlib" = "xyes"]) +AC_SUBST(ZLIB_LIBS) + + +dnl +dnl Imlib (for xine-logoconv) +dnl +AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no) +if test "$IMLIB_CONFIG" != "no" ; then + IMLIB_CFLAGS=`$IMLIB_CONFIG --cflags` + IMLIB_LIBS=`$IMLIB_CONFIG --libs` +fi +AM_CONDITIONAL(HAVE_IMLIB, [test x"$IMLIB_CONFIG" != x"no"]) +AC_SUBST(IMLIB_CFLAGS) +AC_SUBST(IMLIB_LIBS) + + dnl dnl Checks for Xv extension dnl @@ -510,13 +536,6 @@ AM_CONDITIONAL(HAVE_LIBFAME, test x"$have_libfame" = "xyes") AM_CONDITIONAL(HAVE_LIBRTE, test x"$have_librte" = "xyes") AM_CONDITIONAL(HAVE_ENCODER, test x"$have_encoder" = "xyes") -dnl -dnl zlib -dnl -dnl Test for libz -AC_CHECK_LIB(z, gzsetparams, [AC_CHECK_HEADER(zlib.h,have_zlib=yes,)]) -AM_CONDITIONAL(HAVE_ZLIB, [test x"$have_zlib" = "xyes"]) - dnl dnl ASF build can be optional diff --git a/misc/Makefile.am b/misc/Makefile.am index f207b204a..73dfd9844 100644 --- a/misc/Makefile.am +++ b/misc/Makefile.am @@ -2,13 +2,24 @@ SUBDIRS = fonts EXTRA_DIST = autogen.sh upload.pl SlackBuild.in SlackBuild build_rpms.sh \ xine-lib.spec.in xine-lib.spec \ - xine_logo.png xine_logo.zyuy2 xine-fontconv.c xine-logoconv.c - -bin_SCRIPTS = xine-config + xine_logo.png xine_logo.zyuy2 xine-fontconv.c datadir = $(XINE_SKINDIR) data_DATA = xine_logo.png xine_logo.zyuy2 +bin_SCRIPTS = xine-config + +if HAVE_IMLIB +logoconv = xine-logoconv +endif + +bin_PROGRAMS = $(logoconv) + +CFLAGS = $(IMLIB_CFLAGS) +xine_logoconv_SOURCES = xine-logoconv.c +xine_logoconv_LDADD = $(IMLIB_LIBS) + + debug: install-debug: install diff --git a/misc/xine-lib.spec.in b/misc/xine-lib.spec.in index ab8bc10d1..81ba69005 100644 --- a/misc/xine-lib.spec.in +++ b/misc/xine-lib.spec.in @@ -276,6 +276,7 @@ rm -rf $RPM_BUILD_ROOT %{prefix}/lib/xine/plugins/xineplug_vo_out_xshm.la %{prefix}/lib/xine/plugins/xineplug_vo_out_xshm.so # lib, logo and fonts. +@HAVE_IMLIB_TRUE@%{prefix}/bin/xine-logoconv %{prefix}/lib/libxine*.la %{prefix}/lib/libxine*.so* %{prefix}/share/xine/skins/xine_logo.png diff --git a/misc/xine-logoconv.c b/misc/xine-logoconv.c index 20f4a0a4b..a59471239 100644 --- a/misc/xine-logoconv.c +++ b/misc/xine-logoconv.c @@ -35,6 +35,9 @@ * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include @@ -97,11 +100,19 @@ static void save_image (char *oldname, ImlibImage *img) { double y, u, v; unsigned char cy,cu,cv; +#ifdef WORDS_BIGENDIAN r = img->rgb_data[(px+py*w)*3]; g = img->rgb_data[(px+py*w)*3+1]; b = img->rgb_data[(px+py*w)*3+2]; +#else + r = img->rgb_data[(px+py*w)*3+2]; + g = img->rgb_data[(px+py*w)*3+1]; + b = img->rgb_data[(px+py*w)*3]; +#endif - y = LUMARED*r + LUMAGREEN*g + LUMABLUE*b; + y = (LUMARED*r) + (LUMAGREEN*g) + (LUMABLUE*b); + // u = (b-y) / (2 - 2*LUMABLUE); + // v = (r-y) / (2 - 2*LUMABLUE); u = (b-y) / (2 - 2*LUMABLUE); v = (r-y) / (2 - 2*LUMABLUE); @@ -128,9 +139,9 @@ static void save_image (char *oldname, ImlibImage *img) { int main(int argc, char *argv[]) { - Display *display; - ImlibData *imlib_data; - ImlibImage *img; + Display *display; + ImlibData *imlib_data; + ImlibImage *img; if (argc != 2) { printf ("usage: %s foo.png\n", argv[0]); @@ -141,8 +152,8 @@ int main(int argc, char *argv[]) { printf ("failed to open X11 display\n"); exit (1); } - - if (!(imlib_data = Imlib_init (display))) { + + if (!(imlib_data = Imlib_init(display))) { printf ("failed to initialize imlib\n"); exit(1); } diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am index 6b3282cfa..fd5ffa994 100644 --- a/src/xine-engine/Makefile.am +++ b/src/xine-engine/Makefile.am @@ -12,7 +12,7 @@ libxine_la_SOURCES = xine.c metronom.c configfile.c buffer.c \ audio_decoder.c video_out.c audio_out.c resample.c events.c lrb.c \ video_overlay.c osd.c scratch.c locale.c libxine_la_DEPENDENCIES = @INTLLIBS@ -libxine_la_LIBADD = $(THREAD_LIBS) $(DYNAMIC_LD_LIBS) @INTLLIBS@ -lm -lz +libxine_la_LIBADD = $(THREAD_LIBS) $(DYNAMIC_LD_LIBS) @INTLLIBS@ $(ZLIB_LIBS) -lm libxine_la_LDFLAGS = \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 3127f0045..27cc3c7be 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.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.c,v 1.87 2002/03/25 01:02:51 miguelfreitas Exp $ + * $Id: video_out.c,v 1.88 2002/03/28 12:44:37 f1rmb Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "video_out.h" @@ -73,6 +74,8 @@ typedef struct { /* pts value when decoder delivered last video frame */ int64_t last_delivery_pts; + char *logo_pathname; + pthread_mutex_t logo_mutex; int logo_w, logo_h; uint8_t *logo_yuy2; @@ -93,6 +96,65 @@ struct img_buf_fifo_s { pthread_cond_t not_empty; } ; +/* + * Logo related functions + config callback. + */ +static uint16_t gzread_i16(gzFile *fp) { + uint16_t ret; + ret = gzgetc(fp) << 8 ; + ret |= gzgetc(fp); + return ret; +} + +static int _load_logo_file(vos_t *this) { + gzFile *fp; + int retval = 0; + + pthread_mutex_lock(&this->logo_mutex); + + if((fp = gzopen (this->logo_pathname, "rb")) != NULL) { + + free (this->logo_yuy2); + + this->logo_w = gzread_i16 (fp); + this->logo_h = gzread_i16 (fp); +#ifdef LOG + printf ("video_out: loading logo %d x %d pixels, yuy2\n", + this->logo_w, this->logo_h); +#endif + + this->logo_yuy2 = malloc (this->logo_w * this->logo_h *2); + + gzread (fp, this->logo_yuy2, this->logo_w * this->logo_h *2); + gzclose (fp); + + this->backup_is_logo = 0; + + retval = 1; + } + + pthread_mutex_unlock(&this->logo_mutex); + return retval; +} + +static void _logo_change_cb(void *data, cfg_entry_t *cfg) { + vos_t *this = (vos_t *) data; + char default_logo[2048]; + + this->logo_pathname = cfg->str_value; + + if(!_load_logo_file(this)) { +#ifdef LOG + printf("_load_logo_file() failed, reload default\n"); +#endif + snprintf(default_logo, 2048, "%s/xine_logo.zyuy2", XINE_SKINDIR); + cfg->config->update_string(cfg->config, cfg->key, default_logo); + } +} +/* + * End of logo. + */ + static img_buf_fifo_t *vo_new_img_buf_queue () { img_buf_fifo_t *queue; @@ -417,14 +479,17 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts) { printf("video_out: copying logo image\n"); + pthread_mutex_lock(&this->logo_mutex); + this->img_backup = vo_get_frame (&this->vo, this->logo_w, this->logo_h, 42, IMGFMT_YUY2, VO_BOTH_FIELDS); this->img_backup->duration = 3000; - + xine_fast_memcpy(this->img_backup->base[0], this->logo_yuy2, this->logo_w*this->logo_h*2); - + + pthread_mutex_unlock(&this->logo_mutex); this->backup_is_logo = 1; this->redraw_needed = 1; } @@ -797,7 +862,13 @@ static void vo_exit (vo_instance_t *this_gen) { free (this->free_img_buf_queue); free (this->display_img_buf_queue); - free (this->logo_yuy2); + + pthread_mutex_lock(&this->logo_mutex); + if(this->logo_yuy2) + free(this->logo_yuy2); + pthread_mutex_unlock(&this->logo_mutex); + pthread_mutex_destroy(&this->logo_mutex); + free (this); } @@ -820,24 +891,14 @@ static void vo_enable_overlay (vo_instance_t *this_gen, int overlay_enabled) { this->overlay_enabled = overlay_enabled; } -static uint16_t gzread_i16(gzFile *fp) { - uint16_t ret; - ret = gzgetc(fp) << 8 ; - ret |= gzgetc(fp); - return ret; -} - -#define LOGO_PATH_MAX 1025 - vo_instance_t *vo_new_instance (vo_driver_t *driver, xine_t *xine) { - vos_t *this; - int i; - char pathname[LOGO_PATH_MAX]; - pthread_attr_t pth_attrs; - int err; - gzFile *fp; - int num_frame_buffers; + vos_t *this; + int i; + pthread_attr_t pth_attrs; + int err; + int num_frame_buffers; + this = xine_xmalloc (sizeof (vos_t)) ; @@ -892,25 +953,25 @@ vo_instance_t *vo_new_instance (vo_driver_t *driver, xine_t *xine) { img); } + /* * load xine logo */ - - snprintf (pathname, LOGO_PATH_MAX, "%s/xine_logo.zyuy2", XINE_SKINDIR); - - if ((fp = gzopen (pathname, "rb")) != NULL) { - - this->logo_w = gzread_i16 (fp); - this->logo_h = gzread_i16 (fp); + { + config_values_t *config; + char default_logo[2048]; - printf ("video_out: loading logo %d x %d pixels, yuy2\n", - this->logo_w, this->logo_h); - - this->logo_yuy2 = malloc (this->logo_w * this->logo_h *2); + config = xine->config; + + pthread_mutex_init(&this->logo_mutex, NULL); + + snprintf(default_logo, 2048, "%s/xine_logo.zyuy2", XINE_SKINDIR); - gzread (fp, this->logo_yuy2, this->logo_w * this->logo_h *2); + this->logo_pathname = config->register_string(config, "video.logo_file", default_logo, + "logo displayed in video output window", NULL, + _logo_change_cb, (void *) this); - gzclose (fp); + _load_logo_file(this); } /* -- cgit v1.2.3