ac3_bitrate = 128;
png_use_alpha = 0;
+ png_depth = 8;
+ png_compression = 0;
exr_use_alpha = 0;
exr_compression = 0;
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;
}
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);
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);
// for jpeg compression
int jpeg_quality;
+
// for mpeg video compression
int vmpeg_iframe_distance;
int vmpeg_progressive;
// PNG video compression
int png_use_alpha;
-
+ int png_depth;
+ int png_compression;
// EXR video compression
int exr_use_alpha;
int exr_compression;
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;
}
#include "asset.h"
#include "bcsignals.h"
#include "clip.h"
+#include "file.h"
#include "fileexr.h"
#include "filesystem.h"
#include "interlacemodes.h"
}
-
-
-
-
-
-
-
-
-
EXROStream::EXROStream(VFrame *data)
: Imf::OStream("mypath")
{
}
-
-
-
-
-
-
-
-
-
FileEXR::FileEXR(Asset *asset, File *file)
: FileList(asset, file, "EXRLIST", ".exr", FILE_EXR, FILE_EXR_LIST)
{
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)
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();
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()
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),
2,
2));
}
- else
- {
+ else {
framebuffer.insert("R", Imf::Slice(Imf::FLOAT,
(char*)(&rows[-dy][-dx * components]),
sizeof(float) * components,
}
// 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,
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;
}
-
-
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(),
}
-
-
-
-
-
-
-
-
-
-
EXRUnit::EXRUnit(FileEXR *file, FrameWriter *writer)
: FrameWriterUnit(writer)
{
}
-
-
-
-
-
-
-
-
-
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),
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()
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
{
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
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" : "");
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;
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);
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);
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();
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"))
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);
+}
+
#include "file.inc"
#include "filebase.h"
#include "filelist.h"
+#include "filepng.inc"
#include "vframe.inc"
+
class FilePNG : public FileList
{
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:
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
#define FILEPNG_INC
class FilePNG;
+class PNGUnit;
+class PNGConfigVideo;
+class PNGUseAlpha;
+class PNGCompression;
+class PNGDepth8bit;
+class PNGDepth16bit;
#endif
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";
}
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);
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,
// (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(),
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);
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;
}
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))
{
return 0;
}
-
-
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
{
};
-
-
class TIFFConfigVideo : public BC_Window
{
public:
int value;
};
-
-
-
class TIFFCompression : public BC_PopupMenu
{
public:
int value;
};
-
-
-
-
#endif
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 ) {
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
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)
$(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))