if(debug) PRINT_TRACE
if( !file ) return 1;
if(debug) PRINT_TRACE
+ int result = 0;
int supported_colormodel = colormodel_supported(frame->get_color_model());
int advance_position = 1;
int cache_active = use_cache || asset->single_frame ? 1 : 0;
// printf("File::read_frame %d\n", __LINE__);
temp_frame->copy_stacks(frame);
- int result = file->read_frame(temp_frame);
- if( result && frame->get_status() > 0 )
+ result = file->read_frame(temp_frame);
+ if( !result )
+ frame->transfer_from(temp_frame);
+ else if( result && frame->get_status() > 0 )
frame->set_status(-1);
-//for(int i = 0; i < 1000 * 1000; i++) ((float*)temp_frame->get_rows()[0])[i] = 1.0;
-// printf("File::read_frame %d %d %d %d %d %d\n",
-// temp_frame->get_color_model(),
-// temp_frame->get_w(),
-// temp_frame->get_h(),
-// frame->get_color_model(),
-// frame->get_w(),
-// frame->get_h());
- BC_CModels::transfer(frame->get_rows(), temp_frame->get_rows(),
- frame->get_y(), frame->get_u(), frame->get_v(),
- temp_frame->get_y(), temp_frame->get_u(), temp_frame->get_v(),
- 0, 0, temp_frame->get_w(), temp_frame->get_h(),
- 0, 0, frame->get_w(), frame->get_h(),
- temp_frame->get_color_model(),
- frame->get_color_model(), 0, temp_frame->get_w(),
- frame->get_w());
-// printf("File::read_frame %d\n", __LINE__);
+//printf("File::read_frame %d\n", __LINE__);
}
else
{
// Can't advance position here because it needs to be added to cache
//printf("File::read_frame %d\n", __LINE__);
- int result = file->read_frame(frame);
+ 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;
}
+ if( result && !current_frame )
+ frame->clear_frame();
+
if( cache_active && advance_position && frame->get_status() > 0 )
frame_cache->put_frame(frame, cache_position,
current_layer, asset->frame_rate, 1, 0);
ogg_stream_pagein(&tf->to, &og);
}
ogg_stream_packetout(&tf->to, &op);
+ if( theora_packet_isheader(&op) ) continue;
//printf("frame %jd, key %d\n", ogg_frame_position, theora_packet_iskeyframe(&op));
if (expect_keyframe && !theora_packet_iskeyframe(&op))
{
frame->get_w());
delete temp_frame;
}
- else if( !ogg_frame_position )
- frame->clear_frame();
next_frame_position ++;
MWindow::MWindow()
: Thread(1, 0, 0)
{
+ run_lock = new Mutex("MWindow::run_lock");
plugin_gui_lock = new Mutex("MWindow::plugin_gui_lock");
dead_plugin_lock = new Mutex("MWindow::dead_plugin_lock");
vwindows_lock = new Mutex("MWindow::vwindows_lock");
// Need to delete brender temporary here.
MWindow::~MWindow()
{
+ run_lock->lock("MWindow::~MWindow");
in_destructor = 1;
- stop_playback(1);
- stop_brender();
//printf("MWindow::~MWindow %d\n", __LINE__);
gui->stop_drawing();
gui->remote_control->deactivate();
#ifdef HAVE_DVB
gui->channel_info->stop();
#endif
- brender_lock->lock("MWindow::quit");
- delete brender; brender = 0;
- brender_lock->unlock();
delete create_bd; create_bd = 0;
delete create_dvd; create_dvd = 0;
delete batch_render; batch_render = 0;
interlace_asset_fixmethods.remove_all_objects();
sighandler->terminate();
delete sighandler;
+ delete run_lock;
}
-void MWindow::quit(int unlock)
+void MWindow::quit()
{
- if(unlock) gui->unlock_window();
- stop_playback(1);
-
- brender_lock->lock("MWindow::quit");
- delete brender; brender = 0;
- brender_lock->unlock();
-
- interrupt_indexes();
- clean_indexes();
- save_defaults();
gui->set_done(0);
- if(unlock) gui->lock_window("MWindow::quit");
}
void MWindow::init_error()
void MWindow::run()
{
+ run_lock->lock("MWindow::run");
gui->run_window();
+ stop_playback(1);
+
+ brender_lock->lock("MWindow::run 1");
+ delete brender; brender = 0;
+ brender_lock->unlock();
+
+ interrupt_indexes();
+ clean_indexes();
+ save_defaults();
+ run_lock->unlock();
}
void MWindow::show_vwindow()
int run_script(FileXML *script);
int new_project();
int delete_project(int flash = 1);
- void quit(int unlock);
+ void quit();
int restart() { return restart_status; }
int load_defaults();
int wait_warning();
// Levels
LevelWindow *lwindow;
+ Mutex *run_lock;
// Lock during creation and destruction of GUI
Mutex *plugin_gui_lock;
Mutex *dead_plugin_lock;
record->record_gui->interrupt_thread->start(0);
break;
case KPHAND:
- mwindow->quit(0);
+ mwindow->quit();
break;
#ifdef HAVE_DVB
case KPBOOK:
}
else
{ // quit
- mwindow->quit(1);
+ mwindow->quit();
}
return 0;
}
error.run_window();
return;
}
-//printf("Quit::run 1\n");
-// Quit
- {
-//printf("Quit::run 2\n");
- ConfirmQuitWindow confirm(mwindow);
-//printf("Quit::run 2\n");
- confirm.create_objects(_("Save edit list before exiting?"));
-//printf("Quit::run 2\n");
- result = confirm.run_window();
-//printf("Quit::run 2\n");
- }
-//printf("Quit::run 3\n");
- switch(result)
- {
- case 0: // quit
- if(mwindow->gui)
- {
- mwindow->quit(0);
- }
- break;
+ ConfirmQuitWindow confirm(mwindow);
+ confirm.create_objects(_("Save edit list before exiting?"));
+ result = confirm.run_window();
+
+ switch( result ) {
+ case 0: // quit
+ if( mwindow->gui )
+ mwindow->quit();
+ break;
- case 1: // cancel
- return;
- break;
+ case 1: // cancel
+ break;
- case 2: // save
- save->save_before_quit();
- return;
- break;
+ case 2: // save
+ save->save_before_quit();
+ break;
}
}
else {
unlock_window();
mwindow->restart_status = 1;
- mwindow->quit(0);
+ mwindow->quit();
}
}
}
mwindow->session->changes_made = 0;
// Last command in program
-// if(saveas->quit_now) mwindow->gui->set_done(0);
- if(saveas->quit_now) mwindow->playback_3d->quit();
+ if( saveas->quit_now )
+ mwindow->quit();
}
return 1;
}
mwindow->session->changes_made = 0;
mmenu->add_load(filename);
// Last command in program
-// if(quit_now) mwindow->gui->set_done(0);
- if(quit_now) mwindow->playback_3d->quit();
+ if( quit_now )
+ mwindow->quit();
return;
}
//zmsgs("get_transport_pes_packet %x\n", pid);
/* AC3 audio */
stream_id = 0x0;
- got_audio = 1;
- custom_id = pid;
+ custom_id = got_audio = pid;
if( read_all ) astream_table[custom_id] = afmt_AC3;
if( astream == -1 ) astream = custom_id;
}
else if( (stream_id >> 4) == 0x0c || (stream_id >> 4) == 0x0d ) {
/* MPEG audio */
- custom_id = pid;
- got_audio = 1;
+ custom_id = got_audio = pid;
/* Just pick the first available stream if no ID is set */
if( read_all ) astream_table[custom_id] = afmt_MPEG;
if( astream == -1 ) astream = custom_id;
}
else if( (stream_id >> 4) == 0x0e ) {
/* Video */
- custom_id = pid;
- got_video = 1;
+ custom_id = got_video = pid;
/* Just pick the first available stream if no ID is set */
if( read_all )
if( dump ) zmsgs(" 0x%x bytes elementary data\n", raw_size-raw_offset);
// if( pid == 0x1100 ) zmsgs("get_payload 1 0x%x\n", audio_pid);
if( pid == audio_pid && (do_audio || read_all) ) {
- if( do_audio ) got_audio = 1;
+ if( do_audio ) got_audio = pid;
if( dump ) {
zmsgs(" offset=0x%jx 0x%x bytes AC3 pid=0x%x\n",
absolute_position(), raw_size-raw_offset, pid);
get_transport_payload(1, 0);
}
else if( pid == video_pid && (do_video || read_all) ) {
- if( do_video ) got_video = 1;
+ if( do_video ) got_video = pid;
get_transport_payload(0, 1);
}
else {
raw_size = src->packet_size;
raw_offset = 0;
stream_id = 0;
- got_audio = 0;
- got_video = 0;
+ got_audio = -1;
+ got_video = -1;
custom_id = -1;
//zerrs("read transport 1 %jx %jx\n", title->fs->current_byte, title->fs->total_bytes);
/* Audio data */
/* Take first stream ID if -1 */
pes_packet_length -= absolute_position() - pes_packet_start;
- got_audio = 1;
- custom_id = stream_id & 0x0f;
+ custom_id = got_audio = stream_id & 0x0f;
if( read_all )
astream_table[custom_id] = afmt_MPEG;
else if( astream == -1 )
/* Video data */
/* Take first stream ID if -1 */
pes_packet_length -= absolute_position() - pes_packet_start;
- got_video = 1;
- custom_id = stream_id & 0x0f;
+ custom_id = got_video = stream_id & 0x0f;
if( read_all ) {
vstream_table[custom_id] = 1;
} else if( vstream == -1 )
/* only 8 streams, counting from 0x80 */
custom_id = stream_id & 0x87;
if( astream_table[custom_id] >= 0 ) {
- got_audio = 1;
+ got_audio = custom_id;
/* Take first stream ID if not building TOC. */
if( read_all )
astream_table[custom_id] = format;
int pack_count = 0;
const int debug = 0;
- got_audio = 0;
- got_video = 0;
- stream_id = 0;
+ got_audio = -1;
+ got_video = -1;
+ stream_id = -1;
custom_id = -1;
got_subtitle = 0;
if( !result ) {
int idx = 0;
/* Find current PID in tracks. */
- int custom_id = demuxer->custom_id;
/* Got subtitle */
if( demuxer->got_subtitle )
handle_subtitle();
if( is_transport_stream() )
- dvb.atsc_tables(demuxer, custom_id);
+ dvb.atsc_tables(demuxer, demuxer->custom_id);
/* In a transport stream the audio or video is determined by the PID. */
/* In other streams the data type is determined by stream ID. */
- if( demuxer->got_audio || is_transport_stream() || is_audio_stream() ) {
+ if( demuxer->got_audio >= 0 || is_transport_stream() || is_audio_stream() ) {
+ int audio_pid = demuxer->got_audio;
atrack_t *atrk = 0;
for( idx=0; idx < total_atracks; ++idx ) {
- if( atrack[idx]->pid == custom_id ) { /* Update an audio track */
+ if( atrack[idx]->pid == audio_pid ) { /* Update an audio track */
atrk = atrack[idx];
break;
}
}
if( !atrk ) {
if( is_audio_stream() ||
- (demuxer->got_audio && demuxer->astream_table[custom_id]) ) {
- int format = demuxer->astream_table[custom_id];
- atrk = new_atrack_t(custom_id, format, demuxer, total_atracks);
+ (audio_pid >= 0 && demuxer->astream_table[audio_pid]) ) {
+ int format = demuxer->astream_table[audio_pid];
+ atrk = new_atrack_t(audio_pid, format, demuxer, total_atracks);
if( atrk ) {
atrack[idx=total_atracks++] = atrk;
atrk->prev_offset = start_byte;
atrk->handle_audio(idx);
}
}
- if( demuxer->got_video || is_transport_stream() || is_video_stream() ) {
+ if( demuxer->got_video >= 0 || is_transport_stream() || is_video_stream() ) {
+ int video_pid = demuxer->got_video;
vtrack_t *vtrk = 0;
for( idx=0; idx < total_vtracks; ++idx ) {
- if( vtrack[idx]->pid == custom_id ) { /* Update a video track */
+ if( vtrack[idx]->pid == video_pid ) { /* Update a video track */
vtrk = vtrack[idx];
break;
}
}
if( !vtrk ) {
if( is_video_stream() ||
- (demuxer->got_video && demuxer->vstream_table[custom_id]) ) {
- vtrk = new_vtrack_t(custom_id, demuxer, total_vtracks);
+ (video_pid >= 0 && demuxer->vstream_table[video_pid]) ) {
+ vtrk = new_vtrack_t(video_pid, demuxer, total_vtracks);
/* Make the first offset correspond to the */
/* start of the first packet. */
if( vtrk ) {
}
EchoOffset::EchoOffset(EchoWindow *window, int x, int y)
- : BC_FPot(x, y, window->plugin->config.offset, 0, 999)
+ : BC_FPot(x, y, window->plugin->config.offset, 1, 999)
{
this->window = window;
}