Blender  V2.93
stereoimbuf.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2015 by Blender Foundation
17  * All rights reserved.
18  */
19 
24 #include <stddef.h>
25 
26 #include "IMB_imbuf.h"
27 #include "IMB_imbuf_types.h"
28 
29 #include "IMB_allocimbuf.h"
31 #include "IMB_filetype.h"
32 #include "IMB_metadata.h"
33 
34 #include "imbuf.h"
35 
36 #include "MEM_guardedalloc.h"
37 
38 #include "BLI_utildefines.h"
39 
40 #include "BLI_math.h"
41 
42 #include "DNA_scene_types.h"
43 #include "DNA_userdef_types.h"
44 
45 /* prototypes */
46 struct Stereo3DData;
47 static void imb_stereo3d_write_doit(struct Stereo3DData *s3d_data, struct Stereo3dFormat *s3d);
48 static void imb_stereo3d_read_doit(struct Stereo3DData *s3d_data, struct Stereo3dFormat *s3d);
49 
50 typedef struct Stereo3DData {
51  struct {
52  float *left, *right, *stereo;
53  } rectf;
54  struct {
56  } rect;
57  size_t x, y, channels;
58  bool is_float;
60 
61 /* -------------------------------------------------------------------- */
66 {
67  int x, y;
68  size_t width = s3d->x;
69  size_t height = s3d->y;
70  const size_t channels = s3d->channels;
71 
72  const int stride_from = width;
73  const int stride_to = width;
74 
75  const int anaglyph_encoding[3][3] = {
76  {0, 1, 1},
77  {1, 0, 1},
78  {0, 0, 1},
79  };
80 
81  int r, g, b;
82 
83  r = anaglyph_encoding[mode][0];
84  g = anaglyph_encoding[mode][1];
85  b = anaglyph_encoding[mode][2];
86 
87  if (s3d->is_float) {
88  float *rect_left = s3d->rectf.left;
89  float *rect_right = s3d->rectf.right;
90  float *rect_to = s3d->rectf.stereo;
91 
92  if (channels == 3) {
93  for (y = 0; y < height; y++) {
94  float *to = rect_to + stride_to * y * 3;
95  float *from[2] = {
96  rect_left + stride_from * y * 3,
97  rect_right + stride_from * y * 3,
98  };
99 
100  for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
101  to[0] = from[r][0];
102  to[1] = from[g][1];
103  to[2] = from[b][2];
104  }
105  }
106  }
107  else if (channels == 4) {
108  for (y = 0; y < height; y++) {
109  float *to = rect_to + stride_to * y * 4;
110  float *from[2] = {
111  rect_left + stride_from * y * 4,
112  rect_right + stride_from * y * 4,
113  };
114 
115  for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
116  to[0] = from[r][0];
117  to[1] = from[g][1];
118  to[2] = from[b][2];
119  to[3] = MAX2(from[0][3], from[1][3]);
120  }
121  }
122  }
123  }
124  else {
125  uchar *rect_left = s3d->rect.left;
126  uchar *rect_right = s3d->rect.right;
127  uchar *rect_to = s3d->rect.stereo;
128 
129  if (channels == 3) {
130  for (y = 0; y < height; y++) {
131  uchar *to = rect_to + stride_to * y * 3;
132  uchar *from[2] = {
133  rect_left + stride_from * y * 3,
134  rect_right + stride_from * y * 3,
135  };
136 
137  for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
138  to[0] = from[r][0];
139  to[1] = from[g][1];
140  to[2] = from[b][2];
141  }
142  }
143  }
144  else if (channels == 4) {
145  for (y = 0; y < height; y++) {
146  uchar *to = rect_to + stride_to * y * 4;
147  uchar *from[2] = {
148  rect_left + stride_from * y * 4,
149  rect_right + stride_from * y * 4,
150  };
151 
152  for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
153  to[0] = from[r][0];
154  to[1] = from[g][1];
155  to[2] = from[b][2];
156  to[3] = MAX2(from[0][3], from[1][3]);
157  }
158  }
159  }
160  }
161 }
162 
164  enum eStereo3dInterlaceType mode,
165  const bool swap)
166 {
167  int x, y;
168  size_t width = s3d->x;
169  size_t height = s3d->y;
170  const size_t channels = s3d->channels;
171 
172  const int stride_from = width;
173  const int stride_to = width;
174 
175  if (s3d->is_float) {
176  const float *rect_left = s3d->rectf.left;
177  const float *rect_right = s3d->rectf.right;
178  float *rect_to = s3d->rectf.stereo;
179 
180  switch (mode) {
181  case S3D_INTERLACE_ROW: {
182  char i = (char)swap;
183  for (y = 0; y < height; y++) {
184  float *to = rect_to + stride_to * y * channels;
185  const float *from[2] = {
186  rect_left + stride_from * y * channels,
187  rect_right + stride_from * y * channels,
188  };
189  memcpy(to, from[i], sizeof(float) * channels * stride_from);
190  i = !i;
191  }
192  break;
193  }
194  case S3D_INTERLACE_COLUMN: {
195  if (channels == 1) {
196  for (y = 0; y < height; y++) {
197  float *to = rect_to + stride_to * y;
198  const float *from[2] = {
199  rect_left + stride_from * y,
200  rect_right + stride_from * y,
201  };
202 
203  char i = (char)swap;
204  for (x = 0; x < width; x++, from[0] += 1, from[1] += 1, to += 1) {
205  to[0] = from[i][0];
206  i = !i;
207  }
208  }
209  }
210  else if (channels == 3) {
211  for (y = 0; y < height; y++) {
212  float *to = rect_to + stride_to * y * 3;
213  const float *from[2] = {
214  rect_left + stride_from * y * 3,
215  rect_right + stride_from * y * 3,
216  };
217 
218  char i = (char)swap;
219  for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
220  copy_v3_v3(to, from[i]);
221  i = !i;
222  }
223  }
224  }
225  else if (channels == 4) {
226  for (y = 0; y < height; y++) {
227  float *to = rect_to + stride_to * y * channels;
228  const float *from[2] = {
229  rect_left + stride_from * y * channels,
230  rect_right + stride_from * y * channels,
231  };
232 
233  char i = (char)swap;
234  for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
235  copy_v4_v4(to, from[i]);
236  i = !i;
237  }
238  }
239  }
240  break;
241  }
243  if (channels == 1) {
244  char i = (char)swap;
245  for (y = 0; y < height; y++) {
246  float *to = rect_to + stride_to * y;
247  const float *from[2] = {
248  rect_left + stride_from * y,
249  rect_right + stride_from * y,
250  };
251  char j = i;
252  for (x = 0; x < width; x++, from[0] += 1, from[1] += 1, to += 1) {
253  to[0] = from[j][0];
254  j = !j;
255  }
256  i = !i;
257  }
258  }
259  else if (channels == 3) {
260  char i = (char)swap;
261  for (y = 0; y < height; y++) {
262  float *to = rect_to + stride_to * y * 3;
263  const float *from[2] = {
264  rect_left + stride_from * y * 3,
265  rect_right + stride_from * y * 3,
266  };
267  char j = i;
268  for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
269  copy_v3_v3(to, from[j]);
270  j = !j;
271  }
272  i = !i;
273  }
274  }
275  else if (channels == 4) {
276  char i = (char)swap;
277  for (y = 0; y < height; y++) {
278  float *to = rect_to + stride_to * y * 4;
279  const float *from[2] = {
280  rect_left + stride_from * y * 4,
281  rect_right + stride_from * y * 4,
282  };
283  char j = i;
284  for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
285  copy_v4_v4(to, from[j]);
286  j = !j;
287  }
288  i = !i;
289  }
290  }
291  break;
292  }
293  default: {
294  break;
295  }
296  }
297  }
298  else {
299  const uchar *rect_left = s3d->rect.left;
300  const uchar *rect_right = s3d->rect.right;
301  uchar *rect_to = s3d->rect.stereo;
302 
303  switch (mode) {
304  case S3D_INTERLACE_ROW: {
305  char i = (char)swap;
306  for (y = 0; y < height; y++) {
307  uchar *to = rect_to + stride_to * y * channels;
308  const uchar *from[2] = {
309  rect_left + stride_from * y * channels,
310  rect_right + stride_from * y * channels,
311  };
312  memcpy(to, from[i], sizeof(uchar) * channels * stride_from);
313  i = !i;
314  }
315  break;
316  }
317  case S3D_INTERLACE_COLUMN: {
318  if (channels == 1) {
319  for (y = 0; y < height; y++) {
320  uchar *to = rect_to + stride_to * y;
321  const uchar *from[2] = {
322  rect_left + stride_from * y,
323  rect_right + stride_from * y,
324  };
325  char i = (char)swap;
326  for (x = 0; x < width; x++, from[0] += 1, from[1] += 1, to += 1) {
327  to[0] = from[i][0];
328  i = !i;
329  }
330  }
331  }
332  else if (channels == 3) {
333  for (y = 0; y < height; y++) {
334  uchar *to = rect_to + stride_to * y * 3;
335  const uchar *from[2] = {
336  rect_left + stride_from * y * 3,
337  rect_right + stride_from * y * 3,
338  };
339  char i = (char)swap;
340  for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
341  copy_v3_v3_uchar(to, from[i]);
342  i = !i;
343  }
344  }
345  }
346  else if (channels == 4) {
347  for (y = 0; y < height; y++) {
348  uchar *to = rect_to + stride_to * y * 4;
349  const uchar *from[2] = {
350  rect_left + stride_from * y * 4,
351  rect_right + stride_from * y * 4,
352  };
353  char i = (char)swap;
354  for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
355  copy_v4_v4_uchar(to, from[i]);
356  i = !i;
357  }
358  }
359  }
360  break;
361  }
363  if (channels == 1) {
364  char i = (char)swap;
365  for (y = 0; y < height; y++) {
366  uchar *to = rect_to + stride_to * y;
367  const uchar *from[2] = {
368  rect_left + stride_from * y,
369  rect_right + stride_from * y,
370  };
371  char j = i;
372  for (x = 0; x < width; x++, from[0] += 1, from[1] += 1, to += 1) {
373  to[0] = from[j][0];
374  j = !j;
375  }
376  i = !i;
377  }
378  }
379  else if (channels == 3) {
380  char i = (char)swap;
381  for (y = 0; y < height; y++) {
382  uchar *to = rect_to + stride_to * y * 3;
383  const uchar *from[2] = {
384  rect_left + stride_from * y * 3,
385  rect_right + stride_from * y * 3,
386  };
387  char j = i;
388  for (x = 0; x < width; x++, from[0] += 3, from[1] += 3, to += 3) {
389  copy_v3_v3_uchar(to, from[j]);
390  j = !j;
391  }
392  i = !i;
393  }
394  }
395  else if (channels == 4) {
396  char i = (char)swap;
397  for (y = 0; y < height; y++) {
398  uchar *to = rect_to + stride_to * y * 4;
399  const uchar *from[2] = {
400  rect_left + stride_from * y * 4,
401  rect_right + stride_from * y * 4,
402  };
403  char j = i;
404  for (x = 0; x < width; x++, from[0] += 4, from[1] += 4, to += 4) {
405  copy_v4_v4_uchar(to, from[j]);
406  j = !j;
407  }
408  i = !i;
409  }
410  }
411  break;
412  }
413  default: {
414  break;
415  }
416  }
417  }
418 }
419 
420 /* stereo3d output (s3d->rectf.stereo) is always unsqueezed */
421 static void imb_stereo3d_write_sidebyside(Stereo3DData *s3d, const bool crosseyed)
422 {
423  int y;
424  size_t width = s3d->x;
425  size_t height = s3d->y;
426  const size_t channels = s3d->channels;
427 
428  const int stride_from = width;
429  const int stride_to = width * 2;
430 
431  const int l = (int)crosseyed;
432  const int r = !l;
433 
434  if (s3d->is_float) {
435  const float *rect_left = s3d->rectf.left;
436  const float *rect_right = s3d->rectf.right;
437  float *rect_to = s3d->rectf.stereo;
438 
439  for (y = 0; y < height; y++) {
440  float *to = rect_to + stride_to * y * channels;
441  const float *from[2] = {
442  rect_left + stride_from * y * channels,
443  rect_right + stride_from * y * channels,
444  };
445 
446  memcpy(to, from[l], sizeof(float) * channels * stride_from);
447  memcpy(to + channels * stride_from, from[r], sizeof(float) * channels * stride_from);
448  }
449  }
450  else {
451  const uchar *rect_left = s3d->rect.left;
452  const uchar *rect_right = s3d->rect.right;
453  uchar *rect_to = s3d->rect.stereo;
454 
455  for (y = 0; y < height; y++) {
456  uchar *to = rect_to + stride_to * y * channels;
457  const uchar *from[2] = {
458  rect_left + stride_from * y * channels,
459  rect_right + stride_from * y * channels,
460  };
461 
462  memcpy(to, from[l], sizeof(uchar) * channels * stride_from);
463  memcpy(to + channels * stride_from, from[r], sizeof(uchar) * channels * stride_from);
464  }
465  }
466 }
467 
468 /* stereo3d output (s3d->rectf.stereo) is always unsqueezed */
470 {
471  int y;
472  size_t width = s3d->x;
473  size_t height = s3d->y;
474  const size_t channels = s3d->channels;
475 
476  const int stride_from = width;
477  const int stride_to = width;
478 
479  if (s3d->is_float) {
480  const float *rect_left = s3d->rectf.left;
481  const float *rect_right = s3d->rectf.right;
482  float *rect_to = s3d->rectf.stereo;
483 
484  for (y = 0; y < height; y++) {
485  float *to = rect_to + stride_to * y * channels;
486  const float *from[2] = {
487  rect_left + stride_from * y * channels,
488  rect_right + stride_from * y * channels,
489  };
490 
491  memcpy(to, from[1], sizeof(float) * channels * stride_from);
492  memcpy(
493  to + channels * height * stride_from, from[0], sizeof(float) * channels * stride_from);
494  }
495  }
496  else {
497  const uchar *rect_left = s3d->rect.left;
498  const uchar *rect_right = s3d->rect.right;
499  uchar *rect_to = s3d->rect.stereo;
500 
501  for (y = 0; y < height; y++) {
502  uchar *to = rect_to + stride_to * y * channels;
503  const uchar *from[2] = {
504  rect_left + stride_from * y * channels,
505  rect_right + stride_from * y * channels,
506  };
507 
508  memcpy(to, from[1], sizeof(uchar) * channels * stride_from);
509  memcpy(
510  to + channels * height * stride_from, from[0], sizeof(uchar) * channels * stride_from);
511  }
512  }
513 }
514 
517 /* -------------------------------------------------------------------- */
521 void IMB_stereo3d_write_dimensions(const char mode,
522  const bool is_squeezed,
523  const size_t width,
524  const size_t height,
525  size_t *r_width,
526  size_t *r_height)
527 {
528  switch (mode) {
529  case S3D_DISPLAY_SIDEBYSIDE: {
530  *r_width = is_squeezed ? width : width * 2;
531  *r_height = height;
532  break;
533  }
534  case S3D_DISPLAY_TOPBOTTOM: {
535  *r_width = width;
536  *r_height = is_squeezed ? height : height * 2;
537  break;
538  }
541  default: {
542  *r_width = width;
543  *r_height = height;
544  break;
545  }
546  }
547 }
548 
549 void IMB_stereo3d_read_dimensions(const char mode,
550  const bool is_squeezed,
551  const size_t width,
552  const size_t height,
553  size_t *r_width,
554  size_t *r_height)
555 {
556  switch (mode) {
557  case S3D_DISPLAY_SIDEBYSIDE: {
558  *r_width = is_squeezed ? width / 2 : width;
559  *r_height = height;
560  break;
561  }
562  case S3D_DISPLAY_TOPBOTTOM: {
563  *r_width = width;
564  *r_height = is_squeezed ? height / 2 : height;
565  break;
566  }
569  default: {
570  *r_width = width;
571  *r_height = height;
572  break;
573  }
574  }
575 }
576 
579 /* -------------------------------------------------------------------- */
584  Stereo3dFormat *s3d,
585  const size_t x,
586  const size_t y)
587 {
589  return;
590  }
591 
592  if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0) {
593  return;
594  }
595 
596  IMB_scaleImBuf_threaded(ibuf, x, y);
597 }
598 
600  Stereo3dFormat *s3d,
601  const size_t x,
602  const size_t y)
603 {
605  return;
606  }
607 
608  if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0) {
609  return;
610  }
611 
612  IMB_scaleImBuf_threaded(ibuf, x, y);
613 }
614 
616  float *rectf, Stereo3dFormat *s3d, const size_t x, const size_t y, const size_t channels)
617 {
618  ImBuf *ibuf;
619  size_t width, height;
620 
622  return;
623  }
624 
625  if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0) {
626  return;
627  }
628 
629  /* creates temporary imbuf to store the rectf */
631  ibuf = IMB_allocImBuf(width, height, channels, IB_rectfloat);
632 
634  rectf,
635  channels,
638  false,
639  width,
640  height,
641  width,
642  width);
643 
644  IMB_scaleImBuf_threaded(ibuf, x, y);
645  memcpy(rectf, ibuf->rect_float, x * y * sizeof(float[4]));
646  IMB_freeImBuf(ibuf);
647 }
648 
650  int *rect, Stereo3dFormat *s3d, const size_t x, const size_t y, const size_t channels)
651 {
652  ImBuf *ibuf;
653  size_t width, height;
654 
656  return;
657  }
658 
659  if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0) {
660  return;
661  }
662 
663  /* creates temporary imbuf to store the rectf */
665  ibuf = IMB_allocImBuf(width, height, channels, IB_rect);
666 
667  IMB_buffer_byte_from_byte((unsigned char *)ibuf->rect,
668  (unsigned char *)rect,
671  false,
672  width,
673  height,
674  width,
675  width);
676 
677  IMB_scaleImBuf_threaded(ibuf, x, y);
678  memcpy(rect, ibuf->rect, x * y * sizeof(unsigned int));
679  IMB_freeImBuf(ibuf);
680 }
681 
684 /* -------------------------------------------------------------------- */
688 static void imb_stereo3d_data_init(Stereo3DData *s3d_data,
689  const bool is_float,
690  const size_t x,
691  const size_t y,
692  const size_t channels,
693  int *rect_left,
694  int *rect_right,
695  int *rect_stereo,
696  float *rectf_left,
697  float *rectf_right,
698  float *rectf_stereo)
699 {
700  s3d_data->is_float = is_float;
701  s3d_data->x = x;
702  s3d_data->y = y;
703  s3d_data->channels = channels;
704  s3d_data->rect.left = (uchar *)rect_left;
705  s3d_data->rect.right = (uchar *)rect_right;
706  s3d_data->rect.stereo = (uchar *)rect_stereo;
707  s3d_data->rectf.left = rectf_left;
708  s3d_data->rectf.right = rectf_right;
709  s3d_data->rectf.stereo = rectf_stereo;
710 }
711 
713  const size_t x,
714  const size_t y,
715  const size_t channels,
716  int *rect_left,
717  int *rect_right)
718 {
719  int *r_rect;
720  Stereo3DData s3d_data = {{NULL}};
721  size_t width, height;
722  const bool is_float = im_format->depth > 8;
723 
725  im_format->stereo3d_format.display_mode, false, x, y, &width, &height);
726  r_rect = MEM_mallocN(channels * sizeof(int) * width * height, __func__);
727 
729  &s3d_data, is_float, x, y, channels, rect_left, rect_right, r_rect, NULL, NULL, NULL);
730  imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format);
731  imb_stereo3d_squeeze_rect(r_rect, &im_format->stereo3d_format, x, y, channels);
732 
733  return r_rect;
734 }
735 
737  const size_t x,
738  const size_t y,
739  const size_t channels,
740  float *rectf_left,
741  float *rectf_right)
742 {
743  float *r_rectf;
744  Stereo3DData s3d_data = {{NULL}};
745  size_t width, height;
746  const bool is_float = im_format->depth > 8;
747 
749  im_format->stereo3d_format.display_mode, false, x, y, &width, &height);
750  r_rectf = MEM_mallocN(channels * sizeof(float) * width * height, __func__);
751 
753  &s3d_data, is_float, x, y, channels, NULL, NULL, NULL, rectf_left, rectf_right, r_rectf);
754  imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format);
755  imb_stereo3d_squeeze_rectf(r_rectf, &im_format->stereo3d_format, x, y, channels);
756 
757  return r_rectf;
758 }
759 
760 /* left/right are always float */
761 ImBuf *IMB_stereo3d_ImBuf(ImageFormatData *im_format, ImBuf *ibuf_left, ImBuf *ibuf_right)
762 {
763  ImBuf *ibuf_stereo = NULL;
764  Stereo3DData s3d_data = {{NULL}};
765  size_t width, height;
766  const bool is_float = im_format->depth > 8;
767 
769  im_format->stereo3d_format.display_mode, false, ibuf_left->x, ibuf_left->y, &width, &height);
770  ibuf_stereo = IMB_allocImBuf(
771  width, height, ibuf_left->planes, (is_float ? IB_rectfloat : IB_rect));
772 
773  ibuf_stereo->rect_colorspace = ibuf_left->rect_colorspace;
774  ibuf_stereo->float_colorspace = ibuf_left->float_colorspace;
775 
776  ibuf_stereo->flags = ibuf_left->flags;
777 
778  imb_stereo3d_data_init(&s3d_data,
779  is_float,
780  ibuf_left->x,
781  ibuf_left->y,
782  4,
783  (int *)ibuf_left->rect,
784  (int *)ibuf_right->rect,
785  (int *)ibuf_stereo->rect,
786  ibuf_left->rect_float,
787  ibuf_right->rect_float,
788  ibuf_stereo->rect_float);
789 
790  imb_stereo3d_write_doit(&s3d_data, &im_format->stereo3d_format);
791  imb_stereo3d_squeeze_ImBuf(ibuf_stereo, &im_format->stereo3d_format, ibuf_left->x, ibuf_left->y);
792 
793  return ibuf_stereo;
794 }
795 
797 {
798  switch (s3d->display_mode) {
801  break;
804  s3d_data, s3d->interlace_type, (s3d->flag & S3D_INTERLACE_SWAP) != 0);
805  break;
808  break;
811  break;
812  default:
813  break;
814  }
815 }
816 
819 /* -------------------------------------------------------------------- */
824 {
825  int x, y;
826  size_t width = s3d->x;
827  size_t height = s3d->y;
828  const size_t channels = s3d->channels;
829 
830  const int stride_from = width;
831  const int stride_to = width;
832 
833  const int anaglyph_encoding[3][3] = {
834  {0, 1, 1},
835  {1, 0, 1},
836  {0, 0, 1},
837  };
838 
839  int r, g, b;
840 
841  r = anaglyph_encoding[mode][0];
842  g = anaglyph_encoding[mode][1];
843  b = anaglyph_encoding[mode][2];
844 
845  if (s3d->is_float) {
846  float *rect_left = s3d->rectf.left;
847  float *rect_right = s3d->rectf.right;
848  float *rect_from = s3d->rectf.stereo;
849 
850  if (channels == 3) {
851  for (y = 0; y < height; y++) {
852  float *from = rect_from + stride_from * y * 3;
853  float *to[2] = {
854  rect_left + stride_to * y * 3,
855  rect_right + stride_to * y * 3,
856  };
857 
858  for (x = 0; x < width; x++, from += 3, to[0] += 3, to[1] += 3) {
859  to[r][0] = from[0];
860  to[g][1] = from[1];
861  to[b][2] = from[2];
862  }
863  }
864  }
865  else if (channels == 4) {
866  for (y = 0; y < height; y++) {
867  float *from = rect_from + stride_from * y * 4;
868  float *to[2] = {
869  rect_left + stride_to * y * 4,
870  rect_right + stride_to * y * 4,
871  };
872 
873  for (x = 0; x < width; x++, from += 4, to[0] += 4, to[1] += 4) {
874  to[r][0] = from[0];
875  to[g][1] = from[1];
876  to[b][2] = from[2];
877  to[0][3] = to[1][3] = from[3];
878  }
879  }
880  }
881  }
882  else {
883  uchar *rect_left = s3d->rect.left;
884  uchar *rect_right = s3d->rect.right;
885  uchar *rect_from = s3d->rect.stereo;
886 
887  if (channels == 3) {
888  for (y = 0; y < height; y++) {
889  uchar *from = rect_from + stride_from * y * 3;
890  uchar *to[2] = {
891  rect_left + stride_to * y * 3,
892  rect_right + stride_to * y * 3,
893  };
894 
895  for (x = 0; x < width; x++, from += 3, to[0] += 3, to[1] += 3) {
896  to[r][0] = from[0];
897  to[g][1] = from[1];
898  to[b][2] = from[2];
899  }
900  }
901  }
902  else if (channels == 4) {
903  for (y = 0; y < height; y++) {
904  uchar *from = rect_from + stride_from * y * 4;
905  uchar *to[2] = {
906  rect_left + stride_to * y * 4,
907  rect_right + stride_to * y * 4,
908  };
909 
910  for (x = 0; x < width; x++, from += 4, to[0] += 4, to[1] += 4) {
911  to[r][0] = from[0];
912  to[g][1] = from[1];
913  to[b][2] = from[2];
914  to[0][3] = to[1][3] = from[3];
915  }
916  }
917  }
918  }
919 }
920 
922  enum eStereo3dInterlaceType mode,
923  const bool swap)
924 {
925  int x, y;
926  size_t width = s3d->x;
927  size_t height = s3d->y;
928  const size_t channels = s3d->channels;
929 
930  const int stride_from = width;
931  const int stride_to = width;
932 
933  if (s3d->is_float) {
934  float *rect_left = s3d->rectf.left;
935  float *rect_right = s3d->rectf.right;
936  const float *rect_from = s3d->rectf.stereo;
937 
938  switch (mode) {
939  case S3D_INTERLACE_ROW: {
940  char i = (char)swap;
941  for (y = 0; y < height; y++) {
942  const float *from = rect_from + stride_from * y * channels;
943  float *to[2] = {
944  rect_left + stride_to * y * channels,
945  rect_right + stride_to * y * channels,
946  };
947  memcpy(to[i], from, sizeof(float) * channels * stride_to);
948  i = !i;
949  }
950  break;
951  }
952  case S3D_INTERLACE_COLUMN: {
953  if (channels == 1) {
954  for (y = 0; y < height; y++) {
955  const float *from = rect_from + stride_from * y;
956  float *to[2] = {
957  rect_left + stride_to * y,
958  rect_right + stride_to * y,
959  };
960 
961  char i = (char)swap;
962  for (x = 0; x < width; x++, from += 1, to[0] += 1, to[1] += 1) {
963  to[i][0] = from[0];
964  i = !i;
965  }
966  }
967  }
968  else if (channels == 3) {
969  for (y = 0; y < height; y++) {
970  const float *from = rect_from + stride_from * y * 3;
971  float *to[2] = {
972  rect_left + stride_to * y * 3,
973  rect_right + stride_to * y * 3,
974  };
975 
976  char i = (char)swap;
977  for (x = 0; x < width; x++, from += 3, to[0] += 3, to[1] += 3) {
978  copy_v3_v3(to[i], from);
979  i = !i;
980  }
981  }
982  }
983  else if (channels == 4) {
984  for (y = 0; y < height; y++) {
985  const float *from = rect_from + stride_from * y * channels;
986  float *to[2] = {
987  rect_left + stride_to * y * channels,
988  rect_right + stride_to * y * channels,
989  };
990 
991  char i = (char)swap;
992  for (x = 0; x < width; x++, from += 4, to[0] += 4, to[1] += 4) {
993  copy_v4_v4(to[i], from);
994  i = !i;
995  }
996  }
997  }
998  break;
999  }
1001  if (channels == 1) {
1002  char i = (char)swap;
1003  for (y = 0; y < height; y++) {
1004  const float *from = rect_from + stride_from * y;
1005  float *to[2] = {
1006  rect_left + stride_to * y,
1007  rect_right + stride_to * y,
1008  };
1009  char j = i;
1010  for (x = 0; x < width; x++, from += 1, to[0] += 1, to[1] += 1) {
1011  to[j][0] = from[0];
1012  j = !j;
1013  }
1014  i = !i;
1015  }
1016  }
1017  else if (channels == 3) {
1018  char i = (char)swap;
1019  for (y = 0; y < height; y++) {
1020  const float *from = rect_from + stride_from * y * 3;
1021  float *to[2] = {
1022  rect_left + stride_to * y * 3,
1023  rect_right + stride_to * y * 3,
1024  };
1025  char j = i;
1026  for (x = 0; x < width; x++, from += 3, to[0] += 3, to[1] += 3) {
1027  copy_v3_v3(to[j], from);
1028  j = !j;
1029  }
1030  i = !i;
1031  }
1032  }
1033  else if (channels == 4) {
1034  char i = (char)swap;
1035  for (y = 0; y < height; y++) {
1036  const float *from = rect_from + stride_from * y * 4;
1037  float *to[2] = {
1038  rect_left + stride_to * y * 4,
1039  rect_right + stride_to * y * 4,
1040  };
1041  char j = i;
1042  for (x = 0; x < width; x++, from += 4, to[0] += 4, to[1] += 4) {
1043  copy_v4_v4(to[j], from);
1044  j = !j;
1045  }
1046  i = !i;
1047  }
1048  }
1049  break;
1050  }
1051  default: {
1052  break;
1053  }
1054  }
1055  }
1056  else {
1057  uchar *rect_left = s3d->rect.right;
1058  uchar *rect_right = s3d->rect.left;
1059  const uchar *rect_from = s3d->rect.stereo;
1060 
1061  switch (mode) {
1062  case S3D_INTERLACE_ROW: {
1063  char i = (char)swap;
1064  for (y = 0; y < height; y++) {
1065  const uchar *from = rect_from + stride_from * y * channels;
1066  uchar *to[2] = {
1067  rect_left + stride_to * y * channels,
1068  rect_right + stride_to * y * channels,
1069  };
1070  memcpy(to[i], from, sizeof(uchar) * channels * stride_to);
1071  i = !i;
1072  }
1073  break;
1074  }
1075  case S3D_INTERLACE_COLUMN: {
1076  if (channels == 1) {
1077  for (y = 0; y < height; y++) {
1078  const uchar *from = rect_from + stride_from * y;
1079  uchar *to[2] = {
1080  rect_left + stride_to * y,
1081  rect_right + stride_to * y,
1082  };
1083  char i = (char)swap;
1084  for (x = 0; x < width; x++, from += 1, to[0] += 1, to[1] += 1) {
1085  to[i][0] = from[0];
1086  i = !i;
1087  }
1088  }
1089  }
1090  else if (channels == 3) {
1091  for (y = 0; y < height; y++) {
1092  const uchar *from = rect_from + stride_from * y * 3;
1093  uchar *to[2] = {
1094  rect_left + stride_to * y * 3,
1095  rect_right + stride_to * y * 3,
1096  };
1097  char i = (char)swap;
1098  for (x = 0; x < width; x++, from += 3, to[0] += 3, to[1] += 3) {
1099  copy_v3_v3_uchar(to[i], from);
1100  i = !i;
1101  }
1102  }
1103  }
1104  else if (channels == 4) {
1105  for (y = 0; y < height; y++) {
1106  const uchar *from = rect_from + stride_from * y * 4;
1107  uchar *to[2] = {
1108  rect_left + stride_to * y * 4,
1109  rect_right + stride_to * y * 4,
1110  };
1111  char i = (char)swap;
1112  for (x = 0; x < width; x++, from += 4, to[0] += 4, to[1] += 4) {
1113  copy_v4_v4_uchar(to[i], from);
1114  i = !i;
1115  }
1116  }
1117  }
1118  break;
1119  }
1121  if (channels == 1) {
1122  char i = (char)swap;
1123  for (y = 0; y < height; y++) {
1124  const uchar *from = rect_from + stride_from * y;
1125  uchar *to[2] = {
1126  rect_left + stride_to * y,
1127  rect_right + stride_to * y,
1128  };
1129  char j = i;
1130  for (x = 0; x < width; x++, from += 1, to[0] += 1, to[1] += 1) {
1131  to[j][0] = from[0];
1132  j = !j;
1133  }
1134  i = !i;
1135  }
1136  }
1137  else if (channels == 3) {
1138  char i = (char)swap;
1139  for (y = 0; y < height; y++) {
1140  const uchar *from = rect_from + stride_from * y * 3;
1141  uchar *to[2] = {
1142  rect_left + stride_to * y * 3,
1143  rect_right + stride_to * y * 3,
1144  };
1145  char j = i;
1146  for (x = 0; x < width; x++, from += 3, to[0] += 3, to[1] += 3) {
1147  copy_v3_v3_uchar(to[j], from);
1148  j = !j;
1149  }
1150  i = !i;
1151  }
1152  }
1153  else if (channels == 4) {
1154  char i = (char)swap;
1155  for (y = 0; y < height; y++) {
1156  const uchar *from = rect_from + stride_from * y * 4;
1157  uchar *to[2] = {
1158  rect_left + stride_to * y * 4,
1159  rect_right + stride_to * y * 4,
1160  };
1161  char j = i;
1162  for (x = 0; x < width; x++, from += 4, to[0] += 4, to[1] += 4) {
1163  copy_v4_v4_uchar(to[j], from);
1164  j = !j;
1165  }
1166  i = !i;
1167  }
1168  }
1169  break;
1170  }
1171  default: {
1172  break;
1173  }
1174  }
1175  }
1176 }
1177 
1178 /* stereo input (s3d->rectf.stereo) is always unsqueezed */
1179 static void imb_stereo3d_read_sidebyside(Stereo3DData *s3d, const bool crosseyed)
1180 {
1181  int y;
1182  size_t width = s3d->x;
1183  size_t height = s3d->y;
1184  const size_t channels = s3d->channels;
1185 
1186  const int stride_from = width * 2;
1187  const int stride_to = width;
1188 
1189  const int l = (int)crosseyed;
1190  const int r = !l;
1191 
1192  if (s3d->is_float) {
1193  float *rect_left = s3d->rectf.left;
1194  float *rect_right = s3d->rectf.right;
1195  const float *rect_from = s3d->rectf.stereo;
1196 
1197  for (y = 0; y < height; y++) {
1198  const float *from = rect_from + stride_from * y * channels;
1199  float *to[2] = {
1200  rect_left + stride_to * y * channels,
1201  rect_right + stride_to * y * channels,
1202  };
1203 
1204  memcpy(to[l], from, sizeof(float) * channels * stride_to);
1205  memcpy(to[r], from + channels * stride_to, sizeof(float) * channels * stride_to);
1206  }
1207  }
1208  else {
1209  uchar *rect_left = s3d->rect.left;
1210  uchar *rect_right = s3d->rect.right;
1211  const uchar *rect_from = s3d->rect.stereo;
1212 
1213  /* always RGBA input/output */
1214  for (y = 0; y < height; y++) {
1215  const uchar *from = rect_from + stride_from * y * channels;
1216  uchar *to[2] = {
1217  rect_left + stride_to * y * channels,
1218  rect_right + stride_to * y * channels,
1219  };
1220 
1221  memcpy(to[l], from, sizeof(uchar) * channels * stride_to);
1222  memcpy(to[r], from + channels * stride_to, sizeof(uchar) * channels * stride_to);
1223  }
1224  }
1225 }
1226 
1227 /* stereo input (s3d->rectf.stereo) is always unsqueezed */
1229 {
1230  int y;
1231  size_t width = s3d->x;
1232  size_t height = s3d->y;
1233  const size_t channels = s3d->channels;
1234 
1235  const int stride_from = width;
1236  const int stride_to = width;
1237 
1238  if (s3d->is_float) {
1239  float *rect_left = s3d->rectf.left;
1240  float *rect_right = s3d->rectf.right;
1241  const float *rect_from = s3d->rectf.stereo;
1242 
1243  for (y = 0; y < height; y++) {
1244  const float *from = rect_from + stride_from * y * channels;
1245  float *to[2] = {
1246  rect_left + stride_to * y * channels,
1247  rect_right + stride_to * y * channels,
1248  };
1249 
1250  memcpy(to[1], from, sizeof(float) * channels * stride_to);
1251  memcpy(to[0], from + channels * height * stride_to, sizeof(float) * channels * stride_to);
1252  }
1253  }
1254  else {
1255  uchar *rect_left = s3d->rect.left;
1256  uchar *rect_right = s3d->rect.right;
1257  const uchar *rect_from = s3d->rect.stereo;
1258 
1259  for (y = 0; y < height; y++) {
1260  const uchar *from = rect_from + stride_from * y * channels;
1261  uchar *to[2] = {
1262  rect_left + stride_to * y * channels,
1263  rect_right + stride_to * y * channels,
1264  };
1265 
1266  memcpy(to[1], from, sizeof(uchar) * channels * stride_to);
1267  memcpy(to[0], from + channels * height * stride_to, sizeof(uchar) * channels * stride_to);
1268  }
1269  }
1270 }
1271 
1274 /* -------------------------------------------------------------------- */
1278 /* reading a stereo encoded ibuf (*left) and generating two ibufs from it (*left and *right) */
1280  ImBuf *ibuf_stereo3d,
1281  ImBuf **r_ibuf_left,
1282  ImBuf **r_ibuf_right)
1283 {
1284  Stereo3DData s3d_data = {{NULL}};
1285  ImBuf *ibuf_left, *ibuf_right;
1286  size_t width, height;
1287  const bool is_float = (ibuf_stereo3d->rect_float != NULL);
1288 
1290  ((s3d->flag & S3D_SQUEEZED_FRAME) == 0),
1291  ibuf_stereo3d->x,
1292  ibuf_stereo3d->y,
1293  &width,
1294  &height);
1295 
1296  ibuf_left = IMB_allocImBuf(
1297  width, height, ibuf_stereo3d->planes, (is_float ? IB_rectfloat : IB_rect));
1298  ibuf_right = IMB_allocImBuf(
1299  width, height, ibuf_stereo3d->planes, (is_float ? IB_rectfloat : IB_rect));
1300 
1301  ibuf_left->flags = ibuf_stereo3d->flags;
1302  ibuf_right->flags = ibuf_stereo3d->flags;
1303 
1304  /* we always work with unsqueezed formats */
1306  ((s3d->flag & S3D_SQUEEZED_FRAME) == 0),
1307  ibuf_stereo3d->x,
1308  ibuf_stereo3d->y,
1309  &width,
1310  &height);
1311  imb_stereo3d_unsqueeze_ImBuf(ibuf_stereo3d, s3d, width, height);
1312 
1313  imb_stereo3d_data_init(&s3d_data,
1314  is_float,
1315  ibuf_left->x,
1316  ibuf_left->y,
1317  4,
1318  (int *)ibuf_left->rect,
1319  (int *)ibuf_right->rect,
1320  (int *)ibuf_stereo3d->rect,
1321  ibuf_left->rect_float,
1322  ibuf_right->rect_float,
1323  ibuf_stereo3d->rect_float);
1324 
1325  imb_stereo3d_read_doit(&s3d_data, s3d);
1326 
1327  if (ibuf_stereo3d->flags & (IB_zbuf | IB_zbuffloat)) {
1328  if (is_float) {
1329  addzbuffloatImBuf(ibuf_left);
1330  addzbuffloatImBuf(ibuf_right);
1331  }
1332  else {
1333  addzbufImBuf(ibuf_left);
1334  addzbufImBuf(ibuf_right);
1335  }
1336 
1337  imb_stereo3d_data_init(&s3d_data,
1338  is_float,
1339  ibuf_left->x,
1340  ibuf_left->y,
1341  1,
1342  (int *)ibuf_left->zbuf,
1343  (int *)ibuf_right->zbuf,
1344  (int *)ibuf_stereo3d->zbuf,
1345  ibuf_left->zbuf_float,
1346  ibuf_right->zbuf_float,
1347  ibuf_stereo3d->zbuf_float);
1348 
1349  imb_stereo3d_read_doit(&s3d_data, s3d);
1350  }
1351 
1352  IMB_freeImBuf(ibuf_stereo3d);
1353 
1354  *r_ibuf_left = ibuf_left;
1355  *r_ibuf_right = ibuf_right;
1356 }
1357 
1359 {
1360  switch (s3d->display_mode) {
1361  case S3D_DISPLAY_ANAGLYPH:
1362  imb_stereo3d_read_anaglyph(s3d_data, s3d->anaglyph_type);
1363  break;
1364  case S3D_DISPLAY_INTERLACE:
1366  s3d_data, s3d->interlace_type, (s3d->flag & S3D_INTERLACE_SWAP) != 0);
1367  break;
1370  break;
1371  case S3D_DISPLAY_TOPBOTTOM:
1372  imb_stereo3d_read_topbottom(s3d_data);
1373  break;
1374  default:
1375  break;
1376  }
1377 }
1378 
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])
unsigned char uchar
Definition: BLI_sys_types.h:86
#define MAX2(a, b)
#define ELEM(...)
void swap(T &a, T &b)
Definition: Common.h:33
eStereo3dAnaglyphType
@ S3D_SQUEEZED_FRAME
@ S3D_INTERLACE_SWAP
@ S3D_SIDEBYSIDE_CROSSEYED
@ S3D_DISPLAY_ANAGLYPH
@ S3D_DISPLAY_INTERLACE
@ S3D_DISPLAY_TOPBOTTOM
@ S3D_DISPLAY_SIDEBYSIDE
eStereo3dInterlaceType
@ S3D_INTERLACE_ROW
@ S3D_INTERLACE_COLUMN
@ S3D_INTERLACE_CHECKERBOARD
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Header file for allocimbuf.c.
bool addzbufImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:272
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:478
void IMB_freeImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:211
void IMB_buffer_byte_from_byte(unsigned char *rect_to, const unsigned char *rect_from, int profile_to, int profile_from, bool predivide, int width, int height, int stride_to, int stride_from)
Definition: divers.c:651
void IMB_buffer_float_from_float(float *rect_to, const float *rect_from, int channels_from, int profile_to, int profile_from, bool predivide, int width, int height, int stride_to, int stride_from)
Definition: divers.c:430
bool addzbuffloatImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:289
void IMB_scaleImBuf_threaded(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Definition: scaling.c:1889
Contains defines and structs used throughout the imbuf module.
#define IB_PROFILE_SRGB
#define IB_PROFILE_LINEAR_RGB
@ IB_zbuf
@ IB_rectfloat
@ IB_zbuffloat
@ IB_rect
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMLoop * l
StackEntry * from
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
struct Stereo3DData Stereo3DData
static void imb_stereo3d_unsqueeze_ImBuf(ImBuf *ibuf, Stereo3dFormat *s3d, const size_t x, const size_t y)
Definition: stereoimbuf.c:599
static void imb_stereo3d_write_interlace(Stereo3DData *s3d, enum eStereo3dInterlaceType mode, const bool swap)
Definition: stereoimbuf.c:163
static void imb_stereo3d_squeeze_rectf(float *rectf, Stereo3dFormat *s3d, const size_t x, const size_t y, const size_t channels)
Definition: stereoimbuf.c:615
static void imb_stereo3d_squeeze_rect(int *rect, Stereo3dFormat *s3d, const size_t x, const size_t y, const size_t channels)
Definition: stereoimbuf.c:649
void IMB_ImBufFromStereo3d(Stereo3dFormat *s3d, ImBuf *ibuf_stereo3d, ImBuf **r_ibuf_left, ImBuf **r_ibuf_right)
Definition: stereoimbuf.c:1279
static void imb_stereo3d_squeeze_ImBuf(ImBuf *ibuf, Stereo3dFormat *s3d, const size_t x, const size_t y)
Definition: stereoimbuf.c:583
int * IMB_stereo3d_from_rect(ImageFormatData *im_format, const size_t x, const size_t y, const size_t channels, int *rect_left, int *rect_right)
Definition: stereoimbuf.c:712
static void imb_stereo3d_read_anaglyph(Stereo3DData *s3d, enum eStereo3dAnaglyphType mode)
Definition: stereoimbuf.c:823
float * IMB_stereo3d_from_rectf(ImageFormatData *im_format, const size_t x, const size_t y, const size_t channels, float *rectf_left, float *rectf_right)
Definition: stereoimbuf.c:736
ImBuf * IMB_stereo3d_ImBuf(ImageFormatData *im_format, ImBuf *ibuf_left, ImBuf *ibuf_right)
Definition: stereoimbuf.c:761
static void imb_stereo3d_read_doit(struct Stereo3DData *s3d_data, struct Stereo3dFormat *s3d)
Definition: stereoimbuf.c:1358
static void imb_stereo3d_write_anaglyph(Stereo3DData *s3d, enum eStereo3dAnaglyphType mode)
Definition: stereoimbuf.c:65
static void imb_stereo3d_read_topbottom(Stereo3DData *s3d)
Definition: stereoimbuf.c:1228
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)
Definition: stereoimbuf.c:521
static void imb_stereo3d_write_sidebyside(Stereo3DData *s3d, const bool crosseyed)
Definition: stereoimbuf.c:421
static void imb_stereo3d_read_sidebyside(Stereo3DData *s3d, const bool crosseyed)
Definition: stereoimbuf.c:1179
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)
Definition: stereoimbuf.c:688
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)
Definition: stereoimbuf.c:549
static void imb_stereo3d_read_interlace(Stereo3DData *s3d, enum eStereo3dInterlaceType mode, const bool swap)
Definition: stereoimbuf.c:921
static void imb_stereo3d_write_topbottom(Stereo3DData *s3d)
Definition: stereoimbuf.c:469
static void imb_stereo3d_write_doit(struct Stereo3DData *s3d_data, struct Stereo3dFormat *s3d)
Definition: stereoimbuf.c:796
float * zbuf_float
struct ColorSpace * rect_colorspace
unsigned char planes
unsigned int * rect
float * rect_float
struct ColorSpace * float_colorspace
int * zbuf
Stereo3dFormat stereo3d_format
float * right
Definition: stereoimbuf.c:52
struct Stereo3DData::@670 rectf
float * stereo
Definition: stereoimbuf.c:52
float * left
Definition: stereoimbuf.c:52
struct Stereo3DData::@671 rect
uchar * left
Definition: stereoimbuf.c:55
size_t channels
Definition: stereoimbuf.c:57