[MPlayer-dev-eng] [PATCH] gif demux & decode support
Joey Parrish
joey at nicewarrior.org
Wed Jan 8 03:43:37 CET 2003
On Tue, Jan 07, 2003 at 12:09:40AM +0100, Arpi wrote:
> Hi,
> > - what fields in demuxer_t should be set to what during demux_open
> NOTHING!
Thanks, Fixed.
> > - how to handle that GIFs are not constant framerate
> just fill pts values when adding new packets to the queue, and add a case
> into video.c that handle your demuxer as pts-based variable fps.
Ah, I see. Thanks!
> A'rpi / Astral & ESP-team
Okay, new patch attached. This one has variable fps support,
documentation for the new demuxer/decoder, and demux_open is fixed.
Seeking is still not working, however. Because I'm using libungif
to handle the GIF file for me, I don't think I'll be able to seek
without a clever hack. Also, the decoder is dependant on the demuxer,
so forcing -vc gif will probably make a mess. These things are
all mentioned in the DOCS patch, btw.
But, I can finally play back my GIF anims in something other than a
browser, so I'm happy. :)
Thanks,
--Joey
-------------- next part --------------
diff -Nur main.cvs/AUTHORS main.dev/AUTHORS
--- main.cvs/AUTHORS Tue Dec 31 12:03:25 2002
+++ main.dev/AUTHORS Tue Jan 7 20:41:29 2003
@@ -346,9 +346,10 @@
* skip-deinterlace video filter
* MUXER layer, and new MPEG-PS muxer
-Joey Parrish <joey at yunamusic.com>
+Joey Parrish <joey at nicewarrior.org>
* various fixes
- * -vo gif89 author
+ * -vo gif89a author
+ * gif demuxer/decoder author
Juergen Hammelmann <juergen.hammelmann at gmx.de>
* TOOLS/menvcd author
diff -Nur main.cvs/DOCS/codecs.html main.dev/DOCS/codecs.html
--- main.cvs/DOCS/codecs.html Sun Dec 22 16:34:26 2002
+++ main.dev/DOCS/codecs.html Tue Jan 7 20:32:48 2003
@@ -35,6 +35,7 @@
<LI>RealVideo 1.0 codec from libavcodec, and RealVideo 2.0, 3.0 and 4.0
codecs using RealPlayer libraries</LI>
<LI>native decoder for HuffYUV</LI>
+ <LI>GIF encoded frames</LI>
<LI>various old simple RLE-like formats</LI>
</UL>
@@ -300,6 +301,18 @@
<LI>extract QuickTime DLL pack to your Win32 codecs directory (default:
<CODE>/usr/lib/win32</CODE>)</LI>
</OL>
+
+
+<H4><A NAME="gif">2.2.1.11 GIF encoded frames</A></H4>
+
+<P>MPlayer can play GIF files, both animated and non-animated.</P>
+
+<P>Currently, the GIF decoder is heavily dependant on the GIF demuxer.
+ This means that MPlayer cannot yet play GIF encoded frames from any
+ file format other than GIF. However, there is not yet any known encoder
+ that produces such files. The GIF support maintainer is currently working
+ on decode support for this in MPlayer as well as encode support for
+ this in MEncoder. <I>;)</I></P>
<H3><A NAME="audio_codecs">2.2.2 Audio codecs</A></H3>
diff -Nur main.cvs/DOCS/documentation.html main.dev/DOCS/documentation.html
--- main.cvs/DOCS/documentation.html Tue Jan 7 16:42:12 2003
+++ main.dev/DOCS/documentation.html Tue Jan 7 20:32:48 2003
@@ -65,6 +65,7 @@
<LI><A HREF="formats.html#ogg">2.1.1.12 OGG/OGM files</A></LI>
<LI><A HREF="formats.html#sdp">2.1.1.13 SDP files</A></LI>
<LI><A HREF="formats.html#pva">2.1.1.14 PVA files</A></LI>
+ <LI><A HREF="formats.html#gif">2.1.1.15 GIF files</A></LI>
</UL>
</LI>
<LI><A HREF="formats.html#audio_formats">2.1.2 Audio formats</A>
@@ -94,6 +95,7 @@
<LI><A HREF="codecs.html#realvideo">2.2.1.8 RealVideo</A></LI>
<LI><A HREF="codecs.html#xvid">2.2.1.9 XViD</A></LI>
<LI><A HREF="codecs.html#sorenson">2.2.1.10 Sorenson</A></LI>
+ <LI><A HREF="codecs.html#gif">2.2.1.11 GIF encoded frames</A></LI>
</UL>
</LI>
<LI><A HREF="codecs.html#audio_codecs">2.2.2 Audio codecs</A>
diff -Nur main.cvs/DOCS/formats.html main.dev/DOCS/formats.html
--- main.cvs/DOCS/formats.html Tue Jan 7 16:42:12 2003
+++ main.dev/DOCS/formats.html Tue Jan 7 20:32:48 2003
@@ -233,6 +233,35 @@
<A HREF="http://www.technotrend.de/download/av_format_v1.pdf">http://www.technotrend.de/download/av_format_v1.pdf</A></P>
+<H4><A NAME="gif">2.1.1.15 GIF files</A></H4>
+
+<P>The <B>GIF</B> format is a common format for web graphics. There are two
+ versions of the GIF spec, GIF87a and GIF89a. The main difference is that
+ GIF89a allows for animation. MPlayer supports both formats through use
+ of libungif or another libgif-compatible library. Non-animated GIFs will
+ be displayed as single frame videos. (Use the <CODE>-loop</CODE> and
+ <CODE>-fixed-vo</CODE> options to display these longer.)</P>
+
+<P>MPlayer currently does not support seeking in GIF files. GIF files do
+ not necessarily have a fixed frame size, nor a fixed framerate. Rather,
+ each frame is of independant size and is supposed to be positioned in a
+ certain place on a field of fixed-size. The framerate is controlled by
+ an optional block before each frame that specifies a next frame's delay
+ in centiseconds.</P>
+
+<P>Standard GIF files contain only <A HREF="codecs.html#gif">GIF frames,</A>
+ which are LZW-compressed frames with at most an 8-bit indexed pallete.
+ Some GIF encoders produce uncompressed frames to avoid patent issues with
+ LZW compression, but these files can still be read as spec-compliant by GIF
+ decoders.</P>
+
+<P>Though many common Linux distributions come with libungif, you can
+ download a copy from the following address:
+ <A HREF="http://prtr-13.ucsc.edu/~badger/software/libungif/index.shtml">http://prtr-13.ucsc.edu/~badger/software/libungif/index.shtml</A></P>
+
+<P>The GIF specification can be downloaded from the following address:
+ <A HREF="http://www.w3.org/Graphics/GIF/spec-gif89a.txt">http://www.w3.org/Graphics/GIF/spec-gif89a.txt</A></P>
+
<H3><A NAME="audio_formats">2.1.2 Audio formats</A></H3>
<P>MPlayer is a <B>Movie</B> and not a <B>Media</B> player, although
diff -Nur main.cvs/DOCS/tech/formats.txt main.dev/DOCS/tech/formats.txt
--- main.cvs/DOCS/tech/formats.txt Mon Oct 21 20:06:32 2002
+++ main.dev/DOCS/tech/formats.txt Tue Jan 7 20:40:19 2003
@@ -152,3 +152,12 @@
Note, that similarity of real and asf has some background - they worked
together on the (never finished/used) ASF v2 spec for some time.
+
+ - GIF files:
+ The GIF format is a common format for web graphics that supports
+ animation. These are read through libungif or compatible library.
+ Variable frame delays are supported, but seeking is not supported.
+ Currently the heavy dependance on libungif is why seeking has not
+ been finished. Removing this dependance, however, would require
+ writing lots of GIF parsing and decoding, and is (at the moment)
+ more work than it's worth.
diff -Nur main.cvs/Makefile main.dev/Makefile
--- main.cvs/Makefile Fri Dec 27 10:02:44 2002
+++ main.dev/Makefile Tue Jan 7 20:32:48 2003
@@ -33,9 +33,9 @@
OBJS_MENCODER = $(SRCS_MENCODER:.c=.o)
OBJS_MPLAYER = $(SRCS_MPLAYER:.c=.o)
-VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MP1E_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB) $(GIF_LIB)
+VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MP1E_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB)
AO_LIBS = $(ARTS_LIB) $(ESD_LIB) $(NAS_LIB) $(SGIAUDIO_LIB)
-CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(LIBLZO_LIB) $(XVID_LIB) $(DECORE_LIB) $(PNG_LIB) $(Z_LIB) $(JPEG_LIB) $(ALSA_LIB) $(XMMS_LIB)
+CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(LIBLZO_LIB) $(XVID_LIB) $(DECORE_LIB) $(PNG_LIB) $(Z_LIB) $(JPEG_LIB) $(ALSA_LIB) $(XMMS_LIB) $(GIF_LIB)
COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a $(PP_LIB) postproc/libswscale.a linux/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(STREAMING_LIB) $(WIN32_LIB)
CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) # -Wall
diff -Nur main.cvs/configure main.dev/configure
--- main.cvs/configure Sat Jan 4 13:26:04 2003
+++ main.dev/configure Tue Jan 7 20:32:48 2003
@@ -167,7 +167,7 @@
--disable-sortsub Disable subtitles sorting [enabled]
Codecs:
- --enable-gif enable gif89a output support [autodetect]
+ --enable-gif enable gif89a support [autodetect]
--enable-png enable png input/output support [autodetect]
--enable-jpeg enable jpeg input/output support [autodetect]
--enable-liblzo enable external liblzo support [autodetect]
@@ -2913,8 +2913,9 @@
_def_gif='#define HAVE_GIF 1'
_vosrc="$_vosrc vo_gif89a.c"
_vomodules="gif89a $_vomodules"
+ _codecmodules="gif $_codecmodules"
_mkf_gif="yes"
- _gif="yes (old version, some functions disabled)"
+ _gif="yes (old version, some encoding functions disabled)"
_def_gif_4='#undef HAVE_GIF_4'
cat > $TMPC << EOF
@@ -2936,6 +2937,7 @@
_def_gif='#undef HAVE_GIF'
_def_gif_4='#undef HAVE_GIF_4'
_novomodules="gif89a $_novomodules"
+ _nocodecmodules="gif $_codecmodules"
_mkf_gif="no"
fi
echores "$_gif"
diff -Nur main.cvs/etc/codecs.conf main.dev/etc/codecs.conf
--- main.cvs/etc/codecs.conf Tue Jan 7 16:42:13 2003
+++ main.dev/etc/codecs.conf Tue Jan 7 20:32:48 2003
@@ -60,6 +60,13 @@
driver mpng
out BGR32,BGR24
+videocodec gif
+ info "GIF decoder"
+ status working
+ fourcc GIFV
+ driver gif
+ out RGB24
+
videocodec mtga
info "TGA images decoder"
status working
diff -Nur main.cvs/libmpcodecs/Makefile main.dev/libmpcodecs/Makefile
--- main.cvs/libmpcodecs/Makefile Sun Dec 15 19:49:39 2002
+++ main.dev/libmpcodecs/Makefile Tue Jan 7 20:32:48 2003
@@ -10,7 +10,7 @@
AUDIO_SRCS=dec_audio.c ad.c $(AUDIO_SRCS_LIB) $(AUDIO_SRCS_NAT) $(AUDIO_SRCS_OPT)
VIDEO_SRCS_LIB=vd_libmpeg2.c vd_nuv.c vd_lzo.c
-VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_qtrpza.c vd_raw.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_msrle.c vd_huffyuv.c vd_mpegpes.c vd_svq1.c vd_lcl.c vd_mtga.c
+VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_qtrpza.c vd_raw.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_msrle.c vd_huffyuv.c vd_mpegpes.c vd_svq1.c vd_lcl.c vd_mtga.c vd_gif.c
VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_xanim.c vd_xvid.c vd_libdv.c vd_qtvideo.c
VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT)
diff -Nur main.cvs/libmpcodecs/vd.c main.dev/libmpcodecs/vd.c
--- main.cvs/libmpcodecs/vd.c Fri Dec 27 11:31:52 2002
+++ main.dev/libmpcodecs/vd.c Tue Jan 7 20:32:48 2003
@@ -58,6 +58,7 @@
extern vd_functions_t mpcodecs_vd_lcl;
extern vd_functions_t mpcodecs_vd_lzo;
extern vd_functions_t mpcodecs_vd_qtvideo;
+extern vd_functions_t mpcodecs_vd_gif;
vd_functions_t* mpcodecs_vd_drivers[] = {
&mpcodecs_vd_null,
@@ -120,6 +121,9 @@
&mpcodecs_vd_lcl,
#ifdef USE_QTX_CODECS
&mpcodecs_vd_qtvideo,
+#endif
+#ifdef HAVE_GIF
+ &mpcodecs_vd_gif,
#endif
NULL
};
diff -Nur main.cvs/libmpcodecs/vd_gif.c main.dev/libmpcodecs/vd_gif.c
--- main.cvs/libmpcodecs/vd_gif.c Wed Dec 31 18:00:00 1969
+++ main.dev/libmpcodecs/vd_gif.c Tue Jan 7 20:32:48 2003
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "config.h"
+#include "mp_msg.h"
+
+#ifdef HAVE_GIF
+
+#include <gif_lib.h>
+
+#include "vd_internal.h"
+
+static vd_info_t info = {
+ "GIF decoder",
+ "gif",
+ "Joey Parrish",
+ "http://www.w3.org/Graphics/GIF/spec-gif89a.txt",
+ "uses libungif and family"
+};
+
+LIBVD_EXTERN(gif)
+
+// to set/get/query special features/parameters
+static int control(sh_video_t *sh,int cmd,void* arg,...){
+ return CONTROL_UNKNOWN;
+}
+
+// init driver
+static int init(sh_video_t *sh){
+ return mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, IMGFMT_RGB24);
+}
+
+// uninit driver
+static void uninit(sh_video_t *sh){
+}
+
+// decode a frame
+static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
+ mp_image_t* mpi;
+ GifFileType *gif = (GifFileType *)sh->ds->demuxer->priv;
+ int x, y;
+
+ if (!gif) return NULL; // no gif structure?
+ // this is bad, it makes the decoder demuxer-dependant.
+
+ if (len <= 0) return NULL; // skipped frame
+
+ mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, sh->disp_w, sh->disp_h);
+ if(!mpi) return NULL;
+
+ for (y = 0; y < gif->Image.Height; y++) {
+ unsigned char *drow = mpi->planes[0];
+ unsigned char *buf = data + (y * gif->Image.Width);
+ ColorMapObject *cmap = gif->Image.ColorMap;
+
+ if (!cmap) cmap = gif->SColorMap; // default to a global map.
+
+ if (!cmap) { // no color map at all?
+ fprintf(stderr, "GIF color map failure.\n");
+ return NULL;
+ }
+
+ drow += mpi->stride[0] * (y + gif->Image.Top);
+ drow += gif->Image.Left;
+
+ for (x = 0; x < gif->Image.Width; x++) {
+ drow[(x * 3) + 0] = cmap->Colors[buf[x]].Red;
+ drow[(x * 3) + 1] = cmap->Colors[buf[x]].Green;
+ drow[(x * 3) + 2] = cmap->Colors[buf[x]].Blue;
+ }
+ }
+
+ return mpi;
+}
+
+#endif /* HAVE_GIF */
diff -Nur main.cvs/libmpdemux/Makefile main.dev/libmpdemux/Makefile
--- main.cvs/libmpdemux/Makefile Sun Jan 5 17:51:05 2003
+++ main.dev/libmpdemux/Makefile Tue Jan 7 20:32:48 2003
@@ -3,7 +3,7 @@
include ../config.mak
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c cue_read.c
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c cue_read.c demux_gif.c
ifeq ($(XMMS_PLUGINS),yes)
SRCS += demux_xmms.c
endif
diff -Nur main.cvs/libmpdemux/demux_gif.c main.dev/libmpdemux/demux_gif.c
--- main.cvs/libmpdemux/demux_gif.c Wed Dec 31 18:00:00 1969
+++ main.dev/libmpdemux/demux_gif.c Tue Jan 7 20:32:48 2003
@@ -0,0 +1,153 @@
+/*
+ GIF file parser for MPlayer
+ by Joey Parrish
+ based on demux_fli.c
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
+
+#include "stream.h"
+#include "demuxer.h"
+#include "stheader.h"
+
+#ifdef HAVE_GIF
+
+#include <gif_lib.h>
+
+static int current_pts = 0;
+
+int gif_check_file(demuxer_t *demuxer)
+{
+ lseek(demuxer->stream->fd, 0, SEEK_SET);
+ if (stream_read_dword(demuxer->stream) ==
+ (('G' << 24) | ('I' << 16) | ('F' << 8) | '8'))
+ return 1;
+ return 0;
+}
+
+int demux_gif_fill_buffer(demuxer_t *demuxer)
+{
+ GifFileType *gif = (GifFileType *)demuxer->priv;
+ GifRecordType type = UNDEFINED_RECORD_TYPE;
+ int len = 0;
+ int frametime = 0;
+ demux_packet_t *dp = NULL;
+
+ while (type != IMAGE_DESC_RECORD_TYPE) {
+ if (DGifGetRecordType(gif, &type) == GIF_ERROR) {
+ PrintGifError();
+ return 0; // oops
+ }
+ if (type == TERMINATE_RECORD_TYPE)
+ return 0; // eof
+ if (type == SCREEN_DESC_RECORD_TYPE) {
+ if (DGifGetScreenDesc(gif) == GIF_ERROR) {
+ PrintGifError();
+ return 0; // oops
+ }
+ }
+ if (type == EXTENSION_RECORD_TYPE) {
+ int code;
+ unsigned char *p = NULL;
+ if (DGifGetExtension(gif, &code, &p) == GIF_ERROR) {
+ PrintGifError();
+ return 0; // oops
+ }
+ if (code == 0xF9) {
+ frametime = 0;
+ if (p[0] == 4) // is the length correct?
+ frametime = (p[1] << 8) | p[2]; // set the time, centiseconds
+ }
+ while (p != NULL) {
+ if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) {
+ PrintGifError();
+ return 0; // oops
+ }
+ }
+ }
+ }
+
+ if (DGifGetImageDesc(gif) == GIF_ERROR) {
+ PrintGifError();
+ return 0; // oops
+ }
+
+ len = gif->Image.Width * gif->Image.Height;
+ dp = new_demux_packet(len);
+
+ if (DGifGetLine(gif, dp->buffer, len) == GIF_ERROR) {
+ PrintGifError();
+ return 0; // oops
+ }
+
+ demuxer->video->dpos++;
+ current_pts += frametime;
+ dp->pts = ((float)current_pts) / 100;
+ ds_add_packet(demuxer->video, dp);
+
+ return 1;
+}
+
+demuxer_t* demux_open_gif(demuxer_t* demuxer)
+{
+ sh_video_t *sh_video = NULL;
+ GifFileType *gif = NULL;
+
+ demuxer->seekable = 0;
+ current_pts = 0;
+
+ // go back to the beginning
+ lseek(demuxer->stream->fd, 0, SEEK_SET);
+
+ gif = DGifOpenFileHandle(demuxer->stream->fd);
+ if (!gif) {
+ PrintGifError();
+ return NULL;
+ }
+
+ // create a new video stream header
+ sh_video = new_sh_video(demuxer, 0);
+
+ // make sure the demuxer knows about the new video stream header
+ // (even though new_sh_video() ought to take care of it)
+ demuxer->video->sh = sh_video;
+
+ // make sure that the video demuxer stream header knows about its
+ // parent video demuxer stream (this is getting wacky), or else
+ // video_read_properties() will choke
+ sh_video->ds = demuxer->video;
+
+ sh_video->disp_w = gif->SWidth;
+ sh_video->disp_h = gif->SHeight;
+
+ // custom fourcc for internal MPlayer use
+ sh_video->format = mmioFOURCC('G', 'I', 'F', 'V');
+
+ sh_video->fps = 5.0f;
+ sh_video->frametime = 1.0f / sh_video->fps;
+
+ demuxer->priv = gif;
+
+ return demuxer;
+}
+
+void demux_close_gif(demuxer_t* demuxer)
+{
+ GifFileType *gif = (GifFileType *)demuxer->priv;
+
+ if(!gif)
+ return;
+
+ if (DGifCloseFile(gif) == GIF_ERROR)
+ PrintGifError();
+
+ demuxer->stream->fd = 0;
+ demuxer->priv = NULL;
+}
+#endif /* HAVE_GIF */
diff -Nur main.cvs/libmpdemux/demuxer.c main.dev/libmpdemux/demuxer.c
--- main.cvs/libmpdemux/demuxer.c Mon Jan 6 08:54:36 2003
+++ main.dev/libmpdemux/demuxer.c Tue Jan 7 20:32:48 2003
@@ -133,6 +133,7 @@
extern void demux_close_pva(demuxer_t* demuxer);
extern void demux_close_smjpeg(demuxer_t* demuxer);
extern void demux_close_xmms(demuxer_t* demuxer);
+extern void demux_close_gif(demuxer_t* demuxer);
#ifdef USE_TV
#include "tv.h"
@@ -199,6 +200,10 @@
case DEMUXER_TYPE_XMMS:
demux_close_xmms(demuxer); break;
#endif
+#ifdef HAVE_GIF
+ case DEMUXER_TYPE_GIF:
+ demux_close_gif(demuxer); break;
+#endif
}
// free streams:
@@ -276,6 +281,7 @@
int demux_audio_fill_buffer(demux_stream_t *ds);
int demux_pva_fill_buffer(demuxer_t *demux);
int demux_xmms_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
+int demux_gif_fill_buffer(demuxer_t *demux);
extern int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
extern int demux_ogg_fill_buffer(demuxer_t *d);
@@ -322,6 +328,9 @@
case DEMUXER_TYPE_RTP: return demux_rtp_fill_buffer(demux, ds);
#endif
case DEMUXER_TYPE_SMJPEG: return demux_smjpeg_fill_buffer(demux);
+#ifdef HAVE_GIF
+ case DEMUXER_TYPE_GIF: return demux_gif_fill_buffer(demux);
+#endif
}
return 0;
}
@@ -544,6 +553,8 @@
extern int demux_open_smjpeg(demuxer_t* demuxer);
extern int bmp_check_file(demuxer_t *demuxer);
extern int demux_xmms_open(demuxer_t* demuxer);
+extern int gif_check_file(demuxer_t *demuxer);
+extern int demux_open_gif(demuxer_t* demuxer);
extern demuxer_t* init_avi_with_ogg(demuxer_t* demuxer);
@@ -721,6 +732,19 @@
demuxer = NULL;
}
}
+#ifdef HAVE_GIF
+//=============== Try to open as GIF file: =================
+if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_GIF){
+ demuxer=new_demuxer(stream,DEMUXER_TYPE_GIF,audio_id,video_id,dvdsub_id);
+ if(gif_check_file(demuxer)){
+ mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"GIF");
+ file_format=DEMUXER_TYPE_GIF;
+ } else {
+ free_demuxer(demuxer);
+ demuxer = NULL;
+ }
+}
+#endif
//=============== Try to open as BMP file: =================
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_BMP){
demuxer=new_demuxer(stream,DEMUXER_TYPE_BMP,audio_id,video_id,dvdsub_id);
@@ -917,6 +941,12 @@
if (!demux_open_film(demuxer)) return NULL;
break;
}
+#ifdef HAVE_GIF
+ case DEMUXER_TYPE_GIF: {
+ if (!demux_open_gif(demuxer)) return NULL;
+ break;
+ }
+#endif
case DEMUXER_TYPE_BMP: {
if (!demux_open_bmp(demuxer)) return NULL;
break;
diff -Nur main.cvs/libmpdemux/demuxer.h main.dev/libmpdemux/demuxer.h
--- main.cvs/libmpdemux/demuxer.h Sun Dec 22 15:01:01 2002
+++ main.dev/libmpdemux/demuxer.h Tue Jan 7 20:32:48 2003
@@ -34,6 +34,7 @@
#define DEMUXER_TYPE_PVA 23
#define DEMUXER_TYPE_SMJPEG 24
#define DEMUXER_TYPE_XMMS 25
+#define DEMUXER_TYPE_GIF 26
// This should always match the higest demuxer type number.
// Unless you want to disallow users to force the demuxer to some types
diff -Nur main.cvs/libmpdemux/video.c main.dev/libmpdemux/video.c
--- main.cvs/libmpdemux/video.c Fri Nov 1 11:46:43 2002
+++ main.dev/libmpdemux/video.c Tue Jan 7 20:32:48 2003
@@ -333,6 +333,9 @@
// frame_time = 1/25.0;
}
}
+ case DEMUXER_TYPE_GIF:
+ frame_time=d_video->pts-pts1;
+ break;
}
if(demuxer->file_format==DEMUXER_TYPE_MPEG_PS ||
More information about the MPlayer-dev-eng
mailing list