[FFmpeg-cvslog] targa: Do not read colormap from files without one.

Reimar Döffinger git at videolan.org
Tue Jun 28 18:49:46 CEST 2011


ffmpeg | branch: master | Reimar Döffinger <Reimar.Doeffinger at gmx.de> | Mon Jun 27 19:15:46 2011 +0200| [90cbbbc1e2fbe0ea35da450f82d2b6e53691b9a8] | committer: Reimar Döffinger

targa: Do not read colormap from files without one.

This is necessary because some programs writing TGA files forget
to initialize parts of the header they don't care about, resulting
in "random" data there.
The new behaviour is consistent with other programs, e.g. tgatoppm.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=90cbbbc1e2fbe0ea35da450f82d2b6e53691b9a8
---

 libavcodec/targa.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/targa.c b/libavcodec/targa.c
index 7418f92..88b34f3 100644
--- a/libavcodec/targa.c
+++ b/libavcodec/targa.c
@@ -109,17 +109,22 @@ static int decode_frame(AVCodecContext *avctx,
     AVFrame * const p= (AVFrame*)&s->picture;
     uint8_t *dst;
     int stride;
-    int idlen, compr, y, w, h, bpp, flags;
+    int idlen, pal, compr, y, w, h, bpp, flags;
     int first_clr, colors, csize;
 
     /* parse image header */
     CHECK_BUFFER_SIZE(buf, buf_end, 18, "header");
     idlen = *buf++;
-    buf++; /* pal */
+    pal = *buf++;
     compr = *buf++;
     first_clr = bytestream_get_le16(&buf);
     colors = bytestream_get_le16(&buf);
     csize = *buf++;
+    if (!pal && (first_clr || colors || csize)) {
+        av_log(avctx, AV_LOG_WARNING, "File without colormap has colormap information set.\n");
+        // specification says we should ignore those value in this case
+        first_clr = colors = csize = 0;
+    }
     buf += 2; /* x */
     y = bytestream_get_le16(&buf);
     w = bytestream_get_le16(&buf);



More information about the ffmpeg-cvslog mailing list