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