Hi,

Am Montag, 29. Oktober 2007 17:44 schrieb Michael Riepe:
> >>>A cleaner solution maybe would be to set the export_flag of a
> >>> START-entry only to true, if there follows a STOP-entry...?
> >>
> >>I'd rather keep the flag and make dvbcut act accordingly (i.e. export
> >>everything from the last start marker up to EOF).
> >
> > OK, but this would require a change in philosophy (in FileExport)... up
> > to now ALL unmatched START/STOP marker are ignored...
> > And if we allow for an implicite [EMAIL PROTECTED] we also should allow a
> > implicite [EMAIL PROTECTED] (as it's the case in Batch-Mode without any 
> > Markers)!
>
> Or we make that another configuration option.
>

OK, I did it... but I've doubts if it makes sense to switch back to old 
behavoir for some reason. 

It was rather easy to implement, even switchable... actually the code becomes 
shorter, because we don't need the special "nogui"-part in FileExport() 
anymore! :-)

Default settings are "START_BOF=true" and  "STOP_EOF=true" to have the 
same behavoir as before when specfying a mpeg-file without additional cuts
(converting the whole file). But therefore in GUI-mode now the behavoir is 
different than before... 

Don't wanted to have different settings for GUI/noGUI... 

ciao
Ralph
--- svn/ChangeLog	2007-10-29 15:29:59.000000000 +0100
+++ r97-startstop/ChangeLog	2007-10-30 01:06:15.000000000 +0100
@@ -1,3 +1,14 @@
+2007-10-30  Ralph Glasstetter  <[EMAIL PROTECTED]>  (mr)
+
+	* src/dvbcut.cpp:
+	* src/settings.cpp:
+	* src/settings.h:
+        Automatically add missing start/stop markers at BOF/EOF, 
+        configurable via "start_bof"/"stop_eof" in settings file.
+
+	* src/main.cpp:
+        Improved checking of cut list.
+
 2007-10-29  Ralph Glasstetter  <[EMAIL PROTECTED]>  (mr)
 
 	* src/dvbcut.cpp:
diff -Naur svn/src/dvbcut.cpp r97-startstop/src/dvbcut.cpp
--- svn/src/dvbcut.cpp	2007-10-29 15:29:59.000000000 +0100
+++ r97-startstop/src/dvbcut.cpp	2007-10-29 23:02:23.000000000 +0100
@@ -456,15 +456,21 @@
   // starting export, switch source to sequential mode
   buf.setsequential(true);
 
-  int startpic=-1, stoppic=-1;
+  int startpic, stoppic;
   int totalpics=0;
+  
+  if(settings().start_bof) 
+    startpic=0;
+  else
+    startpic=-1;
 
   for(QListBoxItem *lbi=eventlist->firstItem();lbi;lbi=lbi->next())
     if (lbi->rtti()==EventListItem::RTTI()) {
       EventListItem &eli=(EventListItem&)*lbi;
       switch (eli.geteventtype()) {
 	case EventListItem::start:
-	  if (startpic<0) {
+	  if ((settings().start_bof && startpic<=0) || 
+          (!settings().start_bof && startpic<0)) {
 	    startpic=eli.getpicture();
 	  }
 	  break;
@@ -479,23 +485,32 @@
 	  break;
       }
     }
+  // stop event missing after start (or no start/stop at all)
+  if(settings().stop_eof && startpic>=0) {
+    stoppic=pictures-1;
+    totalpics+=stoppic-startpic;
+  }
 
   int savedpic=0;
   long long savedtime=0;
-  pts_t startpts=0, stoppts=0;
+  pts_t startpts=(*mpg)[0].getpts(), stoppts;
   std::list<pts_t> chapterlist;
   chapterlist.push_back(0);
-  startpic=-1;
 
   if (totalpics > 0) {
-    // at least one START/STOP marker pair was found!
+    if(settings().start_bof) 
+      startpic=0;
+    else
+      startpic=-1;
+
     for(QListBoxItem *lbi=eventlist->firstItem();lbi && (nogui || !prgwin->cancelled());lbi=lbi->next())
       if (lbi->rtti()==EventListItem::RTTI()) {
 	EventListItem &eli=(EventListItem&)*lbi;
 
 	switch (eli.geteventtype()) {
 	  case EventListItem::start:
-	    if (startpic<0) {
+	    if ((settings().start_bof && startpic<=0) || 
+            (!settings().start_bof && startpic<0)) {
 	      startpic=eli.getpicture();
 	      startpts=(*mpg)[startpic].getpts();
 	    }
@@ -523,21 +538,16 @@
 	    break;
 	}
       }
-  }
-  else if (nogui) {
-    // batch conversion with no START/STOP pair given at all! 
-    startpic=0; 
-    startpts=(*mpg)[startpic].getpts();   
-    // last picture is missing! ==> Indexer has to add a (invisible) dummy frame at the end... 
-    stoppic=pictures-1;
-    stoppts=(*mpg)[stoppic].getpts();
-    savedpic=0;
-    totalpics=stoppic-startpic;
-    fprintf(stderr,"Exporting %d pictures: %s .. %s\n",
-		   stoppic-startpic,ptsstring(startpts-firstpts).c_str(),ptsstring(stoppts-firstpts).c_str());
-    mpg->savempg(*mux,startpic,stoppic,savedpic,totalpics,log);
-    savedpic=stoppic-startpic;
-    savedtime=stoppts-startpts;
+
+    if(settings().stop_eof && startpic>=0) {
+      stoppic=pictures-1;
+      stoppts=(*mpg)[stoppic].getpts();
+      log->printheading("Exporting %d pictures: %s .. %s",
+			stoppic-startpic,ptsstring(startpts-firstpts).c_str(),ptsstring(stoppts-firstpts).c_str());
+      mpg->savempg(*mux,startpic,stoppic,savedpic,totalpics,log);
+      savedpic+=stoppic-startpic;
+      savedtime+=stoppts-startpts;
+    }
   }
 
   mux.reset();
@@ -1904,17 +1914,25 @@
 void dvbcut::update_quick_picture_lookup_table() {
   quick_picture_lookup.clear();
     
-  int startpic=-1;
-  int outpics=0;
-  pts_t startpts=0;
-  pts_t outpts=0;
+  int startpic, stoppic, outpics=0;
+  pts_t startpts, stoppts, outpts=0;
+  
+  if(settings().start_bof) {
+    startpic=0;
+    startpts=(*mpg)[0].getpts()-firstpts; 
+  }
+  else {
+    startpic=-1;
+    startpts=0; 
+  }
   
   for (QListBoxItem *item=eventlist->firstItem();item;item=item->next())
     if (item->rtti()==EventListItem::RTTI()) {
     const EventListItem &eli=*static_cast<const EventListItem*>(item);
     switch (eli.geteventtype()) {
       case EventListItem::start:
-        if (startpic<0) {
+	    if ((settings().start_bof && startpic<=0) || 
+            (!settings().start_bof && startpic<0)) {
           startpic=eli.getpicture();
           startpts=eli.getpts();
           
@@ -1923,19 +1941,35 @@
         break;
       case EventListItem::stop:
         if (startpic>=0) {
-          int stoppic=eli.getpicture();
-          pts_t stoppts=eli.getpts();
+          // add a virtual START marker at BOF if missing
+          if(quick_picture_lookup.empty()) 
+            quick_picture_lookup.push_back(quick_picture_lookup_s(startpic,true,startpts,outpics,outpts));
+
+          stoppic=eli.getpicture();
+          stoppts=eli.getpts();
           
           outpics+=stoppic-startpic;
           outpts+=stoppts-startpts;
-          startpic=-1;
           quick_picture_lookup.push_back(quick_picture_lookup_s(stoppic,false,stoppts,outpics,outpts));
+          startpic=-1;
         }
         break;
       default:
         break;
       }
     }
+
+  if(settings().stop_eof && startpic>=0) {
+    if(quick_picture_lookup.empty())  // also missing START marker!
+      quick_picture_lookup.push_back(quick_picture_lookup_s(startpic,true,startpts,outpics,outpts));
+
+    // add a virtual STOP marker at EOF if missing
+    stoppic=pictures-1;
+    stoppts=(*mpg)[stoppic].getpts()-firstpts;
+    outpics+=stoppic-startpic;
+    outpts+=stoppts-startpts;
+    quick_picture_lookup.push_back(quick_picture_lookup_s(stoppic,false,stoppts,outpics,outpts)); 
+  }
   
   update_time_display();
   }
diff -Naur svn/src/main.cpp r97-startstop/src/main.cpp
--- svn/src/main.cpp	2007-10-29 15:29:59.000000000 +0100
+++ r97-startstop/src/main.cpp	2007-10-30 00:30:56.000000000 +0100
@@ -205,19 +205,31 @@
       } else if(cutlist.front()=="TS") {
           main->editImport();     
           main->editConvert();             
-      } else if(cutlist.size()>1) { 
-          // just one entry makes no sense and/or can be a typo!
-          std::vector<int> piclist;
-          for (unsigned int j=0; j<cutlist.size(); j++)                   
-            if(cutlist[j].find(':')!=std::string::npos || cutlist[j].find('.')!=std::string::npos) 
-              piclist.push_back(string2pts(cutlist[j])/main->getTimePerFrame()); // pts divided by 3600(PAL) or 3003(NTSC)
-            else
-              piclist.push_back(atoi(cutlist[j].c_str()));                       // integers are treated as frame numbers!
-          main->addStartStopItems(piclist);
+      } else { 
+          std::vector<int> piclist, prob_item, prob_pos;
+          unsigned int pos, j;
+          for (j=0; j<cutlist.size(); j++)
+            if((pos=cutlist[j].find_first_not_of("0123456789:./"))==std::string::npos) {                 
+              if(cutlist[j].find_first_of(":./")!=std::string::npos) 
+                piclist.push_back(string2pts(cutlist[j])/main->getTimePerFrame()); // pts divided by 3600(PAL) or 3003(NTSC)
+              else
+                piclist.push_back(atoi(cutlist[j].c_str()));                       // integers are treated as frame numbers!
+            } else {
+              prob_item.push_back(j);
+              prob_pos.push_back(pos);
+            }  
           if(piclist.size()%2) 
-            fprintf(stderr,"*** Cut list contained an odd number of entries, discarded last one! ***\n");    
-      } else
-        fprintf(stderr,"*** Problems parsing parameter provided with option `-cut'! ***\n");    
+            fprintf(stderr,"*** Cut list contains an odd number of entries! ***\n");    
+          if(!prob_item.empty()) {
+            fprintf(stderr,"*** Problems parsing parameter provided with option `-cut'! ***\n");    
+            for (j=0; j<prob_item.size(); j++) {
+              fprintf(stderr,"    '%s' ==> discarded!\n",cutlist[prob_item[j]].c_str());
+              for (i=0; i<5+prob_pos[j]; i++) fprintf(stderr," ");
+              fprintf(stderr,"^\n");
+            }  
+          }  
+          main->addStartStopItems(piclist);
+      }  
     }  
     main->fileExport();
     rv = 0;
diff -Naur svn/src/settings.cpp r97-startstop/src/settings.cpp
--- svn/src/settings.cpp	2007-10-12 16:12:16.000000000 +0200
+++ r97-startstop/src/settings.cpp	2007-10-29 22:48:54.000000000 +0100
@@ -109,6 +109,8 @@
     chapter_label = readEntry("/chapter", DVBCUT_DEFAULT_CHAPTER_LABEL);
     bookmark_label = readEntry("/bookmark", DVBCUT_DEFAULT_BOOKMARK_LABEL);
   endGroup();	// labels
+  start_bof = readBoolEntry("/start_bof", true);
+  stop_eof = readBoolEntry("/stop_eof", true);
 }
 
 void
@@ -150,6 +152,8 @@
     writeEntry("/chapter", chapter_label);
     writeEntry("/bookmark", bookmark_label);
   endGroup();	// labels
+  writeEntry("/start_bof", start_bof);
+  writeEntry("/stop_eof", stop_eof);
 }
 
 // private settings variable
diff -Naur svn/src/settings.h r97-startstop/src/settings.h
--- svn/src/settings.h	2007-10-12 16:12:16.000000000 +0200
+++ r97-startstop/src/settings.h	2007-10-29 22:42:00.000000000 +0100
@@ -64,6 +64,8 @@
   QString stop_label;
   QString chapter_label;
   QString bookmark_label;
+  bool start_bof;
+  bool stop_eof;
 
 };
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to