1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
442
  
443
  
444
  
445
  
446
  
447
  
448
  
449
  
450
  
451
  
452
  
453
  
454
  
455
  
456
  
457
  
458
  
459
  
460
  
461
  
462
  
463
  
464
  
465
  
466
  
467
  
468
  
469
  
470
  
471
  
472
  
473
  
474
  
475
  
476
  
477
  
478
  
479
  
480
  
481
  
482
  
483
  
484
  
485
  
486
  
487
  
488
  
489
  
490
  
491
  
492
  
493
  
494
  
495
  
496
  
497
  
498
  
499
  
500
  
501
  
502
  
503
  
504
  
505
  
506
  
507
  
508
  
509
  
510
  
511
  
512
  
513
  
514
  
515
  
516
  
517
  
518
  
519
  
520
  
521
  
522
  
523
  
524
  
525
  
526
  
527
  
528
  
529
  
530
  
531
  
532
  
533
  
534
  
535
  
536
  
537
  
538
  
539
  
540
  
541
  
542
  
543
  
544
  
545
  
546
  
547
  
548
  
549
  
550
  
551
  
552
  
553
  
554
  
555
  
556
  
557
  
558
  
559
  
560
  
561
  
562
  
563
  
564
  
565
  
566
  
567
  
568
  
569
  
570
  
571
  
572
  
573
  
574
  
575
  
576
  
577
  
578
  
579
  
580
  
581
  
582
  
583
  
584
  
585
  
586
  
587
  
588
  
589
  
590
  
591
  
592
  
593
  
594
  
595
  
596
  
597
  
598
  
599
  
600
  
601
  
602
  
603
  
604
  
605
  
606
  
607
  
608
  
609
  
/* -*- c -*- 
|| This file is part of Pike. For copyright information see COPYRIGHT. 
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING 
|| for more information. 
*/ 
 
#include "pike_macros.h" 
#include "object.h" 
#include "constants.h" 
#include "interpret.h" 
#include "svalue.h" 
#include "threads.h" 
#include "array.h" 
#include "builtin_functions.h" 
#include "mapping.h" 
#include "pike_error.h" 
#include "operators.h" 
#include "module_support.h" 
#include "modules/Image/image.h" 
#include "config.h" 
 
#ifdef HAVE_LIBWEBP 
DECLARATIONS 
 
/* #define DEFAULT_CMOD_STORAGE static*/ 
#define true 1 
#define false 0 
 
#include <webp/encode.h> 
#include <webp/decode.h> 
 
#if WEBP_ENCODER_ABI_VERSION < 0x0201 
typedef struct WebPMemoryWriter 
{ 
  uint8_t* mem;       // final buffer (of size 'max_size', larger than 'size'). 
  size_t   size;      // final size 
  size_t   max_size;  // total capacity 
  uint32_t pad[1];    // padding for later use 
} WebPMemoryWriter; 
 
/* This is from LIBWEBP 0.3.1+ */ 
void WebPMemoryWriterInit(WebPMemoryWriter* writer) 
{ 
    writer->mem = NULL; 
    writer->size = 0; 
    writer->max_size = 0; 
} 
 
int WebPMemoryWrite(const uint8_t* data, size_t data_size, 
                    const WebPPicture* picture) 
{ 
    WebPMemoryWriter* const w = (WebPMemoryWriter*)picture->custom_ptr; 
    uint64_t next_size; 
    if (w == NULL) 
    { 
        return 1; 
    } 
 
    next_size = (uint64_t)w->size + data_size; 
 
    if (next_size > w->max_size) 
    { 
        uint8_t* new_mem; 
        size_t next_max_size = 2ULL * w->max_size; 
        if (next_max_size < next_size) next_max_size = next_size; 
        if (next_max_size < 8192ULL) next_max_size = 8192ULL; 
        new_mem = xalloc(next_max_size); 
        if (w->size > 0) { 
            memcpy(new_mem, w->mem, w->size); 
        } 
        free(w->mem); 
        w->mem = new_mem; 
        w->max_size = (size_t)next_max_size; 
    } 
    if (data_size > 0) { 
        memcpy(w->mem + w->size, data, data_size); 
        w->size += data_size; 
    } 
    return 1; 
} 
#endif 
 
 
typedef int (*Importer)(WebPPicture* const, const uint8_t* const, int); 
 
 
typedef struct object object; 
typedef struct program program; 
 
static program *img_program; 
 
static program *image_program() 
{ 
  if( !img_program ) 
  { 
    push_static_text("Image.Image"); 
    SAFE_APPLY_MASTER("resolv",1); 
    img_program = Pike_sp[-1].u.program; 
    Pike_sp--; 
  } 
  return img_program; 
} 
 
static object *allocate_image(int w, int h ) 
{ 
  push_int(w); 
  push_int(h); 
  return clone_object(image_program(),2); 
} 
 
static inline int image_width( object *img ) 
{ 
  char *x; 
  if( !img ) return 0; 
  x = get_storage( img, image_program() ); 
  if( !x ) return 0; 
  return ((struct image *)x)->xsize; 
} 
 
static inline int image_height( object *img ) 
{ 
  char *x; 
  if( !img ) return 0; 
  x = get_storage( img, image_program() ); 
  if( !x ) return 0; 
  return ((struct image *)x)->ysize; 
} 
 
static inline unsigned char *image_ptr( object *img ) 
{ 
  char *x; 
  if( !img ) return 0; 
  x = get_storage( img, image_program() ); 
  if( !x ) return 0; 
  return (unsigned char *)(((struct image  *)x)->img); 
} 
 
 
static size_t Encode(const uint8_t* rgba, int width, int height, int stride, 
                     Importer import, WebPConfig *config, uint8_t** output) 
{ 
 WebPPicture pic; 
 WebPMemoryWriter wrt; 
 int ok; 
 
 if( !WebPPictureInit(&pic) ) 
   return 0; 
 
#if WEBP_ENCODER_ABI_VERSION > 0x0200 
 pic.use_argb = !!config->lossless; 
#endif 
 pic.width = width; 
 pic.height = height; 
 pic.writer = WebPMemoryWrite; 
 pic.custom_ptr = &wrt; 
 WebPMemoryWriterInit(&wrt); 
 
 ok = import(&pic, rgba, stride) && WebPEncode(config, &pic); 
 WebPPictureFree(&pic); 
 
 if (!ok) 
 { 
  free(wrt.mem); 
  *output = NULL; 
  switch( pic.error_code ) 
  { 
   case VP8_ENC_ERROR_OUT_OF_MEMORY: 
     *output = (uint8_t*)"Out of memory\n"; 
     break; 
   case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: 
     *output = (uint8_t*)"Out of memory while writing\n"; 
     break; 
   case VP8_ENC_ERROR_NULL_PARAMETER: 
     *output =(uint8_t*) "Pointer parameter is NULL\n"; 
     break; 
   case VP8_ENC_ERROR_INVALID_CONFIGURATION: 
     *output = (uint8_t*)"Invalid parameters\n"; 
     break; 
   case VP8_ENC_ERROR_BAD_DIMENSION: 
     *output = (uint8_t*)"Invalid image size\n"; 
     break; 
   case VP8_ENC_ERROR_PARTITION0_OVERFLOW: 
     *output = (uint8_t*)"Invalid partition0 size\n"; 
     break; 
   case VP8_ENC_ERROR_PARTITION_OVERFLOW: 
     *output = (uint8_t*)"Invalid partition size\n"; 
     break; 
   case VP8_ENC_ERROR_FILE_TOO_BIG: 
     *output = (uint8_t*)"File too big, >4G\n"; 
     break; 
#ifdef VP8_ENC_ERROR_USER_ABORT 
   case VP8_ENC_ERROR_USER_ABORT: 
     *output = (uint8_t*)"User aborted\n"; 
     break; 
#endif 
   default: 
     *output = (uint8_t*)"Unknown error\n"; 
     break; 
   } 
  return 0; 
 } 
 *output = wrt.mem; 
 return wrt.size; 
} 
 
 
/*! @module Image 
 *! 
 *! @module WebP 
 *! 
 *! WebP is a truecolor image format with alpha channel support 
 *! currently developed by Google. 
 *! 
 *! This module supports decoding and encoding of lossy and lossless 
 *! WebP images with and without alpha channels using the libwebp library. 
 *! 
 *! WebP images are generally smaller than the same quality JPEG or 
 *! PNG image, but takes longer to encode and decode, and support in 
 *! various applications is less common. 
 *! 
 */ 
 
/*! @decl mapping _decode( string data ) 
 *! 
 *! Decode a WebP image. 
 *! 
 *! @returns 
 *! @mapping 
 *! @member Image.Image "alpha" 
 *! @member Image.Image "image" 
 *! @member string "format" 
 *! @member int(1..16384) "width" 
 *! @member int(1..16384) "height" 
 *! @endmapping 
 */ 
 
/*! @decl Image.Image decode( string data ) 
 *! 
 *! Decode a WebP image, like @[_decode]. 
 *! @returns 
 *! The decoded image or an error 
 */ 
 
PIKEFUN mapping(string:object(Image.Image)|string) _decode( string data ) 
{ 
  int width, height, npix; 
  uint8_t *ip, *rp, *ap; 
  object *i = NULL, *a = NULL; 
  WebPBitstreamFeatures features; 
  uint8_t *res = WebPDecodeRGBA( (uint8_t*)data->str, data->len, 
                                 &width, &height ); 
  WebPGetFeatures( (uint8_t*)data->str, data->len, &features ); 
 
  if( !res ) 
    Pike_error("Failed to decode image\n"); 
 
  ip = ap = NULL; 
  rp = res; 
  npix = width * height; 
 
  if( features.has_alpha ) 
  { 
    a = allocate_image( width, height ); 
    ap = image_ptr( a ); 
  } 
  i = allocate_image( width, height ); 
  ip = image_ptr( i ); 
 
  while( npix-- ) 
  { 
    uint8_t av; 
    *(ip++) = *(rp++); // R 
    *(ip++) = *(rp++); // G 
    *(ip++) = *(rp++); // B 
    av = *(rp++); 
 
    if( ap ) 
    { 
      *(ap++) = av; // A 
      *(ap++) = av; 
      *(ap++) = av; 
    } 
  } 
  free( res ); 
 
  pop_n_elems(args); 
 
  push_static_text( "image" );  push_object( i ); 
  push_static_text( "img" );  ref_push_object( i ); 
  push_static_text( "alpha" ); 
  if( a ) 
    push_object( a ); 
  else 
    push_undefined( ); 
  push_static_text("format"); push_text("image/webp"); 
  push_static_text( "xsize" ); push_int( width ); 
  push_static_text( "ysize" ); push_int( height ); 
  f_aggregate_mapping( 12 ); 
} 
 
PIKEFUN object(Image.Image) decode( string data ) 
{ 
  struct mapping *m; 
  struct svalue *p; 
 
  apply(Pike_fp->current_object, "_decode", args); 
 
  m = Pike_sp[-1].u.mapping; 
 
  if( TYPEOF(Pike_sp[-1]) != PIKE_T_MAPPING ) 
      Pike_error("Decoding failed\n"); 
 
  p = simple_mapping_string_lookup(m,"image"); 
 
  if( !p || TYPEOF(*p) != PIKE_T_OBJECT ) 
      Pike_error("Decoding failed\n"); 
 
  ref_push_object( p->u.object ); 
  stack_unlink(1); 
} 
 
static int parameter_int(struct mapping *map, const char *what, int def ) 
{ 
   struct svalue *v = simple_mapping_string_lookup(map,what); 
   if (v && TYPEOF(*v) == PIKE_T_INT) return v->u.integer; 
   return def; 
} 
 
static double parameter_float(struct mapping *map, const char *what, 
                              double def ) 
{ 
   struct svalue *v = simple_mapping_string_lookup(map,what); 
   if (!v) return def; 
   if( TYPEOF(*v) == PIKE_T_INT ) 
       return (float)v->u.integer; 
   if( TYPEOF(*v) == PIKE_T_FLOAT ) 
       return (float)v->u.float_number; 
   return def; 
} 
 
static object *parameter_obj(struct mapping *map, const char *what ) 
{ 
   struct svalue *v = simple_mapping_string_lookup(map,what); 
   if( v && TYPEOF(*v) == PIKE_T_OBJECT ) 
       return v->u.object; 
   return NULL; 
} 
 
 
/*! @decl string encode( Image.Image image, mapping(string:int|float|Image.Image)|void options ) 
 *! 
 *! Encode an image using the WebP format. 
 *! 
 *! The image to encode has to be at most 16384 pixels in any direction. 
 *! 
 *! Commonly used options: 
 *! 
 *! @mapping 
 *! @member Image.Image "alpha" 
 *!  If present, the alpha channel for the image will be the green 
 *!  component of this image. Has to be the same size as the @[image] 
 *! @member int "preset" 
 *!  Initialization for the encoding options. 
 *!  One of PRESET_DEFAULT, PRESET_PICTURE, PRESET_PHOTO 
 *!  PRESET_DRAWING, PRESET_ICON and PRESET_TEXT 
 *! @member bool "lossless" 
 *!  If set, do lossless encoding. 
 *! @member float "quality" 
 *!  Between 0 and 99. If quality is 100+, lossless encoding with 
 *!  quality 70 will be used. 
 *! @endmapping 
 *! 
 *!  Additionally these advanced options are also supported: 
 *! 
 *! @mapping 
 *! @member int "image_hint" 
 *!   One of HINT_DEFAULT, HINT_PICTURE, HINT_PHOTO and HINT_GRAPH. 
 *!   Only used in lossless mode 
 *! @member int "target_size" 
 *!  If non zero, sets the desired filesize, in bytes. Takes 
 *!  precedence over quality. 
 *! @member int "target_PSNR" 
 *!  if non-zero, specifies the minimal distortion to try to 
 *!  achieve. Takes precedence over target_size. 
 *! @member int(1..4) "segments" 
 *!  maximum number of segments to use. 
 *! @member int(0..100) "sns_strength" 
 *!   Spatial Noise Shaping. 0=off, 100=maximum. 
 *! @member int(0..100) "filter_strength" 
 *!  0=off 
 *! @member int(0..7) "filter_sharpness" 
 *!  0=off 
 *! @member int(0..1) "filter_type" 
 *!   For the type, 0=simple, 1=strong. 
 *! @member bool autofilter 
 *!   If true, automatically adjust the filter strengths 
 *! @member int(0..1) "alpha_compression" 
 *!  Select alpha channel encoding format. Currently supported are 0: No alpha and 1: WebP lossless 
 *! @member int(0..2) "alpha_filtering" 
 *!  Select alpha filtering method. 0: none, 1: fast, 2: best. Default if 1. 
 *! @member int(0..100) "alpha_quality" 
 *!  Select the base image quality for the alpha channel. 
 *! @member int(1..10) "pass" 
 *!   The number of entropy analysis passes. Defaults to 1. 
 *! @member bool "show_compressed" 
 *! 
 *! @member bool "preprocessing" 
 *!  If true, do preprocessing (segment-smooth) 
 *! @member int(0..3) "partitions" 
 *!  log2(number of token partitions). Default is set to 0 for easier 
 *!  progressive decoding. 
 *! @member int(0..100) "partition_limit" 
 *!  quality degradation allowed to fit the 512k limit on prediction 
 *!  modes coding (0: no degradation, 100: maximum possible 
 *!  degradation). 
 *! @member bool "emulate_jpeg_size" 
 *!  If true, try to map the quality setting to generate similar sizes 
 *!  when compared to jpeg. 
 *! @member int "thread_level" 
 *!   The maximum number of extra threads to use. Defaults to 0 
 *! @member bool "low_memory" 
 *!   Decrease memory usage at the cost of encoding speed 
 *! @endmapping 
 *! 
 *! @returns 
 *! Always returns the encoded image as a string or throws an error. 
 *! 
 */ 
PIKEFUN string(0..255) encode( object(Image.Image) i, 
                               mapping(string:int|float|object(Image.Image))|void options ) 
{ 
    unsigned char *result = NULL; 
    size_t size; 
    object *a; 
    int width  = image_width( i ); 
    int height  = image_height( i ); 
    unsigned char *iptr = image_ptr( i ); 
    unsigned char *rgba = NULL; 
    Importer importer = WebPPictureImportRGB; 
    WebPConfig config; 
    WebPPreset preset; 
    if( !iptr || !width || !height ) 
    { 
        Pike_error("Image argument is not a valid image."); 
    } 
 
    if( options ) 
    { 
        if( (preset = (WebPPreset)parameter_int( options, "preset", 0 )) ) 
        { 
            if( !WebPConfigPreset(&config, preset, 75.0) ) 
                Pike_error("Failed to initialize config.\n"); 
        } 
        else 
        { 
            if( !WebPConfigInit( &config ) ) 
                Pike_error("Failed to initialize config.\n"); 
        } 
 
        a = parameter_obj( options, "alpha" ); 
 
#define GET_ENUM(Y,X) (config.X = (Y)parameter_int( options, #X, config.X )); 
#define GET_INT(X) (config.X = parameter_int( options, #X, config.X )); 
#define GET_FLT(X) (config.X = parameter_float( options, #X, config.X )); 
#define GET_BOL(X) (config.X = !!parameter_int( options, #X, config.X )); 
 
#if WEBP_ENCODER_ABI_VERSION > 0x0200 
        GET_BOL(lossless); 
#else 
        if( parameter_int( options, "lossless", 0 ) ) 
            Pike_error("Your libwebp is too old to support lossless encoding.\n"); 
#endif 
        GET_FLT(quality); 
        GET_INT(method); 
#if WEBP_ENCODER_ABI_VERSION > 0x0200 
        GET_ENUM(WebPImageHint,image_hint); 
#endif 
        GET_INT(target_size); 
        GET_FLT(target_PSNR); 
        GET_INT(segments); 
        GET_INT(sns_strength); 
        GET_INT(filter_strength); 
        GET_INT(filter_sharpness); 
        GET_INT(filter_type); 
        GET_INT(autofilter); 
 
#if WEBP_ENCODER_ABI_VERSION > 0x0200 
        GET_INT(alpha_compression); 
        GET_INT(alpha_filtering); 
        GET_INT(alpha_quality); 
#endif 
        GET_INT(pass); 
        GET_INT(show_compressed); 
        GET_INT(preprocessing); 
        GET_INT(partitions); 
        GET_INT(partition_limit); 
#if WEBP_ENCODER_ABI_VERSION > 0x0200 
        GET_BOL(emulate_jpeg_size); 
        GET_BOL(thread_level); 
        GET_BOL(low_memory); 
#endif 
#undef GET_BOL 
#undef GET_FLT 
#undef GET_INT 
#undef GET_ENUM 
 
#if WEBP_ENCODER_ABI_VERSION > 0x0200 
        if( config.quality >= 100 ) 
        { 
            config.quality = 70; 
            config.lossless = true; 
        } 
#endif 
    } 
    else 
    { 
        a = 0; 
        if( !WebPConfigInit( &config ) ) 
            Pike_error("Failed to initialize config.\n"); 
    } 
 
    if( a ) 
    { 
        unsigned char *aptr = image_ptr( a ); 
        int num = width*height; 
        unsigned char *dst; 
        importer = WebPPictureImportRGBA; 
 
        if( !aptr ) 
            Pike_error("Alpha channels is not an image object\n"); 
#if WEBP_ENCODER_ABI_VERSION < 0x0201 
        else 
            Pike_error("Alpha channels are not supported by your libwebp.\n"); 
#endif 
        if( image_width( a ) != width || image_height( a ) != height ) 
            Pike_error("The alpha channel does not have the same size as the image\n"); 
 
        dst = rgba = xalloc( num * 4 ); 
 
        while( num-- ) 
        { 
            *(dst++) = *(iptr++); // r 
            *(dst++) = *(iptr++); // g 
            *(dst++) = *(iptr++); // b 
            *(dst++) = *(aptr); // a 
            aptr += 3; 
        } 
    } 
 
    size = Encode( rgba ? rgba : iptr, width, height, width*(rgba?4:3), 
                   importer, &config, &result ); 
 
    if( rgba ) free( rgba ); 
 
    if( size == 0  ) 
        Pike_error( (const char *)result ); 
 
    push_string( make_shared_binary_string( (const char *)result, size ) ); 
    free( result ); 
} 
 
EXIT { 
    if (img_program) { 
        free_program(img_program); 
        img_program = NULL; 
    } 
} 
 
/* 
*! @decl constant PRESET_DEFAULT 
*! @decl constant PRESET_PICTURE 
*! @decl constant PRESET_PHOTO 
*! @decl constant PRESET_DRAWING 
*! @decl constant PRESET_ICON 
*! @decl constant PRESET_TREXT 
*!  Constants used to select the default values for the various encoding options in @[encode]. 
*! 
*! @decl constant HINT_DEFAULT 
*! @decl constant HINT_PICTURE 
*! @decl constant HINT_PHOTO 
*! @decl constant HINT_GRAPH 
*!  Constants used to give hints to the lossless encoder when using @[encode]. 
*!  (selected automatically when using a hint.) 
*/ 
 
EXTRA { 
#define CONST(X)  add_integer_constant( #X, WEBP_##X, 0 ); 
    CONST(PRESET_DEFAULT); 
    CONST(PRESET_PICTURE); 
    CONST(PRESET_PHOTO); 
    CONST(PRESET_DRAWING); 
    CONST(PRESET_ICON); 
    CONST(PRESET_TEXT); 
 
#if WEBP_ENCODER_ABI_VERSION > 0x0200 
    CONST(HINT_DEFAULT); 
    CONST(HINT_PICTURE); 
    CONST(HINT_PHOTO); 
    CONST(HINT_GRAPH); 
#endif 
#undef CONST 
} 
#endif /* HAVE_LIBVPX */ 
 
/*! @endmodule 
 *! 
 *! @endmodule 
 */