comparison tiff.c @ 8426:898722eb4fd2 libavcodec

Calculate line size variable correctly for lower bitdepths and use it for raw data copying
author kostya
date Mon, 22 Dec 2008 06:39:31 +0000
parents 3bbfd02865d7
children 2dfb0cc864b6
comparison
equal deleted inserted replaced
8425:b8d72c9851c7 8426:898722eb4fd2
72 } 72 }
73 73
74 static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){ 74 static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){
75 int c, line, pixels, code; 75 int c, line, pixels, code;
76 const uint8_t *ssrc = src; 76 const uint8_t *ssrc = src;
77 int width = s->width * (s->bpp / 8); 77 int width = s->width * s->bpp >> 3;
78 #ifdef CONFIG_ZLIB 78 #ifdef CONFIG_ZLIB
79 uint8_t *zbuf; unsigned long outlen; 79 uint8_t *zbuf; unsigned long outlen;
80 80
81 if(s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE){ 81 if(s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE){
82 outlen = width * lines; 82 outlen = width * lines;
107 av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n"); 107 av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n");
108 return -1; 108 return -1;
109 } 109 }
110 switch(s->compr){ 110 switch(s->compr){
111 case TIFF_RAW: 111 case TIFF_RAW:
112 memcpy(dst, src, s->width * (s->bpp / 8)); 112 memcpy(dst, src, width);
113 src += s->width * (s->bpp / 8); 113 src += width;
114 break; 114 break;
115 case TIFF_PACKBITS: 115 case TIFF_PACKBITS:
116 for(pixels = 0; pixels < width;){ 116 for(pixels = 0; pixels < width;){
117 code = (int8_t)*src++; 117 code = (int8_t)*src++;
118 if(code >= 0){ 118 if(code >= 0){