First set of 50 GPL attribution for CV-Contributors added
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / filetiff.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #include "asset.h"
24 #include "edit.h"
25 #include "file.h"
26 #include "filetiff.h"
27 #include "interlacemodes.h"
28 #include "language.h"
29 #include "vframe.h"
30 #include "mainerror.h"
31
32 #include <stdint.h>
33 #include <string.h>
34 #include <unistd.h>
35
36 FileTIFF::FileTIFF(Asset *asset, File *file)
37  : FileList(asset, file, "TIFFLIST", ".tif", FILE_TIFF, FILE_TIFF_LIST)
38 {
39         asset->video_data = 1;
40         temp = 0;
41 }
42
43 FileTIFF::~FileTIFF()
44 {
45         if(temp) delete temp;
46 }
47
48
49 void FileTIFF::get_parameters(BC_WindowBase *parent_window,
50         Asset *asset, BC_WindowBase* &format_window,
51         int audio_options, int video_options, EDL *edl)
52 {
53         if(video_options)
54         {
55                 TIFFConfigVideo *window = new TIFFConfigVideo(parent_window, asset);
56                 format_window = window;
57                 window->create_objects();
58                 window->run_window();
59                 delete window;
60         }
61 }
62
63
64 int FileTIFF::check_sig(Asset *asset)
65 {
66         FILE *stream = fopen(asset->path, "rb");
67
68         if(stream)
69         {
70                 char test[10];
71                 (void)fread(test, 10, 1, stream);
72                 fclose(stream);
73
74                 if(test[0] == 'I' && test[1] == 'I')
75                 {
76                         // Reject cr2, libtiff fails with it
77                         if( test[4] == 0x10 && !test[5] && !test[6] && !test[7] &&
78                                         test[8] == 'C' && test[9] == 'R' )
79                                 return 0;
80                         return 1;
81                 }
82                 else
83                 if(test[0] == 'T' && test[1] == 'I' && test[2] == 'F' && test[3] == 'F' &&
84                         test[4] == 'L' && test[5] == 'I' && test[6] == 'S' && test[7] == 'T')
85                 {
86                         return 1;
87                 }
88                 else
89                 if(strlen(asset->path) > 4 &&
90                         !strcasecmp(asset->path + strlen(asset->path) - 4, ".tif"))
91                 {
92                         return 1;
93                 }
94                 else
95                 if(strlen(asset->path) > 5 &&
96                         !strcasecmp(asset->path + strlen(asset->path) - 5, ".tiff"))
97                 {
98                         return 1;
99                 }
100         }
101         return 0;
102 }
103
104 const char* FileTIFF::compression_to_str(int value)
105 {
106         switch( value ) {
107         case FileTIFF::NONE:            break;
108         case FileTIFF::LZW:             return "LZW";
109         case FileTIFF::PACK_BITS:       return "Pack Bits";
110         case FileTIFF::DEFLATE:         return "Deflate";
111         case FileTIFF::JPEG:            return "JPEG";
112         case FileTIFF::PIXARFILM:       return "PIXARFILM";
113         case FileTIFF::PIXARLOG:        return "PIXARLOG";
114         case FileTIFF::JP2000:          return "JP2000";
115         case FileTIFF::SGILOG:          return "SGILOG";
116         case FileTIFF::LZMA:            return "LZMA";
117         case FileTIFF::ADOBE_DEFLATE:   return "Adobe Deflate";
118         }
119         return _("None");
120 }
121
122 const char* FileTIFF::cmodel_to_str(int value)
123 {
124         switch( value ) {
125         case FileTIFF::RGB_888:         return "RGB-8 Bit";
126         case FileTIFF::RGB_161616:      return "RGB-16 Bit";
127         case FileTIFF::RGBA_8888:       return "RGBA-8 Bit";
128         case FileTIFF::RGBA_16161616:   return "RGBA-16 Bit";
129         case FileTIFF::RGB_FLOAT:       return "RGB-FLOAT";
130         case FileTIFF::RGBA_FLOAT:      return "RGBA-FLOAT";
131         case FileTIFF::GREYSCALE:       return "Greyscale";
132         }
133         return "RGB-8 Bit";
134 }
135
136
137 int FileTIFF::can_copy_from(Asset *asset, int64_t position)
138 {
139         if(asset->format == FILE_TIFF_LIST ||
140                 asset->format == FILE_TIFF)
141                 return 1;
142
143         return 0;
144 }
145
146
147
148 int FileTIFF::read_frame_header(char *path)
149 {
150         TIFF *stream;
151         int result = 0;
152
153         if(!(stream = TIFFOpen(path, "rb")))
154         {
155                 eprintf("Error while opening \"%s\" for reading. \n%m\n", asset->path);
156                 return 1;
157         }
158
159         char *ptr = 0;
160         TIFFGetField(stream, TIFFTAG_MODEL, &ptr);
161 //printf("FileTIFF::read_frame_header 1 %s\n", ptr);
162         if(ptr && !strcmp(ptr, "Canon EOS-1DS"))       // FIXME: Does this have a purpose?
163         {
164                 printf("FileTIFF::read_frame_header: got a %s.\n",
165                         ptr);
166         }
167
168 // The raw format for certain cameras deviates from TIFF here.
169
170         TIFFGetField(stream, TIFFTAG_IMAGEWIDTH, &(asset->width));
171         TIFFGetField(stream, TIFFTAG_IMAGELENGTH, &(asset->height));
172
173         int components = 0;
174         TIFFGetField(stream, TIFFTAG_SAMPLESPERPIXEL, &components);
175         int bitspersample = 0;
176         TIFFGetField(stream, TIFFTAG_BITSPERSAMPLE, &bitspersample);
177         int sampleformat = 0;
178         TIFFGetField(stream, TIFFTAG_SAMPLEFORMAT, &sampleformat);
179
180         if(bitspersample == 8 && components == 3)
181                 asset->tiff_cmodel = FileTIFF::RGB_888;
182         else
183         if(bitspersample == 16 && components == 3)
184                 asset->tiff_cmodel = FileTIFF::RGB_161616;
185         else
186         if(bitspersample == 8 && components == 4)
187                 asset->tiff_cmodel = FileTIFF::RGBA_8888;
188         else
189         if(bitspersample == 16 && components == 4)
190                 asset->tiff_cmodel = FileTIFF::RGBA_16161616;
191         else
192         if(bitspersample == 32 && components == 3)
193                 asset->tiff_cmodel = FileTIFF::RGB_FLOAT;
194         else
195         if(bitspersample == 32 && components == 4)
196                 asset->tiff_cmodel = FileTIFF::RGBA_FLOAT;
197         else
198         if(bitspersample == 8 && (components == 1 || components == 0))
199                 asset->tiff_cmodel = FileTIFF::GREYSCALE;
200
201 //printf("FileTIFF::read_frame_header %d %d %d\n", bitspersample, components, asset->tiff_cmodel);
202         TIFFClose(stream);
203
204         asset->interlace_mode = ILACE_MODE_NOTINTERLACED;
205         return result;
206 }
207
208 int FileTIFF::colormodel_supported(int colormodel)
209 {
210         switch(asset->tiff_cmodel)
211         {
212                 case FileTIFF::RGB_888: return BC_RGB888; break;
213                 case FileTIFF::RGB_161616: return BC_RGB_FLOAT; break;
214                 case FileTIFF::GREYSCALE: return BC_RGB888; break;
215                 case FileTIFF::RGBA_8888: return BC_RGBA8888; break;
216                 case FileTIFF::RGBA_16161616: return BC_RGBA_FLOAT; break;
217                 case FileTIFF::RGB_FLOAT: return BC_RGB_FLOAT; break;
218                 case FileTIFF::RGBA_FLOAT: return BC_RGBA_FLOAT; break;
219                 default: return BC_RGB888; break;
220         }
221 }
222
223 int FileTIFF::get_best_colormodel(Asset *asset, int driver)
224 {
225         switch(asset->tiff_cmodel)
226         {
227                 case FileTIFF::GREYSCALE: return BC_RGB888; break;
228                 case FileTIFF::RGB_888: return BC_RGB888; break;
229                 case FileTIFF::RGB_161616: return BC_RGB_FLOAT; break;
230                 case FileTIFF::RGBA_8888: return BC_RGBA8888; break;
231                 case FileTIFF::RGBA_16161616: return BC_RGBA_FLOAT; break;
232                 case FileTIFF::RGB_FLOAT: return BC_RGB_FLOAT; break;
233                 case FileTIFF::RGBA_FLOAT: return BC_RGBA_FLOAT; break;
234                 default: return BC_RGB888; break;
235         }
236 }
237
238
239 static tsize_t tiff_read(thandle_t ptr, tdata_t buf, tsize_t size)
240 {
241         FileTIFFUnit *tiff_unit = (FileTIFFUnit*)ptr;
242         if(tiff_unit->data->get_compressed_size() < tiff_unit->offset + size)
243                 return 0;
244         memcpy(buf, tiff_unit->data->get_data() + tiff_unit->offset, size);
245         tiff_unit->offset += size;
246         return size;
247 }
248
249 static tsize_t tiff_write(thandle_t ptr, tdata_t buf, tsize_t size)
250 {
251         FileTIFFUnit *tiff_unit = (FileTIFFUnit*)ptr;
252         if(tiff_unit->data->get_compressed_allocated() < tiff_unit->offset + size)
253         {
254                 tiff_unit->data->allocate_compressed_data((tiff_unit->offset + size) * 2);
255         }
256
257
258         if(tiff_unit->data->get_compressed_size() < tiff_unit->offset + size)
259                 tiff_unit->data->set_compressed_size(tiff_unit->offset + size);
260         memcpy(tiff_unit->data->get_data() + tiff_unit->offset,
261                 buf,
262                 size);
263         tiff_unit->offset += size;
264         return size;
265 }
266
267 static toff_t tiff_seek(thandle_t ptr, toff_t off, int whence)
268 {
269         FileTIFFUnit *tiff_unit = (FileTIFFUnit*)ptr;
270         switch(whence)
271         {
272                 case SEEK_SET:
273                         tiff_unit->offset = off;
274                         break;
275                 case SEEK_CUR:
276                         tiff_unit->offset += off;
277                         break;
278                 case SEEK_END:
279                         tiff_unit->offset = tiff_unit->data->get_compressed_size() + off;
280                         break;
281         }
282         return tiff_unit->offset;
283 }
284
285 static int tiff_close(thandle_t ptr)
286 {
287         return 0;
288 }
289
290 static toff_t tiff_size(thandle_t ptr)
291 {
292         FileTIFFUnit *tiff_unit = (FileTIFFUnit*)ptr;
293         return tiff_unit->data->get_compressed_size();
294 }
295
296 static int tiff_mmap(thandle_t ptr, tdata_t* pbase, toff_t* psize)
297 {
298         FileTIFFUnit *tiff_unit = (FileTIFFUnit*)ptr;
299         *pbase = tiff_unit->data->get_data();
300         *psize = tiff_unit->data->get_compressed_size();
301         return 0;
302 }
303
304 void tiff_unmap(thandle_t ptr, tdata_t base, toff_t size)
305 {
306 }
307
308 int FileTIFF::read_frame(VFrame *output, VFrame *input)
309 {
310         FileTIFFUnit *unit = new FileTIFFUnit(this, 0);
311         TIFF *stream;
312         unit->offset = 0;
313         unit->data = input;
314
315         stream = TIFFClientOpen("FileTIFF",
316                 "r",
317             (void*)unit,
318             tiff_read,
319                 tiff_write,
320             tiff_seek,
321                 tiff_close,
322             tiff_size,
323             tiff_mmap,
324                 tiff_unmap);
325
326 // This loads the original TIFF data into each scanline of the output frame,
327 // assuming the output scanlines are bigger than the input scanlines.
328 // Then it expands the input data in reverse to fill the row.
329         for(int i = 0; i < asset->height; i++)
330         {
331                 TIFFReadScanline(stream, output->get_rows()[i], i, 0);
332
333 // For the greyscale model, the output is RGB888 but the input must be expanded
334                 if(asset->tiff_cmodel == FileTIFF::GREYSCALE)
335                 {
336                         unsigned char *row = output->get_rows()[i];
337                         for(int j = output->get_w() - 1; j >= 0; j--)
338                         {
339                                 unsigned char value = row[j];
340                                 row[j * 3] = value;
341                                 row[j * 3 + 1] = value;
342                                 row[j * 3 + 2] = value;
343                         }
344                 }
345 // For the 16 bit models, the output is floating point.
346                 else
347                 if(asset->tiff_cmodel == FileTIFF::RGB_161616)
348                 {
349                         uint16_t *input_row = (uint16_t*)output->get_rows()[i];
350                         float *output_row = (float*)output->get_rows()[i];
351                         for(int j = output->get_w() - 1; j >= 0; j--)
352                         {
353                                 uint16_t r = input_row[j * 3];
354                                 uint16_t g = input_row[j * 3 + 1];
355                                 uint16_t b = input_row[j * 3 + 2];
356                                 output_row[j * 3] = (float)r / 65535;
357                                 output_row[j * 3 + 1] = (float)g / 65535;
358                                 output_row[j * 3 + 2] = (float)b / 65535;
359                         }
360                 }
361                 else
362                 if(asset->tiff_cmodel == FileTIFF::RGBA_16161616)
363                 {
364                         uint16_t *input_row = (uint16_t*)output->get_rows()[i];
365                         float *output_row = (float*)output->get_rows()[i];
366                         for(int j = output->get_w() - 1; j >= 0; j--)
367                         {
368                                 uint16_t r = input_row[j * 4];
369                                 uint16_t g = input_row[j * 4 + 1];
370                                 uint16_t b = input_row[j * 4 + 2];
371                                 output_row[j * 4] = (float)r / 65535;
372                                 output_row[j * 4 + 1] = (float)g / 65535;
373                                 output_row[j * 4 + 2] = (float)b / 65535;
374                         }
375                 }
376         }
377
378         TIFFClose(stream);
379         delete unit;
380
381         return 0;
382 }
383
384 int FileTIFF::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
385 {
386 //printf("FileTIFF::write_frame 1\n");
387         FileTIFFUnit *tiff_unit = (FileTIFFUnit*)unit;
388         int result = 0;
389         TIFF *stream;
390         tiff_unit->offset = 0;
391         tiff_unit->data = data;
392         tiff_unit->data->set_compressed_size(0);
393
394         stream = TIFFClientOpen("FileTIFF",
395                 "w",
396             (void*)tiff_unit,
397             tiff_read,
398                 tiff_write,
399             tiff_seek,
400                 tiff_close,
401             tiff_size,
402             tiff_mmap,
403                 tiff_unmap);
404
405         int components, color_model, bits, compression;
406         int sampleformat = SAMPLEFORMAT_UINT;
407         //int bytesperrow, type;
408         switch( asset->tiff_cmodel ) {
409         case FileTIFF::RGB_888:
410                 components = 3;  color_model = BC_RGB888;  bits = 8;
411                 //type = TIFF_BYTE;  bytesperrow = 3 * asset->width;
412                 break;
413         case FileTIFF::RGB_161616:
414                 components = 3;  color_model = BC_RGB_FLOAT;  bits = 16;
415                 //type = TIFF_SHORT;  bytesperrow = 6 * asset->width;
416                         break;
417         case FileTIFF::RGBA_8888:
418                 components = 4;  color_model = BC_RGBA8888;  bits = 8;
419                 //type = TIFF_BYTE;  bytesperrow = 4 * asset->width;
420                 break;
421         case FileTIFF::RGBA_16161616:
422                 components = 4;  color_model = BC_RGBA_FLOAT;  bits = 16;
423                 //type = TIFF_SHORT;  bytesperrow = 8 * asset->width;
424                 break;
425         case FileTIFF::RGB_FLOAT:
426                 components = 3;  color_model = BC_RGB_FLOAT;  bits = 32;
427                 //type = TIFF_FLOAT;  bytesperrow = 12 * asset->width;
428                 sampleformat = SAMPLEFORMAT_IEEEFP;
429                 break;
430         case FileTIFF::RGBA_FLOAT:
431                 components = 4;  color_model = BC_RGBA_FLOAT;  bits = 32;
432                 //type = TIFF_FLOAT;  bytesperrow = 16 * asset->width;
433                 sampleformat = SAMPLEFORMAT_IEEEFP;
434                 break;
435         default:
436                 components = 3;  color_model = BC_RGB888;  bits = 8;
437                 //type = TIFF_BYTE;  bytesperrow = 3 * asset->width;
438                 break;
439         }
440
441         switch(asset->tiff_compression) {
442         case FileTIFF::LZW:           compression = COMPRESSION_LZW;        break;
443         case FileTIFF::PACK_BITS:     compression = COMPRESSION_PACKBITS;   break;
444         case FileTIFF::DEFLATE:       compression = COMPRESSION_DEFLATE;    break;
445         case FileTIFF::JPEG:          compression = COMPRESSION_JPEG;       break;
446         case FileTIFF::PIXARFILM:     compression = COMPRESSION_PIXARFILM;  break;
447         case FileTIFF::PIXARLOG:      compression = COMPRESSION_PIXARLOG;   break;
448         case FileTIFF::JP2000:        compression = COMPRESSION_JP2000;     break;
449         case FileTIFF::LZMA:          compression = COMPRESSION_LZMA;       break;
450         case FileTIFF::SGILOG:        compression = COMPRESSION_SGILOG;     break;
451         case FileTIFF::ADOBE_DEFLATE: compression = ADOBE_DEFLATE;          break;
452         default:                      compression = COMPRESSION_NONE;       break;
453         }
454
455         TIFFSetField(stream, TIFFTAG_IMAGEWIDTH, asset->width);
456         TIFFSetField(stream, TIFFTAG_IMAGELENGTH, asset->height);
457         TIFFSetField(stream, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
458         TIFFSetField(stream, TIFFTAG_SAMPLESPERPIXEL, components);
459         TIFFSetField(stream, TIFFTAG_BITSPERSAMPLE, bits);
460         TIFFSetField(stream, TIFFTAG_SAMPLEFORMAT, sampleformat);
461         if( components == 4 ) {
462                 uint16 out[1];  out[0] = EXTRASAMPLE_UNASSALPHA;
463                 TIFFSetField(stream, TIFFTAG_EXTRASAMPLES, 1, &out);
464         }
465         TIFFSetField(stream, TIFFTAG_COMPRESSION, compression);
466         TIFFSetField(stream, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
467         TIFFSetField(stream, TIFFTAG_ROWSPERSTRIP,
468                 TIFFDefaultStripSize(stream, (uint32_t)-1));
469 //      TIFFSetField(stream, TIFFTAG_ROWSPERSTRIP,
470 //              (8 * 1024) / bytesperrow);
471         TIFFSetField(stream, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
472
473         if( frame->get_color_model() == color_model ) {
474                 for( int y=0; y<asset->height; ++y )
475                         TIFFWriteScanline(stream, frame->get_rows()[y], y, 0);
476         }
477         else {
478                 if( tiff_unit->temp &&
479                     tiff_unit->temp->get_color_model() != color_model ) {
480                         delete tiff_unit->temp;  tiff_unit->temp = 0;
481                 }
482                 if( !tiff_unit->temp )
483                         tiff_unit->temp = new VFrame(asset->width, asset->height, color_model, 0);
484
485                 BC_CModels::transfer(tiff_unit->temp->get_rows(), frame->get_rows(),
486                         tiff_unit->temp->get_y(), tiff_unit->temp->get_u(), tiff_unit->temp->get_v(),
487                         frame->get_y(), frame->get_u(), frame->get_v(),
488                         0, 0, frame->get_w(), frame->get_h(),
489                         0, 0, frame->get_w(), frame->get_h(),
490                         frame->get_color_model(), color_model,
491                         0, frame->get_w(), frame->get_w());
492                 for( int y=0; y<asset->height; ++y )
493                         TIFFWriteScanline(stream, tiff_unit->temp->get_rows()[y], y, 0);
494         }
495
496         TIFFClose(stream);
497
498 //printf("FileTIFF::write_frame 10\n");
499         return result;
500 }
501
502 FrameWriterUnit* FileTIFF::new_writer_unit(FrameWriter *writer)
503 {
504         return new FileTIFFUnit(this, writer);
505 }
506
507
508 FileTIFFUnit::FileTIFFUnit(FileTIFF *file, FrameWriter *writer)
509  : FrameWriterUnit(writer)
510 {
511         this->file = file;
512         temp = 0;
513 }
514
515 FileTIFFUnit::~FileTIFFUnit()
516 {
517         if(temp) delete temp;
518 }
519
520
521
522
523
524
525
526
527
528
529
530
531 TIFFConfigVideo::TIFFConfigVideo(BC_WindowBase *parent_window, Asset *asset)
532  : BC_Window(_(PROGRAM_NAME ": Video Compression"),
533         parent_window->get_abs_cursor_x(1),
534         parent_window->get_abs_cursor_y(1),
535         xS(400), yS(200))
536 {
537         this->parent_window = parent_window;
538         this->asset = asset;
539 // *** CONTEXT_HELP ***
540         context_help_set_keyword("Single File Rendering");
541 }
542
543 TIFFConfigVideo::~TIFFConfigVideo()
544 {
545 }
546
547 void TIFFConfigVideo::create_objects()
548 {
549         lock_window("TIFFConfigVideo::create_objects");
550         int x = xS(10), y = yS(10);
551
552         add_subwindow(new BC_Title(x, y, _("Colorspace:")));
553         TIFFColorspace *menu1;
554         add_subwindow(menu1 = new TIFFColorspace(this, x + xS(150), y, xS(200)));
555         menu1->create_objects();
556         y += yS(40);
557         add_subwindow(new BC_Title(x, y, _("Compression:")));
558         TIFFCompression *menu2;
559         add_subwindow(menu2 = new TIFFCompression(this, x + xS(150), y, xS(200)));
560         menu2->create_objects();
561
562         add_subwindow(new BC_OKButton(this));
563         show_window(1);
564         unlock_window();
565 }
566
567 int TIFFConfigVideo::close_event()
568 {
569         set_done(0);
570         return 1;
571 }
572
573
574 TIFFColorspace::TIFFColorspace(TIFFConfigVideo *gui, int x, int y, int w)
575  : BC_PopupMenu(x, y, w, FileTIFF::cmodel_to_str(gui->asset->tiff_cmodel))
576 {
577         this->gui = gui;
578 }
579 int TIFFColorspace::handle_event()
580 {
581         return 1;
582 }
583 void TIFFColorspace::create_objects()
584 {
585         add_item(new TIFFColorspaceItem(gui, FileTIFF::RGB_888));
586 //      add_item(new TIFFColorspaceItem(gui, FileTIFF::RGB_16161616));
587         add_item(new TIFFColorspaceItem(gui, FileTIFF::RGBA_8888));
588 //      add_item(new TIFFColorspaceItem(gui, FileTIFF::RGBA_16161616));
589         add_item(new TIFFColorspaceItem(gui, FileTIFF::RGB_FLOAT));
590         add_item(new TIFFColorspaceItem(gui, FileTIFF::RGBA_FLOAT));
591 }
592
593
594 TIFFColorspaceItem::TIFFColorspaceItem(TIFFConfigVideo *gui, int value)
595  : BC_MenuItem(FileTIFF::cmodel_to_str(value))
596 {
597         this->gui = gui;
598         this->value = value;
599 }
600 int TIFFColorspaceItem::handle_event()
601 {
602         gui->asset->tiff_cmodel = value;
603         return 0;
604 }
605
606
607
608
609
610
611
612 TIFFCompression::TIFFCompression(TIFFConfigVideo *gui, int x, int y, int w)
613  : BC_PopupMenu(x, y, w, FileTIFF::compression_to_str(gui->asset->tiff_compression))
614 {
615         this->gui = gui;
616 }
617 int TIFFCompression::handle_event()
618 {
619         return 1;
620 }
621 void TIFFCompression::create_objects()
622 {
623         add_item(new TIFFCompressionItem(gui, FileTIFF::NONE));
624         add_item(new TIFFCompressionItem(gui, FileTIFF::LZW)); // patent expired in 2004 ?
625         add_item(new TIFFCompressionItem(gui, FileTIFF::PACK_BITS));
626         add_item(new TIFFCompressionItem(gui, FileTIFF::DEFLATE)); // works!
627 //      add_item(new TIFFCompressionItem(gui, FileTIFF::SGILOG));  scanline encoding not implemented
628         add_item(new TIFFCompressionItem(gui, FileTIFF::LZMA)); // works, a bit new for data exchange?
629 //      add_item(new TIFFCompressionItem(gui, FileTIFF::ADOBE_DEFLATE)); scanline encoding not implemented
630 //      add_item(new TIFFCompressionItem(gui, FileTIFF::PIXARFILM)); not supported for scanline encoding
631 //      add_item(new TIFFCompressionItem(gui, FileTIFF::PIXARLOG)); only 8 bit ?
632 //      add_item(new TIFFCompressionItem(gui, FileTIFF::JP2000)); doesn't support scanline encoding
633 //      add_item(new TIFFCompressionItem(gui, FileTIFF::JPEG));
634 }
635
636
637 TIFFCompressionItem::TIFFCompressionItem(TIFFConfigVideo *gui, int value)
638  : BC_MenuItem(FileTIFF::compression_to_str(value))
639 {
640         this->gui = gui;
641         this->value = value;
642 }
643 int TIFFCompressionItem::handle_event()
644 {
645         gui->asset->tiff_compression = value;
646         return 0;
647 }
648