Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[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         if(!stream)
327         return 0;
328
329 // This loads the original TIFF data into each scanline of the output frame,
330 // assuming the output scanlines are bigger than the input scanlines.
331 // Then it expands the input data in reverse to fill the row.
332         for(int i = 0; i < asset->height; i++)
333         {
334                 TIFFReadScanline(stream, output->get_rows()[i], i, 0);
335
336 // For the greyscale model, the output is RGB888 but the input must be expanded
337                 if(asset->tiff_cmodel == FileTIFF::GREYSCALE)
338                 {
339                         unsigned char *row = output->get_rows()[i];
340                         for(int j = output->get_w() - 1; j >= 0; j--)
341                         {
342                                 unsigned char value = row[j];
343                                 row[j * 3] = value;
344                                 row[j * 3 + 1] = value;
345                                 row[j * 3 + 2] = value;
346                         }
347                 }
348 // For the 16 bit models, the output is floating point.
349                 else
350                 if(asset->tiff_cmodel == FileTIFF::RGB_161616)
351                 {
352                         uint16_t *input_row = (uint16_t*)output->get_rows()[i];
353                         float *output_row = (float*)output->get_rows()[i];
354                         for(int j = output->get_w() - 1; j >= 0; j--)
355                         {
356                                 uint16_t r = input_row[j * 3];
357                                 uint16_t g = input_row[j * 3 + 1];
358                                 uint16_t b = input_row[j * 3 + 2];
359                                 output_row[j * 3] = (float)r / 65535;
360                                 output_row[j * 3 + 1] = (float)g / 65535;
361                                 output_row[j * 3 + 2] = (float)b / 65535;
362                         }
363                 }
364                 else
365                 if(asset->tiff_cmodel == FileTIFF::RGBA_16161616)
366                 {
367                         uint16_t *input_row = (uint16_t*)output->get_rows()[i];
368                         float *output_row = (float*)output->get_rows()[i];
369                         for(int j = output->get_w() - 1; j >= 0; j--)
370                         {
371                                 uint16_t r = input_row[j * 4];
372                                 uint16_t g = input_row[j * 4 + 1];
373                                 uint16_t b = input_row[j * 4 + 2];
374                                 output_row[j * 4] = (float)r / 65535;
375                                 output_row[j * 4 + 1] = (float)g / 65535;
376                                 output_row[j * 4 + 2] = (float)b / 65535;
377                         }
378                 }
379         }
380
381         TIFFClose(stream);
382         delete unit;
383
384         return 0;
385 }
386
387 int FileTIFF::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
388 {
389 //printf("FileTIFF::write_frame 1\n");
390         FileTIFFUnit *tiff_unit = (FileTIFFUnit*)unit;
391         int result = 0;
392         TIFF *stream;
393         tiff_unit->offset = 0;
394         tiff_unit->data = data;
395         tiff_unit->data->set_compressed_size(0);
396
397         stream = TIFFClientOpen("FileTIFF",
398                 "w",
399             (void*)tiff_unit,
400             tiff_read,
401                 tiff_write,
402             tiff_seek,
403                 tiff_close,
404             tiff_size,
405             tiff_mmap,
406                 tiff_unmap);
407
408         int components, color_model, bits, compression;
409         int sampleformat = SAMPLEFORMAT_UINT;
410         //int bytesperrow, type;
411         switch( asset->tiff_cmodel ) {
412         case FileTIFF::RGB_888:
413                 components = 3;  color_model = BC_RGB888;  bits = 8;
414                 //type = TIFF_BYTE;  bytesperrow = 3 * asset->width;
415                 break;
416         case FileTIFF::RGB_161616:
417                 components = 3;  color_model = BC_RGB_FLOAT;  bits = 16;
418                 //type = TIFF_SHORT;  bytesperrow = 6 * asset->width;
419                         break;
420         case FileTIFF::RGBA_8888:
421                 components = 4;  color_model = BC_RGBA8888;  bits = 8;
422                 //type = TIFF_BYTE;  bytesperrow = 4 * asset->width;
423                 break;
424         case FileTIFF::RGBA_16161616:
425                 components = 4;  color_model = BC_RGBA_FLOAT;  bits = 16;
426                 //type = TIFF_SHORT;  bytesperrow = 8 * asset->width;
427                 break;
428         case FileTIFF::RGB_FLOAT:
429                 components = 3;  color_model = BC_RGB_FLOAT;  bits = 32;
430                 //type = TIFF_FLOAT;  bytesperrow = 12 * asset->width;
431                 sampleformat = SAMPLEFORMAT_IEEEFP;
432                 break;
433         case FileTIFF::RGBA_FLOAT:
434                 components = 4;  color_model = BC_RGBA_FLOAT;  bits = 32;
435                 //type = TIFF_FLOAT;  bytesperrow = 16 * asset->width;
436                 sampleformat = SAMPLEFORMAT_IEEEFP;
437                 break;
438         default:
439                 components = 3;  color_model = BC_RGB888;  bits = 8;
440                 //type = TIFF_BYTE;  bytesperrow = 3 * asset->width;
441                 break;
442         }
443
444         switch(asset->tiff_compression) {
445         case FileTIFF::LZW:           compression = COMPRESSION_LZW;        break;
446         case FileTIFF::PACK_BITS:     compression = COMPRESSION_PACKBITS;   break;
447         case FileTIFF::DEFLATE:       compression = COMPRESSION_DEFLATE;    break;
448         case FileTIFF::JPEG:          compression = COMPRESSION_JPEG;       break;
449         case FileTIFF::PIXARFILM:     compression = COMPRESSION_PIXARFILM;  break;
450         case FileTIFF::PIXARLOG:      compression = COMPRESSION_PIXARLOG;   break;
451         case FileTIFF::JP2000:        compression = COMPRESSION_JP2000;     break;
452         case FileTIFF::LZMA:          compression = COMPRESSION_LZMA;       break;
453         case FileTIFF::SGILOG:        compression = COMPRESSION_SGILOG;     break;
454         case FileTIFF::ADOBE_DEFLATE: compression = ADOBE_DEFLATE;          break;
455         default:                      compression = COMPRESSION_NONE;       break;
456         }
457
458         TIFFSetField(stream, TIFFTAG_IMAGEWIDTH, asset->width);
459         TIFFSetField(stream, TIFFTAG_IMAGELENGTH, asset->height);
460         TIFFSetField(stream, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
461         TIFFSetField(stream, TIFFTAG_SAMPLESPERPIXEL, components);
462         TIFFSetField(stream, TIFFTAG_BITSPERSAMPLE, bits);
463         TIFFSetField(stream, TIFFTAG_SAMPLEFORMAT, sampleformat);
464         if( components == 4 ) {
465                 uint16 out[1];  out[0] = EXTRASAMPLE_UNASSALPHA;
466                 TIFFSetField(stream, TIFFTAG_EXTRASAMPLES, 1, &out);
467         }
468         TIFFSetField(stream, TIFFTAG_COMPRESSION, compression);
469         TIFFSetField(stream, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
470         TIFFSetField(stream, TIFFTAG_ROWSPERSTRIP,
471                 TIFFDefaultStripSize(stream, (uint32_t)-1));
472 //      TIFFSetField(stream, TIFFTAG_ROWSPERSTRIP,
473 //              (8 * 1024) / bytesperrow);
474         TIFFSetField(stream, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
475
476         if( frame->get_color_model() == color_model ) {
477                 for( int y=0; y<asset->height; ++y )
478                         TIFFWriteScanline(stream, frame->get_rows()[y], y, 0);
479         }
480         else {
481                 if( tiff_unit->temp &&
482                     tiff_unit->temp->get_color_model() != color_model ) {
483                         delete tiff_unit->temp;  tiff_unit->temp = 0;
484                 }
485                 if( !tiff_unit->temp )
486                         tiff_unit->temp = new VFrame(asset->width, asset->height, color_model, 0);
487
488                 BC_CModels::transfer(tiff_unit->temp->get_rows(), frame->get_rows(),
489                         tiff_unit->temp->get_y(), tiff_unit->temp->get_u(), tiff_unit->temp->get_v(),
490                         frame->get_y(), frame->get_u(), frame->get_v(),
491                         0, 0, frame->get_w(), frame->get_h(),
492                         0, 0, frame->get_w(), frame->get_h(),
493                         frame->get_color_model(), color_model,
494                         0, frame->get_w(), frame->get_w());
495                 for( int y=0; y<asset->height; ++y )
496                         TIFFWriteScanline(stream, tiff_unit->temp->get_rows()[y], y, 0);
497         }
498
499         TIFFClose(stream);
500
501 //printf("FileTIFF::write_frame 10\n");
502         return result;
503 }
504
505 FrameWriterUnit* FileTIFF::new_writer_unit(FrameWriter *writer)
506 {
507         return new FileTIFFUnit(this, writer);
508 }
509
510
511 FileTIFFUnit::FileTIFFUnit(FileTIFF *file, FrameWriter *writer)
512  : FrameWriterUnit(writer)
513 {
514         this->file = file;
515         temp = 0;
516 }
517
518 FileTIFFUnit::~FileTIFFUnit()
519 {
520         if(temp) delete temp;
521 }
522
523
524
525
526
527
528
529
530
531
532
533
534 TIFFConfigVideo::TIFFConfigVideo(BC_WindowBase *parent_window, Asset *asset)
535  : BC_Window(_(PROGRAM_NAME ": Video Compression"),
536         parent_window->get_abs_cursor_x(1),
537         parent_window->get_abs_cursor_y(1),
538         xS(400), yS(200))
539 {
540         this->parent_window = parent_window;
541         this->asset = asset;
542 // *** CONTEXT_HELP ***
543         context_help_set_keyword("Single File Rendering");
544 }
545
546 TIFFConfigVideo::~TIFFConfigVideo()
547 {
548 }
549
550 void TIFFConfigVideo::create_objects()
551 {
552         lock_window("TIFFConfigVideo::create_objects");
553         int x = xS(10), y = yS(10);
554
555         add_subwindow(new BC_Title(x, y, _("Colorspace:")));
556         TIFFColorspace *menu1;
557         add_subwindow(menu1 = new TIFFColorspace(this, x + xS(150), y, xS(200)));
558         menu1->create_objects();
559         y += yS(40);
560         add_subwindow(new BC_Title(x, y, _("Compression:")));
561         TIFFCompression *menu2;
562         add_subwindow(menu2 = new TIFFCompression(this, x + xS(150), y, xS(200)));
563         menu2->create_objects();
564
565         add_subwindow(new BC_OKButton(this));
566         show_window(1);
567         unlock_window();
568 }
569
570 int TIFFConfigVideo::close_event()
571 {
572         set_done(0);
573         return 1;
574 }
575
576
577 TIFFColorspace::TIFFColorspace(TIFFConfigVideo *gui, int x, int y, int w)
578  : BC_PopupMenu(x, y, w, FileTIFF::cmodel_to_str(gui->asset->tiff_cmodel))
579 {
580         this->gui = gui;
581 }
582 int TIFFColorspace::handle_event()
583 {
584         return 1;
585 }
586 void TIFFColorspace::create_objects()
587 {
588         add_item(new TIFFColorspaceItem(gui, FileTIFF::RGB_888));
589 //      add_item(new TIFFColorspaceItem(gui, FileTIFF::RGB_16161616));
590         add_item(new TIFFColorspaceItem(gui, FileTIFF::RGBA_8888));
591 //      add_item(new TIFFColorspaceItem(gui, FileTIFF::RGBA_16161616));
592         add_item(new TIFFColorspaceItem(gui, FileTIFF::RGB_FLOAT));
593         add_item(new TIFFColorspaceItem(gui, FileTIFF::RGBA_FLOAT));
594 }
595
596
597 TIFFColorspaceItem::TIFFColorspaceItem(TIFFConfigVideo *gui, int value)
598  : BC_MenuItem(FileTIFF::cmodel_to_str(value))
599 {
600         this->gui = gui;
601         this->value = value;
602 }
603 int TIFFColorspaceItem::handle_event()
604 {
605         gui->asset->tiff_cmodel = value;
606         return 0;
607 }
608
609
610
611
612
613
614
615 TIFFCompression::TIFFCompression(TIFFConfigVideo *gui, int x, int y, int w)
616  : BC_PopupMenu(x, y, w, FileTIFF::compression_to_str(gui->asset->tiff_compression))
617 {
618         this->gui = gui;
619 }
620 int TIFFCompression::handle_event()
621 {
622         return 1;
623 }
624 void TIFFCompression::create_objects()
625 {
626         add_item(new TIFFCompressionItem(gui, FileTIFF::NONE));
627         add_item(new TIFFCompressionItem(gui, FileTIFF::LZW)); // patent expired in 2004 ?
628         add_item(new TIFFCompressionItem(gui, FileTIFF::PACK_BITS));
629         add_item(new TIFFCompressionItem(gui, FileTIFF::DEFLATE)); // works!
630 //      add_item(new TIFFCompressionItem(gui, FileTIFF::SGILOG));  scanline encoding not implemented
631         add_item(new TIFFCompressionItem(gui, FileTIFF::LZMA)); // works, a bit new for data exchange?
632 //      add_item(new TIFFCompressionItem(gui, FileTIFF::ADOBE_DEFLATE)); scanline encoding not implemented
633 //      add_item(new TIFFCompressionItem(gui, FileTIFF::PIXARFILM)); not supported for scanline encoding
634 //      add_item(new TIFFCompressionItem(gui, FileTIFF::PIXARLOG)); only 8 bit ?
635 //      add_item(new TIFFCompressionItem(gui, FileTIFF::JP2000)); doesn't support scanline encoding
636 //      add_item(new TIFFCompressionItem(gui, FileTIFF::JPEG));
637 }
638
639
640 TIFFCompressionItem::TIFFCompressionItem(TIFFConfigVideo *gui, int value)
641  : BC_MenuItem(FileTIFF::compression_to_str(value))
642 {
643         this->gui = gui;
644         this->value = value;
645 }
646 int TIFFCompressionItem::handle_event()
647 {
648         gui->asset->tiff_compression = value;
649         return 0;
650 }
651