Hi,

I hacked together this patch against svn-r166.

It adds an entry field and a list of small frames below the current
picture. This sequence shows some frames before and after the current
picture. The default distance between the frames is 7500 frames (about
5 minutes), but you can change this with the edit field above.

When you click on one of the small frames, this frame becomes the
current one. So you can step through a movie by fixed amounts.

I have tested this only lightly, so be warned. But I hope, you might
find this useful nonetheless.

Regards, Olaf
Index: src/Makefile.in
===================================================================
--- src/Makefile.in	(revision 166)
+++ src/Makefile.in	(working copy)
@@ -70,7 +70,8 @@
 	moc_mplayererrorbase.cpp \
 	moc_progressstatusbar.cpp \
 	moc_progresswindow.cpp \
-	moc_progresswindowbase.cpp
+	moc_progresswindowbase.cpp \
+	moc_framesequence.cpp
 
 UIC = \
 	uic_dvbcutbase.cpp \
@@ -84,7 +85,8 @@
 	imageprovider.cpp index.cpp lavfmuxer.cpp logoutput.cpp \
 	main.cpp mpegmuxer.cpp mpgfile.cpp playaudio.cpp \
 	progressstatusbar.cpp progresswindow.cpp psfile.cpp \
-	pts.cpp streamdata.cpp tsfile.cpp settings.cpp $(MOC) $(UIC) \
+	pts.cpp streamdata.cpp tsfile.cpp settings.cpp framesequence.cpp \
+	$(MOC) $(UIC) \
 	$(STDLIB)
 
 OBJS = $(SRCS:.cpp=.$(OBJEXT))
Index: src/dvbcut.cpp
===================================================================
--- src/dvbcut.cpp	(revision 166)
+++ src/dvbcut.cpp	(working copy)
@@ -51,6 +51,7 @@
 #include <qsettings.h>
 #include <qregexp.h>
 #include <qstatusbar.h>
+#include <qlayout.h>
 
 #include "port.h"
 #include "dvbcut.h"
@@ -68,6 +69,7 @@
 #include "exportdialog.h"
 #include "settings.h"
 #include "exception.h"
+#include "framesequence.h"
 
 #include "version.h"
 
@@ -131,8 +133,11 @@
     jogsliding(false), jogmiddlepic(0),
     mplayer_process(0), imgp(0), busy(0),
     viewscalefactor(1.0),
-    nogui(false)
+    nogui(false),
+    frameseq_(0)
 {
+  frameseq_ = new framesequence(imagedisplay->parentWidget(), 7, linslider);
+  layout7->addLayout(frameseq_->layout());
 #ifndef HAVE_LIB_AO
   playAudio1Action->setEnabled(false);
   playAudio2Action->setEnabled(false);
@@ -1122,6 +1127,8 @@
   goinput->setEnabled(false);
   gobutton2->setEnabled(false);
   goinput2->setEnabled(false);
+  frameseqbutton->setEnabled(false);
+  frameseqinput->setEnabled(false);
 
 #ifdef HAVE_LIB_AO
 
@@ -1470,6 +1477,25 @@
   //goinput2->clear();
 }
 
+void dvbcut::clickedframeseq()
+{
+  QString text = frameseqinput->text();
+  text.stripWhiteSpace();
+  bool okay = false;
+  int dist;
+  if (text.contains(':') || text.contains('.')) {
+    okay = true;
+    dist = string2pts(text) / getTimePerFrame();
+  }
+  else
+    dist = text.toInt(&okay, 0);
+  if (okay) {
+    frameseq_->distance(dist);
+    frameseq_->update(curpic, fine /* true */);
+  }
+  //frameseqinput->clear();
+}
+
 void dvbcut::mplayer_exited()
 {
   if (mplayer_process) {
@@ -1492,6 +1518,8 @@
   goinput->setEnabled(true);
   gobutton2->setEnabled(true);
   goinput2->setEnabled(true);
+  frameseqbutton->setEnabled(true);
+  frameseqinput->setEnabled(true);
 
 #ifdef HAVE_LIB_AO
 
@@ -1580,10 +1608,16 @@
   if (showimage) {
     if (!imgp)
       imgp=new imageprovider(*mpg,new dvbcutbusy(this),false,viewscalefactor);
+
     QPixmap px=imgp->getimage(curpic,fine);
     imagedisplay->setMinimumSize(px.size());
     imagedisplay->setPixmap(px);
     qApp->processEvents();
+
+    if (!frameseq_->imgp())
+      frameseq_->imgp(new imageprovider(*mpg, new dvbcutbusy(this), false, viewscalefactor * 7.));
+
+    frameseq_->update(curpic, fine);
   }
 }
 
@@ -1728,6 +1762,8 @@
   gobutton->setEnabled(false);
   goinput2->setEnabled(false);
   gobutton2->setEnabled(false);
+  frameseqbutton->setEnabled(false);
+  frameseqinput->setEnabled(false);
   linslider->setEnabled(false);
   jogslider->setEnabled(false);
 
@@ -2076,6 +2112,8 @@
   gobutton->setEnabled(true);
   goinput2->setEnabled(true);
   gobutton2->setEnabled(true);
+  frameseqbutton->setEnabled(true);
+  frameseqinput->setEnabled(true);
   linslider->setEnabled(true);
   jogslider->setEnabled(true);
 
Index: src/framesequence.h
===================================================================
--- src/framesequence.h	(revision 0)
+++ src/framesequence.h	(revision 0)
@@ -0,0 +1,48 @@
+#ifndef __framesequence_h_included__
+#define __framesequence_h_included__
+
+// -*- mode: c++ -*-
+// Copyright (c) 2009 Olaf Dietsche
+
+#include <vector>
+#include <qobject.h>
+class QBoxLayout;
+class QPushButton;
+class QSlider;
+class QWidget;
+class imageprovider;
+
+class frame : public QObject {
+	Q_OBJECT
+public:
+	QPushButton *image_;
+	int frameno_;
+	QSlider *linslider_;
+public slots:
+	void gotoFrame();
+};
+
+class framesequence {
+public:
+	framesequence(QWidget *parent, int nframes, QSlider *slider, imageprovider *imgp = 0);
+	virtual ~framesequence();
+
+	QBoxLayout *layout() const { return layout_; }
+	imageprovider *imgp() const { return imgp_; }
+	void imgp(imageprovider *imgp)  { imgp_ = imgp; }
+	void distance(int distance) { distance_ = distance; }
+	void update(int frameno, bool decodeallgop);
+
+private:
+	framesequence(const framesequence&);
+	framesequence& operator=(const framesequence&);
+
+	void createWidgets(QWidget *parent, int nframes, QSlider *slider);
+
+	QBoxLayout *layout_;
+	std::vector<frame*> frames_;
+	imageprovider *imgp_;
+	int distance_;
+};
+
+#endif
Index: src/dvbcutbase.ui
===================================================================
--- src/dvbcutbase.ui	(revision 166)
+++ src/dvbcutbase.ui	(working copy)
@@ -363,6 +363,63 @@
                             </widget>
                         </hbox>
                     </widget>
+                    <widget class="QLayoutWidget">
+                        <property name="name">
+                            <cstring>layout6</cstring>
+                        </property>
+                        <hbox>
+                            <property name="name">
+                                <cstring>unnamed</cstring>
+                            </property>
+                            <widget class="QLineEdit">
+                                <property name="name">
+                                    <cstring>frameseqinput</cstring>
+                                </property>
+                                <property name="enabled">
+                                    <bool>false</bool>
+                                </property>
+                                <property name="sizePolicy">
+                                    <sizepolicy>
+                                        <hsizetype>1</hsizetype>
+                                        <vsizetype>0</vsizetype>
+                                        <horstretch>0</horstretch>
+                                        <verstretch>0</verstretch>
+                                    </sizepolicy>
+                                </property>
+                                <property name="maxLength">
+                                    <number>16</number>
+                                </property>
+                            </widget>
+                            <widget class="QPushButton">
+                                <property name="name">
+                                    <cstring>frameseqbutton</cstring>
+                                </property>
+                                <property name="enabled">
+                                    <bool>false</bool>
+                                </property>
+                                <property name="text">
+                                    <string>go</string>
+                                </property>
+                            </widget>
+                            <spacer>
+                                <property name="name">
+                                    <cstring>spacer6</cstring>
+                                </property>
+                                <property name="orientation">
+                                    <enum>Horizontal</enum>
+                                </property>
+                                <property name="sizeType">
+                                    <enum>Expanding</enum>
+                                </property>
+                                <property name="sizeHint">
+                                    <size>
+                                        <width>2</width>
+                                        <height>10</height>
+                                    </size>
+                                </property>
+                            </spacer>
+                        </hbox>
+                    </widget>
                 </vbox>
             </widget>
         </widget>
@@ -1159,6 +1216,18 @@
         <slot>clickedgo2()</slot>
     </connection>
     <connection>
+        <sender>frameseqbutton</sender>
+        <signal>clicked()</signal>
+        <receiver>dvbcutbase</receiver>
+        <slot>clickedframeseq()</slot>
+    </connection>
+    <connection>
+        <sender>frameseqinput</sender>
+        <signal>returnPressed()</signal>
+        <receiver>dvbcutbase</receiver>
+        <slot>clickedframeseq()</slot>
+    </connection>
+    <connection>
         <sender>playPlayAction</sender>
         <signal>activated()</signal>
         <receiver>dvbcutbase</receiver>
@@ -1306,6 +1375,7 @@
     <slot>eventlistcontextmenu(QListBoxItem *, const QPoint &amp;)</slot>
     <slot>clickedgo()</slot>
     <slot>clickedgo2()</slot>
+    <slot>clickedframeseq()</slot>
     <slot>playPlay()</slot>
     <slot>playStop()</slot>
     <slot>playAudio1()</slot>
Index: src/framesequence.cpp
===================================================================
--- src/framesequence.cpp	(revision 0)
+++ src/framesequence.cpp	(revision 0)
@@ -0,0 +1,71 @@
+// -*- mode: c++ -*-
+// Copyright (c) 2009 Olaf Dietsche
+
+#include "framesequence.h"
+#include <sstream>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qslider.h>
+#include "imageprovider.h"
+
+void frame::gotoFrame()
+{
+	linslider_->setValue(frameno_);
+}
+
+framesequence::framesequence(QWidget *parent, int nframes, QSlider *slider, imageprovider *imgp)
+	: layout_(0),
+	  imgp_(imgp),
+	  distance_(7500)
+{
+	createWidgets(parent, nframes, slider);
+}
+
+framesequence::~framesequence()
+{
+	for (std::vector<frame*>::iterator i = frames_.begin(); i != frames_.end(); ++i)
+		delete *i;
+
+	frames_.clear();
+// FIXME	delete layout_;
+}
+
+void framesequence::update(int frameno, bool decodeallgop)
+{
+	if (!imgp_)
+		return;
+
+	int n = frames_.size();
+	frameno -= n / 2 * distance_;
+	for (std::vector<frame*>::iterator i = frames_.begin(); i != frames_.end(); ++i, frameno += distance_) {
+		QPixmap px = imgp_->getimage(frameno, decodeallgop);
+		if (px.isNull()) {
+			(*i)->image_->hide();
+		} else {
+			(*i)->frameno_ = frameno;
+			(*i)->image_->show();
+			(*i)->image_->setMinimumSize(px.size());
+			(*i)->image_->setPixmap(px);
+		}
+	}
+}
+
+void framesequence::createWidgets(QWidget *parent, int nframes, QSlider *slider)
+{
+	layout_ = new QHBoxLayout(-1, "framesequence");
+	QSpacerItem *spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
+	layout_->addItem(spacer);
+	for (int i = 0; i < nframes; ++i) {
+		QPushButton *w = new QPushButton(parent);
+		layout_->addWidget(w);
+		frame *f = new frame();
+		f->image_ = w;
+		f->linslider_ = slider;
+		frames_.push_back(f);
+		QObject::connect(w, SIGNAL(clicked()), f, SLOT(gotoFrame()));
+		w->hide();
+	}
+
+	spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
+	layout_->addItem(spacer);
+}
Index: src/dvbcut.h
===================================================================
--- src/dvbcut.h	(revision 166)
+++ src/dvbcut.h	(working copy)
@@ -31,6 +31,7 @@
 
 class QProcess;
 class imageprovider;
+class framesequence;
 
 class dvbcut: public dvbcutbase
   {
@@ -102,6 +103,7 @@
   int exportformat; 
   bool start_bof; 
   bool stop_eof; 
+  framesequence *frameseq_;
 
 protected:
   //   QPixmap getpixmap(int picture, bool allgop=false);
@@ -186,6 +188,7 @@
   virtual void mplayer_readstdout();
   virtual void clickedgo();
   virtual void clickedgo2();
+  virtual void clickedframeseq();
   virtual void updateimagedisplay();
   virtual void audiotrackchosen(int id);
   virtual void loadrecentfile(int id);
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
DVBCUT-devel mailing list
DVBCUT-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-devel

Reply via email to