Browse code

tiffdec: hotfix for fate failure.

Only use pal8 as output if the file has a palette or more than 2 colors.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/12/31 12:49:33
Showing 1 changed files
... ...
@@ -161,7 +161,11 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
161 161
         }
162 162
         src = zbuf;
163 163
         for(line = 0; line < lines; line++){
164
-            horizontal_fill(s->bpp, dst, 1, src, 0, width, 0);
164
+            if(s->bpp < 8 && s->avctx->pix_fmt == PIX_FMT_PAL8){
165
+                horizontal_fill(s->bpp, dst, 1, src, 0, width, 0);
166
+            }else{
167
+                memcpy(dst, src, width);
168
+            }
165 169
             dst += stride;
166 170
             src += width;
167 171
         }
... ...
@@ -202,7 +206,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
202 202
             ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, s->compr, s->fax_opts);
203 203
             break;
204 204
         }
205
-        if (s->bpp < 8)
205
+        if (s->bpp < 8 && s->avctx->pix_fmt == PIX_FMT_PAL8)
206 206
             for (line = 0; line < lines; line++) {
207 207
                 horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);
208 208
                 dst += stride;
... ...
@@ -258,7 +262,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
258 258
                 av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", pixels, width);
259 259
                 return -1;
260 260
             }
261
-            if (s->bpp < 8)
261
+            if (s->bpp < 8 && s->avctx->pix_fmt == PIX_FMT_PAL8)
262 262
                 horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);
263 263
             break;
264 264
         }
... ...
@@ -274,6 +278,10 @@ static int init_image(TiffContext *s)
274 274
 
275 275
     switch (s->bpp * 10 + s->bppcount) {
276 276
     case 11:
277
+        if (!s->palette_is_set) {
278
+            s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
279
+            break;
280
+        }
277 281
     case 21:
278 282
     case 41:
279 283
     case 81: