28 #define SGI_SINGLE_CHAN 2
29 #define SGI_MULTI_CHAN 3
33 if (avctx->
width > 65535 || avctx->
height > 65535) {
48 uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf, *
buf;
50 unsigned int width,
height,
depth, dimension, bytes_per_channel, pixmax, put_be;
51 unsigned char *end_buf;
58 bytes_per_channel = 1;
60 put_be = HAVE_BIGENDIAN;
76 put_be = !HAVE_BIGENDIAN;
79 bytes_per_channel = 2;
85 put_be = !HAVE_BIGENDIAN;
88 bytes_per_channel = 2;
94 put_be = !HAVE_BIGENDIAN;
97 bytes_per_channel = 2;
106 tablesize = depth * height * 4;
109 length += depth * height *
width;
111 length += tablesize * 2 + depth * height * (2 * width + 1);
121 bytestream_put_byte(&buf, bytes_per_channel);
122 bytestream_put_be16(&buf, dimension);
123 bytestream_put_be16(&buf, width);
124 bytestream_put_be16(&buf, height);
125 bytestream_put_be16(&buf, depth);
127 bytestream_put_be32(&buf, 0
L);
128 bytestream_put_be32(&buf, pixmax);
129 bytestream_put_be32(&buf, 0
L);
136 bytestream_put_be32(&buf, 0
L);
154 for (z = 0; z <
depth; z++) {
155 in_buf = p->
data[0] + p->
linesize[0] * (height - 1) + z;
157 for (y = 0; y <
height; y++) {
158 bytestream_put_be32(&offsettab, buf - pkt->
data);
160 for (x = 0; x <
width; x++)
161 encode_buf[x] = in_buf[depth * x];
163 if ((length =
ff_rle_encode(buf, end_buf - buf - 1, encode_buf, 1, width, 0, 0, 0x80, 0)) < 1) {
169 bytestream_put_byte(&buf, 0);
170 bytestream_put_be32(&lengthtab, length + 1);
177 for (z = 0; z <
depth; z++) {
178 in_buf = p->
data[0] + p->
linesize[0] * (height - 1) + z * bytes_per_channel;
180 for (y = 0; y <
height; y++) {
182 if (bytes_per_channel == 1) {
183 bytestream_put_byte(&buf, in_buf[x]);
186 bytestream_put_be16(&buf, ((uint16_t *)in_buf)[x]);
188 bytestream_put_le16(&buf, ((uint16_t *)in_buf)[x]);