43 size_t width = s3d->
x;
44 size_t height = s3d->
y;
45 const size_t channels = s3d->
channels;
47 const int stride_from = width;
48 const int stride_to = width;
50 const int anaglyph_encoding[3][3] = {
58 r = anaglyph_encoding[mode][0];
59 g = anaglyph_encoding[mode][1];
60 b = anaglyph_encoding[mode][2];
68 for (
y = 0;
y < height;
y++) {
69 float *to = rect_to + stride_to *
y * 3;
71 rect_left + stride_from *
y * 3,
72 rect_right + stride_from *
y * 3,
75 for (
x = 0;
x < width;
x++,
from[0] += 3,
from[1] += 3, to += 3) {
82 else if (channels == 4) {
83 for (
y = 0;
y < height;
y++) {
84 float *to = rect_to + stride_to *
y * 4;
86 rect_left + stride_from *
y * 4,
87 rect_right + stride_from *
y * 4,
90 for (
x = 0;
x < width;
x++,
from[0] += 4,
from[1] += 4, to += 4) {
94 to[3] = std::max(
from[0][3],
from[1][3]);
105 for (
y = 0;
y < height;
y++) {
106 uchar *to = rect_to + stride_to *
y * 3;
108 rect_left + stride_from *
y * 3,
109 rect_right + stride_from *
y * 3,
112 for (
x = 0;
x < width;
x++,
from[0] += 3,
from[1] += 3, to += 3) {
119 else if (channels == 4) {
120 for (
y = 0;
y < height;
y++) {
121 uchar *to = rect_to + stride_to *
y * 4;
123 rect_left + stride_from *
y * 4,
124 rect_right + stride_from *
y * 4,
127 for (
x = 0;
x < width;
x++,
from[0] += 4,
from[1] += 4, to += 4) {
131 to[3] = std::max(
from[0][3],
from[1][3]);
143 size_t width = s3d->
x;
144 size_t height = s3d->
y;
145 const size_t channels = s3d->
channels;
147 const int stride_from = width;
148 const int stride_to = width;
151 const float *rect_left = s3d->
rectf.
left;
158 for (
y = 0;
y < height;
y++) {
159 float *to = rect_to + stride_to *
y * channels;
160 const float *
from[2] = {
161 rect_left + stride_from *
y * channels,
162 rect_right + stride_from *
y * channels,
164 memcpy(to,
from[i],
sizeof(
float) * channels * stride_from);
171 for (
y = 0;
y < height;
y++) {
172 float *to = rect_to + stride_to *
y;
173 const float *
from[2] = {
174 rect_left + stride_from *
y,
175 rect_right + stride_from *
y,
179 for (
x = 0;
x < width;
x++,
from[0] += 1,
from[1] += 1, to += 1) {
185 else if (channels == 3) {
186 for (
y = 0;
y < height;
y++) {
187 float *to = rect_to + stride_to *
y * 3;
188 const float *
from[2] = {
189 rect_left + stride_from *
y * 3,
190 rect_right + stride_from *
y * 3,
194 for (
x = 0;
x < width;
x++,
from[0] += 3,
from[1] += 3, to += 3) {
200 else if (channels == 4) {
201 for (
y = 0;
y < height;
y++) {
202 float *to = rect_to + stride_to *
y * channels;
203 const float *
from[2] = {
204 rect_left + stride_from *
y * channels,
205 rect_right + stride_from *
y * channels,
209 for (
x = 0;
x < width;
x++,
from[0] += 4,
from[1] += 4, to += 4) {
220 for (
y = 0;
y < height;
y++) {
221 float *to = rect_to + stride_to *
y;
222 const float *
from[2] = {
223 rect_left + stride_from *
y,
224 rect_right + stride_from *
y,
227 for (
x = 0;
x < width;
x++,
from[0] += 1,
from[1] += 1, to += 1) {
234 else if (channels == 3) {
236 for (
y = 0;
y < height;
y++) {
237 float *to = rect_to + stride_to *
y * 3;
238 const float *
from[2] = {
239 rect_left + stride_from *
y * 3,
240 rect_right + stride_from *
y * 3,
243 for (
x = 0;
x < width;
x++,
from[0] += 3,
from[1] += 3, to += 3) {
250 else if (channels == 4) {
252 for (
y = 0;
y < height;
y++) {
253 float *to = rect_to + stride_to *
y * 4;
254 const float *
from[2] = {
255 rect_left + stride_from *
y * 4,
256 rect_right + stride_from *
y * 4,
259 for (
x = 0;
x < width;
x++,
from[0] += 4,
from[1] += 4, to += 4) {
281 for (
y = 0;
y < height;
y++) {
282 uchar *to = rect_to + stride_to *
y * channels;
284 rect_left + stride_from *
y * channels,
285 rect_right + stride_from *
y * channels,
287 memcpy(to,
from[i],
sizeof(
uchar) * channels * stride_from);
294 for (
y = 0;
y < height;
y++) {
295 uchar *to = rect_to + stride_to *
y;
297 rect_left + stride_from *
y,
298 rect_right + stride_from *
y,
301 for (
x = 0;
x < width;
x++,
from[0] += 1,
from[1] += 1, to += 1) {
307 else if (channels == 3) {
308 for (
y = 0;
y < height;
y++) {
309 uchar *to = rect_to + stride_to *
y * 3;
311 rect_left + stride_from *
y * 3,
312 rect_right + stride_from *
y * 3,
315 for (
x = 0;
x < width;
x++,
from[0] += 3,
from[1] += 3, to += 3) {
321 else if (channels == 4) {
322 for (
y = 0;
y < height;
y++) {
323 uchar *to = rect_to + stride_to *
y * 4;
325 rect_left + stride_from *
y * 4,
326 rect_right + stride_from *
y * 4,
329 for (
x = 0;
x < width;
x++,
from[0] += 4,
from[1] += 4, to += 4) {
340 for (
y = 0;
y < height;
y++) {
341 uchar *to = rect_to + stride_to *
y;
343 rect_left + stride_from *
y,
344 rect_right + stride_from *
y,
347 for (
x = 0;
x < width;
x++,
from[0] += 1,
from[1] += 1, to += 1) {
354 else if (channels == 3) {
356 for (
y = 0;
y < height;
y++) {
357 uchar *to = rect_to + stride_to *
y * 3;
359 rect_left + stride_from *
y * 3,
360 rect_right + stride_from *
y * 3,
363 for (
x = 0;
x < width;
x++,
from[0] += 3,
from[1] += 3, to += 3) {
370 else if (channels == 4) {
372 for (
y = 0;
y < height;
y++) {
373 uchar *to = rect_to + stride_to *
y * 4;
375 rect_left + stride_from *
y * 4,
376 rect_right + stride_from *
y * 4,
379 for (
x = 0;
x < width;
x++,
from[0] += 4,
from[1] += 4, to += 4) {
399 size_t width = s3d->
x;
400 size_t height = s3d->
y;
401 const size_t channels = s3d->
channels;
403 const int stride_from = width;
404 const int stride_to = width * 2;
406 const int l = int(crosseyed);
410 const float *rect_left = s3d->
rectf.
left;
414 for (
y = 0;
y < height;
y++) {
415 float *to = rect_to + stride_to *
y * channels;
416 const float *
from[2] = {
417 rect_left + stride_from *
y * channels,
418 rect_right + stride_from *
y * channels,
421 memcpy(to,
from[
l],
sizeof(
float) * channels * stride_from);
422 memcpy(to + channels * stride_from,
from[r],
sizeof(
float) * channels * stride_from);
430 for (
y = 0;
y < height;
y++) {
431 uchar *to = rect_to + stride_to *
y * channels;
433 rect_left + stride_from *
y * channels,
434 rect_right + stride_from *
y * channels,
437 memcpy(to,
from[
l],
sizeof(
uchar) * channels * stride_from);
438 memcpy(to + channels * stride_from,
from[r],
sizeof(
uchar) * channels * stride_from);
447 size_t width = s3d->
x;
448 size_t height = s3d->
y;
449 const size_t channels = s3d->
channels;
451 const int stride_from = width;
452 const int stride_to = width;
455 const float *rect_left = s3d->
rectf.
left;
459 for (
y = 0;
y < height;
y++) {
460 float *to = rect_to + stride_to *
y * channels;
461 const float *
from[2] = {
462 rect_left + stride_from *
y * channels,
463 rect_right + stride_from *
y * channels,
466 memcpy(to,
from[1],
sizeof(
float) * channels * stride_from);
468 to + channels * height * stride_from,
from[0],
sizeof(
float) * channels * stride_from);
476 for (
y = 0;
y < height;
y++) {
477 uchar *to = rect_to + stride_to *
y * channels;
479 rect_left + stride_from *
y * channels,
480 rect_right + stride_from *
y * channels,
483 memcpy(to,
from[1],
sizeof(
uchar) * channels * stride_from);
485 to + channels * height * stride_from,
from[0],
sizeof(
uchar) * channels * stride_from);
497 const bool is_squeezed,
505 *r_width = is_squeezed ? width : width * 2;
511 *r_height = is_squeezed ? height : height * 2;
525 const bool is_squeezed,
533 *r_width = is_squeezed ? width / 2 : width;
539 *r_height = is_squeezed ? height / 2 : height;
600 const size_t channels,
622 ImBuf *ibuf_stereo =
nullptr;
624 size_t width, height;
627 !(is_byte && im_format->
depth <= 8);
629 if (!(is_float || is_byte)) {
697 size_t width = s3d->
x;
698 size_t height = s3d->
y;
699 const size_t channels = s3d->
channels;
701 const int stride_from = width;
702 const int stride_to = width;
704 const int anaglyph_encoding[3][3] = {
712 r = anaglyph_encoding[mode][0];
713 g = anaglyph_encoding[mode][1];
714 b = anaglyph_encoding[mode][2];
722 for (
y = 0;
y < height;
y++) {
723 float *
from = rect_from + stride_from *
y * 3;
725 rect_left + stride_to *
y * 3,
726 rect_right + stride_to *
y * 3,
729 for (
x = 0;
x < width;
x++,
from += 3, to[0] += 3, to[1] += 3) {
736 else if (channels == 4) {
737 for (
y = 0;
y < height;
y++) {
738 float *
from = rect_from + stride_from *
y * 4;
740 rect_left + stride_to *
y * 4,
741 rect_right + stride_to *
y * 4,
744 for (
x = 0;
x < width;
x++,
from += 4, to[0] += 4, to[1] += 4) {
748 to[0][3] = to[1][3] =
from[3];
759 for (
y = 0;
y < height;
y++) {
760 uchar *
from = rect_from + stride_from *
y * 3;
762 rect_left + stride_to *
y * 3,
763 rect_right + stride_to *
y * 3,
766 for (
x = 0;
x < width;
x++,
from += 3, to[0] += 3, to[1] += 3) {
773 else if (channels == 4) {
774 for (
y = 0;
y < height;
y++) {
775 uchar *
from = rect_from + stride_from *
y * 4;
777 rect_left + stride_to *
y * 4,
778 rect_right + stride_to *
y * 4,
781 for (
x = 0;
x < width;
x++,
from += 4, to[0] += 4, to[1] += 4) {
785 to[0][3] = to[1][3] =
from[3];
797 size_t width = s3d->
x;
798 size_t height = s3d->
y;
799 const size_t channels = s3d->
channels;
801 const int stride_from = width;
802 const int stride_to = width;
812 for (
y = 0;
y < height;
y++) {
813 const float *
from = rect_from + stride_from *
y * channels;
815 rect_left + stride_to *
y * channels,
816 rect_right + stride_to *
y * channels,
818 memcpy(to[i],
from,
sizeof(
float) * channels * stride_to);
825 for (
y = 0;
y < height;
y++) {
826 const float *
from = rect_from + stride_from *
y;
828 rect_left + stride_to *
y,
829 rect_right + stride_to *
y,
833 for (
x = 0;
x < width;
x++,
from += 1, to[0] += 1, to[1] += 1) {
839 else if (channels == 3) {
840 for (
y = 0;
y < height;
y++) {
841 const float *
from = rect_from + stride_from *
y * 3;
843 rect_left + stride_to *
y * 3,
844 rect_right + stride_to *
y * 3,
848 for (
x = 0;
x < width;
x++,
from += 3, to[0] += 3, to[1] += 3) {
854 else if (channels == 4) {
855 for (
y = 0;
y < height;
y++) {
856 const float *
from = rect_from + stride_from *
y * channels;
858 rect_left + stride_to *
y * channels,
859 rect_right + stride_to *
y * channels,
863 for (
x = 0;
x < width;
x++,
from += 4, to[0] += 4, to[1] += 4) {
874 for (
y = 0;
y < height;
y++) {
875 const float *
from = rect_from + stride_from *
y;
877 rect_left + stride_to *
y,
878 rect_right + stride_to *
y,
881 for (
x = 0;
x < width;
x++,
from += 1, to[0] += 1, to[1] += 1) {
888 else if (channels == 3) {
890 for (
y = 0;
y < height;
y++) {
891 const float *
from = rect_from + stride_from *
y * 3;
893 rect_left + stride_to *
y * 3,
894 rect_right + stride_to *
y * 3,
897 for (
x = 0;
x < width;
x++,
from += 3, to[0] += 3, to[1] += 3) {
904 else if (channels == 4) {
906 for (
y = 0;
y < height;
y++) {
907 const float *
from = rect_from + stride_from *
y * 4;
909 rect_left + stride_to *
y * 4,
910 rect_right + stride_to *
y * 4,
913 for (
x = 0;
x < width;
x++,
from += 4, to[0] += 4, to[1] += 4) {
935 for (
y = 0;
y < height;
y++) {
936 const uchar *
from = rect_from + stride_from *
y * channels;
938 rect_left + stride_to *
y * channels,
939 rect_right + stride_to *
y * channels,
941 memcpy(to[i],
from,
sizeof(
uchar) * channels * stride_to);
948 for (
y = 0;
y < height;
y++) {
949 const uchar *
from = rect_from + stride_from *
y;
951 rect_left + stride_to *
y,
952 rect_right + stride_to *
y,
955 for (
x = 0;
x < width;
x++,
from += 1, to[0] += 1, to[1] += 1) {
961 else if (channels == 3) {
962 for (
y = 0;
y < height;
y++) {
963 const uchar *
from = rect_from + stride_from *
y * 3;
965 rect_left + stride_to *
y * 3,
966 rect_right + stride_to *
y * 3,
969 for (
x = 0;
x < width;
x++,
from += 3, to[0] += 3, to[1] += 3) {
975 else if (channels == 4) {
976 for (
y = 0;
y < height;
y++) {
977 const uchar *
from = rect_from + stride_from *
y * 4;
979 rect_left + stride_to *
y * 4,
980 rect_right + stride_to *
y * 4,
983 for (
x = 0;
x < width;
x++,
from += 4, to[0] += 4, to[1] += 4) {
994 for (
y = 0;
y < height;
y++) {
995 const uchar *
from = rect_from + stride_from *
y;
997 rect_left + stride_to *
y,
998 rect_right + stride_to *
y,
1001 for (
x = 0;
x < width;
x++,
from += 1, to[0] += 1, to[1] += 1) {
1008 else if (channels == 3) {
1009 char i = char(swap);
1010 for (
y = 0;
y < height;
y++) {
1011 const uchar *
from = rect_from + stride_from *
y * 3;
1013 rect_left + stride_to *
y * 3,
1014 rect_right + stride_to *
y * 3,
1017 for (
x = 0;
x < width;
x++,
from += 3, to[0] += 3, to[1] += 3) {
1024 else if (channels == 4) {
1025 char i = char(swap);
1026 for (
y = 0;
y < height;
y++) {
1027 const uchar *
from = rect_from + stride_from *
y * 4;
1029 rect_left + stride_to *
y * 4,
1030 rect_right + stride_to *
y * 4,
1033 for (
x = 0;
x < width;
x++,
from += 4, to[0] += 4, to[1] += 4) {
1053 size_t width = s3d->
x;
1054 size_t height = s3d->
y;
1055 const size_t channels = s3d->
channels;
1057 const int stride_from = width * 2;
1058 const int stride_to = width;
1060 const int l = int(crosseyed);
1068 for (
y = 0;
y < height;
y++) {
1069 const float *
from = rect_from + stride_from *
y * channels;
1071 rect_left + stride_to *
y * channels,
1072 rect_right + stride_to *
y * channels,
1075 memcpy(to[
l],
from,
sizeof(
float) * channels * stride_to);
1076 memcpy(to[r],
from + channels * stride_to,
sizeof(
float) * channels * stride_to);
1085 for (
y = 0;
y < height;
y++) {
1086 const uchar *
from = rect_from + stride_from *
y * channels;
1088 rect_left + stride_to *
y * channels,
1089 rect_right + stride_to *
y * channels,
1092 memcpy(to[
l],
from,
sizeof(
uchar) * channels * stride_to);
1093 memcpy(to[r],
from + channels * stride_to,
sizeof(
uchar) * channels * stride_to);
1102 size_t width = s3d->
x;
1103 size_t height = s3d->
y;
1104 const size_t channels = s3d->
channels;
1106 const int stride_from = width;
1107 const int stride_to = width;
1114 for (
y = 0;
y < height;
y++) {
1115 const float *
from = rect_from + stride_from *
y * channels;
1117 rect_left + stride_to *
y * channels,
1118 rect_right + stride_to *
y * channels,
1121 memcpy(to[1],
from,
sizeof(
float) * channels * stride_to);
1122 memcpy(to[0],
from + channels * height * stride_to,
sizeof(
float) * channels * stride_to);
1130 for (
y = 0;
y < height;
y++) {
1131 const uchar *
from = rect_from + stride_from *
y * channels;
1133 rect_left + stride_to *
y * channels,
1134 rect_right + stride_to *
y * channels,
1137 memcpy(to[1],
from,
sizeof(
uchar) * channels * stride_to);
1138 memcpy(to[0],
from + channels * height * stride_to,
sizeof(
uchar) * channels * stride_to);
1150 ImBuf *ibuf_stereo3d,
1151 ImBuf **r_ibuf_left,
1152 ImBuf **r_ibuf_right)
1155 ImBuf *ibuf_left, *ibuf_right;
1156 size_t width, height;
1206 *r_ibuf_left = ibuf_left;
1207 *r_ibuf_right = ibuf_right;
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v4_v4_uchar(unsigned char r[4], const unsigned char a[4])
MINLINE void copy_v3_v3_uchar(unsigned char r[3], const unsigned char a[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
@ S3D_SIDEBYSIDE_CROSSEYED
@ S3D_INTERLACE_CHECKERBOARD
bool IMB_alloc_byte_pixels(ImBuf *ibuf, bool initialize_pixels=true)
void IMB_freeImBuf(ImBuf *ibuf)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
bool IMB_alloc_float_pixels(ImBuf *ibuf, const unsigned int channels, bool initialize_pixels=true)
bool IMB_scale(ImBuf *ibuf, unsigned int newx, unsigned int newy, IMBScaleFilter filter, bool threaded=true)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static void imb_stereo3d_squeeze_ImBuf(ImBuf *ibuf, const Stereo3dFormat *s3d, const size_t x, const size_t y)
static void imb_stereo3d_read_interlace(const Stereo3DData *s3d, enum eStereo3dInterlaceType mode, const bool swap)
static void imb_stereo3d_write_interlace(const Stereo3DData *s3d, enum eStereo3dInterlaceType mode, const bool swap)
static void imb_stereo3d_write_doit(Stereo3DData *s3d_data, const Stereo3dFormat *s3d)
void IMB_ImBufFromStereo3d(const Stereo3dFormat *s3d, ImBuf *ibuf_stereo3d, ImBuf **r_ibuf_left, ImBuf **r_ibuf_right)
static void imb_stereo3d_write_anaglyph(const Stereo3DData *s3d, enum eStereo3dAnaglyphType mode)
static void imb_stereo3d_write_sidebyside(const Stereo3DData *s3d, const bool crosseyed)
void IMB_stereo3d_write_dimensions(const char mode, const bool is_squeezed, const size_t width, const size_t height, size_t *r_width, size_t *r_height)
static void imb_stereo3d_read_anaglyph(const Stereo3DData *s3d, enum eStereo3dAnaglyphType mode)
static void imb_stereo3d_read_sidebyside(const Stereo3DData *s3d, const bool crosseyed)
ImBuf * IMB_stereo3d_ImBuf(const ImageFormatData *im_format, ImBuf *ibuf_left, ImBuf *ibuf_right)
static void imb_stereo3d_data_init(Stereo3DData *s3d_data, const bool is_float, const size_t x, const size_t y, const size_t channels, int *rect_left, int *rect_right, int *rect_stereo, float *rectf_left, float *rectf_right, float *rectf_stereo)
static void imb_stereo3d_unsqueeze_ImBuf(ImBuf *ibuf, const Stereo3dFormat *s3d, const size_t x, const size_t y)
static void imb_stereo3d_read_doit(Stereo3DData *s3d_data, const Stereo3dFormat *s3d)
void IMB_stereo3d_read_dimensions(const char mode, const bool is_squeezed, const size_t width, const size_t height, size_t *r_width, size_t *r_height)
static void imb_stereo3d_write_topbottom(const Stereo3DData *s3d)
static void imb_stereo3d_read_topbottom(const Stereo3DData *s3d)
const ColorSpace * colorspace
const ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
struct Stereo3DData::@638 rect
struct Stereo3DData::@637 rectf