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