]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/sgienc.c
lavc/sgienc: Fix default 16bit encoding.
[ffmpeg] / libavcodec / sgienc.c
index 13756f16088b2a1b8c9753cc3dc64a041f78fe90..40771d46662209799ec81e3b6570d02c97ede884 100644 (file)
@@ -219,7 +219,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
                 bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc));
 
                 for (x = 0; x < width * bytes_per_channel; x += bytes_per_channel)
-                    encode_buf[x] = in_buf[depth * x];
+                    if (bytes_per_channel == 1) {
+                        encode_buf[x]     = in_buf[depth * x];
+                    } else if (HAVE_BIGENDIAN ^ put_be) {
+                        encode_buf[x + 1] = in_buf[depth * x];
+                        encode_buf[x]     = in_buf[depth * x + 1];
+                    } else {
+                        encode_buf[x]     = in_buf[depth * x];
+                        encode_buf[x + 1] = in_buf[depth * x + 1];
+                    }
 
                 length = sgi_rle_encode(&pbc, encode_buf, width,
                                         bytes_per_channel);