28 #define SGI_SINGLE_CHAN 2
29 #define SGI_MULTI_CHAN 3
33 if (avctx->
width > 65535 || avctx->
height > 65535) {
35 "Unsupported resolution %dx%d.\n", avctx->
width, avctx->
height);
51 uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf, *
buf;
54 unsigned int bytes_per_channel, pixmax, put_be;
55 unsigned char *end_buf;
62 bytes_per_channel = 1;
64 put_be = HAVE_BIGENDIAN;
80 put_be = !HAVE_BIGENDIAN;
83 bytes_per_channel = 2;
89 put_be = !HAVE_BIGENDIAN;
92 bytes_per_channel = 2;
98 put_be = !HAVE_BIGENDIAN;
101 bytes_per_channel = 2;
110 tablesize = depth * height * 4;
113 length += depth * height *
width;
115 length += tablesize * 2 + depth * height * (2 * width + 1);
125 bytestream_put_byte(&buf, bytes_per_channel);
126 bytestream_put_be16(&buf, dimension);
127 bytestream_put_be16(&buf, width);
128 bytestream_put_be16(&buf, height);
129 bytestream_put_be16(&buf, depth);
131 bytestream_put_be32(&buf, 0
L);
132 bytestream_put_be32(&buf, pixmax);
133 bytestream_put_be32(&buf, 0
L);
140 bytestream_put_be32(&buf, 0
L);
158 for (z = 0; z <
depth; z++) {
159 in_buf = p->
data[0] + p->
linesize[0] * (height - 1) + z;
161 for (y = 0; y <
height; y++) {
162 bytestream_put_be32(&offsettab, buf - pkt->
data);
164 for (x = 0; x <
width; x++)
165 encode_buf[x] = in_buf[depth * x];
167 if ((length =
ff_rle_encode(buf, end_buf - buf - 1, encode_buf, 1, width, 0, 0, 0x80, 0)) < 1) {
173 bytestream_put_byte(&buf, 0);
174 bytestream_put_be32(&lengthtab, length + 1);
181 for (z = 0; z <
depth; z++) {
182 in_buf = p->
data[0] + p->
linesize[0] * (height - 1) + z * bytes_per_channel;
184 for (y = 0; y <
height; y++) {
186 if (bytes_per_channel == 1) {
187 bytestream_put_byte(&buf, in_buf[x]);
190 bytestream_put_be16(&buf, ((uint16_t *)in_buf)[x]);
192 bytestream_put_le16(&buf, ((uint16_t *)in_buf)[x]);