andrew file-exr/png/tiff mods, png add depth/compression, exr add b44-dwab, tiff...
authorGood Guy <good1.2guy@gmail.com>
Tue, 17 Mar 2020 19:54:58 +0000 (13:54 -0600)
committerGood Guy <good1.2guy@gmail.com>
Tue, 17 Mar 2020 19:54:58 +0000 (13:54 -0600)
13 files changed:
cinelerra-5.1/cinelerra/asset.C
cinelerra-5.1/cinelerra/asset.h
cinelerra-5.1/cinelerra/dvdcreate.C
cinelerra-5.1/cinelerra/fileexr.C
cinelerra-5.1/cinelerra/fileexr.h
cinelerra-5.1/cinelerra/filempeg.C
cinelerra-5.1/cinelerra/filepng.C
cinelerra-5.1/cinelerra/filepng.h
cinelerra-5.1/cinelerra/filepng.inc
cinelerra-5.1/cinelerra/filetiff.C
cinelerra-5.1/cinelerra/filetiff.h
cinelerra-5.1/cinelerra/render.C
cinelerra-5.1/thirdparty/Makefile

index fd6e97e4436f738e172c4215ecf034655c52c885..fe169cbcd0d2623332b85f0135350ff39d72d388 100644 (file)
@@ -133,6 +133,8 @@ int Asset::init_values()
        ac3_bitrate = 128;
 
        png_use_alpha = 0;
+       png_depth = 8;
+       png_compression = 0;
 
        exr_use_alpha = 0;
        exr_compression = 0;
@@ -279,13 +281,14 @@ void Asset::copy_format(Asset *asset, int do_index)
        ac3_bitrate = asset->ac3_bitrate;
 
        png_use_alpha = asset->png_use_alpha;
+       png_depth = asset->png_depth;
+       png_compression = asset->png_compression;
        exr_use_alpha = asset->exr_use_alpha;
        exr_compression = asset->exr_compression;
 
        tiff_cmodel = asset->tiff_cmodel;
        tiff_compression = asset->tiff_compression;
-       
-       
+
        mov_sphere = asset->mov_sphere;
        jpeg_sphere = asset->jpeg_sphere;
 }
@@ -803,6 +806,8 @@ void Asset::load_defaults(BC_Hash *defaults,
        ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
 
        png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
+       png_depth = GET_DEFAULT("PNG_DEPTH", png_depth);
+       png_compression = GET_DEFAULT("PNG_COMPRESSION", png_compression);
        exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
        exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
        tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
@@ -899,6 +904,8 @@ void Asset::save_defaults(BC_Hash *defaults,
 
 
                UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
+               UPDATE_DEFAULT("PNG_DEPTH", png_depth);
+               UPDATE_DEFAULT("PNG_COMPRESSION", png_compression);
                UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
                UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
                UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
index 096ea9882a0f58b0d0067a7adb074792cf1a527e..92b15794ced82f6f31a2144c87ad78c114564cf4 100644 (file)
@@ -189,6 +189,7 @@ public:
 // for jpeg compression
        int jpeg_quality;
 
+
 // for mpeg video compression
        int vmpeg_iframe_distance;
        int vmpeg_progressive;
@@ -220,7 +221,8 @@ public:
 
 // PNG video compression
        int png_use_alpha;
-
+       int png_depth;
+       int png_compression;
 // EXR video compression
        int exr_use_alpha;
        int exr_compression;
index f4587fc682d8d499cdd42bdc7df0db741f4656ea..adeb8df59b2a0e3a5e9436afe003bfb346835647 100644 (file)
@@ -177,7 +177,7 @@ char *DVD_BatchRenderJob::create_script(EDL *edl, ArrayList<Indexable *> *idxbls
        int file_seq = farmed || labeled ? 1 : 0;
        if( !muxed ) {
                if( file_seq ) {
-                       fprintf(fp, "cat > $dir/dvd.m2v $dir/dvd.m2v0*\n");
+                       fprintf(fp, "cat > $dir/dvd.m2v $dir/dvd.m2v[0-9]*\n");
                        fprintf(fp, "mplex -M -f 8 -o $dir/dvd.mpg $dir/dvd.m2v $dir/dvd.ac3\n");
                        file_seq = 0;
                }
index 998372b50f1d10c4f341dc64232e901701fdc6d8..e84ef84d4bcc68987942b1d035b05575f91c16ee 100644 (file)
@@ -24,6 +24,7 @@
 #include "asset.h"
 #include "bcsignals.h"
 #include "clip.h"
+#include "file.h"
 #include "fileexr.h"
 #include "filesystem.h"
 #include "interlacemodes.h"
@@ -120,15 +121,6 @@ void EXRIStream::clear()
 }
 
 
-
-
-
-
-
-
-
-
-
 EXROStream::EXROStream(VFrame *data)
  : Imf::OStream("mypath")
 {
@@ -160,15 +152,6 @@ void EXROStream::seekp(Imf::Int64 pos)
 }
 
 
-
-
-
-
-
-
-
-
-
 FileEXR::FileEXR(Asset *asset, File *file)
  : FileList(asset, file, "EXRLIST", ".exr", FILE_EXR, FILE_EXR_LIST)
 {
@@ -181,54 +164,58 @@ FileEXR::FileEXR(Asset *asset, File *file)
 
 FileEXR::~FileEXR()
 {
-       if(temp_y) delete [] temp_y;
-       if(temp_u) delete [] temp_u;
-       if(temp_v) delete [] temp_v;
+       delete [] temp_y;
+       delete [] temp_u;
+       delete [] temp_v;
 }
 
 const char* FileEXR::compression_to_str(int compression)
 {
-       switch(compression)
-       {
-               case FileEXR::NONE: return "None"; break;
-               case FileEXR::PIZ: return "PIZ"; break;
-               case FileEXR::ZIP: return "ZIP"; break;
-               case FileEXR::ZIPS: return "ZIPS"; break;
-               case FileEXR::RLE: return "RLE"; break;
-               case FileEXR::PXR24: return "PXR24"; break;
+       switch( compression ) {
+       case NONE:      break;
+       case PIZ:       return "PIZ";
+       case ZIP:       return "ZIP";
+       case ZIPS:      return "ZIPS";
+       case RLE:       return "RLE";
+       case PXR24:     return "PXR24";
+       case B44:       return "B44";
+       case B44A:      return "B44A";
+       case DWAB:      return "DWAB";
+       case DWAA:      return "DWAA";
        }
        return _("None");
 }
 
 int FileEXR::compression_to_exr(int compression)
 {
-       switch(compression)
-       {
-               case FileEXR::NONE: return (int)Imf::NO_COMPRESSION; break;
-               case FileEXR::PIZ: return (int)Imf::PIZ_COMPRESSION; break;
-               case FileEXR::ZIP: return (int)Imf::ZIP_COMPRESSION; break;
-               case FileEXR::ZIPS: return (int)Imf::ZIPS_COMPRESSION; break;
-               case FileEXR::RLE: return (int)Imf::RLE_COMPRESSION; break;
-               case FileEXR::PXR24: return (int)Imf::PXR24_COMPRESSION; break;
+       switch( compression ) {
+       case NONE:      return Imf::NO_COMPRESSION;
+       case PIZ:       return Imf::PIZ_COMPRESSION;
+       case ZIP:       return Imf::ZIP_COMPRESSION;
+       case ZIPS:      return Imf::ZIPS_COMPRESSION;
+       case RLE:       return Imf::RLE_COMPRESSION;
+       case PXR24:     return Imf::PXR24_COMPRESSION;
+       case B44:       return Imf::B44_COMPRESSION;
+       case B44A:      return Imf::B44A_COMPRESSION;
+       case DWAA:      return Imf::DWAA_COMPRESSION;
+       case DWAB:      return Imf::DWAB_COMPRESSION;
        }
        return Imf::NO_COMPRESSION;
 }
 
 int FileEXR::str_to_compression(char *string)
 {
-       if(!strcmp(compression_to_str(FileEXR::NONE), string))
-               return FileEXR::NONE;
-       if(!strcmp(compression_to_str(FileEXR::PIZ), string))
-               return FileEXR::PIZ;
-       if(!strcmp(compression_to_str(FileEXR::ZIP), string))
-               return FileEXR::ZIP;
-       if(!strcmp(compression_to_str(FileEXR::ZIPS), string))
-               return FileEXR::ZIPS;
-       if(!strcmp(compression_to_str(FileEXR::RLE), string))
-               return FileEXR::RLE;
-       if(!strcmp(compression_to_str(FileEXR::PXR24), string))
-               return PXR24;
-       return FileEXR::NONE;
+       if( !strcmp(compression_to_str(NONE), string) ) return NONE;
+       if( !strcmp(compression_to_str(PIZ), string)  ) return PIZ;
+       if( !strcmp(compression_to_str(ZIP), string)  ) return ZIP;
+       if( !strcmp(compression_to_str(ZIPS), string) ) return ZIPS;
+       if( !strcmp(compression_to_str(RLE), string)  ) return RLE;
+       if( !strcmp(compression_to_str(RLE), string)  ) return B44;
+       if( !strcmp(compression_to_str(RLE), string)  ) return B44A;
+       if( !strcmp(compression_to_str(RLE), string)  ) return DWAA;
+       if( !strcmp(compression_to_str(RLE), string)  ) return DWAB;
+       if( !strcmp(compression_to_str(PXR24),string) ) return PXR24;
+       return NONE;
 }
 
 int FileEXR::check_sig(Asset *asset, char *test)
@@ -247,8 +234,7 @@ void FileEXR::get_parameters(BC_WindowBase *parent_window,
        Asset *asset, BC_WindowBase* &format_window,
        int audio_options, int video_options, EDL *edl)
 {
-       if(video_options)
-       {
+       if( video_options ) {
                EXRConfigVideo *window = new EXRConfigVideo(parent_window, asset);
                format_window = window;
                window->create_objects();
@@ -264,10 +250,7 @@ int FileEXR::colormodel_supported(int colormodel)
 
 int FileEXR::get_best_colormodel(Asset *asset, int driver)
 {
-       if(asset->exr_use_alpha)
-               return BC_RGBA_FLOAT;
-       else
-               return BC_RGB_FLOAT;
+       return asset->exr_use_alpha ? BC_RGBA_FLOAT : BC_RGB_FLOAT;
 }
 
 int64_t FileEXR::get_memory_usage()
@@ -328,20 +311,19 @@ int FileEXR::read_frame_header(char *path)
 
 int FileEXR::read_frame(VFrame *frame, VFrame *data)
 {
+       Imf::setGlobalThreadCount(file->cpus);
        EXRIStream exr_stream((char*)data->get_data(), data->get_compressed_size());
        Imf::InputFile file(exr_stream);
        Imath::Box2i dw = file.header().dataWindow();
-    int dx = dw.min.x;
-    int dy = dw.min.y;
+       int dx = dw.min.x, dy = dw.min.y;
        Imf::FrameBuffer framebuffer;
        float **rows = (float**)frame->get_rows();
        int components = BC_CModels::components(frame->get_color_model());
 
-       if(is_yuv)
-       {
-               if(!temp_y) temp_y = new float[asset->width * asset->height];
-               if(!temp_u) temp_u = new float[asset->width * asset->height / 4];
-               if(!temp_v) temp_v = new float[asset->width * asset->height / 4];
+       if( is_yuv ) {
+               if( !temp_y ) temp_y = new float[asset->width * asset->height];
+               if( !temp_u ) temp_u = new float[asset->width * asset->height / 4];
+               if( !temp_v ) temp_v = new float[asset->width * asset->height / 4];
                framebuffer.insert("Y", Imf::Slice(Imf::FLOAT,
                        (char*)(temp_y - dy * asset->width - dx),
                        sizeof(float),
@@ -359,8 +341,7 @@ int FileEXR::read_frame(VFrame *frame, VFrame *data)
                        2,
                        2));
        }
-       else
-       {
+       else {
                framebuffer.insert("R", Imf::Slice(Imf::FLOAT,
                        (char*)(&rows[-dy][-dx * components]),
                        sizeof(float) * components,
@@ -376,8 +357,7 @@ int FileEXR::read_frame(VFrame *frame, VFrame *data)
        }
 
 // Alpha always goes directly to the output frame
-       if(components == 4)
-       {
+       if( components == 4 ) {
                framebuffer.insert("A", Imf::Slice(Imf::FLOAT,
                        (char*)(&rows[-dy][-dx * components + 3]),
                        sizeof(float) * components,
@@ -387,23 +367,20 @@ int FileEXR::read_frame(VFrame *frame, VFrame *data)
        file.setFrameBuffer(framebuffer);
        file.readPixels (dw.min.y, dw.max.y);
 
-       if(is_yuv)
-       {
+       if( is_yuv ) {
 // Convert to RGB using crazy ILM equations
                Imath::V3f yw;
                Imf::Chromaticities cr;
                yw = Imf::RgbaYca::computeYw(cr);
 
-               for(int i = 0; i < asset->height - 1; i += 2)
-               {
+               for( int i=0; i<asset->height-1; i+=2 ) {
                        float *y_row1 = temp_y + i * asset->width;
                        float *y_row2 = temp_y + (i + 1) * asset->width;
                        float *u_row = temp_u + (i * asset->width / 4);
                        float *v_row = temp_v + (i * asset->width / 4);
                        float *out_row1 = rows[i];
                        float *out_row2 = rows[i + 1];
-                       for(int j = 0; j < asset->width - 1; j += 2)
-                       {
+                       for( int j=0; j<asset->width-1; j+=2 ) {
                                float v = *u_row++;
                                float u = *v_row++;
                                float y;
@@ -451,22 +428,19 @@ int FileEXR::read_frame(VFrame *frame, VFrame *data)
 }
 
 
-
-
 int FileEXR::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
 {
        EXRUnit *exr_unit = (EXRUnit*)unit;
 
        VFrame *output_frame;
        data->set_compressed_size(0);
-
+       Imf::setGlobalThreadCount(file->cpus);
 
        int native_cmodel = asset->exr_use_alpha ? BC_RGBA_FLOAT : BC_RGB_FLOAT;
        int components = BC_CModels::components(native_cmodel);
 
-       if(frame->get_color_model() != native_cmodel)
-       {
-               if(!exr_unit->temp_frame) exr_unit->temp_frame =
+       if( frame->get_color_model() != native_cmodel ) {
+               if( !exr_unit->temp_frame ) exr_unit->temp_frame =
                        new VFrame(asset->width, asset->height, native_cmodel, 0);
                BC_CModels::transfer(exr_unit->temp_frame->get_rows(), /* Leave NULL if non existent */
                        frame->get_rows(),
@@ -538,16 +512,6 @@ FrameWriterUnit* FileEXR::new_writer_unit(FrameWriter *writer)
 }
 
 
-
-
-
-
-
-
-
-
-
-
 EXRUnit::EXRUnit(FileEXR *file, FrameWriter *writer)
  : FrameWriterUnit(writer)
 {
@@ -561,15 +525,6 @@ EXRUnit::~EXRUnit()
 }
 
 
-
-
-
-
-
-
-
-
-
 EXRConfigVideo::EXRConfigVideo(BC_WindowBase *parent_window, Asset *asset)
  : BC_Window(_(PROGRAM_NAME ": Video Compression"),
        parent_window->get_abs_cursor_x(1), parent_window->get_abs_cursor_y(1),
@@ -634,6 +589,10 @@ void EXRCompression::create_objects()
        add_item(new EXRCompressionItem(gui, FileEXR::ZIPS));
        add_item(new EXRCompressionItem(gui, FileEXR::RLE));
        add_item(new EXRCompressionItem(gui, FileEXR::PXR24));
+       add_item(new EXRCompressionItem(gui, FileEXR::B44));
+       add_item(new EXRCompressionItem(gui, FileEXR::B44A));
+       add_item(new EXRCompressionItem(gui, FileEXR::DWAA));
+       add_item(new EXRCompressionItem(gui, FileEXR::DWAB));
 }
 
 int EXRCompression::handle_event()
index 3e474891d0f406c770d386837f7a9c657b67c242..5f5b251e6ab4f118f009bf6c24b7b51119fdfe20 100644 (file)
@@ -48,25 +48,16 @@ public:
        FrameWriterUnit* new_writer_unit(FrameWriter *writer);
 
 // exr_compression values
-       enum
-       {
-               NONE,
-               PIZ,
-               ZIP,
-               ZIPS,
-               RLE,
-               PXR24
-       };
+       enum { NONE,
+               PIZ, ZIP, ZIPS, RLE, PXR24,
+               B44, B44A, DWAA, DWAB, };
 
        static const char* compression_to_str(int compression);
        static int str_to_compression(char *string);
        static int compression_to_exr(int compression);
 
-       int native_cmodel;
-       int is_yuv;
-       float *temp_y;
-       float *temp_u;
-       float *temp_v;
+       int native_cmodel, is_yuv;
+       float *temp_y, *temp_u, *temp_v;
 };
 
 class EXRUnit : public FrameWriterUnit
index bd8da56ba95d07fef27bc697995b505357571d8b..fb4ee731d05c868f41d25fd307b60b9aecdf0109 100644 (file)
@@ -501,10 +501,6 @@ int FileMPEG::open_file(int rd, int wr)
                                {
                                        append_vcommand_line("-a");
 // Square pixels
-                                       if(EQUIV((double)asset->width / asset->height,
-                                               asset->aspect_ratio))
-                                               append_vcommand_line("1");
-                                       else
                                        if(EQUIV(asset->aspect_ratio, 1.333))
                                                append_vcommand_line("2");
                                        else
@@ -513,6 +509,10 @@ int FileMPEG::open_file(int rd, int wr)
                                        else
                                        if(EQUIV(asset->aspect_ratio, 2.11))
                                                append_vcommand_line("4");
+                                       else
+                                       if(EQUIV((double)asset->width / asset->height,
+                                               asset->aspect_ratio))
+                                               append_vcommand_line("1");
                                }
 
                                append_vcommand_line(asset->vmpeg_derivative == 1 ? "-1" : "");
index f6326079eea84e437fdbc19f01f2c009fa080c54..66d45962dee3a919fd87f040e2c5560cbb4e7066 100644 (file)
@@ -102,32 +102,28 @@ int FilePNG::can_copy_from(Asset *asset, int64_t position)
        return 0;
 }
 
-
 int FilePNG::colormodel_supported(int colormodel)
 {
-       if( ((colormodel == BC_RGBA8888)  && (native_cmodel == BC_RGBA16161616)) ||
-           ((colormodel == BC_RGB161616) && (native_cmodel == BC_RGBA16161616)) ||
-            (colormodel == BC_RGB888) || (colormodel == BC_RGBA8888) )
+       if( colormodel == BC_RGB888 || colormodel == BC_RGBA8888 )
+               return colormodel;
+       if( colormodel == BC_RGB161616 && native_cmodel == BC_RGBA16161616 )
                return colormodel;
-       if( (colormodel == BC_RGB161616) && (native_cmodel == BC_RGBA8888) )
-               return BC_RGB888;
        if( native_cmodel >= 0 )
                return native_cmodel;
-       return asset->png_use_alpha ? BC_RGBA8888 : BC_RGB888;
+       int use_16bit = BC_CModels::is_float(colormodel) ||
+                BC_CModels::calculate_max(colormodel) > 255 ? 1 : 0;
+       return BC_CModels::has_alpha(colormodel) ?
+               (use_16bit ? BC_RGBA16161616 : BC_RGBA8888) :
+               (use_16bit ? BC_RGB161616 : BC_RGB888);
 }
 
-
 int FilePNG::get_best_colormodel(Asset *asset, int driver)
 {
-       if(asset->png_use_alpha)
-               return BC_RGBA8888;
-       else
-               return BC_RGB888;
+       return asset->png_depth == 16 ?
+               (asset->png_use_alpha ? BC_RGBA16161616 : BC_RGB161616) :
+               (asset->png_use_alpha ? BC_RGBA8888 : BC_RGB888);
 }
 
-
-
-
 int FilePNG::read_frame_header(char *path)
 {
        int result = 0;
@@ -207,21 +203,19 @@ int FilePNG::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
        PNGUnit *png_unit = (PNGUnit*)unit;
        png_structp png_ptr = 0;
        png_infop info_ptr = 0;
-       VFrame *output_frame;
+       VFrame *output_frame = frame;
        int result = 1;
        data->set_compressed_size(0);
 //printf("FilePNG::write_frame 1\n");
-       native_cmodel = asset->png_use_alpha ? BC_RGBA8888 : BC_RGB888;
-       if(frame->get_color_model() != native_cmodel)
-       {
-               if(!png_unit->temp_frame) png_unit->temp_frame =
-                       new VFrame(asset->width, asset->height, native_cmodel, 0);
-
+       native_cmodel = asset->png_depth == 16 ?
+               (asset->png_use_alpha ?  BC_RGBA16161616 : BC_RGB161616) :
+               (asset->png_use_alpha ?  BC_RGBA8888 : BC_RGB888) ;
+       if( frame->get_color_model() != native_cmodel ) {
+               VFrame::get_temp(png_unit->temp_frame,
+                       asset->width, asset->height, native_cmodel);
                png_unit->temp_frame->transfer_from(frame);
                output_frame = png_unit->temp_frame;
        }
-       else
-               output_frame = frame;
 
 //printf("FilePNG::write_frame 1\n");
        png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
@@ -230,11 +224,13 @@ int FilePNG::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
                        info_ptr = png_create_info_struct(png_ptr);
                        png_set_write_fn(png_ptr, data,
                                (png_rw_ptr)write_function, (png_flush_ptr)flush_function);
-                       png_set_compression_level(png_ptr, 5);
-
-                       png_set_IHDR(png_ptr, info_ptr, asset->width, asset->height, 8,
+                       png_set_compression_level(png_ptr, asset->png_compression);
+                       png_set_IHDR(png_ptr, info_ptr, asset->width, asset->height, asset->png_depth,
                                asset->png_use_alpha ?  PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB,
                                PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+// does not work (gg 2020/03/17 libpng16 fc31)
+//                     if( asset->png_depth == 16 && BC_Resources::little_endian )
+//                             png_set_swap(png_ptr);
                        png_write_info(png_ptr, info_ptr);
                        png_write_image(png_ptr, output_frame->get_rows());
                        png_write_end(png_ptr, info_ptr);
@@ -351,21 +347,39 @@ PNGUnit::~PNGUnit()
 PNGConfigVideo::PNGConfigVideo(BC_WindowBase *parent_window, Asset *asset)
  : BC_Window(_(PROGRAM_NAME ": Video Compression"),
        parent_window->get_abs_cursor_x(1), parent_window->get_abs_cursor_y(1),
-       xS(200), yS(100))
+       xS(240), yS(160))
 {
        this->parent_window = parent_window;
        this->asset = asset;
+       use_alpha = 0;
+       compression = 0;
+       depth8 = 0;
+       depth16 = 0;
 }
 
 PNGConfigVideo::~PNGConfigVideo()
 {
+       delete compression;
 }
 
 void PNGConfigVideo::create_objects()
 {
        lock_window("PNGConfigVideo::create_objects");
-       int x = xS(10), y = yS(10);
-       add_subwindow(new PNGUseAlpha(this, x, y));
+       BC_Title *title;
+       int xs5 = xS(5), ys5 = yS(5), xs10 = xS(10), ys10 = yS(10);
+       int x = xs10, y = ys10;
+       add_subwindow(use_alpha = new PNGUseAlpha(this, x, y));
+       y += use_alpha->get_h() + ys10;
+       add_subwindow(title = new BC_Title(x,y,_("Compression:")));
+       int x1 = x + title->get_w() + xs10;
+       compression = new PNGCompression(this, x1, y);
+       compression->create_objects();
+       y += compression->get_h() + ys5;
+       add_subwindow(title = new BC_Title(x,y,_("Depth:")));
+       x1 = x + title->get_w() + xs10;
+       add_subwindow(depth8 = new PNGDepth8bit(this, x1, y));
+       x1 += depth8->get_w() + xs5;
+       add_subwindow(depth16 = new PNGDepth16bit(this, x1, y));
        add_subwindow(new BC_OKButton(this));
        show_window(1);
        unlock_window();
@@ -377,6 +391,14 @@ int PNGConfigVideo::close_event()
        return 1;
 }
 
+int PNGConfigVideo::update_depth(int depth)
+{
+       asset->png_depth = depth;
+        depth8->update(depth == 8);
+        depth16->update(depth == 16);
+        return 1;
+}
+
 
 PNGUseAlpha::PNGUseAlpha(PNGConfigVideo *gui, int x, int y)
  : BC_CheckBox(x, y, gui->asset->png_use_alpha, _("Use alpha"))
@@ -390,3 +412,38 @@ int PNGUseAlpha::handle_event()
        return 1;
 }
 
+PNGCompression::PNGCompression(PNGConfigVideo *gui, int x, int y)
+ : BC_TumbleTextBox(gui, (int64_t)gui->asset->png_compression,
+       (int64_t)0, (int64_t)9, x, y, xS(40))
+{
+       this->gui = gui;
+}
+
+int PNGCompression::handle_event()
+{
+       gui->asset->png_compression = atol(get_text());
+       return 1;
+}
+
+PNGDepth8bit::PNGDepth8bit(PNGConfigVideo *gui, int x, int y)
+ : BC_Radial(x, y, gui->asset->png_depth==8,_("8 Bit"))
+{
+       this->gui = gui;
+}
+
+int PNGDepth8bit::handle_event()
+{
+       return gui->update_depth(8);
+}
+
+PNGDepth16bit::PNGDepth16bit(PNGConfigVideo *gui, int x, int y)
+ : BC_Radial(x, y, gui->asset->png_depth==16,_("16 Bit"))
+{
+       this->gui = gui;
+}
+
+int PNGDepth16bit::handle_event()
+{
+       return gui->update_depth(16);
+}
+
index 2263bc381a8a526ad77eb700fe6f15dff4ce19b2..42c2e6caec1189d8a9ce900f0a7cb8a8e3a4ecc9 100644 (file)
 #include "file.inc"
 #include "filebase.h"
 #include "filelist.h"
+#include "filepng.inc"
 #include "vframe.inc"
 
+
 class FilePNG : public FileList
 {
 public:
@@ -74,12 +76,16 @@ public:
 
        void create_objects();
        int close_event();
+       int update_depth(int depth);
 
        BC_WindowBase *parent_window;
        Asset *asset;
+       PNGUseAlpha *use_alpha;
+       PNGCompression *compression;
+       PNGDepth8bit *depth8;
+       PNGDepth16bit *depth16;
 };
 
-
 class PNGUseAlpha : public BC_CheckBox
 {
 public:
@@ -88,5 +94,30 @@ public:
        PNGConfigVideo *gui;
 };
 
+class PNGCompression : public BC_TumbleTextBox
+{
+public:
+        PNGCompression(PNGConfigVideo *gui, int x, int y);
+        int handle_event();
+        PNGConfigVideo *gui;
+};
+
+class PNGDepth8bit : public BC_Radial
+{
+public:
+       PNGDepth8bit(PNGConfigVideo *gui, int x, int y);
+       int handle_event();
+
+       PNGConfigVideo *gui;
+};
+
+class PNGDepth16bit : public BC_Radial
+{
+public:
+       PNGDepth16bit(PNGConfigVideo *gui, int x, int y);
+       int handle_event();
+
+       PNGConfigVideo *gui;
+};
 
 #endif
index 0c11ad057df69f1a450b54a6817f66e7c4d6c54d..99498094bb84cee80b1cc2a6c91c20c873c8b904 100644 (file)
 #define FILEPNG_INC
 
 class FilePNG;
+class PNGUnit;
+class PNGConfigVideo;
+class PNGUseAlpha;
+class PNGCompression;
+class PNGDepth8bit;
+class PNGDepth16bit;
 
 #endif
index cde59a0b397fef2e950e7bdd2cf357c8980f7325..7104eed4f7daa4e650b48793976d203c1dd62d6a 100644 (file)
@@ -102,34 +102,34 @@ int FileTIFF::check_sig(Asset *asset)
 
 const char* FileTIFF::compression_to_str(int value)
 {
-       switch(value)
-       {
-               case FileTIFF::NONE: return "None"; break;
-               case FileTIFF::LZW: return "LZW"; break;
-               case FileTIFF::PACK_BITS: return "Pack Bits"; break;
-               case FileTIFF::DEFLATE: return "Deflate"; break;
-               case FileTIFF::JPEG: return "JPEG"; break;
-               default:
-                       return "None";
-                       break;
+       switch( value ) {
+       case FileTIFF::NONE:            break;
+       case FileTIFF::LZW:             return "LZW";
+       case FileTIFF::PACK_BITS:       return "Pack Bits";
+       case FileTIFF::DEFLATE:         return "Deflate";
+       case FileTIFF::JPEG:            return "JPEG";
+       case FileTIFF::PIXARFILM:       return "PIXARFILM";
+       case FileTIFF::PIXARLOG:        return "PIXARLOG";
+       case FileTIFF::JP2000:          return "JP2000";
+       case FileTIFF::SGILOG:          return "SGILOG";
+       case FileTIFF::LZMA:            return "LZMA";
+       case FileTIFF::ADOBE_DEFLATE:   return "Adobe Deflate";
        }
+       return _("None");
 }
 
 const char* FileTIFF::cmodel_to_str(int value)
 {
-       switch(value)
-       {
-               case FileTIFF::GREYSCALE: return "Greyscale"; break;
-               case FileTIFF::RGB_888: return "RGB-8 Bit"; break;
-               case FileTIFF::RGB_161616: return "RGB-16 Bit"; break;
-               case FileTIFF::RGBA_8888: return "RGBA-8 Bit"; break;
-               case FileTIFF::RGBA_16161616: return "RGBA-16 Bit"; break;
-               case FileTIFF::RGB_FLOAT: return "RGB-FLOAT"; break;
-               case FileTIFF::RGBA_FLOAT: return "RGBA-FLOAT"; break;
-               default:
-                       return "RGB-8 Bit";
-                       break;
+       switch( value ) {
+       case FileTIFF::RGB_888:         return "RGB-8 Bit";
+       case FileTIFF::RGB_161616:      return "RGB-16 Bit";
+       case FileTIFF::RGBA_8888:       return "RGBA-8 Bit";
+       case FileTIFF::RGBA_16161616:   return "RGBA-16 Bit";
+       case FileTIFF::RGB_FLOAT:       return "RGB-FLOAT";
+       case FileTIFF::RGBA_FLOAT:      return "RGBA-FLOAT";
+       case FileTIFF::GREYSCALE:       return "Greyscale";
        }
+       return "RGB-8 Bit";
 }
 
 
@@ -404,79 +404,51 @@ int FileTIFF::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
        int components, color_model, bits, compression;
        int sampleformat = SAMPLEFORMAT_UINT;
        //int bytesperrow, type;
-       switch(asset->tiff_cmodel)
-       {
-               case FileTIFF::RGB_888:
-                       components = 3;
-                       color_model = BC_RGB888;
-                       bits = 8;
-                       //type = TIFF_BYTE;
-                       //bytesperrow = 3 * asset->width;
-                       break;
-               case FileTIFF::RGB_161616:
-                       components = 3;
-                       color_model = BC_RGB_FLOAT;
-                       bits = 16;
-                       //type = TIFF_SHORT;
-                       //bytesperrow = 6 * asset->width;
-                       break;
-               case FileTIFF::RGBA_8888:
-                       components = 4;
-                       color_model = BC_RGBA8888;
-                       bits = 8;
-                       //type = TIFF_BYTE;
-                       //bytesperrow = 4 * asset->width;
-                       break;
-               case FileTIFF::RGBA_16161616:
-                       components = 4;
-                       color_model = BC_RGBA_FLOAT;
-                       bits = 16;
-                       //type = TIFF_SHORT;
-                       //bytesperrow = 8 * asset->width;
-                       break;
-               case FileTIFF::RGB_FLOAT:
-                       components = 3;
-                       color_model = BC_RGB_FLOAT;
-                       bits = 32;
-                       //type = TIFF_FLOAT;
-                       sampleformat = SAMPLEFORMAT_IEEEFP;
-                       //bytesperrow = 12 * asset->width;
-                       break;
-               case FileTIFF::RGBA_FLOAT:
-                       components = 4;
-                       color_model = BC_RGBA_FLOAT;
-                       bits = 32;
-                       //type = TIFF_FLOAT;
-                       sampleformat = SAMPLEFORMAT_IEEEFP;
-                       //bytesperrow = 16 * asset->width;
-                       break;
-               default:
-                       components = 3;
-                       color_model = BC_RGB888;
-                       bits = 8;
-                       //type = TIFF_BYTE;
-                       //bytesperrow = 3 * asset->width;
+       switch( asset->tiff_cmodel ) {
+       case FileTIFF::RGB_888:
+               components = 3;  color_model = BC_RGB888;  bits = 8;
+               //type = TIFF_BYTE;  bytesperrow = 3 * asset->width;
+               break;
+       case FileTIFF::RGB_161616:
+               components = 3;  color_model = BC_RGB_FLOAT;  bits = 16;
+               //type = TIFF_SHORT;  bytesperrow = 6 * asset->width;
                        break;
+       case FileTIFF::RGBA_8888:
+               components = 4;  color_model = BC_RGBA8888;  bits = 8;
+               //type = TIFF_BYTE;  bytesperrow = 4 * asset->width;
+               break;
+       case FileTIFF::RGBA_16161616:
+               components = 4;  color_model = BC_RGBA_FLOAT;  bits = 16;
+               //type = TIFF_SHORT;  bytesperrow = 8 * asset->width;
+               break;
+       case FileTIFF::RGB_FLOAT:
+               components = 3;  color_model = BC_RGB_FLOAT;  bits = 32;
+               //type = TIFF_FLOAT;  bytesperrow = 12 * asset->width;
+               sampleformat = SAMPLEFORMAT_IEEEFP;
+               break;
+       case FileTIFF::RGBA_FLOAT:
+               components = 4;  color_model = BC_RGBA_FLOAT;  bits = 32;
+               //type = TIFF_FLOAT;  bytesperrow = 16 * asset->width;
+               sampleformat = SAMPLEFORMAT_IEEEFP;
+               break;
+       default:
+               components = 3;  color_model = BC_RGB888;  bits = 8;
+               //type = TIFF_BYTE;  bytesperrow = 3 * asset->width;
+               break;
        }
 
-
-       switch(asset->tiff_compression)
-       {
-               case FileTIFF::LZW:
-                       compression = COMPRESSION_LZW;
-                       break;
-               case FileTIFF::PACK_BITS:
-                       compression = COMPRESSION_PACKBITS;
-                       break;
-               case FileTIFF::DEFLATE:
-                       compression = COMPRESSION_DEFLATE;
-                       break;
-               case FileTIFF::JPEG:
-                       compression = COMPRESSION_JPEG;
-                       break;
-               default:
-                       compression = COMPRESSION_NONE;
-                       break;
+       switch(asset->tiff_compression) {
+       case FileTIFF::LZW:           compression = COMPRESSION_LZW;        break;
+       case FileTIFF::PACK_BITS:     compression = COMPRESSION_PACKBITS;   break;
+       case FileTIFF::DEFLATE:       compression = COMPRESSION_DEFLATE;    break;
+       case FileTIFF::JPEG:          compression = COMPRESSION_JPEG;       break;
+       case FileTIFF::PIXARFILM:     compression = COMPRESSION_PIXARFILM;  break;
+       case FileTIFF::PIXARLOG:      compression = COMPRESSION_PIXARLOG;   break;
+       case FileTIFF::JP2000:        compression = COMPRESSION_JP2000;     break;
+       case FileTIFF::LZMA:          compression = COMPRESSION_LZMA;       break;
+       case FileTIFF::SGILOG:        compression = COMPRESSION_SGILOG;     break;
+       case FileTIFF::ADOBE_DEFLATE: compression = ADOBE_DEFLATE;          break;
+       default:                      compression = COMPRESSION_NONE;       break;
        }
 
        TIFFSetField(stream, TIFFTAG_IMAGEWIDTH, asset->width);
@@ -484,7 +456,11 @@ int FileTIFF::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
        TIFFSetField(stream, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
        TIFFSetField(stream, TIFFTAG_SAMPLESPERPIXEL, components);
        TIFFSetField(stream, TIFFTAG_BITSPERSAMPLE, bits);
-    TIFFSetField(stream, TIFFTAG_SAMPLEFORMAT, sampleformat);
+        TIFFSetField(stream, TIFFTAG_SAMPLEFORMAT, sampleformat);
+        if( components == 4 ) {
+               uint16 out[1];  out[0] = EXTRASAMPLE_UNASSALPHA;
+               TIFFSetField(stream, TIFFTAG_EXTRASAMPLES, 1, &out);
+       }
        TIFFSetField(stream, TIFFTAG_COMPRESSION, compression);
        TIFFSetField(stream, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
        TIFFSetField(stream, TIFFTAG_ROWSPERSTRIP,
@@ -493,26 +469,17 @@ int FileTIFF::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
 //             (8 * 1024) / bytesperrow);
        TIFFSetField(stream, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
 
-       if(frame->get_color_model() == color_model)
-       {
-               for(int i = 0; i < asset->height; i++)
-               {
-                       TIFFWriteScanline(stream, frame->get_rows()[i], i, 0);
-               }
+       if( frame->get_color_model() == color_model ) {
+               for( int y=0; y<asset->height; ++y )
+                       TIFFWriteScanline(stream, frame->get_rows()[y], y, 0);
        }
-       else
-       {
-               if(tiff_unit->temp &&
-                       tiff_unit->temp->get_color_model() != color_model)
-               {
-                       delete tiff_unit->temp;
-                       tiff_unit->temp = 0;
-               }
-               if(!tiff_unit->temp)
-               {
-                       tiff_unit->temp =
-                               new VFrame(asset->width, asset->height, color_model, 0);
+       else {
+               if( tiff_unit->temp &&
+                   tiff_unit->temp->get_color_model() != color_model ) {
+                       delete tiff_unit->temp;  tiff_unit->temp = 0;
                }
+               if( !tiff_unit->temp )
+                       tiff_unit->temp = new VFrame(asset->width, asset->height, color_model, 0);
 
                BC_CModels::transfer(tiff_unit->temp->get_rows(), frame->get_rows(),
                        tiff_unit->temp->get_y(), tiff_unit->temp->get_u(), tiff_unit->temp->get_v(),
@@ -521,10 +488,8 @@ int FileTIFF::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
                        0, 0, frame->get_w(), frame->get_h(),
                        frame->get_color_model(), color_model,
                        0, frame->get_w(), frame->get_w());
-               for(int i = 0; i < asset->height; i++)
-               {
-                       TIFFWriteScanline(stream, tiff_unit->temp->get_rows()[i], i, 0);
-               }
+               for( int y=0; y<asset->height; ++y )
+                       TIFFWriteScanline(stream, tiff_unit->temp->get_rows()[y], y, 0);
        }
 
        TIFFClose(stream);
@@ -604,10 +569,7 @@ int TIFFConfigVideo::close_event()
 
 
 TIFFColorspace::TIFFColorspace(TIFFConfigVideo *gui, int x, int y, int w)
- : BC_PopupMenu(x,
-       y,
-       w,
-       FileTIFF::cmodel_to_str(gui->asset->tiff_cmodel))
+ : BC_PopupMenu(x, y, w, FileTIFF::cmodel_to_str(gui->asset->tiff_cmodel))
 {
        this->gui = gui;
 }
@@ -656,16 +618,19 @@ int TIFFCompression::handle_event()
 void TIFFCompression::create_objects()
 {
        add_item(new TIFFCompressionItem(gui, FileTIFF::NONE));
-//     add_item(new TIFFCompressionItem(gui, FileTIFF::LZW));
+       add_item(new TIFFCompressionItem(gui, FileTIFF::LZW)); // patent expired in 2004 ?
        add_item(new TIFFCompressionItem(gui, FileTIFF::PACK_BITS));
-//     add_item(new TIFFCompressionItem(gui, FileTIFF::DEFLATE));
+       add_item(new TIFFCompressionItem(gui, FileTIFF::DEFLATE)); // works!
+//     add_item(new TIFFCompressionItem(gui, FileTIFF::SGILOG));  scanline encoding not implemented
+       add_item(new TIFFCompressionItem(gui, FileTIFF::LZMA)); // works, a bit new for data exchange?
+//     add_item(new TIFFCompressionItem(gui, FileTIFF::ADOBE_DEFLATE)); scanline encoding not implemented
+//     add_item(new TIFFCompressionItem(gui, FileTIFF::PIXARFILM)); not supported for scanline encoding
+//     add_item(new TIFFCompressionItem(gui, FileTIFF::PIXARLOG)); only 8 bit ?
+//     add_item(new TIFFCompressionItem(gui, FileTIFF::JP2000)); doesn't support scanline encoding
 //     add_item(new TIFFCompressionItem(gui, FileTIFF::JPEG));
 }
 
 
-
-
-
 TIFFCompressionItem::TIFFCompressionItem(TIFFConfigVideo *gui, int value)
  : BC_MenuItem(FileTIFF::compression_to_str(value))
 {
@@ -678,5 +643,3 @@ int TIFFCompressionItem::handle_event()
        return 0;
 }
 
-
-
index 321ea9be91f354fa6a851ed27eb9f917772a3c6b..5362c323788bffa9b37bef7b22666b66d3879e8e 100644 (file)
@@ -53,30 +53,21 @@ public:
        int write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit);
        FrameWriterUnit* new_writer_unit(FrameWriter *writer);
 
-       enum
-       {
-               NONE,
+       enum { NONE,
 // values stored in Asset::tiff_cmodel
 // Data types
-               RGB_888,
-               RGB_161616,
-               RGBA_8888,
-               RGBA_16161616,
-               RGB_FLOAT,
-               RGBA_FLOAT,
-               GREYSCALE,
+               RGB_888, RGB_161616, RGBA_8888, RGBA_16161616,
+               RGB_FLOAT, RGBA_FLOAT, GREYSCALE,
 // values stored in Asset::tiff_compression
 // Compression types
-               LZW,
-               PACK_BITS,
-               DEFLATE,
-               JPEG
+               LZW, PACK_BITS, DEFLATE, JPEG,
+               PIXARFILM, PIXARLOG, JP2000, ADOBE_DEFLATE,
+               SGILOG, LZMA
        };
 
        Mutex *unit_lock;
 };
 
-
 // For each write frame call, since multiple write_frames are running concurrently.
 class FileTIFFUnit : public FrameWriterUnit
 {
@@ -91,8 +82,6 @@ public:
 };
 
 
-
-
 class TIFFConfigVideo : public  BC_Window
 {
 public:
@@ -127,9 +116,6 @@ public:
        int value;
 };
 
-
-
-
 class TIFFCompression : public BC_PopupMenu
 {
 public:
@@ -148,8 +134,4 @@ public:
        int value;
 };
 
-
-
-
-
 #endif
index 17f8f0a02fd48158e035613bc56da97d054d320f..746b41879f3fd25bdb4c92d63f897d6f031a1bc0 100644 (file)
@@ -733,8 +733,8 @@ void RenderThread::render_single(int test_overwrite, Asset *asset, EDL *edl,
                        render->result = 1;
                }
        }
-
-       render_frames = render->default_asset->frame_rate * total_length;
+// prevent single frame truncation to zero frames
+       render_frames = render->default_asset->frame_rate * total_length + 1e-4;
 
 // Generate packages
        if( !render->result ) {
index 5727aadd84114a264f1534485e83c20bbc17f35b..5315237e099d9ef27fdfcb78e9120d8ff7ab0eb5 100644 (file)
@@ -61,6 +61,10 @@ inc_path=$(call if_pkg,$(1),$(inc_$(1)), $(call pkg_conf,$(1),--cflags))
 ld_path=$(call if_pkg,$(1),-L$(call bld_path,$(1),$(2)) $(lib_$(1)))
 if_ena=$(if $(or $(ver_$(1)),$(filter $(1),$(shared_pkgs))),$(2))
 if_want=$(if $(filter x$(WANT_$(1)),xyes),$(2),$(3))
+sysincs:=usr/include usr/local/include
+syslibs:=usr/lib usr/lib32 usr/lib64 lib lib32 lib64 usr/local/lib usr/local/lib32 usr/local/lib64
+pkg_incl=$(lastword $(wildcard $(foreach f,$(sysincs), $(call bld_path,$(1),$(f)))))
+pkg_libs=$(lastword $(wildcard $(foreach f,$(syslibs), $(call bld_path,$(1),$(f)))))
 
 #$(eval $(call std-build,pkg,deps...))
 #$(pkg.cflags) added as CFLAGS+=$(cflags) to pkg.vars
@@ -241,7 +245,10 @@ opencv.cfg_params?= -DBUILD_SHARED_LIBS:BOOL=OFF
 openexr.cfg_vars?=LD_LIBRARY_PATH=$(call bld_path,ilmbase,usr/lib)
 openexr.cfg_params?=--enable-shared=no --with-ilmbase-prefix=$(call bld_path,ilmbase,usr)
 speech_tools.mak_params?=-j1
-tiff.cfg_params+= --enable-shared=no --disable-zstd $(call if_npkg,libwebp,--without-webp)
+tiff.cfg_vars+=LIBS+=" -lpthread"
+tiff.cfg_params+= --enable-shared=no --disable-zstd $(call if_pkg,libwebp,\
+ --with-webp-include-dir=$(call pkg_incl,libwebp)\
+ --with-webp-lib-dir=$(call pkg_libs,libwebp))
 twolame.cfg_params?=--enable-shared=no
 x264.cfg_params?= --enable-static --enable-pic
 x265.cfg_vars?=$(call cmake_config,source)
@@ -343,7 +350,7 @@ $(call rules,$(call std-build,openexr, ilmbase))
 $(call rules,$(call std-build,openjpeg))
 $(call rules,$(call std-build,opus))
 $(call rules,$(call std-build,speech_tools))
-$(call rules,$(call std-build,tiff))
+$(call rules,$(call std-build,tiff, libwebp))
 $(call rules,$(call std-build,twolame))
 $(call rules,$(call std-build,x264))
 $(call rules,$(call std-build,x265))