[MPlayer-cvslog] r21909 - trunk/libmpdemux/demux_gif.c
reimar
subversion at mplayerhq.hu
Sat Jan 13 13:19:42 CET 2007
Author: reimar
Date: Sat Jan 13 13:19:42 2007
New Revision: 21909
Modified:
trunk/libmpdemux/demux_gif.c
Log:
Partially support gif using "reference" images
Modified: trunk/libmpdemux/demux_gif.c
==============================================================================
--- trunk/libmpdemux/demux_gif.c (original)
+++ trunk/libmpdemux/demux_gif.c Sat Jan 13 13:19:42 2007
@@ -23,6 +23,8 @@
unsigned char *palette;
GifFileType *gif;
int w, h;
+ int useref;
+ char *refimg;
} gif_priv_t;
#define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F')
@@ -50,6 +52,7 @@
demux_packet_t *dp = NULL;
ColorMapObject *effective_map = NULL;
char *buf = NULL;
+ int refmode = 0;
while (type != IMAGE_DESC_RECORD_TYPE) {
if (DGifGetRecordType(gif, &type) == GIF_ERROR) {
@@ -74,7 +77,10 @@
if (code == 0xF9) {
int frametime = 0;
if (p[0] == 4) // is the length correct?
+ {
frametime = (p[3] << 8) | p[2]; // set the time, centiseconds
+ refmode = (p[1] >> 2) & 3;
+ }
priv->current_pts += frametime;
} else if ((code == 0xFE) && (verbose)) { // comment extension
// print iff verbose
@@ -108,7 +114,10 @@
len = gif->Image.Width * gif->Image.Height;
dp = new_demux_packet(priv->w * priv->h);
buf = calloc(gif->Image.Width, gif->Image.Height);
- memset(dp->buffer, 0, priv->w * priv->h);
+ if (priv->useref)
+ memcpy(dp->buffer, priv->refimg, priv->w * priv->h);
+ else
+ memset(dp->buffer, gif->SBackGroundColor, priv->w * priv->h);
if (DGifGetLine(gif, buf, len) == GIF_ERROR) {
PrintGifError();
@@ -140,6 +149,11 @@
free(buf);
+ priv->useref = 1;
+ if (refmode == 1) memcpy(priv->refimg, dp->buffer, priv->w * priv->h);
+ // TODO: refmode == 2, set area of current image to background color
+ if (!refmode) priv->useref = 0;
+
demuxer->video->dpos++;
dp->pts = ((float)priv->current_pts) / 100;
dp->pos = stream_tell(demuxer->stream);
@@ -203,6 +217,7 @@
priv->palette = (unsigned char *)(sh_video->bih + 1);
priv->w = sh_video->disp_w;
priv->h = sh_video->disp_h;
+ priv->refimg = malloc(priv->w * priv->h);
priv->gif = gif;
demuxer->priv = priv;
@@ -216,6 +231,7 @@
if (!priv) return;
if (priv->gif && DGifCloseFile(priv->gif) == GIF_ERROR)
PrintGifError();
+ free(priv->refimg);
free(priv);
}
More information about the MPlayer-cvslog
mailing list