comparison sgienc.c @ 10330:ac0b95400577 libavcodec

Add support for SGI images without RLE compression. patch by Anne-Laure de Smit, annelaure.desmit gmail com
author diego
date Wed, 30 Sep 2009 21:23:47 +0000
parents 38cfe222e1a4
children 118f18919f4b
comparison
equal deleted inserted replaced
10329:5462710f17ee 10330:ac0b95400577
81 return -1; 81 return -1;
82 } 82 }
83 83
84 /* Encode header. */ 84 /* Encode header. */
85 bytestream_put_be16(&buf, SGI_MAGIC); 85 bytestream_put_be16(&buf, SGI_MAGIC);
86 bytestream_put_byte(&buf, 1); /* RLE */ 86 bytestream_put_byte(&buf, avctx->coder_type != FF_CODER_TYPE_RAW); /* RLE 1 - VERBATIM 0*/
87 bytestream_put_byte(&buf, 1); /* bytes_per_channel */ 87 bytestream_put_byte(&buf, 1); /* bytes_per_channel */
88 bytestream_put_be16(&buf, dimension); 88 bytestream_put_be16(&buf, dimension);
89 bytestream_put_be16(&buf, width); 89 bytestream_put_be16(&buf, width);
90 bytestream_put_be16(&buf, height); 90 bytestream_put_be16(&buf, height);
91 bytestream_put_be16(&buf, depth); 91 bytestream_put_be16(&buf, depth);
104 104
105 /* The rest of the 512 byte header is unused. */ 105 /* The rest of the 512 byte header is unused. */
106 buf += 404; 106 buf += 404;
107 offsettab = buf; 107 offsettab = buf;
108 108
109 if (avctx->coder_type != FF_CODER_TYPE_RAW) {
109 /* Skip RLE offset table. */ 110 /* Skip RLE offset table. */
110 buf += tablesize; 111 buf += tablesize;
111 lengthtab = buf; 112 lengthtab = buf;
112 113
113 /* Skip RLE length table. */ 114 /* Skip RLE length table. */
137 in_buf -= p->linesize[0]; 138 in_buf -= p->linesize[0];
138 } 139 }
139 } 140 }
140 141
141 av_free(encode_buf); 142 av_free(encode_buf);
143 } else {
144 for (z = 0; z < depth; z++) {
145 in_buf = p->data[0] + p->linesize[0] * (height - 1) + z;
146
147 for (y = 0; y < height; y++) {
148 for (x = 0; x < width * depth; x += depth)
149 bytestream_put_byte(&buf, in_buf[x]);
150
151 in_buf -= p->linesize[0];
152 }
153 }
154 }
155
142 /* total length */ 156 /* total length */
143 return buf - orig_buf; 157 return buf - orig_buf;
144 } 158 }
145 159
146 AVCodec sgi_encoder = { 160 AVCodec sgi_encoder = {