From: Good Guy Date: Sun, 23 Oct 2016 21:59:31 +0000 (-0600) Subject: first frame ogg, zmpeg3 pid in pkt tracking, echo fix, quit fixes X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=64ee854bdef9fb08e6fec938aa0519715f724b99;p=goodguy%2Fhistory.git first frame ogg, zmpeg3 pid in pkt tracking, echo fix, quit fixes --- diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C index f19ce018..fbc03adf 100644 --- a/cinelerra-5.1/cinelerra/file.C +++ b/cinelerra-5.1/cinelerra/file.C @@ -1174,6 +1174,7 @@ int File::read_frame(VFrame *frame, int is_thread) 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; @@ -1217,37 +1218,26 @@ int File::read_frame(VFrame *frame, int is_thread) // 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); diff --git a/cinelerra-5.1/cinelerra/fileogg.C b/cinelerra-5.1/cinelerra/fileogg.C index 8f1a9d3d..747fa399 100644 --- a/cinelerra-5.1/cinelerra/fileogg.C +++ b/cinelerra-5.1/cinelerra/fileogg.C @@ -1472,6 +1472,7 @@ int FileOGG::read_frame(VFrame *frame) 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)) { @@ -1534,8 +1535,6 @@ int FileOGG::read_frame(VFrame *frame) frame->get_w()); delete temp_frame; } - else if( !ogg_frame_position ) - frame->clear_frame(); next_frame_position ++; diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 520d64f4..55284778 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -175,6 +175,7 @@ Commercials* MWindow::commercials = 0; 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"); @@ -226,9 +227,8 @@ MWindow::MWindow() // 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(); @@ -236,9 +236,6 @@ MWindow::~MWindow() #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; @@ -341,23 +338,13 @@ MWindow::~MWindow() 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() @@ -2097,7 +2084,18 @@ ENABLE_BUFFER 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() diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index 385f47f6..39591eec 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -121,7 +121,7 @@ public: 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(); @@ -596,6 +596,7 @@ public: int wait_warning(); // Levels LevelWindow *lwindow; + Mutex *run_lock; // Lock during creation and destruction of GUI Mutex *plugin_gui_lock; Mutex *dead_plugin_lock; diff --git a/cinelerra-5.1/cinelerra/mwindowgui.C b/cinelerra-5.1/cinelerra/mwindowgui.C index 74f3e1f3..7c3b8575 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.C +++ b/cinelerra-5.1/cinelerra/mwindowgui.C @@ -1292,7 +1292,7 @@ int MWindowGUI::key_listener(int key) record->record_gui->interrupt_thread->start(0); break; case KPHAND: - mwindow->quit(0); + mwindow->quit(); break; #ifdef HAVE_DVB case KPBOOK: diff --git a/cinelerra-5.1/cinelerra/quit.C b/cinelerra-5.1/cinelerra/quit.C index 33676215..2b31b28f 100644 --- a/cinelerra-5.1/cinelerra/quit.C +++ b/cinelerra-5.1/cinelerra/quit.C @@ -61,7 +61,7 @@ int Quit::handle_event() } else { // quit - mwindow->quit(1); + mwindow->quit(); } return 0; } @@ -90,35 +90,22 @@ void Quit::run() 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; } } diff --git a/cinelerra-5.1/cinelerra/remotecontrol.C b/cinelerra-5.1/cinelerra/remotecontrol.C index 23dc4c45..b668e978 100644 --- a/cinelerra-5.1/cinelerra/remotecontrol.C +++ b/cinelerra-5.1/cinelerra/remotecontrol.C @@ -148,7 +148,7 @@ void RemoteGUI::tile_windows(int config) else { unlock_window(); mwindow->restart_status = 1; - mwindow->quit(0); + mwindow->quit(); } } diff --git a/cinelerra-5.1/cinelerra/savefile.C b/cinelerra-5.1/cinelerra/savefile.C index 5ecaeabe..3d15ea45 100644 --- a/cinelerra-5.1/cinelerra/savefile.C +++ b/cinelerra-5.1/cinelerra/savefile.C @@ -116,8 +116,8 @@ int Save::handle_event() } 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; } @@ -227,8 +227,8 @@ void SaveAs::run() 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; } diff --git a/cinelerra-5.1/libzmpeg3/demux.C b/cinelerra-5.1/libzmpeg3/demux.C index 172baa0c..77473ce6 100644 --- a/cinelerra-5.1/libzmpeg3/demux.C +++ b/cinelerra-5.1/libzmpeg3/demux.C @@ -173,8 +173,7 @@ get_transport_pes_packet() //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; @@ -191,8 +190,7 @@ get_transport_pes_packet() } 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; @@ -205,8 +203,7 @@ get_transport_pes_packet() } 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 ) @@ -274,7 +271,7 @@ get_payload() 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); @@ -282,7 +279,7 @@ get_payload() 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 { @@ -308,8 +305,8 @@ read_transport() 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); @@ -761,8 +758,7 @@ get_program_pes_packet( uint32_t header) /* 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 ) @@ -784,8 +780,7 @@ get_program_pes_packet( uint32_t header) /* 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 ) @@ -840,7 +835,7 @@ get_program_pes_packet( uint32_t header) /* 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; @@ -940,9 +935,9 @@ read_program() 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; diff --git a/cinelerra-5.1/libzmpeg3/toc.C b/cinelerra-5.1/libzmpeg3/toc.C index b542da0c..b50c011d 100644 --- a/cinelerra-5.1/libzmpeg3/toc.C +++ b/cinelerra-5.1/libzmpeg3/toc.C @@ -1054,27 +1054,27 @@ do_toc(int64_t *bytes_processed) 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; @@ -1086,18 +1086,19 @@ do_toc(int64_t *bytes_processed) 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 ) { diff --git a/cinelerra-5.1/plugins/echo/echo.C b/cinelerra-5.1/plugins/echo/echo.C index f65f9dc5..f52849f5 100644 --- a/cinelerra-5.1/plugins/echo/echo.C +++ b/cinelerra-5.1/plugins/echo/echo.C @@ -123,7 +123,7 @@ int EchoAtten::handle_event() } 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; }