Skip to content

Commit

Permalink
if player has 1 renderer, no convertion for renderer supported formats
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 28, 2014
1 parent 15e7846 commit 1f527ea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
2 changes: 0 additions & 2 deletions src/OutputSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ QList<AVOutput *> OutputSet::outputs()

void OutputSet::sendVideoFrame(const VideoFrame &frame)
{
QMutexLocker lock(&mMutex);
Q_UNUSED(lock);
if (mOutputs.isEmpty())
return;
foreach(AVOutput *output, mOutputs) {
Expand Down
51 changes: 37 additions & 14 deletions src/VideoThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,16 @@ VideoCapture* VideoThread::setVideoCapture(VideoCapture *cap)

void VideoThread::setBrightness(int val)
{
DPTR_D(VideoThread);
setEQ(val, 101, 101);
}

void VideoThread::setContrast(int val)
{
DPTR_D(VideoThread);
setEQ(101, val, 101);
}

void VideoThread::setSaturation(int val)
{
DPTR_D(VideoThread);
setEQ(101, 101, val);
}

Expand Down Expand Up @@ -256,11 +253,12 @@ void VideoThread::run()
pkt = Packet();
}
}

if (skip_render)
continue;
VideoFrame frame = dec->frame();
if (!frame.isValid())
if (!frame.isValid()) {
qWarning("invalid video frame");
continue;
}
if (skip_render)
continue;
d.conv->setInFormat(frame.pixelFormatFFmpeg());
d.conv->setInSize(frame.width(), frame.height());
Expand Down Expand Up @@ -300,16 +298,41 @@ void VideoThread::run()
qDebug("video thread stop before send decoded data");
break;
}
if (!frame.convertTo(VideoFormat::Format_RGB32)) {
/*
* TODO: send andway and let renderer deal with it?
* renderer may update background but no frame to graw, so flickers
* may crash for some renderer(e.g. d2d) without validate and render an invalid frame
*/
continue;

/*
* TODO: video renderers sorted by preferredPixelFormat() and convert in AVOutputSet.
* Convert only once for the renderers has the same preferredPixelFormat().
*/
d.outputSet->lock();
QList<AVOutput *> outputs = d.outputSet->outputs();
if (outputs.size() > 1) {
if (!frame.convertTo(VideoFormat::Format_RGB32)) {
/*
* use VideoFormat::Format_User to deliver user defined frame
* renderer may update background but no frame to graw, so flickers
* may crash for some renderer(e.g. d2d) without validate and render an invalid frame
*/
d.outputSet->unlock();
continue;
}
} else {
VideoRenderer *vo = static_cast<VideoRenderer*>(outputs.first());
if (!vo->isSupported(frame.pixelFormat())) {
if (!frame.convertTo(vo->preferredPixelFormat())) {
/*
* use VideoFormat::Format_User to deliver user defined frame
* renderer may update background but no frame to graw, so flickers
* may crash for some renderer(e.g. d2d) without validate and render an invalid frame
*/
d.outputSet->unlock();
continue;
}
}
}
d.outputSet->sendVideoFrame(frame); //TODO: group by format, convert group by group
d.outputSet->unlock();
d.capture->setPosition(pts);
// TODO: capture yuv frames
if (d.capture->isRequested()) {
bool auto_name = d.capture->name.isEmpty() && d.capture->autoSave();
if (auto_name) {
Expand Down

0 comments on commit 1f527ea

Please sign in to comment.