Blender  V2.93
jpeg.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) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 /* This little block needed for linking to Blender... */
25 #include <setjmp.h>
26 #include <stdio.h>
27 
28 #include "MEM_guardedalloc.h"
29 
30 #include "BLI_fileops.h"
31 #include "BLI_string.h"
32 #include "BLI_utildefines.h"
33 
34 #include "BKE_idprop.h"
35 
36 #include "DNA_ID.h" /* ID property definitions. */
37 
38 #include "IMB_filetype.h"
39 #include "IMB_imbuf.h"
40 #include "IMB_imbuf_types.h"
41 #include "IMB_metadata.h"
42 #include "imbuf.h"
43 #include "jerror.h"
44 #include "jpeglib.h"
45 
46 #include "IMB_colormanagement.h"
48 
49 /* the types are from the jpeg lib */
50 static void jpeg_error(j_common_ptr cinfo) ATTR_NORETURN;
51 static void init_source(j_decompress_ptr cinfo);
52 static boolean fill_input_buffer(j_decompress_ptr cinfo);
53 static void skip_input_data(j_decompress_ptr cinfo, long num_bytes);
54 static void term_source(j_decompress_ptr cinfo);
55 static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, size_t size);
56 static boolean handle_app1(j_decompress_ptr cinfo);
57 static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int flags);
58 
59 static const uchar jpeg_default_quality = 75;
61 
62 bool imb_is_a_jpeg(const unsigned char *mem, const size_t size)
63 {
64  const char magic[2] = {0xFF, 0xD8};
65  if (size < sizeof(magic)) {
66  return false;
67  }
68  return memcmp(mem, magic, sizeof(magic)) == 0;
69 }
70 
71 /*----------------------------------------------------------
72  * JPG ERROR HANDLING
73  *---------------------------------------------------------- */
74 
75 typedef struct my_error_mgr {
76  struct jpeg_error_mgr pub; /* "public" fields */
77 
78  jmp_buf setjmp_buffer; /* for return to caller */
80 
82 
83 static void jpeg_error(j_common_ptr cinfo)
84 {
85  my_error_ptr err = (my_error_ptr)cinfo->err;
86 
87  /* Always display the message */
88  (*cinfo->err->output_message)(cinfo);
89 
90  /* Let the memory manager delete any temp files before we die */
91  jpeg_destroy(cinfo);
92 
93  /* return control to the setjmp point */
94  longjmp(err->setjmp_buffer, 1);
95 }
96 
97 /*----------------------------------------------------------
98  * INPUT HANDLER FROM MEMORY
99  *---------------------------------------------------------- */
100 
101 #if 0
102 typedef struct {
103  unsigned char *buffer;
104  int filled;
105 } buffer_struct;
106 #endif
107 
108 typedef struct {
109  struct jpeg_source_mgr pub; /* public fields */
110 
111  const unsigned char *buffer;
112  int size;
113  JOCTET terminal[2];
114 } my_source_mgr;
115 
117 
118 static void init_source(j_decompress_ptr cinfo)
119 {
120  (void)cinfo; /* unused */
121 }
122 
123 static boolean fill_input_buffer(j_decompress_ptr cinfo)
124 {
125  my_src_ptr src = (my_src_ptr)cinfo->src;
126 
127  /* Since we have given all we have got already
128  * we simply fake an end of file
129  */
130 
131  src->pub.next_input_byte = src->terminal;
132  src->pub.bytes_in_buffer = 2;
133  src->terminal[0] = (JOCTET)0xFF;
134  src->terminal[1] = (JOCTET)JPEG_EOI;
135 
136  return true;
137 }
138 
139 static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
140 {
141  my_src_ptr src = (my_src_ptr)cinfo->src;
142 
143  if (num_bytes > 0) {
144  /* prevent skipping over file end */
145  size_t skip_size = (size_t)num_bytes <= src->pub.bytes_in_buffer ? num_bytes :
146  src->pub.bytes_in_buffer;
147 
148  src->pub.next_input_byte = src->pub.next_input_byte + skip_size;
149  src->pub.bytes_in_buffer = src->pub.bytes_in_buffer - skip_size;
150  }
151 }
152 
153 static void term_source(j_decompress_ptr cinfo)
154 {
155  (void)cinfo; /* unused */
156 }
157 
158 static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, size_t size)
159 {
160  my_src_ptr src;
161 
162  if (cinfo->src == NULL) { /* first time for this JPEG object? */
163  cinfo->src = (struct jpeg_source_mgr *)(*cinfo->mem->alloc_small)(
164  (j_common_ptr)cinfo, JPOOL_PERMANENT, sizeof(my_source_mgr));
165  }
166 
167  src = (my_src_ptr)cinfo->src;
168  src->pub.init_source = init_source;
169  src->pub.fill_input_buffer = fill_input_buffer;
170  src->pub.skip_input_data = skip_input_data;
171  src->pub.resync_to_restart = jpeg_resync_to_restart;
172  src->pub.term_source = term_source;
173 
174  src->pub.bytes_in_buffer = size;
175  src->pub.next_input_byte = buffer;
176 
177  src->buffer = buffer;
178  src->size = size;
179 }
180 
181 #define MAKESTMT(stuff) \
182  do { \
183  stuff \
184  } while (0)
185 
186 #define INPUT_VARS(cinfo) \
187  struct jpeg_source_mgr *datasrc = (cinfo)->src; \
188  const JOCTET *next_input_byte = datasrc->next_input_byte; \
189  size_t bytes_in_buffer = datasrc->bytes_in_buffer
190 
191 /* Unload the local copies --- do this only at a restart boundary */
192 #define INPUT_SYNC(cinfo) \
193  (datasrc->next_input_byte = next_input_byte, datasrc->bytes_in_buffer = bytes_in_buffer)
194 
195 /* Reload the local copies --- seldom used except in MAKE_BYTE_AVAIL */
196 #define INPUT_RELOAD(cinfo) \
197  (next_input_byte = datasrc->next_input_byte, bytes_in_buffer = datasrc->bytes_in_buffer)
198 
199 /* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available.
200  * Note we do *not* do INPUT_SYNC before calling fill_input_buffer,
201  * but we must reload the local copies after a successful fill.
202  */
203 #define MAKE_BYTE_AVAIL(cinfo, action) \
204  if (bytes_in_buffer == 0) { \
205  if (!(*datasrc->fill_input_buffer)(cinfo)) { \
206  action; \
207  } \
208  INPUT_RELOAD(cinfo); \
209  } \
210  (void)0
211 
212 /* Read a byte into variable V.
213  * If must suspend, take the specified action (typically "return false").
214  */
215 #define INPUT_BYTE(cinfo, V, action) \
216  MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; V = GETJOCTET(*next_input_byte++);)
217 
218 /* As above, but read two bytes interpreted as an unsigned 16-bit integer.
219  * V should be declared unsigned int or perhaps INT32.
220  */
221 #define INPUT_2BYTES(cinfo, V, action) \
222  MAKESTMT(MAKE_BYTE_AVAIL(cinfo, action); bytes_in_buffer--; \
223  V = ((unsigned int)GETJOCTET(*next_input_byte++)) << 8; \
224  MAKE_BYTE_AVAIL(cinfo, action); \
225  bytes_in_buffer--; \
226  V += GETJOCTET(*next_input_byte++);)
227 
228 struct NeoGeo_Word {
233 };
234 BLI_STATIC_ASSERT(sizeof(struct NeoGeo_Word) == 4, "Must be 4 bytes");
235 
236 static boolean handle_app1(j_decompress_ptr cinfo)
237 {
238  INT32 length; /* initialized by the macro */
239  INT32 i;
240  char neogeo[128];
241 
242  INPUT_VARS(cinfo);
243 
244  INPUT_2BYTES(cinfo, length, return false);
245  length -= 2;
246 
247  if (length < 16) {
248  for (i = 0; i < length; i++) {
249  INPUT_BYTE(cinfo, neogeo[i], return false);
250  }
251  length = 0;
252  if (STRPREFIX(neogeo, "NeoGeo")) {
253  struct NeoGeo_Word *neogeo_word = (struct NeoGeo_Word *)(neogeo + 6);
254  ibuf_quality = neogeo_word->quality;
255  }
256  }
257  INPUT_SYNC(cinfo); /* do before skip_input_data */
258  if (length > 0) {
259  (*cinfo->src->skip_input_data)(cinfo, length);
260  }
261  return true;
262 }
263 
264 static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int flags)
265 {
266  JSAMPARRAY row_pointer;
267  JSAMPLE *buffer = NULL;
268  int row_stride;
269  int x, y, depth, r, g, b, k;
270  struct ImBuf *ibuf = NULL;
271  uchar *rect;
272  jpeg_saved_marker_ptr marker;
273  char *str, *key, *value;
274 
275  /* install own app1 handler */
277  jpeg_set_marker_processor(cinfo, 0xe1, handle_app1);
278  cinfo->dct_method = JDCT_FLOAT;
279  jpeg_save_markers(cinfo, JPEG_COM, 0xffff);
280 
281  if (jpeg_read_header(cinfo, false) == JPEG_HEADER_OK) {
282  x = cinfo->image_width;
283  y = cinfo->image_height;
284  depth = cinfo->num_components;
285 
286  if (cinfo->jpeg_color_space == JCS_YCCK) {
287  cinfo->out_color_space = JCS_CMYK;
288  }
289 
290  jpeg_start_decompress(cinfo);
291 
292  if (flags & IB_test) {
293  jpeg_abort_decompress(cinfo);
294  ibuf = IMB_allocImBuf(x, y, 8 * depth, 0);
295  }
296  else if ((ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect)) == NULL) {
297  jpeg_abort_decompress(cinfo);
298  }
299  else {
300  row_stride = cinfo->output_width * depth;
301 
302  row_pointer = (*cinfo->mem->alloc_sarray)((j_common_ptr)cinfo, JPOOL_IMAGE, row_stride, 1);
303 
304  for (y = ibuf->y - 1; y >= 0; y--) {
305  jpeg_read_scanlines(cinfo, row_pointer, 1);
306  rect = (uchar *)(ibuf->rect + y * ibuf->x);
307  buffer = row_pointer[0];
308 
309  switch (depth) {
310  case 1:
311  for (x = ibuf->x; x > 0; x--) {
312  rect[3] = 255;
313  rect[0] = rect[1] = rect[2] = *buffer++;
314  rect += 4;
315  }
316  break;
317  case 3:
318  for (x = ibuf->x; x > 0; x--) {
319  rect[3] = 255;
320  rect[0] = *buffer++;
321  rect[1] = *buffer++;
322  rect[2] = *buffer++;
323  rect += 4;
324  }
325  break;
326  case 4:
327  for (x = ibuf->x; x > 0; x--) {
328  r = *buffer++;
329  g = *buffer++;
330  b = *buffer++;
331  k = *buffer++;
332 
333  r = (r * k) / 255;
334  g = (g * k) / 255;
335  b = (b * k) / 255;
336 
337  rect[3] = 255;
338  rect[2] = b;
339  rect[1] = g;
340  rect[0] = r;
341  rect += 4;
342  }
343  break;
344  }
345  }
346 
347  marker = cinfo->marker_list;
348  while (marker) {
349  if (marker->marker != JPEG_COM) {
350  goto next_stamp_marker;
351  }
352 
353  /*
354  * JPEG marker strings are not null-terminated,
355  * create a null-terminated copy before going further
356  */
357  str = BLI_strdupn((char *)marker->data, marker->data_length);
358 
359  /*
360  * Because JPEG format don't support the
361  * pair "key/value" like PNG, we store the
362  * stamp-info in a single "encode" string:
363  * "Blender:key:value"
364  *
365  * That is why we need split it to the
366  * common key/value here.
367  */
368  if (!STRPREFIX(str, "Blender")) {
369  /*
370  * Maybe the file have text that
371  * we don't know "what it's", in that
372  * case we keep the text (with a
373  * key "None").
374  * This is only for don't "lose"
375  * the information when we write
376  * it back to disk.
377  */
379  IMB_metadata_set_field(ibuf->metadata, "None", str);
380  ibuf->flags |= IB_metadata;
381  MEM_freeN(str);
382  goto next_stamp_marker;
383  }
384 
385  key = strchr(str, ':');
386  /*
387  * A little paranoid, but the file maybe
388  * is broken... and a "extra" check is better
389  * then segfault ;)
390  */
391  if (!key) {
392  MEM_freeN(str);
393  goto next_stamp_marker;
394  }
395 
396  key++;
397  value = strchr(key, ':');
398  if (!value) {
399  MEM_freeN(str);
400  goto next_stamp_marker;
401  }
402 
403  *value = '\0'; /* need finish the key string */
404  value++;
406  IMB_metadata_set_field(ibuf->metadata, key, value);
407  ibuf->flags |= IB_metadata;
408  MEM_freeN(str);
409  next_stamp_marker:
410  marker = marker->next;
411  }
412 
413  jpeg_finish_decompress(cinfo);
414  }
415 
416  if (ibuf) {
417  /* Density_unit may be 0 for unknown, 1 for dots/inch, or 2 for dots/cm. */
418  if (cinfo->density_unit == 1) {
419  /* Convert inches to meters. */
420  ibuf->ppm[0] = cinfo->X_density / 0.0254f;
421  ibuf->ppm[1] = cinfo->Y_density / 0.0254f;
422  }
423  else if (cinfo->density_unit == 2) {
424  ibuf->ppm[0] = cinfo->X_density * 100.0f;
425  ibuf->ppm[1] = cinfo->Y_density * 100.0f;
426  }
427 
428  ibuf->ftype = IMB_FTYPE_JPG;
429  ibuf->foptions.quality = MIN2(ibuf_quality, 100);
430  }
431  jpeg_destroy((j_common_ptr)cinfo);
432  }
433 
434  return ibuf;
435 }
436 
437 ImBuf *imb_load_jpeg(const unsigned char *buffer,
438  size_t size,
439  int flags,
440  char colorspace[IM_MAX_SPACE])
441 {
442  struct jpeg_decompress_struct _cinfo, *cinfo = &_cinfo;
443  struct my_error_mgr jerr;
444  ImBuf *ibuf;
445 
446  if (!imb_is_a_jpeg(buffer, size)) {
447  return NULL;
448  }
449 
451 
452  cinfo->err = jpeg_std_error(&jerr.pub);
453  jerr.pub.error_exit = jpeg_error;
454 
455  /* Establish the setjmp return context for my_error_exit to use. */
456  if (setjmp(jerr.setjmp_buffer)) {
457  /* If we get here, the JPEG code has signaled an error.
458  * We need to clean up the JPEG object, close the input file, and return.
459  */
460  jpeg_destroy_decompress(cinfo);
461  return NULL;
462  }
463 
464  jpeg_create_decompress(cinfo);
465  memory_source(cinfo, buffer, size);
466 
467  ibuf = ibJpegImageFromCinfo(cinfo, flags);
468 
469  return ibuf;
470 }
471 
472 static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf)
473 {
474  JSAMPLE *buffer = NULL;
475  JSAMPROW row_pointer[1];
476  uchar *rect;
477  int x, y;
478  char neogeo[128];
479  struct NeoGeo_Word *neogeo_word;
480 
481  jpeg_start_compress(cinfo, true);
482 
483  strcpy(neogeo, "NeoGeo");
484  neogeo_word = (struct NeoGeo_Word *)(neogeo + 6);
485  memset(neogeo_word, 0, sizeof(*neogeo_word));
486  neogeo_word->quality = ibuf->foptions.quality;
487  jpeg_write_marker(cinfo, 0xe1, (JOCTET *)neogeo, 10);
488  if (ibuf->metadata) {
489  IDProperty *prop;
490  /* Static storage array for the short metadata. */
491  char static_text[1024];
492  const int static_text_size = ARRAY_SIZE(static_text);
493  for (prop = ibuf->metadata->data.group.first; prop; prop = prop->next) {
494  if (prop->type == IDP_STRING) {
495  int text_len;
496  if (STREQ(prop->name, "None")) {
497  jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *)IDP_String(prop), prop->len + 1);
498  }
499 
500  char *text = static_text;
501  int text_size = static_text_size;
502  /* 7 is for Blender, 2 colon separators, length of property
503  * name and property value, followed by the NULL-terminator. */
504  const int text_length_required = 7 + 2 + strlen(prop->name) + strlen(IDP_String(prop)) + 1;
505  if (text_length_required <= static_text_size) {
506  text = MEM_mallocN(text_length_required, "jpeg metadata field");
507  text_size = text_length_required;
508  }
509 
510  /*
511  * The JPEG format don't support a pair "key/value"
512  * like PNG, so we "encode" the stamp in a
513  * single string:
514  * "Blender:key:value"
515  *
516  * The first "Blender" is a simple identify to help
517  * in the read process.
518  */
519  text_len = BLI_snprintf(text, text_size, "Blender:%s:%s", prop->name, IDP_String(prop));
520  jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *)text, text_len + 1);
521 
522  /* TODO(sergey): Ideally we will try to re-use allocation as
523  * much as possible. In practice, such long fields don't happen
524  * often. */
525  if (text != static_text) {
526  MEM_freeN(text);
527  }
528  }
529  }
530  }
531 
532  row_pointer[0] = MEM_mallocN(sizeof(JSAMPLE) * cinfo->input_components * cinfo->image_width,
533  "jpeg row_pointer");
534 
535  for (y = ibuf->y - 1; y >= 0; y--) {
536  rect = (uchar *)(ibuf->rect + y * ibuf->x);
537  buffer = row_pointer[0];
538 
539  switch (cinfo->in_color_space) {
540  case JCS_RGB:
541  for (x = 0; x < ibuf->x; x++) {
542  *buffer++ = rect[0];
543  *buffer++ = rect[1];
544  *buffer++ = rect[2];
545  rect += 4;
546  }
547  break;
548  case JCS_GRAYSCALE:
549  for (x = 0; x < ibuf->x; x++) {
550  *buffer++ = rect[0];
551  rect += 4;
552  }
553  break;
554  case JCS_UNKNOWN:
555  memcpy(buffer, rect, 4 * ibuf->x);
556  break;
557  /* default was missing... intentional ? */
558  default:
559  /* do nothing */
560  break;
561  }
562 
563  jpeg_write_scanlines(cinfo, row_pointer, 1);
564  }
565 
566  jpeg_finish_compress(cinfo);
567  MEM_freeN(row_pointer[0]);
568 }
569 
570 static int init_jpeg(FILE *outfile, struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf)
571 {
572  int quality;
573 
574  quality = ibuf->foptions.quality;
575  if (quality <= 0) {
577  }
578  if (quality > 100) {
579  quality = 100;
580  }
581 
582  jpeg_create_compress(cinfo);
583  jpeg_stdio_dest(cinfo, outfile);
584 
585  cinfo->image_width = ibuf->x;
586  cinfo->image_height = ibuf->y;
587 
588  cinfo->in_color_space = JCS_RGB;
589  if (ibuf->planes == 8) {
590  cinfo->in_color_space = JCS_GRAYSCALE;
591  }
592 #if 0
593  /* just write RGBA as RGB,
594  * unsupported feature only confuses other s/w */
595 
596  if (ibuf->planes == 32) {
597  cinfo->in_color_space = JCS_UNKNOWN;
598  }
599 #endif
600  switch (cinfo->in_color_space) {
601  case JCS_RGB:
602  cinfo->input_components = 3;
603  break;
604  case JCS_GRAYSCALE:
605  cinfo->input_components = 1;
606  break;
607  case JCS_UNKNOWN:
608  cinfo->input_components = 4;
609  break;
610  /* default was missing... intentional ? */
611  default:
612  /* do nothing */
613  break;
614  }
615  jpeg_set_defaults(cinfo);
616 
617  /* own settings */
618 
619  cinfo->dct_method = JDCT_FLOAT;
620  jpeg_set_quality(cinfo, quality, true);
621 
622  return 0;
623 }
624 
625 static bool save_stdjpeg(const char *name, struct ImBuf *ibuf)
626 {
627  FILE *outfile;
628  struct jpeg_compress_struct _cinfo, *cinfo = &_cinfo;
629  struct my_error_mgr jerr;
630 
631  if ((outfile = BLI_fopen(name, "wb")) == NULL) {
632  return 0;
633  }
634 
635  cinfo->err = jpeg_std_error(&jerr.pub);
636  jerr.pub.error_exit = jpeg_error;
637 
638  /* Establish the setjmp return context for jpeg_error to use. */
639  if (setjmp(jerr.setjmp_buffer)) {
640  /* If we get here, the JPEG code has signaled an error.
641  * We need to clean up the JPEG object, close the input file, and return.
642  */
643  jpeg_destroy_compress(cinfo);
644  fclose(outfile);
645  remove(name);
646  return 0;
647  }
648 
649  init_jpeg(outfile, cinfo, ibuf);
650 
651  write_jpeg(cinfo, ibuf);
652 
653  fclose(outfile);
654  jpeg_destroy_compress(cinfo);
655 
656  return 1;
657 }
658 
659 bool imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags)
660 {
661 
662  ibuf->flags = flags;
663  return save_stdjpeg(filepath, ibuf);
664 }
#define IDP_String(prop)
Definition: BKE_idprop.h:181
#define ATTR_NORETURN
File and directory operations.
FILE * BLI_fopen(const char *filename, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:1003
char * BLI_strdupn(const char *str, const size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:54
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
unsigned char uchar
Definition: BLI_sys_types.h:86
#define STRPREFIX(a, b)
#define ARRAY_SIZE(arr)
#define MIN2(a, b)
#define STREQ(a, b)
ID and Library types, which are fundamental for sdna.
@ IDP_STRING
Definition: DNA_ID.h:97
_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 y
@ COLOR_ROLE_DEFAULT_BYTE
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:478
#define IM_MAX_SPACE
Definition: IMB_imbuf.h:65
Contains defines and structs used throughout the imbuf module.
@ IB_metadata
@ IB_test
@ IB_rect
void IMB_metadata_set_field(struct IDProperty *metadata, const char *key, const char *value)
Definition: metadata.c:89
void IMB_metadata_ensure(struct IDProperty **metadata)
Definition: metadata.c:41
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:895
void colorspace_set_default_role(char *colorspace, int size, int role)
#define str(s)
static FT_Error err
Definition: freetypefont.c:52
@ IMB_FTYPE_JPG
#define INPUT_BYTE(cinfo, V, action)
Definition: jpeg.c:215
static const uchar jpeg_default_quality
Definition: jpeg.c:59
static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf)
Definition: jpeg.c:472
bool imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: jpeg.c:659
static bool save_stdjpeg(const char *name, struct ImBuf *ibuf)
Definition: jpeg.c:625
my_source_mgr * my_src_ptr
Definition: jpeg.c:116
#define INPUT_2BYTES(cinfo, V, action)
Definition: jpeg.c:221
#define INPUT_VARS(cinfo)
Definition: jpeg.c:186
struct my_error_mgr my_error_mgr
my_error_mgr * my_error_ptr
Definition: jpeg.c:81
static int init_jpeg(FILE *outfile, struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf)
Definition: jpeg.c:570
BLI_STATIC_ASSERT(sizeof(struct NeoGeo_Word)==4, "Must be 4 bytes")
static void term_source(j_decompress_ptr cinfo)
Definition: jpeg.c:153
static uchar ibuf_quality
Definition: jpeg.c:60
static boolean handle_app1(j_decompress_ptr cinfo)
Definition: jpeg.c:236
#define INPUT_SYNC(cinfo)
Definition: jpeg.c:192
static void skip_input_data(j_decompress_ptr cinfo, long num_bytes)
Definition: jpeg.c:139
static void init_source(j_decompress_ptr cinfo)
Definition: jpeg.c:118
static void jpeg_error(j_common_ptr cinfo) ATTR_NORETURN
Definition: jpeg.c:83
static boolean fill_input_buffer(j_decompress_ptr cinfo)
Definition: jpeg.c:123
bool imb_is_a_jpeg(const unsigned char *mem, const size_t size)
Definition: jpeg.c:62
static void memory_source(j_decompress_ptr cinfo, const unsigned char *buffer, size_t size)
Definition: jpeg.c:158
ImBuf * imb_load_jpeg(const unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: jpeg.c:437
static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int flags)
Definition: jpeg.c:264
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
ListBase group
Definition: DNA_ID.h:64
int len
Definition: DNA_ID.h:84
struct IDProperty * next
Definition: DNA_ID.h:70
char name[64]
Definition: DNA_ID.h:74
IDPropertyData data
Definition: DNA_ID.h:80
char type
Definition: DNA_ID.h:71
struct IDProperty * metadata
ImbFormatOptions foptions
unsigned char planes
enum eImbFileType ftype
unsigned int * rect
double ppm[2]
void * first
Definition: DNA_listBase.h:47
uchar pad2
Definition: jpeg.c:230
uchar pad1
Definition: jpeg.c:229
uchar pad3
Definition: jpeg.c:231
uchar quality
Definition: jpeg.c:232
jmp_buf setjmp_buffer
Definition: jpeg.c:78
struct jpeg_error_mgr pub
Definition: jpeg.c:76
int size
Definition: jpeg.c:112
const unsigned char * buffer
Definition: jpeg.c:111
struct jpeg_source_mgr pub
Definition: jpeg.c:109
JOCTET terminal[2]
Definition: jpeg.c:113
static int magic(const Tex *tex, const float texvec[3], TexResult *texres)