summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-12 01:07:25 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-05-12 01:07:25 +0000
commitc00658414ed5a862f6a029c2ed41768572d8da68 (patch)
treec92052e580e7eccdcff6cdca2829eebf384318f3
parentcfb5ef8d6fe2638da6eade1f87abca8c4253b8e7 (diff)
downloadmpv-c00658414ed5a862f6a029c2ed41768572d8da68.tar.bz2
mpv-c00658414ed5a862f6a029c2ed41768572d8da68.tar.xz
-vo gif - by Joey Parrish <joey@yunamusic.com>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6054 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--Makefile2
-rwxr-xr-xconfigure43
-rw-r--r--libvo/video_out.c6
-rw-r--r--libvo/vo_gif89a.c337
4 files changed, 387 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 19da7dd1c3..7b9f8b9a9d 100644
--- a/Makefile
+++ b/Makefile
@@ -45,7 +45,7 @@ AO_LIBS = -Llibao2 -lao2
A_LIBS = $(ALSA_LIB) $(NAS_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(SGIAUDIO_LIB)
CODEC_LIBS = -Llibmpcodecs -lmpcodecs -Lmp3lib -lMP3 -Lliba52 -la52 -Llibmpeg2 -lmpeg2 $(AV_LIB) $(FAME_LIB)
-COMMON_LIBS = $(CODEC_LIBS) -Llibmpdemux -lmpdemux $(NEW_INPUT_LIB) $(LIB_LOADER) $(A_LIBS) $(CSS_LIB) $(ARCH_LIB) -Lpostproc -lpostproc $(DECORE_LIB) -Llinux -losdep $(TERMCAP_LIB) $(STREAMING_LIB) $(Z_LIB) $(GTK_LIBS) $(PNG_LIB) $(JPEG_LIB) -lm
+COMMON_LIBS = $(CODEC_LIBS) -Llibmpdemux -lmpdemux $(NEW_INPUT_LIB) $(LIB_LOADER) $(A_LIBS) $(CSS_LIB) $(ARCH_LIB) -Lpostproc -lpostproc $(DECORE_LIB) -Llinux -losdep $(TERMCAP_LIB) $(STREAMING_LIB) $(Z_LIB) $(GTK_LIBS) $(PNG_LIB) $(JPEG_LIB) $(GIF_LIB) -lm
ifeq ($(VIDIX),yes)
MISC_LIBS += -Llibdha -ldha -Lvidix -lvidix
endif
diff --git a/configure b/configure
index 873280bea3..1ed7549ff1 100755
--- a/configure
+++ b/configure
@@ -125,6 +125,7 @@ Optional features:
--enable-gui enable GUI [disable]
--enable-png enable png support [autodetect]
--enable-jpeg enable jpeg support [autodetect]
+ --enable-gif enable gif89a support [autodetect]
--disable-tv disable TV Interface (tv/dvb grabbers) [enable]
--disable-tv-v4l disable Video 4 Linux TV Interface support [autodetect]
--disable-win32 disable Win32 DLL support [autodetect]
@@ -768,6 +769,7 @@ _sdl=auto
_nas=auto
_png=auto
_jpg=auto
+_gif=auto
_gl=auto
_ggi=auto
_aa=auto
@@ -859,6 +861,8 @@ for ac_option do
--disable-png) _png=no ;;
--enable-jpeg) _jpg=yes ;;
--disable-jpeg) _jpg=no ;;
+ --enable-gif) _gif=yes ;;
+ --disable-gif) _gif=no ;;
--enable-gl) _gl=yes ;;
--disable-gl) _gl=no ;;
--enable-ggi) _ggi=yes ;;
@@ -2320,6 +2324,40 @@ else
_mkf_jpg="no"
fi
+echocheck "GIF89a support"
+if test "$_gif" = auto ; then
+ _gif=no
+cat > $TMPC << EOF
+#include <gif_lib.h>
+int main(void) {
+ return 0;
+}
+EOF
+ if cc_check -lungif ; then
+ if "$TMPO" >> "$TMPLOG" ; then
+ _gif=yes
+ _ld_gif="-lungif"
+ fi
+ elif cc_check -lgif ; then
+ if "$TMPO" >> "$TMPLOG" ; then
+ _gif=yes
+ _ld_gif="-lgif"
+ fi
+ fi
+fi
+echores "$_gif"
+
+if test "$_gif" = yes ; then
+ _def_gif='#define HAVE_GIF 1'
+ _vosrc="$_vosrc vo_gif89a.c"
+ _vomodules="gif89a $_vomodules"
+ _mkf_gif="yes"
+else
+ _def_gif='#undef HAVE_GIF'
+ _novomodules="gif89a $_novomodules"
+ _mkf_gif="no"
+fi
+
if test "$_vesa" != no ; then
echocheck "VESA support"
@@ -3618,6 +3656,7 @@ VO2 = $_vo2
PNG = $_mkf_png
JPEG = $_mkf_jpg
+GIF = $_mkf_gif
EXTRA_LIB = $_ld_extra
Z_LIB = $_ld_static $_ld_zlib
@@ -3635,6 +3674,7 @@ MLIB_INC = $_inc_mlib
DVB_INC = $_inc_dvb
PNG_LIB = $_ld_png
JPEG_LIB = $_ld_jpg
+GIF_LIB = $_ld_gif
SDL_LIB = $_ld_sdl
SVGA_LIB = $_ld_svga
AA_LIB = $_ld_aa
@@ -3970,6 +4010,9 @@ $_def_png
/* enable JPEG support */
$_def_jpg
+/* enable GIF support */
+$_def_gif
+
/* libmad support */
$_def_mad
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 200f7703e4..f681a43bc9 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -103,6 +103,9 @@ extern vo_functions_t video_out_dxr3;
#ifdef HAVE_JPEG
extern vo_functions_t video_out_jpeg;
#endif
+#ifdef HAVE_GIF
+extern vo_functions_t video_out_gif89a;
+#endif
#ifdef HAVE_VESA
extern vo_functions_t video_out_vesa;
#endif
@@ -170,6 +173,9 @@ vo_functions_t* video_out_drivers[] =
#ifdef HAVE_JPEG
&video_out_jpeg,
#endif
+#ifdef HAVE_GIF
+ &video_out_gif89a,
+#endif
&video_out_null,
// &video_out_odivx,
&video_out_pgm,
diff --git a/libvo/vo_gif89a.c b/libvo/vo_gif89a.c
new file mode 100644
index 0000000000..6ef117fc5c
--- /dev/null
+++ b/libvo/vo_gif89a.c
@@ -0,0 +1,337 @@
+/*
+ * vo_gif89a.c Generate gif89a output in file out.gif
+ *
+ * Originally based on vo_png.c
+ *
+ * Stolen (C) 2002 by GifWhore <joey@yunamusic.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "config.h"
+#include "video_out.h"
+#include "video_out_internal.h"
+
+#include "../postproc/rgb2rgb.h"
+
+#include <gif_lib.h>
+
+#define GIFWHORE_version 0.90
+
+LIBVO_EXTERN (gif89a)
+
+static vo_info_t vo_info =
+{
+ "GIF89a (out.gif)",
+ "gif89a",
+ "GifWhore <joey@yunamusic.com>",
+ ""
+};
+
+extern int verbose;
+extern int vo_config_count;
+
+static int image_width;
+static int image_height;
+static int image_format;
+static uint8_t *image_data=NULL;
+static unsigned int scale_srcW = 0, scale_srcH = 0;
+
+static int reverse_map = 0;
+static unsigned char framenum = 0;
+static int gif_frameskip;
+static int gif_framedelay;
+static int target_fps = 0;
+
+GifFileType *newgif=NULL;
+
+/*
+ * TODO
+ * OSD!!!
+ */
+
+static uint32_t config
+ (uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height,
+ uint32_t fullscreen, char *title, uint32_t format, const vo_tune_info_t *info) {
+ char filename[] = "out.gif";
+ ColorMapObject *Cmap;
+ char LB[] = {
+ 'N','E','T','S',
+ 'C','A','P','E',
+ '2','.','0' };
+ char LB2[] = { 1, 0x00, 0x00 };
+
+ if (target_fps == 0) target_fps = 5;
+ gif_frameskip = (vo_fps + 0.25) / target_fps;
+ gif_framedelay = 100 / target_fps;
+
+ if ((width != d_width) || (height != d_height)) {
+ image_width = (d_width + 7) & ~7;
+ image_height = d_height;
+ scale_srcW = width;
+ scale_srcH = height;
+ SwScale_Init();
+ } else {
+ image_width = width;
+ image_height = height;
+ }
+ image_format = format;
+
+ Cmap = MakeMapObject(256, NULL);
+
+ switch(format) {
+ case IMGFMT_BGR32:
+ case IMGFMT_BGR24:
+ reverse_map = 1;
+ break;
+ case IMGFMT_RGB32:
+ case IMGFMT_RGB24:
+ break;
+ case IMGFMT_IYUV:
+ case IMGFMT_I420:
+ case IMGFMT_YV12:
+ reverse_map = 1;
+ yuv2rgb_init(24, MODE_RGB);
+ image_data = malloc(image_width*image_height*3);
+ break;
+ default:
+ return 1;
+ }
+
+ if (vo_config_count > 0)
+ return 0;
+
+ EGifSetGifVersion("89a");
+ newgif = EGifOpenFileName(filename, 0);
+ if (newgif == NULL)
+ {
+ fprintf(stderr, "error opening file for output.\n");
+ return(1);
+ }
+ EGifPutScreenDesc(newgif, image_width, image_height, 256, 0, Cmap);
+ EGifPutExtensionFirst(newgif, 0xFF, 11, LB);
+ EGifPutExtensionLast(newgif, 0, 3, LB2);
+
+ return 0;
+}
+
+static const vo_info_t* get_info(void)
+{
+ return &vo_info;
+}
+
+static uint32_t draw_frame(uint8_t * src[])
+{
+ uint8_t *use_data;
+ ColorMapObject *Cmap;
+ uint8_t Colors[256 * 3];
+ int z;
+ char CB[] = { (char)(gif_framedelay >> 8), (char)(gif_framedelay & 0xff), 0, 0};
+
+ if ((framenum++ % gif_frameskip)) return(0);
+
+ if ((image_format == IMGFMT_BGR32) || (image_format == IMGFMT_RGB32))
+ {
+ rgb32to24(src[0], image_data, image_width * image_height * 4);
+ src[0] = image_data;
+ }
+
+ Cmap = MakeMapObject(256, NULL);
+ use_data = (uint8_t *)malloc(image_width * image_height);
+ if (gif_reduce(image_width, image_height, src[0], use_data, Colors)) return(0);
+
+ if (reverse_map)
+ {
+ for (z = 0; z < 256; z++) {
+ Cmap->Colors[z].Blue = Colors[(z * 3) + 0];
+ Cmap->Colors[z].Green = Colors[(z * 3) + 1];
+ Cmap->Colors[z].Red = Colors[(z * 3) + 2];
+ }
+ }
+ else
+ {
+ for (z = 0; z < 256; z++) {
+ Cmap->Colors[z].Red = Colors[(z * 3) + 0];
+ Cmap->Colors[z].Green = Colors[(z * 3) + 1];
+ Cmap->Colors[z].Blue = Colors[(z * 3) + 2];
+ }
+ }
+
+ EGifPutExtension(newgif, 0xF9, 0x04, CB);
+ EGifPutImageDesc(newgif, 0, 0, image_width, image_height, 0, Cmap);
+ EGifPutLine(newgif, use_data, image_width * image_height);
+ FreeMapObject(Cmap);
+ free(use_data);
+
+ return (0);
+}
+
+static void draw_osd(void)
+{
+}
+
+static void flip_page (void)
+{
+ uint8_t *use_data;
+ ColorMapObject *Cmap;
+ uint8_t Colors[256 * 3];
+ int z;
+ char CB[] = { (char)(gif_framedelay >> 8), (char)(gif_framedelay & 0xff), 0, 0};
+
+ if ((image_format == IMGFMT_YV12) || (image_format == IMGFMT_IYUV) || (image_format == IMGFMT_I420)) {
+
+ if ((framenum++ % gif_frameskip)) return;
+
+ Cmap = MakeMapObject(256, NULL);
+ use_data = (uint8_t *)malloc(image_width * image_height);
+ if (gif_reduce(image_width, image_height, image_data, use_data, Colors)) return;
+
+ if (reverse_map)
+ {
+ for (z = 0; z < 256; z++) {
+ Cmap->Colors[z].Blue = Colors[(z * 3) + 0];
+ Cmap->Colors[z].Green = Colors[(z * 3) + 1];
+ Cmap->Colors[z].Red = Colors[(z * 3) + 2];
+ }
+ }
+ else
+ {
+ for (z = 0; z < 256; z++) {
+ Cmap->Colors[z].Red = Colors[(z * 3) + 0];
+ Cmap->Colors[z].Green = Colors[(z * 3) + 1];
+ Cmap->Colors[z].Blue = Colors[(z * 3) + 2];
+ }
+ }
+
+ EGifPutExtension(newgif, 0xF9, 0x04, CB);
+ EGifPutImageDesc(newgif, 0, 0, image_width, image_height, 0, Cmap);
+ EGifPutLine(newgif, use_data, image_width * image_height);
+ FreeMapObject(Cmap);
+ free(use_data);
+ }
+}
+
+static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y )
+{
+ /* hack: swap planes for I420 ;) -- alex */
+ if ((image_format == IMGFMT_IYUV) || (image_format == IMGFMT_I420))
+ {
+ uint8_t *src_i420[3];
+
+ src_i420[0] = src[0];
+ src_i420[1] = src[2];
+ src_i420[2] = src[1];
+ src = src_i420;
+ }
+
+ if (scale_srcW) {
+ uint8_t *dst[3] = {image_data, NULL, NULL};
+ SwScale_YV12slice(src,stride,y,h,
+ dst, image_width*3, 24,
+ scale_srcW, scale_srcH, image_width, image_height);
+ } else {
+ uint8_t *dst = image_data + (image_width * y + x) * 3;
+ yuv2rgb(dst,src[0],src[1],src[2],w,h,image_width*3,stride[0],stride[1]);
+ }
+ return 0;
+}
+
+static uint32_t
+query_format(uint32_t format)
+{
+ switch(format){
+ case IMGFMT_IYUV:
+ case IMGFMT_I420:
+ case IMGFMT_YV12:
+ case IMGFMT_RGB|32:
+ case IMGFMT_BGR|32:
+ case IMGFMT_RGB|24:
+ case IMGFMT_BGR|24:
+ return 1 | VFCAP_SWSCALE | VFCAP_TIMER | VFCAP_ACCEPT_STRIDE;
+ }
+ return 0;
+}
+
+static void
+uninit(void)
+{
+ char temp[256];
+
+ if (image_data) { free(image_data); image_data=NULL; }
+
+ if (vo_config_count > 0) {
+ sprintf(temp, "gifwhore v%2.2f (c) %s\r\n",
+ GIFWHORE_version, "joey@yunamusic.com");
+ EGifPutComment(newgif, temp);
+ EGifCloseFile(newgif);
+ }
+}
+
+
+static void check_events(void)
+{
+}
+
+int gif_reduce(int width, int height,
+ unsigned char *source,
+ unsigned char *destination,
+ unsigned char *palette)
+{
+ GifColorType cmap[256];
+ unsigned char Ra[width * height];
+ unsigned char Ga[width * height];
+ unsigned char Ba[width * height];
+ unsigned char *R, *G, *B;
+ int Size = 256;
+ int i;
+
+ R = Ra; G = Ga; B = Ba;
+ for (i = 0; i < width * height; i++)
+ {
+ *R++ = *source++;
+ *G++ = *source++;
+ *B++ = *source++;
+ }
+
+ R = Ra; G = Ga; B = Ba;
+ if (QuantizeBuffer(width, height, &Size,
+ R, G, B,
+ destination, cmap) == GIF_ERROR)
+ {
+ fprintf(stderr, "vo_gif89a: Quantize failed!\n");
+ return(-1);
+ }
+
+ for (i = 0; i < Size; i++)
+ {
+ *palette++ = cmap[i].Red;
+ *palette++ = cmap[i].Green;
+ *palette++ = cmap[i].Blue;
+ }
+
+ return(0);
+}
+
+static uint32_t preinit(const char *arg)
+{
+ int i = 0;
+ if (arg) i = atoi(arg);
+ if (i > vo_fps) i = vo_fps;
+ if (i < 1) i = 5;
+ target_fps = i;
+ return 0;
+}
+
+static uint32_t control(uint32_t request, void *data, ...)
+{
+ switch (request) {
+ case VOCTRL_QUERY_FORMAT:
+ return query_format(*((uint32_t*)data));
+ }
+ return VO_NOTIMPL;
+}
+