+static av_always_inline void copy_loop(uint8_t *out_buf, const uint8_t *in_buf,
+ unsigned offset, unsigned bytes_per_channel,
+ SgiState *s)
+{
+ int x, y, z;
+ for (y = s->height - 1; y >= 0; y--) {
+ uint8_t *line = out_buf + (y * s->linesize);
+ for (x = s->width; x > 0; x--) {
+ const uint8_t *ptr = in_buf;
+ in_buf += bytes_per_channel;
+ for(z = 0; z < s->depth; z ++) {
+ memcpy(line, ptr, bytes_per_channel);
+ line += bytes_per_channel;
+ ptr += offset;
+ }
+ }
+ }
+}
+