Skip to content

Commit 7ba94c4

Browse files
committed
gl: convert pal8 to rgb by sws wang-bin#776
what about gray video?
1 parent 5f1edc2 commit 7ba94c4

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

qml/QQuickItemRenderer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ VideoRendererId QQuickItemRenderer::id() const
9494

9595
bool QQuickItemRenderer::isSupported(VideoFormat::PixelFormat pixfmt) const
9696
{
97-
if (pixfmt == VideoFormat::Format_RGB48BE)
97+
if (pixfmt == VideoFormat::Format_RGB48BE
98+
|| pixfmt == VideoFormat::Format_Invalid
99+
)
98100
return false;
99101
if (!isOpenGL())
100102
return VideoFormat::isRGB(pixfmt);

qml/QuickFBORenderer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ QQuickFramebufferObject::Renderer* QuickFBORenderer::createRenderer() const
116116

117117
bool QuickFBORenderer::isSupported(VideoFormat::PixelFormat pixfmt) const
118118
{
119-
if (pixfmt == VideoFormat::Format_RGB48BE)
119+
if (pixfmt == VideoFormat::Format_RGB48BE
120+
|| pixfmt == VideoFormat::Format_Invalid)
120121
return false;
121122
if (!isOpenGL())
122123
return VideoFormat::isRGB(pixfmt);

src/VideoThread.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,12 @@ bool VideoThread::deliverVideoFrame(VideoFrame &frame)
218218
if (vo && (!vo->isSupported(frame.pixelFormat())
219219
|| (vo->isPreferredPixelFormatForced() && vo->preferredPixelFormat() != frame.pixelFormat())
220220
)) {
221-
VideoFrame outFrame(d.conv.convert(frame, vo->preferredPixelFormat()));
221+
VideoFormat fmt(frame.format());
222+
if (fmt.hasPalette() || fmt.isRGB())
223+
fmt = VideoFormat::Format_RGB32;
224+
else
225+
fmt = vo->preferredPixelFormat();
226+
VideoFrame outFrame(d.conv.convert(frame, fmt));
222227
if (!outFrame.isValid()) {
223228
d.outputSet->unlock();
224229
return false;
@@ -612,6 +617,14 @@ void VideoThread::run()
612617
//qDebug("v_a:%.4f, v_a_: %.4f", v_a, v_a_);
613618
}
614619
}
620+
#if 0
621+
if (d.stop) {// user stop
622+
// decode eof?
623+
qDebug("decoding eof...");
624+
625+
while (d.dec && d.dec->decode(Packet::createEOF())) {d.dec->flush();}
626+
}
627+
#endif
615628
d.packets.clear();
616629
qDebug("Video thread stops running...");
617630
}

src/opengl/OpenGLVideo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ OpenGLVideo::OpenGLVideo() {}
153153

154154
bool OpenGLVideo::isSupported(VideoFormat::PixelFormat pixfmt)
155155
{
156-
return pixfmt != VideoFormat::Format_RGB48BE;
156+
return pixfmt != VideoFormat::Format_RGB48BE && pixfmt != VideoFormat::Format_Invalid;
157157
}
158158

159159
void OpenGLVideo::setOpenGLContext(QOpenGLContext *ctx)
@@ -197,7 +197,7 @@ void OpenGLVideo::setOpenGLContext(QOpenGLContext *ctx)
197197
// TODO: what if ctx is delete?
198198
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
199199
d.manager = new ShaderManager(ctx);
200-
QObject::connect(ctx, SIGNAL(aboutToBeDestroyed()), this, SLOT(resetGL()), Qt::DirectConnection); //direct?
200+
QObject::connect(ctx, SIGNAL(aboutToBeDestroyed()), this, SLOT(resetGL()), Qt::DirectConnection); // direct to make sure there is a valid context. makeCurrent in window.aboutToBeDestroyed()?
201201
#else
202202
d.manager = new ShaderManager(this);
203203
#endif

0 commit comments

Comments
 (0)