changeset 10264:f9efc2bd005d libavcodec

Support both LSB and MSB orders for TIFF CCITT G.x compressed data. This fixes issue 1410.
author kostya
date Thu, 24 Sep 2009 18:30:28 +0000
parents fd9dfd5aa5e9
children 9acd9b34b2b9
files tiff.c tiff.h
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tiff.c	Thu Sep 24 15:13:34 2009 +0000
+++ b/tiff.c	Thu Sep 24 18:30:28 2009 +0000
@@ -44,6 +44,7 @@
     int invert;
     int fax_opts;
     int predictor;
+    int fill_order;
 
     int strips, rps, sstype;
     int sot;
@@ -113,8 +114,12 @@
             av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
             return -1;
         }
-        for(i = 0; i < size; i++)
-            src2[i] = ff_reverse[src[i]];
+        if(!s->fill_order){
+            memcpy(src2, src, size);
+        }else{
+            for(i = 0; i < size; i++)
+                src2[i] = ff_reverse[src[i]];
+        }
         memset(src2+size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
         if(s->compr == TIFF_G3 && !(s->fax_opts & 1))
             s->compr = TIFF_CCITT_RLE;
@@ -375,6 +380,13 @@
             return -1;
         }
         break;
+    case TIFF_FILL_ORDER:
+        if(value < 1 || value > 2){
+            av_log(s->avctx, AV_LOG_ERROR, "Unknown FillOrder value %d, trying default one\n", value);
+            value = 1;
+        }
+        s->fill_order = value - 1;
+        break;
     case TIFF_PAL:
         if(s->avctx->pix_fmt != PIX_FMT_PAL8){
             av_log(s->avctx, AV_LOG_ERROR, "Palette met but this is not palettized format\n");
@@ -433,6 +445,7 @@
     s->le = le;
     s->invert = 0;
     s->compr = TIFF_RAW;
+    s->fill_order = 0;
     // As TIFF 6.0 specification puts it "An arbitrary but carefully chosen number
     // that further identifies the file as a TIFF file"
     if(tget_short(&buf, le) != 42){
--- a/tiff.h	Thu Sep 24 15:13:34 2009 +0000
+++ b/tiff.h	Thu Sep 24 18:30:28 2009 +0000
@@ -37,6 +37,7 @@
     TIFF_BPP,
     TIFF_COMPR,
     TIFF_INVERT = 0x106,
+    TIFF_FILL_ORDER = 0x10A,
     TIFF_STRIP_OFFS = 0x111,
     TIFF_SAMPLES_PER_PIXEL = 0x115,
     TIFF_ROWSPERSTRIP = 0x116,