// happening when new_asset was created but not be happening anymore.
if(asset)
{
- mwindow->remove_asset_from_caches(asset);
+ mwindow->remove_asset_from_caches(asset);
//printf("AssetEdit::handle_close_event %d %f\n", __LINE__, asset->get_frame_rate());
asset->copy_from(changed_params, 0);
//printf("AssetEdit::handle_close_event %d %d %d\n", __LINE__, changed_params->bits, asset->bits);
switch(session->assetlist_format) {
case ASSETS_TEXT:
session->assetlist_format = ASSETS_ICONS;
- session->folderlist_format = FOLDERS_ICONS;
break;
case ASSETS_ICONS:
session->assetlist_format = ASSETS_TEXT;
- session->folderlist_format = FOLDERS_TEXT;
break;
}
agui->asset_list->update_format(session->assetlist_format, 1);
- agui->folder_list->update_format(session->folderlist_format, 1);
if (!mwindow->awindow->gui->allow_iconlisting) {
mwindow->edl->session->assetlist_format = ASSETS_TEXT;
}
switch(mwindow->edl->session->folderlist_format)
{
case FOLDERS_TEXT:
- mwindow->edl->session->assetlist_format = ASSETS_ICONS;
mwindow->edl->session->folderlist_format = FOLDERS_ICONS;
break;
case FOLDERS_ICONS:
- mwindow->edl->session->assetlist_format = ASSETS_TEXT;
mwindow->edl->session->folderlist_format = FOLDERS_TEXT;
break;
}
- mwindow->awindow->gui->asset_list->update_format(
- mwindow->edl->session->folderlist_format, 1);
mwindow->awindow->gui->folder_list->update_format(
mwindow->edl->session->folderlist_format, 1);
menu->update_titles();
void FFAudioStream::load_markers()
{
IndexState *index_state = ffmpeg->file_base->asset->index_state;
+ if( index_state->marker_status == MARKERS_NOTTESTED ) return;
if( !index_state || idx >= index_state->audio_markers.size() ) return;
FFStream::load_markers(*index_state->audio_markers[idx], sample_rate);
}
{
if( asset->format != FILE_FFMPEG ) return;
strcpy(asset->fformat, text);
- strcpy(asset->ff_audio_options, "");
- strcpy(asset->ff_video_options, "");
- asset->audio_data = !load_defaults("audio", text, asset->acodec,
- asset->ff_audio_options, sizeof(asset->ff_audio_options));
- asset->video_data = !load_defaults("video", text, asset->vcodec,
- asset->ff_video_options, sizeof(asset->ff_video_options));
+ if( !asset->ff_audio_options[0] ) {
+ asset->audio_data = !load_defaults("audio", text, asset->acodec,
+ asset->ff_audio_options, sizeof(asset->ff_audio_options));
+ }
+ if( !asset->ff_video_options[0] ) {
+ asset->video_data = !load_defaults("video", text, asset->vcodec,
+ asset->ff_video_options, sizeof(asset->ff_video_options));
+ }
}
int FFMPEG::get_encoder(const char *options,
#include "formattools.h"
#include "framecache.h"
#include "language.h"
+#include "mainprogress.inc"
#include "mutex.h"
#include "mwindow.h"
#include "packagingengine.h"
-int File::get_index(char *index_path)
+int File::get_index(IndexFile *index_file, MainProgressBar *progress_bar)
{
- if(file) {
- return file->get_index(index_path);
- }
- return 1;
+ return !file ? -1 : file->get_index(index_file, progress_bar);
}
#include "formattools.h"
#include "framecache.inc"
#include "guicast.h"
+#include "indexfile.inc"
+#include "mainprogress.inc"
#include "mutex.inc"
#include "packagingengine.inc"
#include "pluginserver.inc"
int wr);
// Get index from the file if one exists. Returns 0 on success.
- int get_index(char *index_path);
+ int get_index(IndexFile *index_file, MainProgressBar *progress_bar);
// start a thread for writing to avoid blocking during record
int start_audio_thread(int buffer_size, int ring_buffers);
return !mpg_file ? 0 : mpg_file->read_samples(buffer, len);
}
-int FileAC3::get_index(char *index_path)
+int FileAC3::get_index(IndexFile *index_file, MainProgressBar *progress_bar)
{
- return !mpg_file ? 1 : mpg_file->get_index(index_path);
+ return !mpg_file ? 1 : mpg_file->get_index(index_file, progress_bar);
}
// Channel conversion matrices because ffmpeg encodes a
#include "filebase.h"
#include "filempeg.inc"
+#include "indexfile.inc"
+#include "mainprogress.inc"
class FileAC3 : public FileBase
int close_file();
int read_samples(double *buffer, int64_t len);
int write_samples(double **buffer, int64_t len);
- int get_index(char *index_path);
+ int get_index(IndexFile *index_file, MainProgressBar *progress_bar);
private:
AVCodec *codec;
#include "guicast.h"
#include "file.inc"
#include "filelist.inc"
+#include "indexfile.inc"
+#include "mainprogress.inc"
#include "overlayframe.inc"
#include "strategies.inc"
#include "vframe.inc"
- virtual int get_index(char *index_path) { return 1; }
+ virtual int get_index(IndexFile *index_file, MainProgressBar *progress_bar) { return -1; }
virtual int check_header() { return 0; } // Test file to see if it is of this type.
virtual int reset_parameters_derived() { return 0; }
virtual int read_header() { return 1; } // WAV files for getting header
#include "asset.h"
#include "bcwindowbase.h"
-#include "bcprogressbox.h"
#include "bitspopup.h"
#include "ffmpeg.h"
#include "filebase.h"
#include "fileffmpeg.h"
#include "filesystem.h"
#include "indexfile.h"
+#include "mainprogress.h"
#include "mutex.h"
#include "preferences.h"
#include "videodevice.inc"
return 1;
}
-FFMPEGScanProgress::FFMPEGScanProgress(const char *title, int64_t length, int64_t *position, int *canceled)
+FFMPEGScanProgress::FFMPEGScanProgress(IndexFile *index_file, MainProgressBar *progress_bar,
+ const char *title, int64_t length, int64_t *position, int *canceled)
: Thread(1, 0, 0)
{
+ this->index_file = index_file;
+ this->progress_bar = progress_bar;
strcpy(this->progress_title, title);
this->length = length;
this->position = position;
this->canceled = canceled;
done = 0;
- progress = 0;
start();
}
void FFMPEGScanProgress::run()
{
- BC_ProgressBox *progress = new BC_ProgressBox(-1, -1, progress_title, length);
- progress->start();
-
- struct timeval start_time, now, then;
- gettimeofday(&start_time, 0);
- then = start_time;
-
while( !done ) {
- if( progress->update(*position, 1) ) {
+ if( progress_bar->update(*position) ) {
*canceled = done = 1;
break;
}
- gettimeofday(&now, 0);
- if(now.tv_sec - then.tv_sec >= 1) {
- int64_t elapsed = now.tv_sec - start_time.tv_sec;
- int64_t byte_rate = *position / elapsed;
- int64_t eta = !byte_rate ? 0 : (length - *position) / byte_rate;
- char string[BCTEXTLEN];
- sprintf(string, "%s\nETA: %jdm%jds",
- progress_title, eta / 60, eta % 60);
- progress->update_title(string, 1);
- then = now;
- }
+ index_file->redraw_edits(0);
usleep(500000);
}
-
- progress->stop_progress();
- delete progress;
}
-int FileFFMPEG::get_index(char *index_path)
+int FileFFMPEG::get_index(IndexFile *index_file, MainProgressBar *progress_bar)
{
if( !ff ) return -1;
if( !file->preferences->ffmpeg_marker_indexes ) return 1;
- IndexState *index_state = asset->index_state;
+ IndexState *index_state = index_file->get_state();
if( index_state->index_status != INDEX_NOTTESTED ) return 0;
index_state->reset_index();
index_state->reset_markers();
index_state->add_audio_stream(aud->channels, aud->length);
}
- char progress_title[BCTEXTLEN];
- sprintf(progress_title, _("Creating %s\n"), index_path);
FileSystem fs;
int64_t file_bytes = fs.get_size(ff->fmt_ctx->filename);
- int64_t scan_position = 0;
+ char *index_path = index_file->index_filename;
+
int canceled = 0;
- FFMPEGScanProgress scan_progress(progress_title, file_bytes, &scan_position, &canceled);
+ int64_t scan_position = 0;
+ FFMPEGScanProgress *scan_progress = 0;
+ if( progress_bar ) {
+ char progress_title[BCTEXTLEN];
+ sprintf(progress_title, _("Creating %s\n"), index_path);
+ progress_bar->update_title(progress_title, 1);
+ progress_bar->update_length(file_bytes);
+ scan_progress = new FFMPEGScanProgress(index_file,
+ progress_bar, progress_title, file_bytes,
+ &scan_position, &canceled);
+ }
index_state->index_bytes = file_bytes;
index_state->init_scan(file->preferences->index_size);
+
if( ff->scan(index_state, &scan_position, &canceled) || canceled ) {
index_state->reset_index();
index_state->reset_markers();
return 1;
}
+
+ delete scan_progress;
index_state->marker_status = MARKERS_READY;
return index_state->create_index(index_path, asset);
}
#include "asset.inc"
#include "bcwindowbase.inc"
-#include "bcprogressbox.inc"
#include "bitspopup.inc"
#include "filebase.h"
#include "fileffmpeg.inc"
+#include "indexfile.inc"
+#include "mainprogress.inc"
#include "mutex.h"
#include "thread.h"
#include "vframe.inc"
int get_audio_for_video(int vstream, int astream, int64_t &channel_mask);
static void get_info(char *path,char *text,int len);
int open_file(int rd,int wr);
- int get_index(char *index_filename);
+ int get_index(IndexFile *index_file, MainProgressBar *progress_bar);
int close_file(void);
int write_samples(double **buffer,int64_t len);
int write_frames(VFrame ***frames,int len);
class FFMPEGScanProgress : public Thread
{
public:
+ IndexFile *index_file;
+ MainProgressBar *progress_bar;
char progress_title[BCTEXTLEN];
- BC_ProgressBox *progress;
int64_t length, *position;
int done, *canceled;
- FFMPEGScanProgress(const char *title, int64_t length, int64_t *position, int *canceled);
+ FFMPEGScanProgress(IndexFile *index_file, MainProgressBar *progress_bar,
+ const char *title, int64_t length, int64_t *position, int *canceled);
~FFMPEGScanProgress();
void run();
};
int result = 0;
if(rd) {
+ fd = 0;
char toc_name[BCTEXTLEN];
result = file->preferences->get_asset_file_path(asset, toc_name);
- int error = 0;
- fd = mpeg3_open_title(asset->path, toc_name, &error);
- if( !fd ) {
- result = 1;
- if(error == zmpeg3_t::ERR_INVALID_TOC_VERSION) {
- eprintf(_("Couldn't open %s: invalid table of contents version.\n"
- "Rebuilding the table of contents."), asset->path);
- }
- else if(error == zmpeg3_t::ERR_TOC_DATE_MISMATCH) {
- eprintf(_("Couldn't open %s: table of contents out of date.\n"
- "Rebuilding the table of contents."), asset->path);
+ if( result >= 0 ) {
+ int error = 0;
+// if toc exists, use it otherwise just probe file
+ char *path = !result ? toc_name : asset->path;
+ fd = mpeg3_open_title(asset->path, path, &error);
+ if( !fd ) {
+ switch( error ) {
+ case zmpeg3_t::ERR_INVALID_TOC_VERSION:
+ eprintf(_("Couldn't open %s: invalid table of contents version.\n"),asset->path);
+ result = 1;
+ break;
+ case zmpeg3_t::ERR_TOC_DATE_MISMATCH:
+ eprintf(_("Couldn't open %s: table of contents out of date.\n"),asset->path);
+ result = 1;
+ break;
+ default:
+ eprintf(_("Couldn't open %s: table of contents corrupt.\n"),asset->path);
+ result = -1;
+ break;
+ }
+ if( result > 0 ) {
+ eprintf(_("Rebuilding the table of contents\n"));
+ }
+
}
else {
- eprintf(_("Couldn't open %s: table of contents corrupt.\n"
- "Rebuilding the table of contents."), asset->path);
- }
- char filename[BCTEXTLEN];
- strcpy(filename, toc_name);
- char *sfx = strrchr(filename,'.');
- if( sfx && !strcmp(sfx+1,"toc") ) {
- remove(filename);
- strcpy(sfx+1,"idx");
- remove(filename);
- strcpy(toc_name, asset->path);
- fd = mpeg3_open_title(asset->path, toc_name, &error);
- if( fd ) result = 0;
+ if( mpeg3_has_toc(fd) )
+ result = 0;
+ else if( mpeg3_total_vstreams(fd) || mpeg3_total_astreams(fd) )
+ result = 1;
+ else {
+ eprintf(_("Couldn't open %s: no audio or video.\n"),asset->path);
+ result = -1;
+ }
}
- if( result )
- eprintf(_("Couldn't open %s: rebuild failed.\n"), asset->path);
}
- if(!result) {
-// Determine if the file needs a table of contents and create one if needed.
-// If it has video it must be scanned since video has keyframes.
- if(mpeg3_total_vstreams(fd) || mpeg3_total_astreams(fd)) {
- if(create_index()) return 1;
- }
-// more than 4 doesnt help much
+ if( result > 0 ) {
+ if( fd ) { mpeg3_close(fd); fd = 0; }
+ result = create_toc(toc_name);
+ }
+
+ if( !result ) {
mpeg3_set_cpus(fd, file->cpus < 4 ? file->cpus : 4);
file->current_program = mpeg3_set_program(fd, -1);
if( asset->program < 0 )
if(!asset->sample_rate)
asset->sample_rate = mpeg3_sample_rate(fd, 0);
asset->audio_length = mpeg3_audio_samples(fd, 0);
- if(!asset->channels ||
- !asset->sample_rate)
+ if( !asset->channels || !asset->sample_rate )
result = 1;
}
asset->video_data = mpeg3_has_video(fd);
- if(asset->video_data) {
+ if( !result && asset->video_data ) {
asset->interlace_mode = BC_ILACE_MODE_UNDETECTED;
if( !asset->layers ) {
asset->layers = mpeg3_total_vstreams(fd);
asset->frame_rate = mpeg3_frame_rate(fd, 0);
}
}
+ if( result ) {
+ eprintf(_("Couldn't open %s: failed.\n"), asset->path);
+ }
}
-
-
- if(!result && wr && asset->format == FILE_VMPEG)
- {
+ if( !result && wr && asset->format == FILE_VMPEG ) {
// Heroine Virtual encoder
// this one is cinelerra-x.x.x/mpeg2enc
if(asset->vmpeg_cmodel == BC_YUV422P)
video_out->start();
}
}
- else
- if(wr && asset->format == FILE_AMPEG)
- {
+ else if( !result && wr && asset->format == FILE_AMPEG) {
//char encoder_string[BCTEXTLEN]; encoder_string[0] = 0;
//printf("FileMPEG::open_file 1 %d\n", asset->ampeg_derivative);
}
// Transport stream for DVB capture
- if(!result && !rd && !wr && asset->format == FILE_MPEG)
- {
+ if( !result && !rd && !wr && asset->format == FILE_MPEG ) {
if( (recd_fd = open(asset->path, O_CREAT+O_TRUNC+O_WRONLY,
- S_IRUSR+S_IWUSR + S_IRGRP+S_IWGRP)) < 0 )
- {
+ S_IRUSR+S_IWUSR + S_IRGRP+S_IWGRP)) < 0 ) {
perror("FileMPEG::open_file");
eprintf(_("Error while opening \"%s\" for writing\n%m\n"), asset->path);
result = 1;
}
-int FileMPEG::create_index()
+int FileMPEG::create_toc(char *toc_path)
{
-// Calculate TOC path
- char index_filename[BCTEXTLEN];
- char source_filename[BCTEXTLEN];
-
- IndexFile::get_index_filename(source_filename,
- file->preferences->index_directory,
- index_filename,
- asset->path);
- char *ptr = strrchr(index_filename, '.');
- int error = 0;
-
- if(!ptr) return 1;
-
-// File is a table of contents.
- if(fd && mpeg3_has_toc(fd)) return 0;
-
- sprintf(ptr, ".toc");
+// delete any existing toc files
+ char toc_file[BCTEXTLEN];
+ strcpy(toc_file, toc_path);
+ remove(toc_file);
+ char *bp = strrchr(toc_file, '/');
+ if( !bp ) bp = toc_file;
+ char *sfx = strrchr(bp,'.');
+ if( sfx ) {
+ strcpy(sfx+1,"toc");
+ remove(toc_file);
+ }
- int need_toc = 1;
+ int64_t total_bytes = 0, last_bytes = -1;
+ fd = mpeg3_start_toc(asset->path, toc_file,
+ file->current_program, &total_bytes);
+ if( !fd ) {
+ eprintf(_("cant start toc/idx for file: %s\n"), asset->path);
+ return 1;
+ }
- if(fd) mpeg3_close(fd);
- fd = 0;
+// File needs a table of contents.
+ struct timeval new_time, prev_time, start_time, current_time;
+ gettimeofday(&prev_time, 0); gettimeofday(&start_time, 0);
+ if( file->preferences->scan_commercials ) {
+ set_skimming(-1, 1, toc_nail, file);
+ if( MWindow::commercials->resetDb() != 0 )
+ eprintf(_("cant access commercials database"));
+ }
+// This gets around the fact that MWindowGUI may be locked.
+ char progress_title[BCTEXTLEN];
+ sprintf(progress_title, _("Creating %s\n"), toc_file);
+ BC_ProgressBox progress(-1, -1, progress_title, total_bytes);
+ progress.start();
-// Test existing copy of TOC
- if((fd = mpeg3_open_title(asset->path, index_filename, &error)))
- need_toc = 0;
+ int result = 0;
+ while( !result ) {
+ int64_t bytes_processed = 0;
+ if( mpeg3_do_toc(fd, &bytes_processed) ) break;
- if(need_toc)
- {
- int result = 0;
-// Create progress window.
-// This gets around the fact that MWindowGUI is locked.
- int64_t total_bytes = 0, last_bytes = -1;
- fd = mpeg3_start_toc( asset->path, index_filename,
- file->current_program, &total_bytes);
- if( !fd ) {
- eprintf(_("cant init toc index\n"));
- result = 1;
+ if( bytes_processed >= total_bytes ) break;
+ if( bytes_processed == last_bytes ) {
+ eprintf(_("toc scan stopped before eof"));
+ break;
}
-
- struct timeval new_time, prev_time, start_time, current_time;
- gettimeofday(&prev_time, 0); gettimeofday(&start_time, 0);
-
- if( !result && file->preferences->scan_commercials ) {
- set_skimming(-1, 1, toc_nail, file);
- if( (result=MWindow::commercials->resetDb() ) != 0 )
- eprintf(_("cant access commercials database"));
+ last_bytes = bytes_processed;
+
+ gettimeofday(&new_time, 0);
+ if( new_time.tv_sec - prev_time.tv_sec >= 1 ) {
+ gettimeofday(¤t_time, 0);
+ int64_t elapsed_seconds = current_time.tv_sec - start_time.tv_sec;
+ int64_t total_seconds = !bytes_processed ? 0 :
+ elapsed_seconds * total_bytes / bytes_processed;
+ int64_t eta = total_seconds - elapsed_seconds;
+ progress.update(bytes_processed, 1);
+ char string[BCTEXTLEN];
+ sprintf(string, "%sETA: %jdm%jds",
+ progress_title, eta / 60, eta % 60);
+ progress.update_title(string, 1);
+// fprintf(stderr, "ETA: %dm%ds \r",
+// bytes_processed * 100 / total_bytes,
+// eta / 60, eta % 60);
+// fflush(stdout);
+ prev_time = new_time;
}
- char progress_title[BCTEXTLEN]; progress_title[0] = 0;
- BC_ProgressBox *progress = 0;
- if( !result ) {
- sprintf(progress_title, _("Creating %s\n"), index_filename);
- progress = new BC_ProgressBox(-1, -1,
- progress_title, total_bytes);
- progress->start();
+ if( progress.is_cancelled() ) {
+ result = 1;
+ break;
}
+ }
- while( !result ) {
- int64_t bytes_processed = 0;
- if( mpeg3_do_toc(fd, &bytes_processed) ) break;
- gettimeofday(&new_time, 0);
+ if( file->preferences->scan_commercials ) {
+ if( !result ) MWindow::commercials->write_ads(asset->path);
+ MWindow::commercials->closeDb();
+ }
- if(new_time.tv_sec - prev_time.tv_sec >= 1)
- {
- gettimeofday(¤t_time, 0);
- int64_t elapsed_seconds = current_time.tv_sec - start_time.tv_sec;
- int64_t total_seconds = !bytes_processed ? 0 :
- elapsed_seconds * total_bytes / bytes_processed;
- int64_t eta = total_seconds - elapsed_seconds;
- progress->update(bytes_processed, 1);
- char string[BCTEXTLEN];
- sprintf(string, "%sETA: %jdm%jds",
- progress_title, eta / 60, eta % 60);
- progress->update_title(string, 1);
-// fprintf(stderr, "ETA: %dm%ds \r",
-// bytes_processed * 100 / total_bytes,
-// eta / 60, eta % 60);
-// fflush(stdout);
- prev_time = new_time;
- }
- if(bytes_processed >= total_bytes) break;
- if(progress->is_cancelled()) result = 1;
- if( bytes_processed == last_bytes ) {
- eprintf(_("toc scan stopped before eof"));
- break;
- }
- last_bytes = bytes_processed;
- }
+ mpeg3_stop_toc(fd);
+ fd = 0;
- // record scan results
- if( file->preferences->scan_commercials ) {
- if( !result ) MWindow::commercials->write_ads(asset->path);
- MWindow::commercials->closeDb();
- }
+ progress.stop_progress();
- if( fd ) { mpeg3_stop_toc(fd); fd = 0; }
- if( progress ) { progress->stop_progress(); delete progress; }
- if( result ) { remove_file(index_filename); return 1; }
+ if( result ) {
+ remove_file(toc_file);
+ return 1;
}
- if(!fd)
- {
-// Reopen file from index path instead of asset path.
- if(!(fd = mpeg3_open(index_filename, &error)))
- {
- return 1;
+// Reopen file from toc path instead of asset path.
+ int error = 0;
+ fd = mpeg3_open(toc_file, &error);
+ if( !fd ) {
+ eprintf(_("mpeg3_open failed: %s"), toc_file);
+ return 1;
+ }
+ return 0;
+}
+
+int FileMPEG::get_index(IndexFile *index_file, MainProgressBar *progress_bar)
+{
+ if( !fd ) return 1;
+ IndexState *index_state = index_file->get_state();
+ index_state->reset_index();
+ index_state->reset_markers();
+
+// Convert the index tables from tracks to channels.
+ int ntracks = mpeg3_index_tracks(fd);
+ if( !ntracks ) return 1;
+
+ int index_zoom = mpeg3_index_zoom(fd);
+ int64_t offset = 0;
+ for( int i = 0; i < ntracks; ++i ) {
+ int nch = mpeg3_index_channels(fd, i);
+ for( int j = 0; j < nch; ++j ) {
+ float *bfr = (float *)mpeg3_index_data(fd, i, j);
+ int64_t size = 2*mpeg3_index_size(fd, i);
+ index_state->add_index_entry(bfr, offset, size);
+ offset += size;
}
}
- return 0;
+ FileSystem fs;
+ int64_t file_bytes = fs.get_size(asset->path);
+ char *index_path = index_file->index_filename;
+ return index_state->write_index(index_path, asset, index_zoom, file_bytes);
}
return colormodel;
}
-int FileMPEG::get_index(char *index_path)
-{
- if(!fd) return 1;
- IndexState *index_state = asset->index_state;
- index_state->reset_index();
- index_state->reset_markers();
-
-// Convert the index tables from tracks to channels.
- if(mpeg3_index_tracks(fd)) {
- int index_zoom = mpeg3_index_zoom(fd);
- int ntracks = mpeg3_index_tracks(fd);
- int64_t offset = 0;
- for(int i = 0; i < ntracks; i++) {
- int nch = mpeg3_index_channels(fd, i);
- for(int j = 0; j < nch; j++) {
- float *bfr = (float *)mpeg3_index_data(fd, i, j);
- int64_t size = 2*mpeg3_index_size(fd, i);
- index_state->add_index_entry(bfr, offset, size);
- offset += size;
- }
- }
- FileSystem fs;
- int64_t file_bytes = fs.get_size(asset->path);
- return index_state->write_index(index_path, asset, index_zoom, file_bytes);
- }
-
- return 1;
-}
-
-
int FileMPEG::can_copy_from(Asset *asset, int64_t position)
{
return 0;
#include "condition.inc"
#include "file.inc"
#include "filebase.h"
+#include "indexfile.inc"
#include "twolame.h"
#include "lame/lame.h"
#include "libzmpeg3.h"
+#include "mainprogress.inc"
#include "thread.h"
static void get_info(char *title_path, char *path, char *text, int len);
int open_file(int rd, int wr);
int close_file();
- int create_index();
+ int create_toc(char *toc_path);
+ int get_index(IndexFile *index_file, MainProgressBar *progress_bar);
-
- int get_index(char *index_path);
int set_video_position(int64_t x);
int set_audio_position(int64_t x);
int write_samples(double **buffer,
asset->format = new_format;
asset->audio_data = File::supports_audio(asset->format);
asset->video_data = File::supports_video(asset->format);
+ asset->ff_audio_options[0] = 0;
+ asset->ff_video_options[0] = 0;
format->format_text->update(selection->get_text());
format->update_extension();
format->close_format_windows();
if( selection ) {
char *text = get_selection(0, 0)->get_text();
format->ffmpeg_type->update(text);
+ format->asset->ff_audio_options[0] = 0;
+ format->asset->ff_video_options[0] = 0;
FFMPEG::set_asset_format(format->asset, text);
format->update_extension();
format->close_format_windows();
// Some file formats have their own sample index.
// Test for index in stream table of contents
- if(source && !source->get_index(index_filename))
+ if(source && !source->get_index(this, progress))
{
IndexState *index_state = get_state();
index_state->index_status = INDEX_READY;
}
fclose(fp);
- reset_index();
return 0;
}
#include "language.h"
#include "loadfile.h"
#include "guicast.h"
+#include "mainerror.h"
#include "mainindexes.h"
#include "mainprogress.h"
#include "mutex.h"
index_state = indexable->index_state;
SET_TRACE
- int got_it = 0;
-
-SET_TRACE
- if(!indexfile.open_index())
- {
+ int ret = indexfile.open_index();
+ if( !ret ) {
index_state->index_status = INDEX_READY;
indexfile.close_index();
- got_it = 1;
- }
-
-//printf("MainIndexes::add_next_asset %d %f\n", __LINE__, indexable->get_frame_rate());
-
-SET_TRACE
-// No index
- if(!got_it)
- {
- File *this_file = file;
-
-SET_TRACE
- if(!file && indexable->is_asset)
- {
- Asset *asset = (Asset *)indexable;
- this_file = new File;
- this_file->open_file(mwindow->preferences, asset, 1, 0);
- }
-
-
-SET_TRACE
- char index_filename[BCTEXTLEN];
- char source_filename[BCTEXTLEN];
-SET_TRACE
- IndexFile::get_index_filename(source_filename,
- mwindow->preferences->index_directory,
- index_filename,
- indexable->path);
-
-SET_TRACE
- if(this_file && !this_file->get_index(index_filename))
- {
-SET_TRACE
- if(!indexfile.open_index())
- {
-SET_TRACE
- indexfile.close_index();
-SET_TRACE
- index_state->index_status = INDEX_READY;
- got_it = 1;
- }
-SET_TRACE
- }
-
-SET_TRACE
- if(this_file && !file) delete this_file;
-SET_TRACE
}
-SET_TRACE
-
-//printf("MainIndexes::add_next_asset %d %f\n", __LINE__, indexable->get_frame_rate());
-
+ else {
// Put source in stack
- if(!got_it)
- {
index_state->index_status = INDEX_NOTTESTED;
next_indexables.append(indexable);
indexable->add_user();
void MainIndexes::run()
{
- while(!done)
- {
+ while(!done) {
// Wait for new indexables to be released
input_lock->lock("MainIndexes::run 1");
if(done) return;
-
interrupt_lock->lock("MainIndexes::run 2");
load_next_sources();
interrupt_flag = 0;
-
-
-
-
-
// test index of each indexable
MainProgressBar *progress = 0;
int total_sources = current_indexables.size();
- for(int i = 0;
- i < total_sources && !interrupt_flag;
- i++)
- {
- Indexable *indexable = 0;
-// Take an indexable
- indexable = current_indexables.get(i);
-
- IndexState *index_state = 0;
- index_state = indexable->index_state;
-
-//printf("MainIndexes::run 3 %s %d %d\n", indexable->path, indexable->index_status, indexable->audio_data);
-
- if(index_state->index_status == INDEX_NOTTESTED &&
- indexable->have_audio())
- {
-
- index_lock->lock("MainIndexes::run 1");
- indexfile = new IndexFile(mwindow, indexable);
- index_lock->unlock();
+ for( int i = 0; i < total_sources && !interrupt_flag; ++i ) {
+ Indexable *indexable = current_indexables[i];
+ IndexState *index_state = indexable->index_state;
+// if status is known, no probe
+ if( index_state->index_status != INDEX_NOTTESTED ) continue;
-
-// Doesn't exist if this returns 1.
- if(indexfile->open_index())
- {
-// Try to create index now.
- if(!progress)
- {
- if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 1");
- progress = mwindow->mainprogress->start_progress(_("Building Indexes..."), 1);
- if(mwindow->gui) mwindow->gui->unlock_window();
- }
-
-
- indexfile->create_index(progress);
- if(progress->is_cancelled()) interrupt_flag = 1;
- }
- else
-// Exists. Update real thing.
- {
-//printf("MainIndexes::run 8\n");
- if(index_state->index_status == INDEX_NOTTESTED)
- {
- index_state->index_status = INDEX_READY;
- if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 2");
- mwindow->edl->set_index_file(indexable);
- if(mwindow->gui) mwindow->gui->unlock_window();
- }
- indexfile->close_index();
- }
-
- index_lock->lock("MainIndexes::run 2");
- delete indexfile;
- indexfile = 0;
- index_lock->unlock();
-//printf("MainIndexes::run 8\n");
+ IndexFile indexfile(mwindow, indexable);
+ int ret = indexfile.open_index();
+ if( !ret ) {
+ indexfile.close_index();
+// use existing index
+ index_state->index_status = INDEX_READY;
+ if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 2");
+ mwindow->edl->set_index_file(indexable);
+ if(mwindow->gui) mwindow->gui->unlock_window();
+ continue;
}
-//printf("MainIndexes::run 9\n");
+// Doesn't exist
+ if( !progress ) {
+ if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 1");
+ progress = mwindow->mainprogress->start_progress(_("Building Indexes..."), 1);
+ if(mwindow->gui) mwindow->gui->unlock_window();
+ }
+// only if audio tracks
+ indexfile.create_index(progress);
+ if( progress->is_cancelled() )
+ interrupt_flag = 1;
}
- if(progress) // progress box is only created when an index is built
- {
+ if(progress) { // progress box is only created when an index is built
if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 3");
progress->stop_progress();
delete progress;
progress = 0;
}
-
-
-
-
-
interrupt_lock->unlock();
}
}
viewmenu->add_item(show_transitions = new ShowTransitions(mwindow, "2"));
viewmenu->add_item(fade_automation = new ShowAutomation(mwindow, _("Fade"), "3", AUTOMATION_FADE));
viewmenu->add_item(mute_automation = new ShowAutomation(mwindow, _("Mute"), "4", AUTOMATION_MUTE));
- viewmenu->add_item(mode_automation = new ShowAutomation(mwindow, _("Mode"), "5", AUTOMATION_MODE));
+ viewmenu->add_item(mode_automation = new ShowAutomation(mwindow, _("Overlay mode"), "5", AUTOMATION_MODE));
viewmenu->add_item(pan_automation = new ShowAutomation(mwindow, _("Pan"), "6", AUTOMATION_PAN));
viewmenu->add_item(plugin_automation = new PluginAutomation(mwindow, "7"));
viewmenu->add_item(mask_automation = new ShowAutomation(mwindow, _("Mask"), "8", AUTOMATION_MASK));
else
if(progress_bar)
{
+ char text[BCTEXTLEN], *cp = text, *ep = cp+sizeof(text)-1;
+ for( const unsigned char *bp = (const unsigned char *)string; *bp && cp<ep; ++bp )
+ *cp++ = *bp >= ' ' ? *bp : ' ';
+ *cp = 0;
mwindow->gui->lock_window("MainProgressBar::update_title");
- mwindow->gui->show_message(string);
+ mwindow->gui->show_message(text);
mwindow->gui->unlock_window();
}
}
}
// Test existing EDLs
- if(result)
- {
- for(int j = 0; j < new_edls.total + 1; j++)
- {
- Asset *old_asset;
- if(j == new_edls.total)
- {
- old_asset = edl->assets->get_asset(new_asset->path);
- if( old_asset )
- {
- *new_asset = *old_asset;
- result = 0;
- }
- }
- else
- {
- old_asset = new_edls[j]->assets->get_asset(new_asset->path);
- if( old_asset )
- {
- *new_asset = *old_asset;
- result = 0;
- }
- }
+ for(int j = 0; result && j <= new_edls.total; j++) {
+ Asset *old_asset = j < new_edls.total ?
+ new_edls[j]->assets->get_asset(new_asset->path) :
+ edl->assets->get_asset(new_asset->path);
+ if( old_asset ) {
+ *new_asset = *old_asset;
+ result = 0;
}
}
int Preferences::get_asset_file_path(Asset *asset, char *path)
{
strcpy(path, asset->path);
- int result = access(path, R_OK);
+ int result = !access(path, R_OK) ? 0 : -1;
if( !result && asset->format == FILE_MPEG ) {
- char source_filename[BCTEXTLEN];
- char index_filename[BCTEXTLEN];
+ char source_filename[BCTEXTLEN], index_filename[BCTEXTLEN];
IndexFile::get_index_filename(source_filename,
- index_directory, index_filename,
- asset->path, ".toc");
- struct stat st;
- if( !access(index_filename, R_OK) &&
- !stat(index_filename,&st) && st.st_size > 0 )
+ index_directory, index_filename, asset->path, ".toc");
strcpy(path, index_filename);
+ if( access(path, R_OK) )
+ result = 1;
}
+// result = 0, asset->path/toc exist, -1 no asset, 1 no toc
return result;
}
mode = Render::INTERACTIVE;
BC_DialogThread::start();
}
- else if( render_window && !in_progress )
- render_window->raise_window();
- else {
+ else if( in_progress ) {
ErrorBox error_box(_(PROGRAM_NAME ": Error"),
mwindow->gui->get_abs_cursor_x(1),
mwindow->gui->get_abs_cursor_y(1));
error_box.raise_window();
error_box.run_window();
}
+ else if( render_window ) {
+ render_window->raise_window();
+ }
}
{
mode = Render::BATCH;
batch_cancelled = 0;
- // raise the window if rendering hasn't started yet
- if( render_window && ! in_progress ) {
- render_window->raise_window();
- }
- else {
- ErrorBox error_box(PROGRAM_NAME ": Error",
- mwindow->gui->get_abs_cursor_x(1),
- mwindow->gui->get_abs_cursor_y(1));
- error_box.create_objects("Already rendering");
- error_box.raise_window();
- error_box.run_window();
- }
this->jobs = jobs;
completion->reset();
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));
+ error_box.create_objects("Already rendering");
+ error_box.raise_window();
+ error_box.run_window();
+ }
+ // raise the window if rendering hasn't started yet
+ else if( render_window ) {
+ render_window->raise_window();
+ }
}
void Render::start_batches(ArrayList<BatchRenderJob*> *jobs,
--- /dev/null
+mov libfdk_aac | aac_adtstoasc
+strict -2
+b 256000
--- /dev/null
+acc256k.pro
--- /dev/null
+mov prores
+preset medium
+pix_fmt yuv422p10le
--- /dev/null
+med422p10.pro
// file not hidden
if(include_this)
- {
+ {
new_file = new FileItem;
sprintf(full_path, "%s", current_dir);
if(!is_root_dir(current_dir)) strcat(full_path, "/");
DelayAudioWindow::DelayAudioWindow(DelayAudio *plugin)
- : PluginClientWindow(plugin,
- 200,
- 80,
- 200,
- 80,
- 0)
+ : PluginClientWindow(plugin, 285, 80, 285, 80, 0)
{
this->plugin = plugin;
}
DenoiseWindow::DenoiseWindow(DenoiseEffect *plugin)
- : PluginClientWindow(plugin,
- 150,
- 50,
- 150,
- 50,
- 0)
+ : PluginClientWindow(plugin, 280, 50, 280, 50, 0)
{
this->plugin = plugin;
}
FlipWindow::FlipWindow(FlipMain *client)
- : PluginClientWindow(client,
- 250, 100, 250, 100,
- 0)
+ : PluginClientWindow(client, 250, 100, 250, 100, 0)
{
this->client = client;
}
FreezeFrameWindow::FreezeFrameWindow(FreezeFrameMain *client)
- : PluginClientWindow(client,
- 200,
- 100,
- 200,
- 100,
- 0)
+ : PluginClientWindow(client, 260, 100, 260, 100, 0)
{
this->client = client;
}
HueWindow::HueWindow(HueEffect *plugin)
- : PluginClientWindow(plugin,
- 345, 100, 345, 100, 0)
+ : PluginClientWindow(plugin, 345, 100, 345, 100, 0)
{
this->plugin = plugin;
}
ReframeRTWindow::ReframeRTWindow(ReframeRT *plugin)
- : PluginClientWindow(plugin,
- 210,
- 160,
- 200,
- 160,
- 0)
+ : PluginClientWindow(plugin, 230, 160, 230, 160, 0)
{
this->plugin = plugin;
}
ReverseAudioWindow::ReverseAudioWindow(ReverseAudio *plugin)
- : PluginClientWindow(plugin,
- 210,
- 160,
- 200,
- 160,
- 0)
+ : PluginClientWindow(plugin, 265, 60, 265, 60, 0)
{
this->plugin = plugin;
}
RGB601Window::RGB601Window(RGB601Main *client)
- : PluginClientWindow(client,
- 210,
- 200,
- 210,
- 200,
- 0)
+ : PluginClientWindow(client, 235, 100, 235, 100, 0)
{
this->client = client;
}
ScaleWin::ScaleWin(ScaleMain *client)
- : PluginClientWindow(client,
- 400, 100, 400, 100, 0)
+ : PluginClientWindow(client, 400, 100, 400, 100, 0)
{
this->client = client;
}
SharpenWindow::SharpenWindow(SharpenMain *client)
- : PluginClientWindow(client,
- 230, 150, 230, 150, 0)
+ : PluginClientWindow(client, 230, 150, 230, 150, 0)
{
this->client = client;
}
UnsharpWindow::UnsharpWindow(UnsharpMain *plugin)
- : PluginClientWindow(plugin,
- 200,
- 160,
- 200,
- 160,
- 0)
+ : PluginClientWindow(plugin, 285, 160, 285, 160, 0)
{
this->plugin = plugin;
}
WaveWindow::WaveWindow(WaveEffect *plugin)
- : PluginClientWindow(plugin,
- 320,
- 150,
- 320,
- 150,
- 0)
+ : PluginClientWindow(plugin, 335, 150, 335, 150, 0)
{
this->plugin = plugin;
}
void WaveWindow::create_objects()
{
- int x = 10, y = 10, x1 = 100;
+ int x = 10, y = 10, x1 = 115;
// add_subwindow(new BC_Title(x, y, _("Mode:")));
// add_subwindow(smear = new WaveSmear(plugin, this, x1, y));