diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index a42b27f..1997e54 100644
|
a
|
b
|
static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src, |
| 102 | 102 | } |
| 103 | 103 | #endif |
| 104 | 104 | |
| | 105 | static void av_always_inline horizontal_fill(unsigned int bpp, uint8_t* dst, |
| | 106 | int usePtr, const uint8_t *src, |
| | 107 | uint8_t c, int width, int offset) |
| | 108 | { |
| | 109 | int i; |
| | 110 | |
| | 111 | if (bpp == 2) { |
| | 112 | for (i = 0; i < width; i++) { |
| | 113 | dst[(i+offset)*4+0] = (usePtr ? src[i] : c) >> 6; |
| | 114 | dst[(i+offset)*4+1] = (usePtr ? src[i] : c) >> 4 & 0x3; |
| | 115 | dst[(i+offset)*4+2] = (usePtr ? src[i] : c) >> 2 & 0x3; |
| | 116 | dst[(i+offset)*4+3] = (usePtr ? src[i] : c) & 0x3; |
| | 117 | } |
| | 118 | } else if (bpp == 4) { |
| | 119 | for (i = 0; i < width; i++) { |
| | 120 | dst[(i+offset)*2+0] = (usePtr ? src[i] : c) >> 4; |
| | 121 | dst[(i+offset)*2+1] = (usePtr ? src[i] : c) & 0xF; |
| | 122 | } |
| | 123 | } else { |
| | 124 | if (usePtr) { |
| | 125 | memcpy(dst + offset, src, width); |
| | 126 | } else { |
| | 127 | memset(dst + offset, c, width); |
| | 128 | } |
| | 129 | } |
| | 130 | } |
| | 131 | |
| 105 | 132 | static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){ |
| 106 | 133 | int c, line, pixels, code; |
| 107 | 134 | const uint8_t *ssrc = src; |
| … |
… |
static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin |
| 173 | 200 | switch(s->compr){ |
| 174 | 201 | case TIFF_RAW: |
| 175 | 202 | if (!s->fill_order) { |
| 176 | | memcpy(dst, src, width); |
| | 203 | horizontal_fill(s->bpp, dst, 1, src, 0, width, 0); |
| 177 | 204 | } else { |
| 178 | 205 | int i; |
| 179 | 206 | for (i = 0; i < width; i++) |
| … |
… |
static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin |
| 190 | 217 | av_log(s->avctx, AV_LOG_ERROR, "Copy went out of bounds\n"); |
| 191 | 218 | return -1; |
| 192 | 219 | } |
| 193 | | memcpy(dst + pixels, src, code); |
| | 220 | horizontal_fill(s->bpp, dst, 1, src, 0, code, pixels); |
| 194 | 221 | src += code; |
| 195 | 222 | pixels += code; |
| 196 | 223 | }else if(code != -128){ // -127..-1 |
| … |
… |
static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin |
| 200 | 227 | return -1; |
| 201 | 228 | } |
| 202 | 229 | c = *src++; |
| 203 | | memset(dst + pixels, c, code); |
| | 230 | horizontal_fill(s->bpp, dst, 0, NULL, c, code, pixels); |
| 204 | 231 | pixels += code; |
| 205 | 232 | } |
| 206 | 233 | } |
| … |
… |
static int init_image(TiffContext *s) |
| 227 | 254 | case 11: |
| 228 | 255 | s->avctx->pix_fmt = PIX_FMT_MONOBLACK; |
| 229 | 256 | break; |
| | 257 | case 21: |
| | 258 | case 41: |
| 230 | 259 | case 81: |
| 231 | 260 | s->avctx->pix_fmt = PIX_FMT_PAL8; |
| 232 | 261 | break; |