]> git.sesse.net Git - kdenlive/commitdiff
New: analyse stopmotion video feed through color scopes
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 15 Nov 2010 22:24:08 +0000 (22:24 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 15 Nov 2010 22:24:08 +0000 (22:24 +0000)
svn path=/trunk/kdenlive/; revision=5101

src/blackmagic/capture.cpp
src/blackmagic/capture.h
src/kdenlivesettings.kcfg
src/mainwindow.cpp
src/stopmotion/capturehandler.cpp
src/stopmotion/capturehandler.h
src/stopmotion/stopmotion.cpp
src/stopmotion/stopmotion.h
src/v4l/v4lcapture.cpp
src/v4l/v4lcapture.h

index 2989cacfbb3da89abb028c49a8641d52eddcacc8..fd957d80423c6604c0976e164cc451db33969fab 100644 (file)
@@ -338,6 +338,11 @@ void DeckLinkCaptureDelegate::slotProcessFrame()
     videoFrame->Release();
 }
 
+void DeckLinkCaptureDelegate::setAnalyse(bool isOn)
+{
+    m_analyseFrame = isOn;
+}
+
 HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame* videoFrame, IDeckLinkAudioInputPacket* audioFrame)
 {
     IDeckLinkVideoFrame*                    rightEyeFrame = NULL;
@@ -383,6 +388,12 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
                 doCaptureFrame.clear();
                 QtConcurrent::run(this, &DeckLinkCaptureDelegate::slotProcessFrame);
             }
+            if (m_analyseFrame) {
+               QImage image(videoFrame->GetWidth(), videoFrame->GetHeight(), QImage::Format_ARGB32_Premultiplied);
+               //convert from uyvy422 to rgba
+               CaptureHandler::uyvy2rgb((uchar *)frameBytes, (uchar *)image.bits(), videoFrame->GetWidth(), videoFrame->GetHeight());
+               emit gotFrame(image);
+           }
 
             if (videoOutputFile != -1) {
                 videoFrame->GetBytes(&frameBytes);
@@ -536,7 +547,9 @@ void BmdCaptureHandler::startPreview(int deviceId, int captureMode, bool audio)
     }
 
     delegate = new DeckLinkCaptureDelegate();
+    delegate->setAnalyse(m_analyseFrame);
     connect(delegate, SIGNAL(gotTimeCode(ulong)), this, SIGNAL(gotTimeCode(ulong)));
+    connect(delegate, SIGNAL(gotFrame(QImage)), this, SIGNAL(gotFrame(QImage)));
     connect(delegate, SIGNAL(gotMessage(const QString &)), this, SIGNAL(gotMessage(const QString &)));
     connect(delegate, SIGNAL(frameSaved(const QString)), this, SIGNAL(frameSaved(const QString)));
     deckLinkInput->SetCallback(delegate);
index ea60196f51d2a9058f10dd23627a8f0597107964..5e038caf61ae38ed344a842c0772c980c1a3dd82 100644 (file)
@@ -20,7 +20,7 @@ class DeckLinkCaptureDelegate : public QObject, public IDeckLinkInputCallback
 public:
     DeckLinkCaptureDelegate();
     virtual ~DeckLinkCaptureDelegate();
-
+    void setAnalyse(bool isOn);
     virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID /*iid*/, LPVOID */*ppv*/) {
         return E_NOINTERFACE;
     }
@@ -34,6 +34,7 @@ private:
     pthread_mutex_t     m_mutex;
     QList <IDeckLinkVideoInputFrame*> m_framesList;
     QStringList m_framePath;
+    bool m_analyseFrame;
 
 private slots:
     void slotProcessFrame();
@@ -42,6 +43,7 @@ signals:
     void gotTimeCode(ulong);
     void gotMessage(const QString &);
     void frameSaved(const QString);
+    void gotFrame(QImage);
 };
 
 class BmdCaptureHandler : public CaptureHandler
index f3bedc013a352271d21c5e4eb68a57c38f83c4ab..5ffaf0dc4963b89b32fa9a66753151169d3fb374 100644 (file)
       <label>Update parameters while monitor scene changes.</label>
       <default>false</default>
     </entry>
+    <entry name="analyse_stopmotion" type="Bool">
+      <label>Send stopmotion frames to scopes for live analysis.</label>
+      <default>false</default>
+    </entry>
 
     <entry name="showstopmotionthumbs" type="Bool">
       <label>Show sequence thumbnails in stopmotion widget.</label>
index ff4b5255aae3b335920db309529cb8cf3d01efd3..b9072cf9d02f49b484a026bc18a131903ad2a367 100644 (file)
@@ -3995,6 +3995,12 @@ void MainWindow::slotOpenStopmotion()
     if (m_stopmotion == NULL) {
         m_stopmotion = new StopmotionWidget(m_activeDocument->projectFolder(), m_stopmotion_actions->actions(), this);
         connect(m_stopmotion, SIGNAL(addOrUpdateSequence(const QString)), m_projectList, SLOT(slotAddOrUpdateSequence(const QString)));
+       for (int i = 0; i < m_scopesList.count(); i++) {
+           // Check if we need the renderer to send a new frame for update
+           /*if (!m_scopesList.at(i)->widget()->visibleRegion().isEmpty() && !(static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->autoRefreshEnabled())) request = true;*/
+           connect(m_stopmotion, SIGNAL(gotFrame(QImage)), static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget()), SLOT(slotRenderZoneUpdated(QImage)));
+           //static_cast<AbstractScopeWidget *>(m_scopesList.at(i)->widget())->slotMonitorCapture();
+       }
     }
     m_stopmotion->show();
 }
index fc3a9b4989ca10f389824c3239f2a1f3c4af98dc..e41a06ff2989055ca3fb5eb9e4069c839f45a540 100644 (file)
@@ -24,7 +24,8 @@
 
 CaptureHandler::CaptureHandler(QVBoxLayout *lay, QWidget *parent):
     m_layout(lay),
-    m_parent(parent)
+    m_parent(parent),
+    m_analyseFrame(KdenliveSettings::analyse_stopmotion())
 {
 }
 
@@ -33,6 +34,11 @@ CaptureHandler::~CaptureHandler()
     stopCapture();
 }
 
+void CaptureHandler::setAnalyse(bool isOn)
+{
+    m_analyseFrame = isOn;
+}
+
 void CaptureHandler::stopCapture()
 {
 }
index 947111ab9d5822bb5e6118559c306a71725f8b18..9e1e3502979ea63fd768be30078af6bc184c4ce9 100644 (file)
@@ -40,17 +40,20 @@ public:
     virtual void hidePreview(bool hide) = 0;
     virtual QStringList getDeviceName(QString input) = 0;
     virtual void setDevice(const QString input, QString size = QString()) = 0;
+    void setAnalyse(bool isOn);
     static void uyvy2rgb(unsigned char *yuv_buffer, unsigned char *rgb_buffer, int width, int height);
     static void yuyv2rgb(unsigned char *yuv_buffer, unsigned char *rgb_buffer, int width, int height);
 
 protected:
     QVBoxLayout *m_layout;
     QWidget *m_parent;
+    bool m_analyseFrame;
 
 signals:
     void gotTimeCode(ulong);
     void gotMessage(const QString &);
     void frameSaved(const QString);
+    void gotFrame(QImage);
 };
 
 
index 5f3138e5518b6492fc85673f6551d3061e433a43..9026c7675cd695e077cb7e26b22f8e43353363b8 100644 (file)
@@ -89,7 +89,7 @@ void MyLabel::paintEvent(QPaintEvent * event)
 }
 
 
-StopmotionWidget::StopmotionWidget(KUrl projectFolder, const QList< QAction * > actions, QWidget *parent) :
+StopmotionWidget::StopmotionWidget(KUrl projectFolder, QList< QAction * > actions, QWidget *parent) :
     QDialog(parent)
     , Ui::Stopmotion_UI()
     , m_projectFolder(projectFolder)
@@ -98,6 +98,10 @@ StopmotionWidget::StopmotionWidget(KUrl projectFolder, const QList< QAction * >
     , m_animatedIndex(-1)
 {
     //setAttribute(Qt::WA_DeleteOnClose);
+    QAction *analyse = new QAction(i18n("Send frames to color scopes"), this);
+    analyse->setCheckable(true);
+    analyse->setChecked(KdenliveSettings::analyse_stopmotion());
+    connect(analyse, SIGNAL(triggered(bool)), this, SLOT(slotSwitchAnalyse(bool)));
     addActions(actions);
     setupUi(this);
     setWindowTitle(i18n("Stop Motion Capture"));
@@ -169,6 +173,7 @@ StopmotionWidget::StopmotionWidget(KUrl projectFolder, const QList< QAction * >
     confMenu->addAction(showThumbs);
     confMenu->addAction(capInterval);
     confMenu->addAction(removeCurrent);
+    confMenu->addAction(analyse);
     config_button->setIcon(KIcon("configure"));
     config_button->setMenu(confMenu);
 
@@ -221,6 +226,7 @@ StopmotionWidget::StopmotionWidget(KUrl projectFolder, const QList< QAction * >
     connect(capture_device, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateHandler()));
     if (m_bmCapture) {
         connect(m_bmCapture, SIGNAL(frameSaved(const QString)), this, SLOT(slotNewThumb(const QString)));
+       connect(m_bmCapture, SIGNAL(gotFrame(QImage)), this, SIGNAL(gotFrame(QImage)));
     } else live_button->setEnabled(false);
     m_frame_preview = new MyLabel(this);
     connect(m_frame_preview, SIGNAL(seek(bool)), this, SLOT(slotSeekFrame(bool)));
@@ -629,3 +635,11 @@ void StopmotionWidget::slotRemoveFrame()
         delete item;
     }
 }
+
+void StopmotionWidget::slotSwitchAnalyse(bool isOn)
+{
+    KdenliveSettings::setAnalyse_stopmotion(isOn);
+    m_bmCapture->setAnalyse(isOn);
+}
+
+
index 9da28ad60253fa3076c2932128d6ff9cb6efdeb3..f102f41ffcd5b818fd4ffffd7c524e94872a0e4e 100644 (file)
@@ -60,7 +60,7 @@ public:
      * @param projectFolder The current project folder, where captured files will be stored.
      * @param actions The actions for this widget that can have a keyboard shortcut.
      * @param parent (optional) parent widget */
-    StopmotionWidget(KUrl projectFolder, const QList< QAction * > actions, QWidget *parent = 0);
+    StopmotionWidget(KUrl projectFolder, QList< QAction * > actions, QWidget *parent = 0);
     virtual ~StopmotionWidget();
 
 protected:
@@ -196,12 +196,14 @@ private slots:
 
     /** @brief Delete current frame from disk. */
     void slotRemoveFrame();
-
+    /** @brief Enable / disable frame analysis (in color scopes). */
+    void slotSwitchAnalyse(bool isOn);
 signals:
     /** @brief Ask to add sequence to current project. */
     void addOrUpdateSequence(const QString);
 
     void doCreateThumbs(QImage, int);
+    void gotFrame(QImage);
 };
 
 #endif
index 7355e2bc5d4479855a4d2e20d072d003113838fe..76d9a4a68d66d1638774cfdd215c847fbde89102 100644 (file)
@@ -329,6 +329,9 @@ void V4lCaptureHandler::slotUpdate()
         fswc_add_image_grey(&v4lsrc, qimg.bits());
         break;
     }
+    if (m_analyseFrame) {
+       emit gotFrame(qimg);
+    }
     if (!m_captureFramePath.isEmpty()) {
         qimg.save(m_captureFramePath);
         emit frameSaved(m_captureFramePath);
index 80ed0d4ea5457575635b8437fc374a651f350aa2..4a72ed1338919a7e5494d9fc19a8733088ce795a 100644 (file)
@@ -59,6 +59,7 @@ private:
 
 private slots:
     void slotUpdate();
+
 };