Hi, 

it's a little late for christmas presents, but who cares... ;-)

Am Donnerstag, 8. Januar 2009 schrieb Michael Riepe:
> Hi!
>
> Ralph Glasstetter wrote:
> > I also had in mind implementing a black frame detection for "Auto cut
> > points", but that was far too slow with the used imageprovider. Maybe it
> > could be implemented more effectively on the mpeg level during indexing
> > somehow... don't know... however, not every commercial begins with a
> > black frame and not every black frame starts a commercial.
>
> True, but black frames still make good chapter indicators.
>
> Besides that, detecting black frames can be quite fast if you use a
> heuristical approach.
>
>[...]
>
> Actually, looking at three macroblocks might be sufficient for a quick
> scan - one on the left, one on the right and one in the middle of the
> screen. Add their luminosities, and if the result is below a certain
> (configurable) threshold, the frame is probably black.
>
> You don't even have to decode the macroblocks. In MPEG video, one of the
> coefficients directly corresponds to the average luminosity of the MB.

Of course that would speed up things a lot an actually the latter was what 
I've meant with "processing on the mpeg level during indexing" instead of 
using the imageprovider. Unfortunately I don't know much of MPEG 
internals... :-(

Instead, I implemented 1-2 other little things requested by Francesco F. & 
David T. and fixed a bug I stumbled upon concerning the output pipes (had to 
add some quotes to allow for spaces in %OUTPUT% directory/file name).

For the requests:

1. I changed viewscalefactor to a float variable so it's possible to specify  
an arbitrary viewing size divisor (not only 1,2 or 4) by modifing the 
constant in the settings file to any positive floating number (<1 larger, >1 
smaller than original). 

Guess that's also a prerequisite if someone ever wants to implement a variable 
viewing scale depending on screen and/or window size (which would be the
better solution).   

Additionially there is now also a "Custom Size" menu entry which defaults to 3 
but could also be set to 2.5=5/2 in the settings file (which was the value 
reqested by David). Actually whe could now skip the "Quater Size" entry which 
was implemented for the HDTV people... ;-)

2. I've bound the Left / Right Cursor Keys additionally to the backward / 
forword scrolling function. Like for the MouseWheel you can also use the 
Alt/Ctrl/Shift modifiers defined in the settings file (don't care about the 
name /wheel/*).

Concerning the location of the settings file ... that's a QT feature!
Of course,  ~/.dvbcut would be better, but I don't know if that can be 
changed.

Also it would be nice to have all those parameters available in a settings 
menu, but we still wait for the man (or woman) who needs it so urgently that 
he is willing to implement it... same for the help menu ... ;-)

BTW,... there is a nice little help page (which I try to keep uptodate) at 
http://wiki.unbuntuusers.de/dvbcut ... unfortunately only in german. 
But just in case if someone wants to translate ... ;-)

ciao
Ralph

PS: PATCH appended!
--- svn/ChangeLog	2009-01-08 14:33:57.000000000 +0100
+++ r140-viewscale/ChangeLog	2009-01-08 22:30:15.000000000 +0100
@@ -1,3 +1,27 @@
+2009-01-08  Ralph Glasstetter  <ralph.glasstet...@web.de>
+
+        * src/settings.cpp
+                Fixed bug with output pipe directory/file names
+                containing spaces (added quotes)
+
+        * src/dvbcut.cpp
+                bound forward/backward scrolling to Right/Left 
+                keys (Alt/Ctrl/Shift modifiers as for Wheel)
+
+        * src/dvbcutbase.ui
+        * src/dvbcut.cpp
+        * src/dvbcut.h
+        * src/avframe.cpp
+        * src/avframe.h
+        * src/imageprovider.cpp
+        * src/imageprovider.h
+        * src/differenceimageprovider.cpp
+        * src/differenceimageprovider.h
+        * src/settings.cpp
+        * src/settings.h
+                viewscalefactor can now be any positive float,  
+                and implemented "Custem size" viewing scale, 
+
 2009-01-07  Michael Riepe  <too-ti...@users.sourceforge.net>
 
 	* configure.in:
diff -Naur svn/src/avframe.cpp r140-viewscale/src/avframe.cpp
--- svn/src/avframe.cpp	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/avframe.cpp	2009-01-08 17:07:30.000000000 +0100
@@ -82,7 +82,7 @@
 #endif
   }
 
-QImage avframe::getqimage(bool scaled, int viewscalefactor)
+QImage avframe::getqimage(bool scaled, double viewscalefactor)
   {
 #ifdef HAVE_LIB_SWSCALE
   if (w<=0 || h<=0 || img_convert_ctx==NULL)
@@ -114,11 +114,11 @@
   im = im.swapRGB();
 #endif
 
-  if ((scaled && w!=dw)||(viewscalefactor!=1)) {
+  if ((scaled && w!=dw)||(viewscalefactor!=1.0)) {
 #ifdef SMOOTHSCALE
-    im = im.smoothScale((scaled?dw:w)/viewscalefactor, h/viewscalefactor);
+    im = im.smoothScale(int((scaled?dw:w)/viewscalefactor+0.5), int(h/viewscalefactor+0.5));
 #else
-    im = im.scale((scaled?dw:w)/viewscalefactor, h/viewscalefactor);
+    im = im.scale(int((scaled?dw:w)/viewscalefactor+0.5), int(h/viewscalefactor+0.5));
 #endif
     }
 
diff -Naur svn/src/avframe.h r140-viewscale/src/avframe.h
--- svn/src/avframe.h	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/avframe.h	2009-01-08 16:37:11.000000000 +0100
@@ -73,7 +73,7 @@
     {
     return pix_fmt;
     }
-  QImage getqimage(bool scaled=true, int viewscalefactor=1);
+  QImage getqimage(bool scaled=true, double viewscalefactor=1.0);
   };
 
 #endif
diff -Naur svn/src/differenceimageprovider.cpp r140-viewscale/src/differenceimageprovider.cpp
--- svn/src/differenceimageprovider.cpp	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/differenceimageprovider.cpp	2009-01-08 17:06:50.000000000 +0100
@@ -26,7 +26,7 @@
 #include "busyindicator.h"
 
 differenceimageprovider::differenceimageprovider(mpgfile &mpg, int basepicture, busyindicator *bi, 
-                                                 bool unscaled, int factor, int cachesize)
+                                                 bool unscaled, double factor, int cachesize)
     : imageprovider(mpg,bi,unscaled,factor,cachesize), basepic(basepicture)
   {
   RTTI=unscaled?IMAGEPROVIDER_DIFFERENCE_UNSCALED:IMAGEPROVIDER_DIFFERENCE;
@@ -83,9 +83,9 @@
         }
 
 
-    if ((RTTI!=IMAGEPROVIDER_DIFFERENCE_UNSCALED && displaywidth!=im.width())||(viewscalefactor!=1))
-      im=im.scale(((RTTI!=IMAGEPROVIDER_DIFFERENCE_UNSCALED)?displaywidth:im.width())/viewscalefactor,
-	im.height()/viewscalefactor);
+    if ((RTTI!=IMAGEPROVIDER_DIFFERENCE_UNSCALED && displaywidth!=im.width())||(viewscalefactor!=1.0))
+      im=im.scale(int(((RTTI!=IMAGEPROVIDER_DIFFERENCE_UNSCALED)?displaywidth:im.width())/viewscalefactor+0.5),
+	int(im.height()/viewscalefactor+0.5));
     framecache.push_front(framecacheitem(startpic++,im));
     }
   }
diff -Naur svn/src/differenceimageprovider.h r140-viewscale/src/differenceimageprovider.h
--- svn/src/differenceimageprovider.h	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/differenceimageprovider.h	2009-01-08 17:18:24.000000000 +0100
@@ -36,7 +36,7 @@
 
 public:
   differenceimageprovider(mpgfile &mpg, int basepicture, busyindicator *bi=0, 
-                          bool unscaled=false, int factor=1, int cachesize=50);
+                          bool unscaled=false, double factor=1.0, int cachesize=50);
 
   ~differenceimageprovider();
 
diff -Naur svn/src/dvbcutbase.ui r140-viewscale/src/dvbcutbase.ui
--- svn/src/dvbcutbase.ui	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/dvbcutbase.ui	2009-01-08 18:02:18.000000000 +0100
@@ -474,6 +474,7 @@
         <action name="viewFullSizeAction"/>
         <action name="viewHalfSizeAction"/>
         <action name="viewQuarterSizeAction"/>
+        <action name="viewCustomSizeAction"/>
     </item>
     <item text="&amp;Play" name="playMenu">
         <action name="playPlayAction"/>
@@ -883,6 +884,20 @@
     </action>
     <action>
         <property name="name">
+            <cstring>viewCustomSizeAction</cstring>
+        </property>
+        <property name="toggleAction">
+            <bool>true</bool>
+        </property>
+        <property name="text">
+            <string>Custom size</string>
+        </property>
+        <property name="accel">
+            <string>Ctrl+3</string>
+        </property>
+    </action>
+    <action>
+        <property name="name">
             <cstring>viewHalfSizeAction</cstring>
         </property>
         <property name="toggleAction">
@@ -1165,6 +1180,12 @@
         <slot>viewQuarterSize()</slot>
     </connection>
     <connection>
+        <sender>viewCustomSizeAction</sender>
+        <signal>activated()</signal>
+        <receiver>dvbcutbase</receiver>
+        <slot>viewCustomSize()</slot>
+    </connection>
+    <connection>
         <sender>snapshotSaveAction</sender>
         <signal>activated()</signal>
         <receiver>dvbcutbase</receiver>
@@ -1217,6 +1238,7 @@
     <slot>abouttoshowrecentfiles()</slot>
     <slot>viewFullSize()</slot>
     <slot>viewHalfSize()</slot>
+    <slot>viewCustomSize()</slot>
     <slot>viewQuarterSize()</slot>
     <slot>snapshotSave()</slot>
     <slot>chapterSnapshotsSave()</slot>
diff -Naur svn/src/dvbcut.cpp r140-viewscale/src/dvbcut.cpp
--- svn/src/dvbcut.cpp	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/dvbcut.cpp	2009-01-08 22:17:25.000000000 +0100
@@ -130,7 +130,7 @@
     curpic(~0), showimage(true), fine(false),
     jogsliding(false), jogmiddlepic(0),
     mplayer_process(0), imgp(0), busy(0),
-    viewscalefactor(1),
+    viewscalefactor(1.0),
     nogui(false)
 {
 #ifndef HAVE_LIB_AO
@@ -1082,17 +1082,22 @@
 
 void dvbcut::viewFullSize()
 {
-  setviewscalefactor(1);
+  setviewscalefactor(1.0);
 }
 
 void dvbcut::viewHalfSize()
 {
-  setviewscalefactor(2);
+  setviewscalefactor(2.0);
 }
 
 void dvbcut::viewQuarterSize()
 {
-  setviewscalefactor(4);
+  setviewscalefactor(4.0);
+}
+
+void dvbcut::viewCustomSize()
+{
+  setviewscalefactor(settings().viewscalefactor_custom);
 }
 
 void dvbcut::playPlay()
@@ -2096,13 +2101,14 @@
     settings().recentfiles.pop_back();
 }
 
-void dvbcut::setviewscalefactor(int factor)
+void dvbcut::setviewscalefactor(double factor)
 {
-  if (factor!=1 && factor!=2 && factor!=4)
-    factor=1;
-  viewFullSizeAction->setOn(factor==1);
-  viewHalfSizeAction->setOn(factor==2);
-  viewQuarterSizeAction->setOn(factor==4);
+  if (factor<=0.0)
+    factor=1.0;
+  viewFullSizeAction->setOn(factor==1.0);
+  viewHalfSizeAction->setOn(factor==2.0);
+  viewQuarterSizeAction->setOn(factor==4.0);
+  viewCustomSizeAction->setOn(factor==settings().viewscalefactor_custom);
 
   settings().viewscalefactor = factor;
 
@@ -2116,17 +2122,41 @@
 }
 
 bool dvbcut::eventFilter(QObject *watched, QEvent *e) {
-  if (e->type() == QEvent::Wheel) {
+  bool myEvent = false, Alt, Control, Shift;
+  int delta;
+  
+  if (e->type() == QEvent::Wheel && watched == linslider) {
     QWheelEvent *we = (QWheelEvent*)e;
-    if (watched == linslider) {
-      // process event myself
-      int delta = we->delta();
+    // Note: delta is a multiple of 120 (see Qt documentation)
+    delta = - we->delta() / settings().wheel_delta;
+    myEvent = true;
+    Alt = we->state() & AltButton;
+    Control = we->state() & ControlButton;
+    Shift = we->state() & ShiftButton;
+  }  
+  else if (e->type() == QEvent::KeyPress) {
+    QKeyEvent *ke = (QKeyEvent*)e;
+    if (ke->key() == Key_Left) {
+      delta = - ke->count(); 
+      myEvent = true;
+    }  
+    else if (ke->key()== Key_Right) {
+      delta = ke->count(); 
+      myEvent = true;
+    }
+    Alt = ke->state() & AltButton;
+    Control = ke->state() & ControlButton;
+    Shift = ke->state() & ShiftButton;
+  }  
+  
+  if (myEvent) {
+      // process scroll event myself
       int incr = 0;
-      if (we->state() & AltButton)
+      if (Alt)
         incr = settings().wheel_increments[WHEEL_INCR_ALT];
-      else if (we->state() & ControlButton)
+      else if (Control)
         incr = settings().wheel_increments[WHEEL_INCR_CTRL];
-      else if (we->state() & ShiftButton)
+      else if (Shift)
         incr = settings().wheel_increments[WHEEL_INCR_SHIFT];
       else
         incr = settings().wheel_increments[WHEEL_INCR_NORMAL];
@@ -2135,7 +2165,7 @@
 	// use fine positioning if incr is small
         fine = (incr < 0 ? -incr : incr) < settings().wheel_threshold;
 	// Note: delta is a multiple of 120 (see Qt documentation)
-        int newpos = curpic - (delta * incr) / settings().wheel_delta;
+        int newpos = curpic + (delta * incr);
         if (newpos < 0)
 	  newpos = 0;
 	else if (newpos >= pictures)
@@ -2144,8 +2174,8 @@
         fine = save;
       }
       return true;
-    }
   }
+
   // propagate to base class
   return dvbcutbase::eventFilter(watched, e);
 }
diff -Naur svn/src/dvbcut.h r140-viewscale/src/dvbcut.h
--- svn/src/dvbcut.h	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/dvbcut.h	2009-01-08 18:03:56.000000000 +0100
@@ -96,7 +96,7 @@
   pts_t mplayer_curpts;
   imageprovider *imgp;
   int busy;
-  int viewscalefactor;
+  double viewscalefactor;
   int currentaudiotrack;
   bool nogui;
   int exportformat; 
@@ -107,7 +107,7 @@
   //   QPixmap getpixmap(int picture, bool allgop=false);
   void exportvideo(const char *fmt);
   void addtorecentfiles(const std::list<std::string> &filenames, const std::string &idxfilename=std::string());
-  void setviewscalefactor(int factor);
+  void setviewscalefactor(double factor);
 
   // special event handling (mouse wheel)
   bool eventFilter(QObject *watched, QEvent *e);
@@ -166,6 +166,7 @@
   virtual void viewFullSize();
   virtual void viewHalfSize();
   virtual void viewQuarterSize();
+  virtual void viewCustomSize();
   virtual void playAudio2();
   virtual void playAudio1();
   virtual void playStop();
diff -Naur svn/src/imageprovider.cpp r140-viewscale/src/imageprovider.cpp
--- svn/src/imageprovider.cpp	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/imageprovider.cpp	2009-01-08 16:29:26.000000000 +0100
@@ -23,7 +23,7 @@
 #include "avframe.h"
 #include "busyindicator.h"
 
-imageprovider::imageprovider(mpgfile &mpg, busyindicator *bi, bool unscaled, int factor, int cachesize) :
+imageprovider::imageprovider(mpgfile &mpg, busyindicator *bi, bool unscaled, double factor, int cachesize) :
     RTTI(IMAGEPROVIDER_STANDARD), m(mpg), maxcachedframes(cachesize), viewscalefactor(factor),
     busyind(bi)
   {
diff -Naur svn/src/imageprovider.h r140-viewscale/src/imageprovider.h
--- svn/src/imageprovider.h	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/imageprovider.h	2009-01-08 21:05:42.000000000 +0100
@@ -40,7 +40,7 @@
   int RTTI;
   mpgfile &m;
   int maxcachedframes;
-  int viewscalefactor;
+  double viewscalefactor;
   typedef std::pair<int,QImage> framecacheitem;
   std::list<framecacheitem> framecache;
   busyindicator *busyind;
@@ -49,7 +49,7 @@
   virtual void decodepicture(int picture, bool decodeallgop=false);
   
 public:
-  imageprovider(mpgfile &mpg, busyindicator *bi=0, bool unscaled=false, int factor=1, int cachesize=50);
+  imageprovider(mpgfile &mpg, busyindicator *bi=0, bool unscaled=false, double factor=1.0, int cachesize=50);
   virtual ~imageprovider();
   int rtti() const
     {
@@ -60,9 +60,9 @@
     {
     framecache.clear();
     }
-  void setviewscalefactor(int factor)
+  void setviewscalefactor(double factor)
   {
-  if (factor<1) factor=1;
+  if (factor<=0.0) factor=1.0;
   if (factor==viewscalefactor) return;
   clearcache();
   viewscalefactor=factor;
diff -Naur svn/src/settings.cpp r140-viewscale/src/settings.cpp
--- svn/src/settings.cpp	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/settings.cpp	2009-01-08 20:23:29.000000000 +0100
@@ -52,9 +52,9 @@
 	"<font color=\"darkblue\">BOOKMARK</font>"
 
 #define DVBCUT_DEFAULT_PIPE_COMMAND \
-        "|dvdauthor -t -c '%CHAPTERS%' -v mpeg2 -o %OUTPUT% -"
+        "|dvdauthor -t -c '%CHAPTERS%' -v mpeg2 -o '%OUTPUT%' -"
 #define DVBCUT_DEFAULT_PIPE_POST \
-        "dvdauthor -o %OUTPUT% -T"
+        "dvdauthor -o '%OUTPUT%' -T"
 #define DVBCUT_DEFAULT_PIPE_LABEL \
         "DVD-Video titleset (dvdauthor)"
 #define DVBCUT_DEFAULT_PIPE_FORMAT (0)
@@ -63,17 +63,17 @@
 // (ok, for time consuming conversions one does not save any time, but it may be convenient...) 
 // 1. Conversion to mpeg4 avi-file with ffmpeg:
 //    (to recode to a smaller MPEG2 File use "--target dvd -acodec copy"?)!
-pipe/1/command=|ffmpeg -f mpeg2video -i - -f avi -vcodec mpeg4 -b 1200k -g 250 -bf 2 -acodec libmp3lame -ab 128k -ar 44100 %OUTPUT%
+pipe/1/command=|ffmpeg -f mpeg2video -i - -f avi -vcodec mpeg4 -b 1200k -g 250 -bf 2 -acodec libmp3lame -ab 128k -ar 44100 '%OUTPUT%'
 pipe/1/format=1
 pipe/1/label=MPEG-4/ASP (ffmpeg)
 pipe/1/post=
 // 2. Shrinking with vamps by 20%, before piping to dvdauthor:
-pipe/2/command=| vamps -E 1.2 -S 10000000000 -a 1,2,3 | dvdauthor -t -c '%CHAPTERS%' -v mpeg2 -o %OUTPUT% -
+pipe/2/command=| vamps -E 1.2 -S 10000000000 -a 1,2,3 | dvdauthor -t -c '%CHAPTERS%' -v mpeg2 -o '%OUTPUT%' -
 pipe/2/format=0
 pipe/2/label=20% shrinked DVD-Video titleset (vamps & dvdauthor)
-pipe/2/post=dvdauthor -o %OUTPUT% -T
+pipe/2/post=dvdauthor -o '%OUTPUT%' -T
 // 3. recoding to a (smaller?) MPEG2 file with DVD compliant resolution (ca. 3000kbps):
-pipe/3/command=|ffmpeg -f mpeg2video -i - --target dvd -qscale 3.0 -bf 2 -acodec copy %OUTPUT%"
+pipe/3/command=|ffmpeg -f mpeg2video -i - --target dvd -qscale 3.0 -bf 2 -acodec copy '%OUTPUT%'"
 pipe/3/format=1
 pipe/3/label=recoded DVD compliant video (ffmpeg)
 pipe/3/post=
@@ -175,7 +175,17 @@
 	removeEntry("/prjfilter");
 	removeEntry("/loadfilter");
   }
-  viewscalefactor = readNumEntry("/viewscalefactor", 1);
+  if (version >= 2) {
+	beginGroup("/viewscalefactor");
+          viewscalefactor = readDoubleEntry("/current", 1.0);
+          viewscalefactor_custom = readDoubleEntry("/custom", 3.0);
+	endGroup(); // viewscalefactor
+  } 
+  else {
+        viewscalefactor = readDoubleEntry("/viewscalefactor", 1.0);
+        viewscalefactor_custom = 3.0;
+	removeEntry("/viewscalefactor");
+  }
   export_format = readNumEntry("/export_format", 0);
   beginGroup("/recentfiles");
     recentfiles_max = readNumEntry("/max", 5);
@@ -277,7 +287,7 @@
 
 void
 dvbcut_settings::save_settings() {
-  writeEntry("/version", 1);	// latest config version
+  writeEntry("/version", 2);	// latest config version
   beginGroup("/wheel");
 	  writeEntry("/incr_normal", wheel_increments[WHEEL_INCR_NORMAL]);
 	  writeEntry("/incr_shift", wheel_increments[WHEEL_INCR_SHIFT]);
@@ -302,7 +312,10 @@
 	  writeEntry("/prjfilter", prjfilter);
 	  writeEntry("/loadfilter", loadfilter);
   endGroup();	// filter
-  writeEntry("/viewscalefactor", viewscalefactor);
+  beginGroup("/viewscalefactor");
+          writeEntry("/current", viewscalefactor);
+          writeEntry("/custom", viewscalefactor_custom);
+  endGroup();	// viewscalefactor
   writeEntry("/export_format", export_format);
   beginGroup("/recentfiles");
     // first remove any OLD recentfiles entries to clean the settings file (<revision 108)!!!
diff -Naur svn/src/settings.h r140-viewscale/src/settings.h
--- svn/src/settings.h	2009-01-08 14:33:42.000000000 +0100
+++ r140-viewscale/src/settings.h	2009-01-08 18:11:04.000000000 +0100
@@ -51,7 +51,8 @@
   QString loadfilter;
   std::vector<std::pair<std::list<std::string>,std::string> > recentfiles;
   unsigned int recentfiles_max;
-  int viewscalefactor;
+  double viewscalefactor;
+  double viewscalefactor_custom;
   int wheel_increments[WHEEL_INCR_num];
   int wheel_threshold;
   int wheel_delta;
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to