void VideoWidget::overlayFrameReady() { if(!m_overlaySource) return; // if(!frame.isEmpty()) // m_overlayFrame = frame; VideoFramePtr f = m_overlaySource->frame(); if(!f) return; if(f->isValid()) { // if(m_overlayFrame && // m_overlayFrame->release()) // delete m_overlayFrame; m_overlayFrame = f; } // else // { // if(f->release()) // delete f; // } if(m_overlayFrame->image().size() != m_overlaySourceRect.size()) updateOverlaySourceRects(); }
void VideoWidget::oldFrameReady() { if(!m_oldThread) return; VideoFramePtr f = m_oldThread->frame(); if(!f) return; if(f->isValid()) { // if(m_oldFrame && // m_oldFrame->release()) // delete m_oldFrame; m_oldFrame = f; } // else // { // if(f->release()) // delete f; // } // if(m_frame->image().size() != m_origSourceRect.size()) // updateRects(); }
void VideoFilter::frameAvailable() { // qDebug() << "GLVideoDrawable::frameReady(): "<<objectName()<<" m_source:"<<m_source; if(m_source) { VideoFramePtr f = m_source->frame(); // enqueue(f); // return; //qDebug() << "GLVideoDrawable::frameReady(): "<<objectName()<<" f:"<<f; if(!f) return; if(f->isValid()) { QMutexLocker lock(&m_frameAccessMutex); m_frame = f; if(m_isThreaded) { m_frameDirty = true; } else { if(m_processTimer.isActive()) m_processTimer.stop(); m_processTimer.start(); } } } }
void VideoWidget::frameReady() { if(!m_thread) return; // if(frame.isEmpty()) // qDebug() << "VideoWidget::frameReady(): isEmpty: "<<frame.isEmpty(); VideoFramePtr f = m_thread->frame(); if(!f) return; #ifdef DEBUG_VIDEOFRAME_POINTERS qDebug() << "VideoWidget::frameReady(): Received frame ptr:"<<f; #endif if(f->isValid()) { // if(m_frame && // m_frame->release()) // { // #ifdef DEBUG_VIDEOFRAME_POINTERS // qDebug() << "VideoWidget::frameReady(): Deleting old m_frame:"<<m_frame; // #endif // // delete m_frame; // } m_frame = f; #ifdef DEBUG_VIDEOFRAME_POINTERS qDebug() << "VideoWidget::frameReady(): Received new m_frame:"<<m_frame; #endif } // else // { // if(f->release()) // { // #ifdef DEBUG_VIDEOFRAME_POINTERS // qDebug() << "VideoWidget::frameReady(): Deleting invalid f ptr:"<<f; // #endif // // delete f; // } // } if(m_frame && (m_frame->size() != m_origSourceRect.size() || m_targetRect.isEmpty() || m_sourceRect.isEmpty())) updateRects(); //qDebug() << "VideoWidget::frameReady: frame size:"<<m_frame->size()<<", orig source rect size:" <<m_origSourceRect.size(); //QTimer::singleShot(0, this, SLOT(updateTimer())); repaint(); }
void V4LOutput::getFrame() { VideoFramePtr frame = m_source->frame(); if(!frame || !frame->isValid()) { //qDebug() << "V4LOutput::frameReady(): Invalid frame or no frame"; return; } m_frame = frame; if(m_frame->size() != m_outputSize) { m_outputSize = m_frame->size(); setupOutput(); } //if(m_transmitFps <= 0) processFrame(); }
void BMDOutput::getFrame() { VideoFramePtr frame = m_source->frame(); if(!frame || !frame->isValid()) { //qDebug() << "BMDOutput::frameReady(): Invalid frame or no frame"; return; } #ifdef ENABLE_DECKLINK_CAPTURE if(!m_bmd) { m_bmd = BMDOutputDelegate::openDevice(m_bmdOutputName); if(!m_bmd) qDebug() << "BMDOutput::getFrame: Unable to open"<<m_bmdOutputName<<"for output, output will be disabled."; else qDebug() << "BMDOutput::getFrame: Opened"<<m_bmdOutputName<<"with delegate:"<<m_bmd; } if(m_bmd) m_bmd->SetCurrentFrame(frame); #endif }
void BMDOutputDelegate::PrepareFrame() { if(!m_frame || !m_frame->isValid()) return; // To scale the video frame, first we must convert it to a QImage if its not already an image. // If we're lucky, it already is. Otherwise, we have to jump thru hoops to convert the byte // array to a QImage then scale it. QImage image; if(!m_frame->image().isNull()) { image = m_frame->image(); } else { const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(m_frame->pixelFormat()); if(imageFormat != QImage::Format_Invalid) { image = QImage(m_frame->pointer(), m_frame->size().width(), m_frame->size().height(), m_frame->size().width() * (imageFormat == QImage::Format_RGB16 || imageFormat == QImage::Format_RGB555 || imageFormat == QImage::Format_RGB444 || imageFormat == QImage::Format_ARGB4444_Premultiplied ? 2 : imageFormat == QImage::Format_RGB888 || imageFormat == QImage::Format_RGB666 || imageFormat == QImage::Format_ARGB6666_Premultiplied ? 3 : 4), imageFormat); //image = image.copy(); //qDebug() << "Downscaled image from "<<image.byteCount()<<"bytes to "<<scaledImage.byteCount()<<"bytes, orig ptr len:"<<m_frame->pointerLength()<<", orig ptr:"<<m_frame->pointer(); } else { qDebug() << "BMDOutputDelegate::frameImage: Unable to convert pixel format to image format, cannot scale frame. Pixel Format:"<<m_frame->pixelFormat(); } } //qDebug() << "BMDOutputDelegate::ScheduleNextFrame: [1] VideoFrame->QImage: "<<t.restart()<<" ms"; if(image.format() != QImage::Format_ARGB32) image = image.convertToFormat(QImage::Format_ARGB32); //qDebug() << "BMDOutputDelegate::ScheduleNextFrame: [2] Format Conversion: "<<t.restart()<<" ms"; if(image.width() != (int)m_frameWidth || image.height() != (int)m_frameHeight) { image = image.scaled(m_frameWidth, m_frameHeight, Qt::IgnoreAspectRatio); //, Qt::SmoothTransformation); // image = image.scaled(m_frameWidth, m_frameHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation); // // QImage frame(m_frameWidth, m_frameHeight, QImage::Format_ARGB32); // frame.fill(Qt::black); // QPainter p(&frame); // QRect rect = image.rect(); // // rect.moveCenter(frame.rect().center()); // // p.drawImage(rect.topLeft(), image); // p.end(); // // image = frame; } m_image = image.copy(); }