File::~File()
{
- if(getting_options)
- {
- if(format_window) format_window->set_done(0);
+ if( getting_options ) {
+ if( format_window ) format_window->set_done(0);
format_completion->lock("File::~File");
format_completion->unlock();
}
- if(temp_frame) delete temp_frame;
+ if( temp_frame ) delete temp_frame;
close_file(0);
int File::raise_window()
{
- if(getting_options && format_window)
- {
+ if( getting_options && format_window ) {
format_window->raise_window();
format_window->flush();
}
void File::close_window()
{
- if(getting_options)
- {
+ if( getting_options ) {
format_window->lock_window("File::close_window");
format_window->set_done(1);
format_window->unlock_window();
getting_options = 1;
format_completion->lock("File::get_options");
- switch(asset->format)
- {
- case FILE_AC3:
- FileAC3::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
+ switch( asset->format ) {
+ case FILE_AC3:
+ FileAC3::get_parameters(parent_window,
+ asset,
+ format_window,
+ audio_options,
+ video_options);
+ break;
#ifdef HAVE_DV
- case FILE_RAWDV:
- FileDV::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
+ case FILE_RAWDV:
+ FileDV::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
#endif
- case FILE_PCM:
- case FILE_WAV:
- case FILE_AU:
- case FILE_AIFF:
- case FILE_SND:
- FileSndFile::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
- case FILE_FFMPEG:
- FileFFMPEG::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
- case FILE_AMPEG:
- case FILE_VMPEG:
- FileMPEG::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
- case FILE_JPEG:
- case FILE_JPEG_LIST:
- FileJPEG::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
+ case FILE_PCM:
+ case FILE_WAV:
+ case FILE_AU:
+ case FILE_AIFF:
+ case FILE_SND:
+ FileSndFile::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
+ case FILE_FFMPEG:
+ FileFFMPEG::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
+ case FILE_AMPEG:
+ case FILE_VMPEG:
+ FileMPEG::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
+ case FILE_JPEG:
+ case FILE_JPEG_LIST:
+ FileJPEG::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
#ifdef HAVE_OPENEXR
- case FILE_EXR:
- case FILE_EXR_LIST:
- FileEXR::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
+ case FILE_EXR:
+ case FILE_EXR_LIST:
+ FileEXR::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
#endif
- case FILE_FLAC:
- FileFLAC::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
- case FILE_PNG:
- case FILE_PNG_LIST:
- FilePNG::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
- case FILE_TGA:
- case FILE_TGA_LIST:
- FileTGA::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
- case FILE_TIFF:
- case FILE_TIFF_LIST:
- FileTIFF::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
- case FILE_OGG:
- FileOGG::get_parameters(parent_window,
- asset,
- format_window,
- audio_options,
- video_options);
- break;
- default:
- break;
+ case FILE_FLAC:
+ FileFLAC::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
+ case FILE_PNG:
+ case FILE_PNG_LIST:
+ FilePNG::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
+ case FILE_TGA:
+ case FILE_TGA_LIST:
+ FileTGA::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
+ case FILE_TIFF:
+ case FILE_TIFF_LIST:
+ FileTIFF::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
+ case FILE_OGG:
+ FileOGG::get_parameters(parent_window, asset, format_window,
+ audio_options, video_options);
+ break;
+ default:
+ break;
}
- if(!format_window)
- {
+ if( !format_window ) {
ErrorBox *errorbox = new ErrorBox(_(PROGRAM_NAME ": Error"),
parent_window->get_abs_cursor_x(1),
parent_window->get_abs_cursor_y(1));
format_window = errorbox;
getting_options = 1;
- if(audio_options)
+ if( audio_options )
errorbox->create_objects(_("This format doesn't support audio."));
else
- if(video_options)
+ if( video_options )
errorbox->create_objects(_("This format doesn't support video."));
errorbox->run_window();
delete errorbox;
void File::set_cache_frames(int value)
{
// caching only done locally
- if(!video_thread)
+ if( !video_thread )
use_cache = value;
}
{
// caching only done locally
int result = 0;
- if( frame_cache->cache_items() > 0 )
- {
+ if( frame_cache->cache_items() > 0 ) {
frame_cache->remove_all();
result = 1;
}
this->wr = wr;
file = 0;
- if(debug) printf("File::open_file %d\n", __LINE__);
+ if( debug ) printf("File::open_file %d\n", __LINE__);
- if(debug) printf("File::open_file %p %d\n", this, __LINE__);
+ if( debug ) printf("File::open_file %p %d\n", this, __LINE__);
- switch(this->asset->format) {
+ switch( this->asset->format ) {
// get the format now
// If you add another format to case 0, you also need to add another case for the
// file format #define.
// Reopen file with correct parser and get header.
- if(file->open_file(rd, wr)) {
+ if( file->open_file(rd, wr) ) {
delete file; file = 0;
return FILE_NOT_FOUND;
}
// Set extra writing parameters to mandatory settings.
if( wr ) {
- if(this->asset->dither) file->set_dither();
+ if( this->asset->dither ) file->set_dither();
}
if( rd ) {
asset->copy_from(this->asset, 1);
//asset->dump();
- if(debug) printf("File::open_file %d file=%p\n", __LINE__, file);
+ if( debug ) printf("File::open_file %d file=%p\n", __LINE__, file);
// sleep(1);
return FILE_OK;
void File::delete_temp_samples_buffer()
{
- if(temp_samples_buffer) {
- for(int j = 0; j < audio_ring_buffers; j++) {
- for(int i = 0; i < asset->channels; i++) {
+ if( temp_samples_buffer ) {
+ for( int j = 0; j < audio_ring_buffers; j++ ) {
+ for( int i = 0; i < asset->channels; i++ ) {
delete temp_samples_buffer[j][i];
}
delete [] temp_samples_buffer[j];
void File::delete_temp_frame_buffer()
{
- if(temp_frame_buffer) {
- for(int k = 0; k < video_ring_buffers; k++) {
- for(int i = 0; i < asset->layers; i++) {
- for(int j = 0; j < video_buffer_size; j++) {
+ if( temp_frame_buffer ) {
+ for( int k = 0; k < video_ring_buffers; k++ ) {
+ for( int i = 0; i < asset->layers; i++ ) {
+ for( int j = 0; j < video_buffer_size; j++ ) {
delete temp_frame_buffer[k][i][j];
}
delete [] temp_frame_buffer[k][i];
{
const int debug = 0;
- if(debug) printf("File::close_file file=%p %d\n", file, __LINE__);
+ if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
- if(!ignore_thread) {
+ if( !ignore_thread ) {
stop_audio_thread();
stop_video_thread();
}
- if(debug) printf("File::close_file file=%p %d\n", file, __LINE__);
- if(file) {
+ if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
+ if( file ) {
// The file's asset is a copy of the argument passed to open_file so the
// user must copy lengths from the file's asset.
- if(asset && wr) {
+ if( asset && wr ) {
asset->audio_length = current_sample;
asset->video_length = current_frame;
}
file->close_file();
delete file;
}
- if(debug) printf("File::close_file file=%p %d\n", file, __LINE__);
+ if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
delete_temp_samples_buffer();
delete_temp_frame_buffer();
- if(debug) printf("File::close_file file=%p %d\n", file, __LINE__);
+ if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
- if(debug) printf("File::close_file file=%p %d\n", file, __LINE__);
+ if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
reset_parameters();
- if(debug) printf("File::close_file file=%p %d\n", file, __LINE__);
+ if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
return 0;
}
this->audio_ring_buffers = ring_buffers;
- if(!audio_thread)
- {
+ if( !audio_thread ) {
audio_thread = new FileThread(this, 1, 0);
audio_thread->start_writing(buffer_size, 0, ring_buffers, 0);
}
this->video_ring_buffers = ring_buffers;
this->video_buffer_size = buffer_size;
- if(!video_thread)
- {
+ if( !video_thread ) {
video_thread = new FileThread(this, 0, 1);
video_thread->start_writing(buffer_size,
color_model,
{
// Currently, CR2 is the only one which won't work asynchronously, so
// we're not using a virtual function yet.
- if(!video_thread /* && asset->format != FILE_CR2 */)
- {
+ if( !video_thread /* && asset->format != FILE_CR2 */ ) {
video_thread = new FileThread(this, 0, 1);
video_thread->start_reading();
use_cache = 0;
int File::stop_audio_thread()
{
- if(audio_thread)
- {
+ if( audio_thread ) {
audio_thread->stop_writing();
delete audio_thread;
audio_thread = 0;
int File::stop_video_thread()
{
- if(video_thread)
- {
+ if( video_thread ) {
video_thread->stop_reading();
video_thread->stop_writing();
delete video_thread;
int File::set_channel(int channel)
{
- if(file && channel < asset->channels)
- {
+ if( file && channel < asset->channels ) {
current_channel = channel;
return 0;
}
int File::set_layer(int layer, int is_thread)
{
- if(file && layer < asset->layers)
- {
- if(!is_thread && video_thread)
- {
+ if( file && layer < asset->layers ) {
+ if( !is_thread && video_thread ) {
video_thread->set_layer(layer);
}
- else
- {
+ else {
current_layer = layer;
}
return 0;
{
int64_t result = asset->audio_length;
int64_t base_samplerate = -1;
- if(result > 0)
- {
- if(base_samplerate > 0)
+ if( result > 0 ) {
+ if( base_samplerate > 0 )
return (int64_t)((double)result / asset->sample_rate * base_samplerate + 0.5);
else
return result;
{
int64_t result = asset->video_length;
float base_framerate = -1;
- if(result > 0)
- {
- if(base_framerate > 0)
+ if( result > 0 ) {
+ if( base_framerate > 0 )
return (int64_t)((double)result / asset->frame_rate * base_framerate + 0.5);
else
return result;
int64_t File::get_video_position()
{
float base_framerate = -1;
- if(base_framerate > 0)
+ if( base_framerate > 0 )
return (int64_t)((double)current_frame / asset->frame_rate * base_framerate + 0.5);
else
return current_frame;
int64_t File::get_audio_position()
{
// int64_t base_samplerate = -1;
-// if(base_samplerate > 0)
+// if( base_samplerate > 0 )
// {
-// if(normalized_sample_rate == base_samplerate)
+// if( normalized_sample_rate == base_samplerate )
// return normalized_sample;
// else
// return (int64_t)((double)current_sample /
{
int result = 0;
- if(!file) return 1;
+ if( !file ) return 1;
#define REPOSITION(x, y) \
(labs((x) - (y)) > 1)
// normalized_sample);
result = file->set_audio_position(current_sample);
- if(result)
+ if( result )
printf("File::set_audio_position position=%jd"
" base_samplerate=%f asset=%p asset->sample_rate=%d\n",
position, base_samplerate, asset, asset->sample_rate);
int is_thread)
{
int result = 0;
- if(!file) return 0;
+ if( !file ) return 0;
// Convert to file's rate
-// if(base_framerate > 0)
+// if( base_framerate > 0 )
// position = (int64_t)((double)position /
// base_framerate *
// asset->frame_rate +
// 0.5);
- if(video_thread && !is_thread)
- {
+ if( video_thread && !is_thread ) {
// Call thread. Thread calls this again to set the file state.
video_thread->set_video_position(position);
}
else
- if(current_frame != position)
- {
- if(file)
- {
+ if( current_frame != position ) {
+ if( file ) {
current_frame = position;
result = file->set_video_position(current_frame);
}
{
int result = 1;
- if(file)
- {
+ if( file ) {
write_lock->lock("File::write_samples");
// Convert to arrays for backwards compatability
double *temp[asset->channels];
- for(int i = 0; i < asset->channels; i++)
- {
+ for( int i = 0; i < asset->channels; i++ ) {
temp[i] = buffer[i]->get_data();
}
int File::write_audio_buffer(int64_t len)
{
int result = 0;
- if(audio_thread)
- {
+ if( audio_thread ) {
result = audio_thread->write_buffer(len);
}
return result;
int File::write_video_buffer(int64_t len)
{
int result = 0;
- if(video_thread)
- {
+ if( video_thread ) {
result = video_thread->write_buffer(len);
}
Samples** File::get_audio_buffer()
{
- if(audio_thread) return audio_thread->get_audio_buffer();
+ if( audio_thread ) return audio_thread->get_audio_buffer();
return 0;
}
VFrame*** File::get_video_buffer()
{
- if(video_thread)
- {
+ if( video_thread ) {
VFrame*** result = video_thread->get_video_buffer();
return result;
int File::read_samples(Samples *samples, int64_t len)
{
// Never try to read more samples than exist in the file
- if (asset->audio_length >= 0 && current_sample + len > asset->audio_length) {
+ if( asset->audio_length >= 0 && current_sample + len > asset->audio_length ) {
len = asset->audio_length - current_sample;
}
- if(len <= 0) return 0;
+ if( len <= 0 ) return 0;
int result = 0;
const int debug = 0;
- if(debug) PRINT_TRACE
+ if( debug ) PRINT_TRACE
- if(debug) PRINT_TRACE
+ if( debug ) PRINT_TRACE
double *buffer = samples->get_data();
int64_t base_samplerate = asset->sample_rate;
- if(file)
- {
+ if( file ) {
// Resample recursively calls this with the asset sample rate
- if(base_samplerate == 0) base_samplerate = asset->sample_rate;
+ if( base_samplerate == 0 ) base_samplerate = asset->sample_rate;
- if(debug) PRINT_TRACE
+ if( debug ) PRINT_TRACE
result = file->read_samples(buffer, len);
- if(debug) PRINT_TRACE
+ if( debug ) PRINT_TRACE
current_sample += len;
normalized_sample += len;
}
- if(debug) PRINT_TRACE
+ if( debug ) PRINT_TRACE
return result;
}
{
const int debug = 0;
- if(debug) PRINT_TRACE
+ if( debug ) PRINT_TRACE
//printf("File::read_frame %d\n", __LINE__);
- if(video_thread && !is_thread) return video_thread->read_frame(frame);
+ if( video_thread && !is_thread ) return video_thread->read_frame(frame);
//printf("File::read_frame %d\n", __LINE__);
- if(debug) PRINT_TRACE
+ if( debug ) PRINT_TRACE
if( !file ) return 1;
- if(debug) PRINT_TRACE
+ if( debug ) PRINT_TRACE
int result = 0;
int supported_colormodel = colormodel_supported(frame->get_color_model());
int advance_position = 1;
int64_t cache_position = !asset->single_frame ? current_frame : -1;
// Test cache
if( cache_active && frame_cache->get_frame(frame, cache_position,
- current_layer, asset->frame_rate) )
- {
+ current_layer, asset->frame_rate) ) {
// Can't advance position if cache used.
//printf("File::read_frame %d\n", __LINE__);
advance_position = 0;
}
// Need temp
- else if(frame->get_color_model() != BC_COMPRESSED &&
+ else if( frame->get_color_model() != BC_COMPRESSED &&
(supported_colormodel != frame->get_color_model() ||
frame->get_w() != asset->width ||
- frame->get_h() != asset->height))
- {
+ frame->get_h() != asset->height) ) {
// printf("File::read_frame %d\n", __LINE__);
// Can't advance position here because it needs to be added to cache
- if(temp_frame)
- {
- if(!temp_frame->params_match(asset->width, asset->height, supported_colormodel))
- {
+ if( temp_frame ) {
+ if( !temp_frame->params_match(asset->width, asset->height, supported_colormodel) ) {
delete temp_frame;
temp_frame = 0;
}
}
// printf("File::read_frame %d\n", __LINE__);
- if(!temp_frame)
- {
+ if( !temp_frame ) {
temp_frame = new VFrame(0,
-1,
asset->width,
frame->set_status(-1);
//printf("File::read_frame %d\n", __LINE__);
}
- else
- {
+ else {
// Can't advance position here because it needs to be added to cache
//printf("File::read_frame %d\n", __LINE__);
result = file->read_frame(frame);
if( result && frame->get_status() > 0 )
frame->set_status(-1);
-//for(int i = 0; i < 100 * 1000; i++) ((float*)frame->get_rows()[0])[i] = 1.0;
+//for( int i = 0; i < 100 * 1000; i++ ) ((float*)frame->get_rows()[0])[i] = 1.0;
}
if( result && !current_frame )
current_layer, asset->frame_rate, 1, 0);
//printf("File::read_frame %d\n", __LINE__);
- if(advance_position) current_frame++;
- if(debug) PRINT_TRACE
+ if( advance_position ) current_frame++;
+ if( debug ) PRINT_TRACE
return 0;
}
int File::strtoformat(const char *format)
{
- return strtoformat(0, format);
-}
-
-int File::strtoformat(ArrayList<PluginServer*> *plugindb, const char *format)
-{
- if(!strcasecmp(format, _(AC3_NAME))) return FILE_AC3;
- if(!strcasecmp(format, _(SCENE_NAME))) return FILE_SCENE;
- if(!strcasecmp(format, _(WAV_NAME))) return FILE_WAV;
- if(!strcasecmp(format, _(PCM_NAME))) return FILE_PCM;
- if(!strcasecmp(format, _(AU_NAME))) return FILE_AU;
- if(!strcasecmp(format, _(AIFF_NAME))) return FILE_AIFF;
- if(!strcasecmp(format, _(SND_NAME))) return FILE_SND;
- if(!strcasecmp(format, _(PNG_NAME))) return FILE_PNG;
- if(!strcasecmp(format, _(PNG_LIST_NAME))) return FILE_PNG_LIST;
- if(!strcasecmp(format, _(TIFF_NAME))) return FILE_TIFF;
- if(!strcasecmp(format, _(TIFF_LIST_NAME))) return FILE_TIFF_LIST;
- if(!strcasecmp(format, _(JPEG_NAME))) return FILE_JPEG;
- if(!strcasecmp(format, _(JPEG_LIST_NAME))) return FILE_JPEG_LIST;
- if(!strcasecmp(format, _(EXR_NAME))) return FILE_EXR;
- if(!strcasecmp(format, _(EXR_LIST_NAME))) return FILE_EXR_LIST;
- if(!strcasecmp(format, _(FLAC_NAME))) return FILE_FLAC;
- if(!strcasecmp(format, _(CR2_NAME))) return FILE_CR2;
- if(!strcasecmp(format, _(CR2_LIST_NAME))) return FILE_CR2_LIST;
- if(!strcasecmp(format, _(MPEG_NAME))) return FILE_MPEG;
- if(!strcasecmp(format, _(AMPEG_NAME))) return FILE_AMPEG;
- if(!strcasecmp(format, _(VMPEG_NAME))) return FILE_VMPEG;
- if(!strcasecmp(format, _(TGA_NAME))) return FILE_TGA;
- if(!strcasecmp(format, _(TGA_LIST_NAME))) return FILE_TGA_LIST;
- if(!strcasecmp(format, _(OGG_NAME))) return FILE_OGG;
- if(!strcasecmp(format, _(VORBIS_NAME))) return FILE_VORBIS;
- if(!strcasecmp(format, _(RAWDV_NAME))) return FILE_RAWDV;
- if(!strcasecmp(format, _(FFMPEG_NAME))) return FILE_FFMPEG;
- if(!strcasecmp(format, _(DBASE_NAME))) return FILE_DB;
+ if( !strcasecmp(format, _(AC3_NAME)) ) return FILE_AC3;
+ if( !strcasecmp(format, _(SCENE_NAME)) ) return FILE_SCENE;
+ if( !strcasecmp(format, _(WAV_NAME)) ) return FILE_WAV;
+ if( !strcasecmp(format, _(PCM_NAME)) ) return FILE_PCM;
+ if( !strcasecmp(format, _(AU_NAME)) ) return FILE_AU;
+ if( !strcasecmp(format, _(AIFF_NAME)) ) return FILE_AIFF;
+ if( !strcasecmp(format, _(SND_NAME)) ) return FILE_SND;
+ if( !strcasecmp(format, _(PNG_NAME)) ) return FILE_PNG;
+ if( !strcasecmp(format, _(PNG_LIST_NAME)) ) return FILE_PNG_LIST;
+ if( !strcasecmp(format, _(TIFF_NAME)) ) return FILE_TIFF;
+ if( !strcasecmp(format, _(TIFF_LIST_NAME)) ) return FILE_TIFF_LIST;
+ if( !strcasecmp(format, _(JPEG_NAME)) ) return FILE_JPEG;
+ if( !strcasecmp(format, _(JPEG_LIST_NAME)) ) return FILE_JPEG_LIST;
+ if( !strcasecmp(format, _(EXR_NAME)) ) return FILE_EXR;
+ if( !strcasecmp(format, _(EXR_LIST_NAME)) ) return FILE_EXR_LIST;
+ if( !strcasecmp(format, _(FLAC_NAME)) ) return FILE_FLAC;
+ if( !strcasecmp(format, _(CR2_NAME)) ) return FILE_CR2;
+ if( !strcasecmp(format, _(CR2_LIST_NAME)) ) return FILE_CR2_LIST;
+ if( !strcasecmp(format, _(MPEG_NAME)) ) return FILE_MPEG;
+ if( !strcasecmp(format, _(AMPEG_NAME)) ) return FILE_AMPEG;
+ if( !strcasecmp(format, _(VMPEG_NAME)) ) return FILE_VMPEG;
+ if( !strcasecmp(format, _(TGA_NAME)) ) return FILE_TGA;
+ if( !strcasecmp(format, _(TGA_LIST_NAME)) ) return FILE_TGA_LIST;
+ if( !strcasecmp(format, _(OGG_NAME)) ) return FILE_OGG;
+ if( !strcasecmp(format, _(VORBIS_NAME)) ) return FILE_VORBIS;
+ if( !strcasecmp(format, _(RAWDV_NAME)) ) return FILE_RAWDV;
+ if( !strcasecmp(format, _(FFMPEG_NAME)) ) return FILE_FFMPEG;
+ if( !strcasecmp(format, _(DBASE_NAME)) ) return FILE_DB;
return 0;
}
const char* File::formattostr(int format)
{
- return formattostr(0, format);
-}
-
-const char* File::formattostr(ArrayList<PluginServer*> *plugindb, int format)
-{
- switch(format) {
+ switch( format ) {
case FILE_SCENE: return _(SCENE_NAME);
case FILE_AC3: return _(AC3_NAME);
case FILE_WAV: return _(WAV_NAME);
int File::strtobits(const char *bits)
{
- if(!strcasecmp(bits, _(NAME_8BIT))) return BITSLINEAR8;
- if(!strcasecmp(bits, _(NAME_16BIT))) return BITSLINEAR16;
- if(!strcasecmp(bits, _(NAME_24BIT))) return BITSLINEAR24;
- if(!strcasecmp(bits, _(NAME_32BIT))) return BITSLINEAR32;
- if(!strcasecmp(bits, _(NAME_ULAW))) return BITSULAW;
- if(!strcasecmp(bits, _(NAME_ADPCM))) return BITS_ADPCM;
- if(!strcasecmp(bits, _(NAME_FLOAT))) return BITSFLOAT;
+ if( !strcasecmp(bits, _(NAME_8BIT)) ) return BITSLINEAR8;
+ if( !strcasecmp(bits, _(NAME_16BIT)) ) return BITSLINEAR16;
+ if( !strcasecmp(bits, _(NAME_24BIT)) ) return BITSLINEAR24;
+ if( !strcasecmp(bits, _(NAME_32BIT)) ) return BITSLINEAR32;
+ if( !strcasecmp(bits, _(NAME_ULAW)) ) return BITSULAW;
+ if( !strcasecmp(bits, _(NAME_ADPCM)) ) return BITS_ADPCM;
+ if( !strcasecmp(bits, _(NAME_FLOAT)) ) return BITSFLOAT;
return BITSLINEAR16;
}
const char* File::bitstostr(int bits)
{
//printf("File::bitstostr\n");
- switch(bits) {
+ switch( bits ) {
case BITSLINEAR8: return (NAME_8BIT);
case BITSLINEAR16: return (NAME_16BIT);
case BITSLINEAR24: return (NAME_24BIT);
int File::str_to_byteorder(const char *string)
{
- if(!strcasecmp(string, _("Lo Hi"))) return 1;
+ if( !strcasecmp(string, _("Lo Hi")) ) return 1;
return 0;
}
const char* File::byteorder_to_str(int byte_order)
{
- if(byte_order) return _("Lo Hi");
+ if( byte_order ) return _("Lo Hi");
return _("Hi Lo");
}
int File::bytes_per_sample(int bits)
{
- switch(bits)
- {
- case BITSLINEAR8: return 1;
- case BITSLINEAR16: return 2;
- case BITSLINEAR24: return 3;
- case BITSLINEAR32: return 4;
- case BITSULAW: return 1;
+ switch( bits ) {
+ case BITSLINEAR8: return 1;
+ case BITSLINEAR16: return 2;
+ case BITSLINEAR24: return 3;
+ case BITSLINEAR32: return 4;
+ case BITSULAW: return 1;
}
return 1;
}
int File::get_best_colormodel(Asset *asset, int driver)
{
- switch(asset->format)
- {
+ switch( asset->format ) {
#ifdef HAVE_DV
- case FILE_RAWDV: return FileDV::get_best_colormodel(asset, driver);
+ case FILE_RAWDV: return FileDV::get_best_colormodel(asset, driver);
#endif
- case FILE_MPEG: return FileMPEG::get_best_colormodel(asset, driver);
- case FILE_JPEG:
- case FILE_JPEG_LIST: return FileJPEG::get_best_colormodel(asset, driver);
+ case FILE_MPEG: return FileMPEG::get_best_colormodel(asset, driver);
+ case FILE_JPEG:
+ case FILE_JPEG_LIST: return FileJPEG::get_best_colormodel(asset, driver);
#ifdef HAVE_OPENEXR
- case FILE_EXR:
- case FILE_EXR_LIST: return FileEXR::get_best_colormodel(asset, driver);
+ case FILE_EXR:
+ case FILE_EXR_LIST: return FileEXR::get_best_colormodel(asset, driver);
#endif
- case FILE_PNG:
- case FILE_PNG_LIST: return FilePNG::get_best_colormodel(asset, driver);
- case FILE_TGA:
- case FILE_TGA_LIST: return FileTGA::get_best_colormodel(asset, driver);
- case FILE_CR2:
- case FILE_CR2_LIST: return FileCR2::get_best_colormodel(asset, driver);
- case FILE_DB: return FileDB::get_best_colormodel(asset, driver);
- case FILE_FFMPEG: return FileFFMPEG::get_best_colormodel(asset, driver);
+ case FILE_PNG:
+ case FILE_PNG_LIST: return FilePNG::get_best_colormodel(asset, driver);
+ case FILE_TGA:
+ case FILE_TGA_LIST: return FileTGA::get_best_colormodel(asset, driver);
+ case FILE_CR2:
+ case FILE_CR2_LIST: return FileCR2::get_best_colormodel(asset, driver);
+ case FILE_DB: return FileDB::get_best_colormodel(asset, driver);
+ case FILE_FFMPEG: return FileFFMPEG::get_best_colormodel(asset, driver);
}
return BC_RGB888;
int File::colormodel_supported(int colormodel)
{
- if(file)
+ if( file )
return file->colormodel_supported(colormodel);
return BC_RGB888;
int64_t result = 0;
result += file_memory_usage();
- if(temp_frame) result += temp_frame->get_data_size();
+ if( temp_frame ) result += temp_frame->get_data_size();
result += frame_cache->get_memory_usage();
- if(video_thread) result += video_thread->get_memory_usage();
+ if( video_thread ) result += video_thread->get_memory_usage();
- if(result < MIN_CACHEITEM_SIZE) result = MIN_CACHEITEM_SIZE;
+ if( result < MIN_CACHEITEM_SIZE ) result = MIN_CACHEITEM_SIZE;
return result;
}
-int File::supports_video(ArrayList<PluginServer*> *plugindb, char *format)
+int File::renders_video(Asset *asset)
{
- int format_i = strtoformat(plugindb, format);
-
- return supports_video(format_i);
+//printf("File::supports_video %d\n", format);
+ switch( asset->format ) {
+ case FILE_OGG:
+ case FILE_JPEG:
+ case FILE_JPEG_LIST:
+ case FILE_CR2:
+ case FILE_CR2_LIST:
+ case FILE_EXR:
+ case FILE_EXR_LIST:
+ case FILE_PNG:
+ case FILE_PNG_LIST:
+ case FILE_TGA:
+ case FILE_TGA_LIST:
+ case FILE_TIFF:
+ case FILE_TIFF_LIST:
+ case FILE_VMPEG:
+ case FILE_RAWDV:
+ return 1;
+ case FILE_FFMPEG:
+ return FileFFMPEG::renders_video(asset->fformat);
+ }
return 0;
}
-int File::supports_audio(ArrayList<PluginServer*> *plugindb, char *format)
+int File::renders_audio(Asset *asset)
{
- int format_i = strtoformat(plugindb, format);
-
- return supports_audio(format_i);
+ switch( asset->format ) {
+ case FILE_AC3:
+ case FILE_FLAC:
+ case FILE_PCM:
+ case FILE_WAV:
+ case FILE_OGG:
+ case FILE_VORBIS:
+ case FILE_AMPEG:
+ case FILE_AU:
+ case FILE_AIFF:
+ case FILE_SND:
+ case FILE_RAWDV:
+ return 1;
+ case FILE_FFMPEG:
+ return FileFFMPEG::renders_audio(asset->fformat);
+ }
return 0;
}
-
-int File::supports_video(int format)
+int File::is_image_render(int format)
{
-//printf("File::supports_video %d\n", format);
- switch(format)
- {
- case FILE_OGG:
- case FILE_JPEG:
- case FILE_JPEG_LIST:
- case FILE_CR2:
- case FILE_CR2_LIST:
- case FILE_EXR:
- case FILE_EXR_LIST:
- case FILE_PNG:
- case FILE_PNG_LIST:
- case FILE_TGA:
- case FILE_TGA_LIST:
- case FILE_TIFF:
- case FILE_TIFF_LIST:
- case FILE_VMPEG:
- case FILE_FFMPEG:
- case FILE_RAWDV:
- return 1;
+ switch( format ) {
+ case FILE_EXR:
+ case FILE_JPEG:
+ case FILE_PNG:
+ case FILE_TGA:
+ case FILE_TIFF:
+ return 1;
}
- return 0;
-}
-int File::supports_audio(int format)
-{
- switch(format)
- {
- case FILE_AC3:
- case FILE_FLAC:
- case FILE_PCM:
- case FILE_WAV:
- case FILE_OGG:
- case FILE_VORBIS:
- case FILE_AMPEG:
- case FILE_AU:
- case FILE_AIFF:
- case FILE_SND:
- case FILE_FFMPEG:
- case FILE_RAWDV:
- return 1;
- }
return 0;
}
const char* File::get_tag(int format)
{
- switch(format)
- {
- case FILE_AC3: return "ac3";
- case FILE_AIFF: return "aif";
- case FILE_AMPEG: return "mp3";
- case FILE_AU: return "au";
- case FILE_RAWDV: return "dv";
- case FILE_DB: return "db";
- case FILE_EXR: return "exr";
- case FILE_EXR_LIST: return "exr";
- case FILE_FLAC: return "flac";
- case FILE_JPEG: return "jpg";
- case FILE_JPEG_LIST: return "jpg";
- case FILE_OGG: return "ogg";
- case FILE_PCM: return "pcm";
- case FILE_PNG: return "png";
- case FILE_PNG_LIST: return "png";
- case FILE_TGA: return "tga";
- case FILE_TGA_LIST: return "tga";
- case FILE_TIFF: return "tif";
- case FILE_TIFF_LIST: return "tif";
- case FILE_VMPEG: return "m2v";
- case FILE_VORBIS: return "ogg";
- case FILE_WAV: return "wav";
- case FILE_FFMPEG: return "ffmpg";
+ switch( format ) {
+ case FILE_AC3: return "ac3";
+ case FILE_AIFF: return "aif";
+ case FILE_AMPEG: return "mp3";
+ case FILE_AU: return "au";
+ case FILE_RAWDV: return "dv";
+ case FILE_DB: return "db";
+ case FILE_EXR: return "exr";
+ case FILE_EXR_LIST: return "exr";
+ case FILE_FLAC: return "flac";
+ case FILE_JPEG: return "jpg";
+ case FILE_JPEG_LIST: return "jpg";
+ case FILE_OGG: return "ogg";
+ case FILE_PCM: return "pcm";
+ case FILE_PNG: return "png";
+ case FILE_PNG_LIST: return "png";
+ case FILE_TGA: return "tga";
+ case FILE_TGA_LIST: return "tga";
+ case FILE_TIFF: return "tif";
+ case FILE_TIFF_LIST: return "tif";
+ case FILE_VMPEG: return "m2v";
+ case FILE_VORBIS: return "ogg";
+ case FILE_WAV: return "wav";
+ case FILE_FFMPEG: return "ffmpg";
}
return 0;
}
const char* File::get_prefix(int format)
{
- switch(format) {
+ switch( format ) {
case FILE_PCM: return "PCM";
case FILE_WAV: return "WAV";
case FILE_PNG: return "PNG";
PackagingEngine *File::new_packaging_engine(Asset *asset)
{
PackagingEngine *result;
- switch (asset->format)
- {
- case FILE_OGG:
- result = (PackagingEngine*)new PackagingEngineOGG();
- break;
- default:
- result = (PackagingEngine*) new PackagingEngineDefault();
- break;
+ switch( asset->format ) {
+ case FILE_OGG:
+ result = (PackagingEngine*)new PackagingEngineOGG();
+ break;
+ default:
+ result = (PackagingEngine*) new PackagingEngineDefault();
+ break;
}
return result;
setenv_path(cinbwr_path, "CIN_BROWSER", CIN_BROWSER);
}
-
BC_DialogThread::start();
}
else if( in_progress ) {
- ErrorBox error_box(_(PROGRAM_NAME ": Error"),
- mwindow->gui->get_abs_cursor_x(1),
- mwindow->gui->get_abs_cursor_y(1));
+ int cx, cy;
+ mwindow->gui->get_abs_cursor_xy(cx, cy, 1);
+ ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy);
error_box.create_objects(_("Already rendering"));
error_box.raise_window();
error_box.run_window();
start_render();
}
else if( in_progress ) {
- ErrorBox error_box(_(PROGRAM_NAME ": Error"),
- mwindow->gui->get_abs_cursor_x(1),
- mwindow->gui->get_abs_cursor_y(1));
+ int cx, cy;
+ mwindow->gui->get_abs_cursor_xy(cx, cy, 1);
+ ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy);
error_box.create_objects("Already rendering");
error_box.raise_window();
error_box.run_window();
{
this->jobs = 0;
batch_cancelled = 0;
- format_error = 0;
result = 0;
if(mode == Render::INTERACTIVE) {
{
if(!result) {
// add to recentlist only on OK
- render_window->format_tools->path_recent->
+ render_window->render_format->path_recent->
add_item(File::formattostr(asset->format), asset->path);
}
render_window = 0;
void Render::handle_close_event(int result)
{
- int format_error = 0;
const int debug = 0;
+ double render_range = get_render_range();
+ const char *err_msg = 0;
+
+ if( !result && !render_range ) {
+ err_msg = _("zero render range");
+ result = 1;
+ }
+ if( !result && asset->video_data ) {
+ double frame_rate = mwindow->edl->session->frame_rate;
+ if( frame_rate > 0 && render_range+1e-3 < 1./frame_rate ) {
+ err_msg = _("Video data and range less than 1 frame");
+ result = 1;
+ }
+ }
+ if( !result && asset->audio_data ) {
+ double sample_rate = mwindow->edl->session->sample_rate;
+ if( sample_rate > 0 && render_range+1e-6 < 1./sample_rate ) {
+ err_msg = _("Audio data and range less than 1 sample");
+ result = 1;
+ }
+ }
+ if( !result && File::is_image_render(asset->format) ) {
+ if( asset->video_data ) {
+ double frames = render_range * mwindow->edl->session->frame_rate;
+ if( !EQUIV(frames, 1.) ) {
+ err_msg = _("Image format and not 1 frame");
+ result = 1;
+ }
+ }
+ else {
+ err_msg = _("Image format and no video data");
+ result = 1;
+ }
+ }
+ if( err_msg ) {
+ int cx, cy;
+ mwindow->gui->get_abs_cursor_xy(cx, cy, 1);
+ ErrorBox error_box(_(PROGRAM_NAME ": Error"),cx, cy);
+ error_box.create_objects(err_msg);
+ error_box.raise_window();
+ error_box.run_window();
+ }
if(!result) {
// Check the asset format for errors.
FormatCheck format_check(asset);
- format_error = format_check.check_format();
+ if( format_check.check_format() )
+ result = 1;
}
//PRINT_TRACE
mwindow->save_defaults();
//PRINT_TRACE
- if(!format_error && !result)
- {
+ if( !result ) {
if(debug) printf("Render::handle_close_event %d\n", __LINE__);
if(!result) start_render();
if(debug) printf("Render::handle_close_event %d\n", __LINE__);
{
if(asset.video_data &&
edl->tracks->playable_video_tracks() &&
- File::supports_video(asset.format))
+ File::renders_video(&asset))
{
asset.video_data = 1;
asset.layers = 1;
if(asset.audio_data &&
edl->tracks->playable_audio_tracks() &&
- File::supports_audio(asset.format))
+ File::renders_audio(&asset))
{
asset.audio_data = 1;
asset.channels = edl->session->audio_channels;
}
-void RenderThread::render_single(int test_overwrite,
- Asset *asset,
- EDL *edl,
- int strategy,
- int range_type)
+void RenderThread::render_single(int test_overwrite, Asset *asset, EDL *edl,
+ int strategy, int range_type)
{
// Total length in seconds
double total_length;
command->get_edl()->copy_all(edl);
command->change_type = CHANGE_ALL;
- if (range_type == RANGE_BACKCOMPAT) {
+ switch( range_type ) {
+ case RANGE_BACKCOMPAT:
// Get highlighted playback range
command->set_playback_range();
// Adjust playback range with in/out points
command->playback_range_adjust_inout();
- }
- else if (range_type == RANGE_PROJECT) {
+ break;
+ case RANGE_PROJECT:
command->playback_range_project();
- }
- else if (range_type == RANGE_SELECTION) {
+ break;
+ case RANGE_SELECTION:
command->set_playback_range();
- }
- else if (range_type == RANGE_INOUT) {
+ break;
+ case RANGE_INOUT:
command->playback_range_inout();
+ break;
+ case RANGE_1FRAME:
+ command->playback_range_1frame();
+ break;
}
render->packages = new PackageDispatcher;
if(mwindow)
{
if(debug) printf("Render::render %d\n", __LINE__);
- ErrorBox error_box(_(PROGRAM_NAME ": Error"),
- mwindow->gui->get_abs_cursor_x(1),
- mwindow->gui->get_abs_cursor_y(1));
+ int cx, cy;
+ mwindow->gui->get_abs_cursor_xy(cx, cy, 1);
+ ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy);
error_box.create_objects(_("Error rendering data."));
error_box.raise_window();
error_box.run_window();
{
if(render->mode == Render::INTERACTIVE)
{
- render_single(1, render->asset, mwindow->edl, render->strategy, render->range_type);
+ render_single(1, render->asset, mwindow->edl,
+ render->strategy, render->range_type);
}
else
if(render->mode == Render::BATCH)
}
-#define WIDTH 440
+#define WIDTH 480
#define HEIGHT 455
this->mwindow = mwindow;
this->render = render;
this->asset = asset;
+ rangeproject = 0;
+ rangeselection = 0;
+ rangeinout = 0;
+ range1frame = 0;
}
RenderWindow::~RenderWindow()
SET_TRACE
lock_window("RenderWindow::~RenderWindow");
SET_TRACE
- delete format_tools;
+ delete render_format;
SET_TRACE
delete loadmode;
SET_TRACE
{
render->load_profile(profile_slot, asset);
update_range_type(render->range_type);
- format_tools->update(asset, &render->strategy);
+ render_format->update(asset, &render->strategy);
}
void RenderWindow::create_objects()
{
- int x = 10, y = 5;
+ int x = 10, y = 10;
lock_window("RenderWindow::create_objects");
- add_subwindow(new BC_Title(x,
- y,
+ add_subwindow(new BC_Title(x, y,
(char*)((render->strategy == FILE_PER_LABEL ||
render->strategy == FILE_PER_LABEL_FARM) ?
_("Select the first file to render to:") :
_("Select a file to render to:"))));
y += 25;
- format_tools = new FormatTools(mwindow, this, asset);
- format_tools->create_objects(x, y,
+ render_format = new RenderFormat(mwindow, this, asset);
+ render_format->create_objects(x, y,
1, 1, 1, 1, 0, 1, 0, 0, &render->strategy, 0);
- add_subwindow(new BC_Title(x, y, _("Render range:")));
+ BC_Title *title;
+ add_subwindow(title = new BC_Title(x, y, _("Render range:")));
- x += 110;
+ int is_image = File::is_image_render(asset->format);
+ if( is_image )
+ render->range_type = RANGE_1FRAME;
+
+ int x1 = x + title->get_w() + 20, x2 = x1 + 140;
add_subwindow(rangeproject = new RenderRangeProject(this,
- render->range_type == RANGE_PROJECT, x, y));
+ render->range_type == RANGE_PROJECT, x1, y));
+ add_subwindow(range1frame = new RenderRange1Frame(this,
+ render->range_type == RANGE_1FRAME, x2, y));
y += 20;
add_subwindow(rangeselection = new RenderRangeSelection(this,
- render->range_type == RANGE_SELECTION, x, y));
- y += 20;
+ render->range_type == RANGE_SELECTION, x1, y));
add_subwindow(rangeinout = new RenderRangeInOut(this,
- render->range_type == RANGE_INOUT, x, y));
+ render->range_type == RANGE_INOUT, x2, y));
y += 30;
- x = 5;
+
+ if( is_image )
+ enable_render_range(0);
renderprofile = new RenderProfile(mwindow, this, x, y, 1);
renderprofile->create_objects();
add_subwindow(new BC_OKButton(this));
add_subwindow(new BC_CancelButton(this));
+
show_window();
unlock_window();
}
void RenderWindow::update_range_type(int range_type)
{
+ if( render->range_type == range_type ) return;
render->range_type = range_type;
rangeproject->update(range_type == RANGE_PROJECT);
rangeselection->update(range_type == RANGE_SELECTION);
rangeinout->update(range_type == RANGE_INOUT);
+ range1frame->update(range_type == RANGE_1FRAME);
+}
+
+void RenderWindow::enable_render_range(int v)
+{
+ if( v ) {
+ rangeproject->enable();
+ rangeselection->enable();
+ rangeinout->enable();
+ range1frame->enable();
+ }
+ else {
+ rangeproject->disable();
+ rangeselection->disable();
+ rangeinout->disable();
+ range1frame->disable();
+ }
}
return 1;
}
+RenderRange1Frame::RenderRange1Frame(RenderWindow *rwindow, int value, int x, int y)
+ : BC_Radial(x, y, value, _("One Frame"))
+{
+ this->rwindow = rwindow;
+}
+int RenderRange1Frame::handle_event()
+{
+ rwindow->update_range_type(RANGE_1FRAME);
+ return 1;
+}
+
+double Render::get_render_range()
+{
+ EDL *edl = mwindow->edl;
+ double last = edl->tracks->total_playable_length();
+ double framerate = edl->session->frame_rate;
+ if( framerate <= 0 ) framerate = 1;
+ double start = 0, end = last;
+ switch( range_type ) {
+ default:
+ case RANGE_BACKCOMPAT:
+ start = edl->local_session->get_selectionstart(1);
+ end = edl->local_session->get_selectionend(1);
+ if( EQUIV(start, end) ) end = last;
+ break;
+ case RANGE_PROJECT:
+ break;
+ case RANGE_SELECTION:
+ start = edl->local_session->get_selectionstart(1);
+ end = edl->local_session->get_selectionend(1);
+ break;
+ case RANGE_INOUT:
+ start = edl->local_session->inpoint_valid() ?
+ edl->local_session->get_inpoint() : 0;
+ end = edl->local_session->outpoint_valid() ?
+ edl->local_session->get_outpoint() : last;
+ break;
+ case RANGE_1FRAME:
+ start = end = edl->local_session->get_selectionstart(1);
+ if( edl->session->frame_rate > 0 ) end += 1./edl->session->frame_rate;
+ break;
+ }
+ if( start < 0 ) start = 0;
+ if( end > last ) end = last;
+ return end - start;
+}
+
+RenderFormat::RenderFormat(MWindow *mwindow, BC_WindowBase *window, Asset *asset)
+ : FormatTools(mwindow, window, asset)
+{
+}
+RenderFormat::~RenderFormat()
+{
+}
+
+void RenderFormat::update_format()
+{
+ FormatTools::update_format();
+ RenderWindow *render_window = (RenderWindow *)window;
+ if( render_window->is_hidden() ) return;
+
+ int is_image = File::is_image_render(asset->format);
+ if( is_image ) {
+ render_window->update_range_type(RANGE_1FRAME);
+ render_window->enable_render_range(0);
+ }
+ else
+ render_window->enable_render_range(1);
+}