Ana Guerrero 2023-11-06 20:15:05 +00:00 committed by Git OBS Bridge
commit fd4d339a23
11 changed files with 71 additions and 1059 deletions

View File

@ -1,65 +0,0 @@
From 78a2ef9d823cd61b60957948490373dabfed4f1f Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Tue, 25 Jan 2022 14:01:56 +0100
Subject: [PATCH] Fix compilation with ffmpeg5 #63
---
src/streamprocessor/streamprocessor.cpp | 2 +-
src/videoplayer/backend/decoder.h | 1 +
src/videoplayer/backend/framequeue.h | 1 +
src/videoplayer/backend/streamdemuxer.cpp | 2 +-
4 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/streamprocessor/streamprocessor.cpp b/src/streamprocessor/streamprocessor.cpp
index b86795e..8faf8a2 100644
--- a/src/streamprocessor/streamprocessor.cpp
+++ b/src/streamprocessor/streamprocessor.cpp
@@ -195,7 +195,7 @@ StreamProcessor::findStream(int streamType, int streamIndex, bool imageSub)
int ret;
char errorText[1024];
- AVCodec *dec = avcodec_find_decoder(m_avStream->codecpar->codec_id);
+ const AVCodec *dec = avcodec_find_decoder(m_avStream->codecpar->codec_id);
if(!dec) {
qWarning() << "Failed to find decoder for stream" << i;
return false;
diff --git a/src/videoplayer/backend/decoder.h b/src/videoplayer/backend/decoder.h
index 4ab95b2..fb6840d 100644
--- a/src/videoplayer/backend/decoder.h
+++ b/src/videoplayer/backend/decoder.h
@@ -11,6 +11,7 @@
#include <QThread>
extern "C" {
+#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
}
diff --git a/src/videoplayer/backend/framequeue.h b/src/videoplayer/backend/framequeue.h
index dc9b2fa..ece1166 100644
--- a/src/videoplayer/backend/framequeue.h
+++ b/src/videoplayer/backend/framequeue.h
@@ -9,6 +9,7 @@
#define FRAMEQUEUE_H
extern "C" {
+#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
}
diff --git a/src/videoplayer/backend/streamdemuxer.cpp b/src/videoplayer/backend/streamdemuxer.cpp
index 1e339b3..e8320ea 100644
--- a/src/videoplayer/backend/streamdemuxer.cpp
+++ b/src/videoplayer/backend/streamdemuxer.cpp
@@ -230,7 +230,7 @@ StreamDemuxer::componentOpen(int streamIndex)
{
AVFormatContext *ic = m_vs->fmtContext;
AVCodecContext *avCtx;
- AVCodec *codec;
+ const AVCodec *codec;
AVDictionary *opts = nullptr;
AVDictionaryEntry *t = nullptr;
int sampleRate, nbChannels;
--
2.40.1

View File

@ -1,25 +0,0 @@
From 12f4d7f49d0b1a7fc02b0836521a285e7b6bac9d Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <aacid@kde.org>
Date: Sat, 4 Mar 2023 10:58:04 +0100
Subject: [PATCH] Use non deprecated ffmpeg api
---
src/videoplayer/backend/streamdemuxer.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/videoplayer/backend/streamdemuxer.cpp b/src/videoplayer/backend/streamdemuxer.cpp
index e3bd808..39222d8 100644
--- a/src/videoplayer/backend/streamdemuxer.cpp
+++ b/src/videoplayer/backend/streamdemuxer.cpp
@@ -504,7 +504,7 @@ StreamDemuxer::run()
{ // find_stream_info
const int origNbStreams = ic->nb_streams;
- AVDictionary **opts = (AVDictionary **)av_mallocz_array(origNbStreams, sizeof(*opts));
+ AVDictionary **opts = (AVDictionary **)av_calloc(origNbStreams, sizeof(*opts));
if(!opts) {
av_log(nullptr, AV_LOG_ERROR, "Could not alloc memory for stream options.\n");
goto cleanup;
--
2.40.1

View File

@ -1,32 +0,0 @@
From 47376250728b8334ef2476c6f2a5fc956ee70e68 Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Fri, 1 Apr 2022 08:35:17 +0200
Subject: [PATCH] VideoPlayer: Fix usage of deprecated/removed AVCodec option
#68
AVCodecContext.refcounted_frames was useful for deprecated API only
(avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
(avcodec_send_packet/avcodec_receive_frame) always work with reference
counted frames
https://github.com/FFmpeg/FFmpeg/commit/b1cf151c4dfdbd049cd41863b4e0cde927585e17
---
src/videoplayer/backend/streamdemuxer.cpp | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/videoplayer/backend/streamdemuxer.cpp b/src/videoplayer/backend/streamdemuxer.cpp
index e8320ea..7173306 100644
--- a/src/videoplayer/backend/streamdemuxer.cpp
+++ b/src/videoplayer/backend/streamdemuxer.cpp
@@ -286,8 +286,6 @@ StreamDemuxer::componentOpen(int streamIndex)
av_dict_set(&opts, "threads", "auto", 0);
if(stream_lowres)
av_dict_set_int(&opts, "lowres", stream_lowres, 0);
- if(avCtx->codec_type == AVMEDIA_TYPE_VIDEO || avCtx->codec_type == AVMEDIA_TYPE_AUDIO)
- av_dict_set(&opts, "refcounted_frames", "1", 0);
if((ret = avcodec_open2(avCtx, codec, &opts)) < 0) {
goto fail;
}
--
2.40.1

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ef9cb3c0c1fe1f40cf9d8e795859b9b28adf2da3be77a076d46bc28df4cd0255
size 636808

View File

@ -1,16 +0,0 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEEdveQB6VKS2jxVHko4kGHRu+dmyYFAmFdHngACgkQ4kGHRu+d
mybPihAAgwFv4Ksuo6ZgSX4R6N/dd7Bmw94GSd/zjOZQpQ7ELvjd9eFy4ReSTZaY
g1KlsG1gJf7D3HSR5eaCfWGhfZ/wS3yIT+eeij8BlGNThdyuPh4eBEeXergM3nBj
jgcUBUQ7eoy/wkI99jZlNY8i5ouRiqlVGp93Tq1wtbSqaJ1Xf6+FAX8xa+9SjuLJ
p2cHLrqHEb27p5Ae3WC9+Eiaqgj6pLYOPfiut629J1x6Bx0O9qcSQxdqm7FVBDve
q0JLDQo3IrBL1mVrp3aWjVdScHGeBp+nL3R9hh7Hor9y5HSYfHD4m1SewCl6chCN
73PxFy6BQ10XLcxs34qCtsiSueY0ToS/+yFbC833YSEgymYKXcgeh4Hm2zc59dDe
GtEf5J6N94Knbd85AoB1p+/zRF3fv/ec7BlX4l0gJAnpEwOZKbxe5YjrqdylEWb4
4ddHtHGRJAWyEAhJMoH7ayDSYCUhtEcuGBgFZqhYIojpJihLeBnsgbPua/54iBYH
Z71a5tM6xcOu09beIDgxcsV5aBbiV/mgBaK+CAg4/4kAPYWnTzbM5xJXpEplxjZr
l9citFgZzMyAWzA0zl+hMbPTkyt230Unj79NAk1iSNHRlMNIomkgJNWVw0SYFzgE
frQ2HVnBYsMACX06MYS9YCyaW/6aGYTnJa8kaJTwbFu016ZbGAA=
=FxK6
-----END PGP SIGNATURE-----

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b1416bdf7223b1979a36620b913c117c1b6c933bf165e28491af476310d7c9f8
size 730800

View File

@ -0,0 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEEdveQB6VKS2jxVHko4kGHRu+dmyYFAmVI1ZoACgkQ4kGHRu+d
mya4pA/+JFRUft/OeORU3qiXWrVmhA/l6x3enpW0h+gKJSQ/8CrcVU/7G9kN00c6
AqHC23DoAekM8u2c8Dhld9rRyoDNSls0iR1SKg11gB1EAfD/9vedFDXi0Chy6iRD
IUdbIR7wtkyFMY7U+f+o7n/d+ujgCdMBvy9zu1Dbvy2xtLrG4VSzLdiR3I50u8qG
m8uddtofQvL+sSd4SSYdSdAFnmQoNngKz0N3PWldK5pw5Pwm3ZMAD79M6hr49N84
y5exdVzKMdNYuYIKr6xMbDnq6nAAhEi95rO3dVWQfZLblgzoRj/Vkn7JkJsial+o
dryoa2UoL79BRwg5ET9eHcEuo6Hsj1uAqSW9Zm3X/Bj5vvpR3ajbu4RSUhy7nrxR
9NfJ0Tcx7+Qxy7JChMeGsid9aejoOPTtN/4RRTvvkRbMWKaJCoT+duA3zHJCEPe0
qBDnCty5XByXygQHnj9SztEWUe5DYPYcYwIgdooBaZ2g4aha7vRecWWQ52IGy4MV
aEpiWS1g2zof6QRwfRSojMln2pyXq7K2GDF9qedf+U7BIgA3gJRaqbCAU23B55ky
TIlk1miPIBba4EFCF2X6LX/1QT0/SULOnWcZlUZkVgpcAH04dBch4/jNOkQ7sXPM
5f5vjrZPWfw+1QPPcXChUnvqj/4jo+kd/hK9T4Oyv+IpIU7bvA4=
=i/KS
-----END PGP SIGNATURE-----

View File

@ -1,799 +0,0 @@
From 167a941f8070f4a9abacb3aa2f61ee6ee00d6cb8 Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Thu, 7 Oct 2021 19:37:23 +0200
Subject: [PATCH] GLRenderer: added GLES support
---
src/videoplayer/backend/glrenderer.cpp | 44 ++++++++++++++++++++++----
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/src/videoplayer/backend/glrenderer.cpp b/src/videoplayer/backend/glrenderer.cpp
index 7c9c38b..5cb985d 100644
--- a/src/videoplayer/backend/glrenderer.cpp
+++ b/src/videoplayer/backend/glrenderer.cpp
@@ -20,6 +20,7 @@ extern "C" {
}
#define DEBUG_GL 0
+#define FORCE_GLES 0
#define OPENGL_CORE 0
#define OPENGL_VER 2,0
@@ -33,6 +34,17 @@ extern "C" {
#define asGL(glCall) glCall
#endif
+#if defined(GL_ES_VERSION_2_0) || FORCE_GLES
+#define USE_GLES
+#define TEXTURE_RGB_FORMAT GL_RGBA
+// NOTE: we don't currently support more than 8bpp on GLES
+#define TEXTURE_U16_FORMAT GL_R8
+#else
+#undef USE_GLES
+#define TEXTURE_RGB_FORMAT GL_BGRA
+#define TEXTURE_U16_FORMAT GL_R16
+#endif
+
using namespace SubtitleComposer;
enum { ID_Y, ID_U, ID_V, ID_OVR, ID_SIZE };
@@ -82,6 +94,9 @@ void
GLRenderer::setupProfile()
{
QSurfaceFormat format(QSurfaceFormat::defaultFormat());
+#if FORCE_GLES
+ format.setRenderableType(QSurfaceFormat::OpenGLES);
+#endif
format.setVersion(OPENGL_VER);
#if DEBUG_GL
format.setOption(QSurfaceFormat::DebugContext);
@@ -126,7 +141,7 @@ GLRenderer::setFrameFormat(int width, int height, int compBits, int crWidthShift
m_crHeight = crHeight;
m_glType = compBytes == 1 ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
- m_glFormat = compBytes == 1 ? GL_R8 : GL_R16;
+ m_glFormat = compBytes == 1 ? GL_R8 : TEXTURE_U16_FORMAT;
delete[] m_bufYUV;
m_bufSize = bufSize;
@@ -261,7 +276,11 @@ GLRenderer::initShader()
delete m_vertShader;
m_vertShader = new QOpenGLShader(QOpenGLShader::Vertex, this);
bool success = m_vertShader->compileSourceCode(
+#ifdef USE_GLES
+ "#version 100\n"
+#else
"#version 120\n"
+#endif
"attribute vec4 vPos;"
"attribute vec2 vVidTex;"
"attribute vec2 vOvrTex;"
@@ -288,7 +307,13 @@ GLRenderer::initShader()
csms.append(QString::number(csm[i], 'g', 10));
}
- success = m_fragShader->compileSourceCode(QStringLiteral("#version 120\n"
+ success = m_fragShader->compileSourceCode(QStringLiteral(
+#ifdef USE_GLES
+ "#version 100\n"
+ "precision mediump float;\n"
+#else
+ "#version 120\n"
+#endif
"varying vec2 vfVidTex;"
"varying vec2 vfOvrTex;"
"uniform sampler2D texY;"
@@ -348,8 +373,15 @@ GLRenderer::initializeGL()
QMutexLocker l(&m_texMutex);
initializeOpenGLFunctions();
- qDebug() << "OpenGL version: " << reinterpret_cast<const char *>(glGetString(GL_VERSION));
- qDebug() << "GLSL version: " << reinterpret_cast<const char *>(glGetString(GL_SHADING_LANGUAGE_VERSION));
+ qDebug().nospace() << "GL API: OpenGL " << (format().renderableType() == QSurfaceFormat::OpenGLES ? "ES" : "Desktop")
+ << ' ' << format().majorVersion() << "." << format().minorVersion()
+#ifdef USE_GLES
+ << " (compiled for OpenGL ES)";
+#else
+ << " (compiled for OpenGL Desktop)";
+#endif
+ qDebug() << "OpenGL version:" << reinterpret_cast<const char *>(glGetString(GL_VERSION));
+ qDebug() << "GLSL version:" << reinterpret_cast<const char *>(glGetString(GL_SHADING_LANGUAGE_VERSION));
if(m_vao.create())
m_vao.bind();
@@ -453,13 +485,13 @@ GLRenderer::uploadMM(int texWidth, int texHeight, T *texBuf, const T *texSrc)
if(D == 1) {
asGL(glTexImage2D(GL_TEXTURE_2D, level, m_glFormat, texWidth, texHeight, 0, GL_RED, m_glType, texSrc));
} else { // D == 4
- asGL(glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8, texWidth, texHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, texSrc));
+ asGL(glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8, texWidth, texHeight, 0, TEXTURE_RGB_FORMAT, GL_UNSIGNED_BYTE, texSrc));
}
} else {
if(D == 1) {
asGL(glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, texWidth, texHeight, GL_RED, m_glType, texSrc));
} else { // D == 4
- asGL(glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, texWidth, texHeight, GL_BGRA, GL_UNSIGNED_BYTE, texSrc));
+ asGL(glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, texWidth, texHeight, TEXTURE_RGB_FORMAT, GL_UNSIGNED_BYTE, texSrc));
}
}
--
GitLab
From 0242ebca3c5439dfde63a12074212c4d80fc0f1e Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Thu, 7 Oct 2021 23:55:47 +0200
Subject: [PATCH] SubtitleTextOverlay: RGB/BGR pixel support
---
src/videoplayer/backend/glrenderer.cpp | 5 ++++-
src/videoplayer/subtitletextoverlay.cpp | 21 ++++++++++++++++++---
src/videoplayer/subtitletextoverlay.h | 6 ++++--
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/src/videoplayer/backend/glrenderer.cpp b/src/videoplayer/backend/glrenderer.cpp
index 5cb985d..6dad043 100644
--- a/src/videoplayer/backend/glrenderer.cpp
+++ b/src/videoplayer/backend/glrenderer.cpp
@@ -113,6 +113,9 @@ GLRenderer::setOverlay(SubtitleTextOverlay *overlay)
if(m_overlay)
disconnect(m_overlay, nullptr, this, nullptr);
m_overlay = overlay;
+#ifdef USE_GLES
+ overlay->invertPixels(true);
+#endif
connect(m_overlay, &SubtitleTextOverlay::repaintNeeded, this, QOverload<>::of(&GLRenderer::update));
}
@@ -607,7 +610,7 @@ GLRenderer::uploadSubtitle()
// overlay
asGL(glActiveTexture(GL_TEXTURE0 + ID_OVR));
asGL(glBindTexture(GL_TEXTURE_2D, m_idTex[ID_OVR]));
- uploadMM<quint8, 4>(img.width(), img.height(), m_mmOvr, img.bits());
+ uploadMM<quint8, 4>(img.width(), img.height(), m_mmOvr, img.constBits());
if(m_texNeedInit) {
asGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER));
asGL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER));
diff --git a/src/videoplayer/subtitletextoverlay.cpp b/src/videoplayer/subtitletextoverlay.cpp
index afcb344..9fedd5b 100644
--- a/src/videoplayer/subtitletextoverlay.cpp
+++ b/src/videoplayer/subtitletextoverlay.cpp
@@ -18,7 +18,8 @@
using namespace SubtitleComposer;
SubtitleTextOverlay::SubtitleTextOverlay()
- : m_fontSize(SCConfig::fontSize())
+ : m_invertPixels(false),
+ m_fontSize(SCConfig::fontSize())
{
m_font.setStyleStrategy(QFont::PreferAntialias);
}
@@ -192,6 +193,16 @@ SubtitleTextOverlay::image()
return m_image;
}
+void
+SubtitleTextOverlay::invertPixels(bool invert)
+{
+ if(m_invertPixels == invert)
+ return;
+ m_invertPixels = invert;
+ setTextColor(m_textColor);
+ setOutlineColor(m_textOutline.color());
+}
+
const QSize &
SubtitleTextOverlay::textSize()
{
@@ -278,8 +289,10 @@ SubtitleTextOverlay::setFontSize(int fontSize)
}
void
-SubtitleTextOverlay::setTextColor(const QColor &color)
+SubtitleTextOverlay::setTextColor(QColor color)
{
+ if(m_invertPixels)
+ color = QColor(color.blue(), color.green(), color.red(), color.alpha());
if(m_textColor == color)
return;
m_textColor = color;
@@ -287,8 +300,10 @@ SubtitleTextOverlay::setTextColor(const QColor &color)
}
void
-SubtitleTextOverlay::setOutlineColor(const QColor &color)
+SubtitleTextOverlay::setOutlineColor(QColor color)
{
+ if(m_invertPixels)
+ color = QColor(color.blue(), color.green(), color.red(), color.alpha());
if(m_textOutline.color() == color)
return;
m_textOutline.setColor(color);
diff --git a/src/videoplayer/subtitletextoverlay.h b/src/videoplayer/subtitletextoverlay.h
index 5cbe508..204c1fb 100644
--- a/src/videoplayer/subtitletextoverlay.h
+++ b/src/videoplayer/subtitletextoverlay.h
@@ -36,6 +36,7 @@ public:
const QSize & textSize();
inline bool isDirty() const { return m_dirty; }
inline double renderScale() const { return m_renderScale; }
+ void invertPixels(bool invert);
private:
void drawImage();
@@ -53,12 +54,13 @@ public slots:
void setDoc(const RichDocument *doc);
void setFontFamily(const QString &family);
void setFontSize(int fontSize);
- void setTextColor(const QColor &color);
- void setOutlineColor(const QColor &color);
+ void setTextColor(QColor color);
+ void setOutlineColor(QColor color);
void setOutlineWidth(int width);
inline void setRenderScale(double scale) { m_renderScale = scale; }
private:
+ bool m_invertPixels;
QString m_text;
const RichDocument *m_doc = nullptr;
QFont m_font;
--
GitLab
From 89dd7a6bcef81e400946985201a5d92f84b0e980 Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Sat, 9 Oct 2021 11:42:31 +0200
Subject: [PATCH] Moved texture upload code to GLRenderer
---
src/videoplayer/backend/glrenderer.cpp | 97 ++++++++++++++++++++
src/videoplayer/backend/glrenderer.h | 5 ++
src/videoplayer/backend/renderthread.cpp | 107 +----------------------
src/videoplayer/backend/renderthread.h | 3 -
4 files changed, 106 insertions(+), 106 deletions(-)
diff --git a/src/videoplayer/backend/glrenderer.cpp b/src/videoplayer/backend/glrenderer.cpp
index 6dad043..ca99b14 100644
--- a/src/videoplayer/backend/glrenderer.cpp
+++ b/src/videoplayer/backend/glrenderer.cpp
@@ -66,6 +66,7 @@ GLRenderer::GLRenderer(QWidget *parent)
m_fragShader(nullptr),
m_shaderProg(nullptr),
m_texNeedInit(true),
+ m_lastFormat(-1),
m_idTex(nullptr),
m_vaBuf(nullptr)
{
@@ -228,6 +229,102 @@ GLRenderer::setColorspace(const AVFrame *frame)
m_csCM.scale(pixMult, pixMult, pixMult);
}
+bool
+GLRenderer::validTextureFormat(const AVPixFmtDescriptor *fd)
+{
+ const uint64_t &f = fd->flags;
+ if((f & AV_PIX_FMT_FLAG_BITSTREAM)) {
+ qCritical("uploadTexture() failed: unsupported frame format [%s] - bitstream", fd->name);
+ return false;
+ }
+ if((f & AV_PIX_FMT_FLAG_PAL)) {
+ qCritical("uploadTexture() failed: unsupported frame format [%s] - palette", fd->name);
+ return false;
+ }
+ if((f & AV_PIX_FMT_FLAG_BE)) {
+ qCritical("uploadTexture() failed: unsupported frame format [%s] - bigendian", fd->name);
+ return false;
+ }
+
+ const bool isYUV = !(f & AV_PIX_FMT_FLAG_RGB);
+ const bool isPlanar = f & AV_PIX_FMT_FLAG_PLANAR;
+ if(isPlanar && isYUV) {
+ const quint8 b = fd->comp[0].depth > 8 ? 2 : 1;
+ if(fd->comp[0].step != b || fd->comp[1].step != b || fd->comp[2].step != b) {
+ qCritical("validTextureFormat() failed: unsupported plane step [%d, %d, %d] %s",
+ fd->comp[0].step, fd->comp[1].step, fd->comp[2].step, fd->name);
+ return false;
+ }
+ if(fd->comp[0].offset || fd->comp[1].offset || fd->comp[2].offset) {
+ qCritical("validTextureFormat() failed: unsupported plane offset [%d, %d, %d] %s",
+ fd->comp[0].offset, fd->comp[1].offset, fd->comp[2].offset, fd->name);
+ return false;
+ }
+ if(fd->comp[0].shift || fd->comp[1].shift || fd->comp[2].shift) {
+ qCritical("validTextureFormat() failed: unsupported plane shift [%d, %d, %d] %s",
+ fd->comp[0].shift, fd->comp[1].shift, fd->comp[2].shift, fd->name);
+ return false;
+ }
+ if(fd->comp[0].depth != fd->comp[1].depth || fd->comp[0].depth != fd->comp[2].depth) {
+ qCritical("validTextureFormat() failed: unsupported plane depths [%d, %d, %d] %s",
+ fd->comp[0].depth, fd->comp[1].depth, fd->comp[2].depth, fd->name);
+ return false;
+ }
+ if(fd->nb_components < 3) {
+ qCritical("validTextureFormat() failed: unsupported plane count [%d] %s",
+ fd->nb_components, fd->name);
+ return false;
+ }
+ } else {
+ qCritical("validTextureFormat() failed: unsupported frame format [%s]", fd->name);
+ return false;
+ }
+ return true;
+}
+
+int
+GLRenderer::uploadTexture(AVFrame *frame)
+{
+ const AVPixFmtDescriptor *fd = av_pix_fmt_desc_get(AVPixelFormat(frame->format));
+ if(m_lastFormat != frame->format) {
+ if(!validTextureFormat(fd))
+ return -1;
+ m_lastFormat = frame->format;
+ }
+
+ if(!frame->linesize[0] || !frame->linesize[1] || !frame->linesize[2]) {
+ qCritical("uploadTexture() failed: invalid linesize [%d, %d, %d]",
+ frame->linesize[0], frame->linesize[1], frame->linesize[2]);
+ return -1;
+ }
+
+ QMutexLocker l(&m_texMutex);
+
+ setFrameFormat(frame->width, frame->height,
+ fd->comp[0].depth, fd->log2_chroma_w, fd->log2_chroma_h);
+
+ setColorspace(frame);
+
+ if(frame->linesize[0] > 0)
+ setFrameY(frame->data[0], frame->linesize[0]);
+ else
+ setFrameY(frame->data[0] + frame->linesize[0] * (frame->height - 1), -frame->linesize[0]);
+
+ if(frame->linesize[1] > 0)
+ setFrameU(frame->data[1], frame->linesize[1]);
+ else
+ setFrameU(frame->data[1] + frame->linesize[1] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[1]);
+
+ if(frame->linesize[2] > 0)
+ setFrameV(frame->data[2], frame->linesize[2]);
+ else
+ setFrameV(frame->data[2] + frame->linesize[2] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[2]);
+
+ update();
+
+ return 0;
+}
+
void
GLRenderer::setFrameY(quint8 *buf, quint32 pitch)
{
diff --git a/src/videoplayer/backend/glrenderer.h b/src/videoplayer/backend/glrenderer.h
index bb90396..037c817 100644
--- a/src/videoplayer/backend/glrenderer.h
+++ b/src/videoplayer/backend/glrenderer.h
@@ -21,6 +21,8 @@ extern "C" {
QT_FORWARD_DECLARE_CLASS(QOpenGLShader)
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
+struct AVPixFmtDescriptor;
+
namespace SubtitleComposer {
class SubtitleTextOverlay;
@@ -40,6 +42,7 @@ public:
void setFrameFormat(int width, int height, int compBits, int crWidthShift, int crHeightShift);
void setColorspace(const AVFrame *frame);
+ int uploadTexture(AVFrame *frame);
void setFrameY(quint8 *buf, quint32 pitch);
void setFrameU(quint8 *buf, quint32 pitch);
void setFrameV(quint8 *buf, quint32 pitch);
@@ -60,6 +63,7 @@ private:
template<class T, int D> void uploadMM(int texWidth, int texHeight, T *texBuf, const T *texSrc);
void uploadYUV();
void uploadSubtitle();
+ bool validTextureFormat(const AVPixFmtDescriptor *fd);
private:
SubtitleTextOverlay *m_overlay;
@@ -85,6 +89,7 @@ private:
QOpenGLShaderProgram *m_shaderProg;
bool m_texNeedInit;
+ int m_lastFormat;
int m_vpWidth, m_vpHeight;
int m_texY, m_texU, m_texV, m_texOvr;
GLuint *m_idTex;
diff --git a/src/videoplayer/backend/renderthread.cpp b/src/videoplayer/backend/renderthread.cpp
index 051832d..3c16965 100644
--- a/src/videoplayer/backend/renderthread.cpp
+++ b/src/videoplayer/backend/renderthread.cpp
@@ -23,8 +23,7 @@ using namespace SubtitleComposer;
RenderThread::RenderThread(VideoState *state, QObject *parent)
: QThread(parent),
- m_vs(state),
- m_lastFormat(-1)
+ m_vs(state)
{
}
@@ -412,8 +411,10 @@ RenderThread::videoImageDisplay()
#endif
if(!vp->uploaded) {
- if(uploadTexture(vp->frame) < 0)
+ if(m_vs->glRenderer->uploadTexture(vp->frame) < 0) {
+ requestInterruption();
return;
+ }
vp->uploaded = true;
}
@@ -473,103 +474,3 @@ RenderThread::toggleAudioDisplay()
m_vs->showMode = ShowMode(next);
}
}
-
-bool
-RenderThread::validTextureFormat(const AVPixFmtDescriptor *fd)
-{
- const uint64_t &f = fd->flags;
- if((f & AV_PIX_FMT_FLAG_BITSTREAM)) {
- qCritical("uploadTexture() failed: unsupported frame format [%s] - bitstream", fd->name);
- return false;
- }
- if((f & AV_PIX_FMT_FLAG_PAL)) {
- qCritical("uploadTexture() failed: unsupported frame format [%s] - palette", fd->name);
- return false;
- }
- if((f & AV_PIX_FMT_FLAG_BE)) {
- qCritical("uploadTexture() failed: unsupported frame format [%s] - bigendian", fd->name);
- return false;
- }
-
- m_isYUV = !(f & AV_PIX_FMT_FLAG_RGB);
- m_isPlanar = f & AV_PIX_FMT_FLAG_PLANAR;
- if(m_isPlanar && m_isYUV) {
- const quint8 b = fd->comp[0].depth > 8 ? 2 : 1;
- if(fd->comp[0].step != b || fd->comp[1].step != b || fd->comp[2].step != b) {
- qCritical("validTextureFormat() failed: unsupported plane step [%d, %d, %d] %s",
- fd->comp[0].step, fd->comp[1].step, fd->comp[2].step, fd->name);
- return false;
- }
- if(fd->comp[0].offset || fd->comp[1].offset || fd->comp[2].offset) {
- qCritical("validTextureFormat() failed: unsupported plane offset [%d, %d, %d] %s",
- fd->comp[0].offset, fd->comp[1].offset, fd->comp[2].offset, fd->name);
- return false;
- }
- if(fd->comp[0].shift || fd->comp[1].shift || fd->comp[2].shift) {
- qCritical("validTextureFormat() failed: unsupported plane shift [%d, %d, %d] %s",
- fd->comp[0].shift, fd->comp[1].shift, fd->comp[2].shift, fd->name);
- return false;
- }
- if(fd->comp[0].depth != fd->comp[1].depth || fd->comp[0].depth != fd->comp[2].depth) {
- qCritical("validTextureFormat() failed: unsupported plane depths [%d, %d, %d] %s",
- fd->comp[0].depth, fd->comp[1].depth, fd->comp[2].depth, fd->name);
- return false;
- }
- if(fd->nb_components < 3) {
- qCritical("validTextureFormat() failed: unsupported plane count [%d] %s",
- fd->nb_components, fd->name);
- return false;
- }
- } else {
- qCritical("validTextureFormat() failed: unsupported frame format [%s]", fd->name);
- return false;
- }
- return true;
-}
-
-int
-RenderThread::uploadTexture(AVFrame *frame)
-{
- const AVPixFmtDescriptor *fd = av_pix_fmt_desc_get(AVPixelFormat(frame->format));
- if(m_lastFormat != frame->format) {
- if(!validTextureFormat(fd)) {
- requestInterruption();
- return -1;
- }
- m_lastFormat = frame->format;
- }
-
- if(m_isPlanar && m_isYUV) {
- if(!frame->linesize[0] || !frame->linesize[1] || !frame->linesize[2]) {
- qCritical("uploadTexture() failed: invalid linesize [%d, %d, %d]",
- frame->linesize[0], frame->linesize[1], frame->linesize[2]);
- return -1;
- }
-
- QMutexLocker l(m_vs->glRenderer->mutex());
-
- m_vs->glRenderer->setFrameFormat(frame->width, frame->height,
- fd->comp[0].depth, fd->log2_chroma_w, fd->log2_chroma_h);
-
- m_vs->glRenderer->setColorspace(frame);
-
- if(frame->linesize[0] > 0)
- m_vs->glRenderer->setFrameY(frame->data[0], frame->linesize[0]);
- else
- m_vs->glRenderer->setFrameY(frame->data[0] + frame->linesize[0] * (frame->height - 1), -frame->linesize[0]);
-
- if(frame->linesize[1] > 0)
- m_vs->glRenderer->setFrameU(frame->data[1], frame->linesize[1]);
- else
- m_vs->glRenderer->setFrameU(frame->data[1] + frame->linesize[1] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[1]);
-
- if(frame->linesize[2] > 0)
- m_vs->glRenderer->setFrameV(frame->data[2], frame->linesize[2]);
- else
- m_vs->glRenderer->setFrameV(frame->data[2] + frame->linesize[2] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[2]);
-
- m_vs->glRenderer->update();
- }
-
- return 0;
-}
diff --git a/src/videoplayer/backend/renderthread.h b/src/videoplayer/backend/renderthread.h
index a2d0677..8a563f4 100644
--- a/src/videoplayer/backend/renderthread.h
+++ b/src/videoplayer/backend/renderthread.h
@@ -37,14 +37,11 @@ private:
double computeTargetDelay(double delay);
void updateSampleDisplay(short *samples, int samplesSize);
void toggleAudioDisplay();
- bool validTextureFormat(const AVPixFmtDescriptor *fd);
- int uploadTexture(AVFrame *frame);
void videoImageDisplay();
void videoAudioDisplay();
private:
VideoState *m_vs;
- int m_lastFormat;
bool m_isYUV;
bool m_isPlanar;
};
--
GitLab
From c6a0fa92e4f803e35b56588fca89204220a75c97 Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Sat, 9 Oct 2021 12:02:34 +0200
Subject: [PATCH] GLRenderer: added YUV >8bpp support on GLES
---
src/videoplayer/backend/glrenderer.cpp | 69 ++++++++++++++++++--------
src/videoplayer/backend/glrenderer.h | 2 +
src/videoplayer/backend/videostate.h | 1 +
3 files changed, 51 insertions(+), 21 deletions(-)
diff --git a/src/videoplayer/backend/glrenderer.cpp b/src/videoplayer/backend/glrenderer.cpp
index ca99b14..f8c3351 100644
--- a/src/videoplayer/backend/glrenderer.cpp
+++ b/src/videoplayer/backend/glrenderer.cpp
@@ -17,6 +17,7 @@
extern "C" {
#include "libavutil/pixdesc.h"
+#include "libswscale/swscale.h"
}
#define DEBUG_GL 0
@@ -37,14 +38,18 @@ extern "C" {
#if defined(GL_ES_VERSION_2_0) || FORCE_GLES
#define USE_GLES
#define TEXTURE_RGB_FORMAT GL_RGBA
-// NOTE: we don't currently support more than 8bpp on GLES
-#define TEXTURE_U16_FORMAT GL_R8
+// NOTE: we don't support rendering >8bpp on GLES, so 16bit textures are never used
+// and cpu will convert the frame to 8bpp
+#define TEXTURE_U16_FORMAT 0x822A
#else
#undef USE_GLES
#define TEXTURE_RGB_FORMAT GL_BGRA
#define TEXTURE_U16_FORMAT GL_R16
#endif
+#define FRAME_IS_YUV(f) ((f & AV_PIX_FMT_FLAG_RGB) == 0)
+#define FRAME_IS_PLANAR(f) ((f & AV_PIX_FMT_FLAG_PLANAR) != 0)
+
using namespace SubtitleComposer;
enum { ID_Y, ID_U, ID_V, ID_OVR, ID_SIZE };
@@ -54,6 +59,7 @@ GLRenderer::GLRenderer(QWidget *parent)
: QOpenGLWidget(parent),
m_overlay(nullptr),
m_mmOvr(nullptr),
+ m_frameConvCtx(nullptr),
m_bufYUV(nullptr),
m_mmYUV(nullptr),
m_bufSize(0),
@@ -86,6 +92,7 @@ GLRenderer::~GLRenderer()
}
m_vao.destroy();
doneCurrent();
+ sws_freeContext(m_frameConvCtx);
delete[] m_bufYUV;
delete[] m_mmYUV;
delete[] m_mmOvr;
@@ -180,7 +187,7 @@ GLRenderer::setColorspace(const AVFrame *frame)
const AVPixFmtDescriptor *fd = av_pix_fmt_desc_get(AVPixelFormat(frame->format));
const quint8 compBits = fd->comp[0].depth;
const quint8 compBytes = compBits > 8 ? 2 : 1;
- const bool isYUV = ~fd->flags & AV_PIX_FMT_FLAG_RGB;
+ const bool isYUV = FRAME_IS_YUV(fd->flags);
qDebug("Color range: %s(%d); primaries: %s(%d); xfer: %s(%d); space: %s(%d); depth: %d",
av_color_range_name(frame->color_range), frame->color_range,
@@ -246,9 +253,7 @@ GLRenderer::validTextureFormat(const AVPixFmtDescriptor *fd)
return false;
}
- const bool isYUV = !(f & AV_PIX_FMT_FLAG_RGB);
- const bool isPlanar = f & AV_PIX_FMT_FLAG_PLANAR;
- if(isPlanar && isYUV) {
+ if(FRAME_IS_YUV(f) && FRAME_IS_PLANAR(f)) {
const quint8 b = fd->comp[0].depth > 8 ? 2 : 1;
if(fd->comp[0].step != b || fd->comp[1].step != b || fd->comp[2].step != b) {
qCritical("validTextureFormat() failed: unsupported plane step [%d, %d, %d] %s",
@@ -300,25 +305,47 @@ GLRenderer::uploadTexture(AVFrame *frame)
QMutexLocker l(&m_texMutex);
- setFrameFormat(frame->width, frame->height,
- fd->comp[0].depth, fd->log2_chroma_w, fd->log2_chroma_h);
+#ifdef USE_GLES
+ if(fd->comp[0].depth > 8) {
+ // convert >8bpp YUV
+ frame->format = AV_PIX_FMT_YUV420P;
- setColorspace(frame);
+ const static AVPixFmtDescriptor *fd8 = av_pix_fmt_desc_get(AVPixelFormat(frame->format));
+ m_frameConvCtx = sws_getCachedContext(m_frameConvCtx,
+ frame->width, frame->height, AVPixelFormat(m_lastFormat),
+ frame->width, frame->height, AVPixelFormat(frame->format),
+ 0, nullptr, nullptr, nullptr);
- if(frame->linesize[0] > 0)
- setFrameY(frame->data[0], frame->linesize[0]);
- else
- setFrameY(frame->data[0] + frame->linesize[0] * (frame->height - 1), -frame->linesize[0]);
+ setFrameFormat(frame->width, frame->height,
+ fd8->comp[0].depth, fd8->log2_chroma_w, fd8->log2_chroma_h);
- if(frame->linesize[1] > 0)
- setFrameU(frame->data[1], frame->linesize[1]);
- else
- setFrameU(frame->data[1] + frame->linesize[1] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[1]);
+ setColorspace(frame);
- if(frame->linesize[2] > 0)
- setFrameV(frame->data[2], frame->linesize[2]);
- else
- setFrameV(frame->data[2] + frame->linesize[2] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[2]);
+ sws_scale(m_frameConvCtx, frame->data, frame->linesize, 0, frame->height,
+ m_pixels, reinterpret_cast<const int *>(m_pitch));
+ } else
+#endif
+ {
+ setFrameFormat(frame->width, frame->height,
+ fd->comp[0].depth, fd->log2_chroma_w, fd->log2_chroma_h);
+
+ setColorspace(frame);
+
+ if(frame->linesize[0] > 0)
+ setFrameY(frame->data[0], frame->linesize[0]);
+ else
+ setFrameY(frame->data[0] + frame->linesize[0] * (frame->height - 1), -frame->linesize[0]);
+
+ if(frame->linesize[1] > 0)
+ setFrameU(frame->data[1], frame->linesize[1]);
+ else
+ setFrameU(frame->data[1] + frame->linesize[1] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[1]);
+
+ if(frame->linesize[2] > 0)
+ setFrameV(frame->data[2], frame->linesize[2]);
+ else
+ setFrameV(frame->data[2] + frame->linesize[2] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[2]);
+ }
update();
diff --git a/src/videoplayer/backend/glrenderer.h b/src/videoplayer/backend/glrenderer.h
index 037c817..ae6b0cb 100644
--- a/src/videoplayer/backend/glrenderer.h
+++ b/src/videoplayer/backend/glrenderer.h
@@ -22,6 +22,7 @@ QT_FORWARD_DECLARE_CLASS(QOpenGLShader)
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
struct AVPixFmtDescriptor;
+struct SwsContext;
namespace SubtitleComposer {
class SubtitleTextOverlay;
@@ -72,6 +73,7 @@ private:
QOpenGLVertexArrayObject m_vao;
+ SwsContext *m_frameConvCtx;
quint8 *m_bufYUV, *m_mmYUV;
quint32 m_bufSize;
GLsizei m_bufWidth, m_bufHeight;
diff --git a/src/videoplayer/backend/videostate.h b/src/videoplayer/backend/videostate.h
index a669f0f..160b6f7 100644
--- a/src/videoplayer/backend/videostate.h
+++ b/src/videoplayer/backend/videostate.h
@@ -24,6 +24,7 @@
extern "C" {
#include "libavformat/avformat.h"
#include "libavcodec/avfft.h"
+#include "libswscale/swscale.h"
}
--
GitLab
From 0f8f441d3b4da3be178f21b8e0bd06b9e47138be Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Sat, 9 Oct 2021 13:02:03 +0200
Subject: [PATCH] GLRenderer: avoid re-uploading same texture
---
src/videoplayer/backend/glrenderer.cpp | 6 ++++++
src/videoplayer/backend/glrenderer.h | 1 +
src/videoplayer/backend/renderthread.cpp | 2 ++
3 files changed, 9 insertions(+)
diff --git a/src/videoplayer/backend/glrenderer.cpp b/src/videoplayer/backend/glrenderer.cpp
index f8c3351..5c0086f 100644
--- a/src/videoplayer/backend/glrenderer.cpp
+++ b/src/videoplayer/backend/glrenderer.cpp
@@ -347,6 +347,7 @@ GLRenderer::uploadTexture(AVFrame *frame)
setFrameV(frame->data[2] + frame->linesize[2] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[2]);
}
+ m_texUploaded = false;
update();
return 0;
@@ -665,6 +666,11 @@ GLRenderer::uploadMM(int texWidth, int texHeight, T *texBuf, const T *texSrc)
void
GLRenderer::uploadYUV()
{
+ if(!m_texNeedInit && m_texUploaded)
+ return;
+
+ m_texUploaded = true;
+
// load Y data
asGL(glActiveTexture(GL_TEXTURE0 + ID_Y));
asGL(glBindTexture(GL_TEXTURE_2D, m_idTex[ID_Y]));
diff --git a/src/videoplayer/backend/glrenderer.h b/src/videoplayer/backend/glrenderer.h
index ae6b0cb..b517786 100644
--- a/src/videoplayer/backend/glrenderer.h
+++ b/src/videoplayer/backend/glrenderer.h
@@ -91,6 +91,7 @@ private:
QOpenGLShaderProgram *m_shaderProg;
bool m_texNeedInit;
+ bool m_texUploaded;
int m_lastFormat;
int m_vpWidth, m_vpHeight;
int m_texY, m_texU, m_texV, m_texOvr;
diff --git a/src/videoplayer/backend/renderthread.cpp b/src/videoplayer/backend/renderthread.cpp
index 3c16965..695e74b 100644
--- a/src/videoplayer/backend/renderthread.cpp
+++ b/src/videoplayer/backend/renderthread.cpp
@@ -34,6 +34,8 @@ RenderThread::run()
for(;;) {
if(remaining_time > 0.0)
av_usleep((int64_t)(remaining_time * double(AV_TIME_BASE)));
+ else
+ yieldCurrentThread(); // allow gui to update
remaining_time = REFRESH_RATE;
if(isInterruptionRequested())
break;
--
GitLab

View File

@ -1,93 +0,0 @@
From 17811ce518f2db3db4ecb15c81ed774593715713 Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Thu, 14 Oct 2021 02:32:16 +0200
Subject: [PATCH] Fix crashes on empty lines list
---
src/gui/treeview/linesmodel.cpp | 15 ++++++++++++---
src/gui/treeview/linesselectionmodel.cpp | 17 +++++++++++++----
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/src/gui/treeview/linesmodel.cpp b/src/gui/treeview/linesmodel.cpp
index e36c2dd..afcd1db 100644
--- a/src/gui/treeview/linesmodel.cpp
+++ b/src/gui/treeview/linesmodel.cpp
@@ -314,12 +314,14 @@ LinesModel::onLinesRemoved(int firstIndex, int lastIndex)
void
LinesModel::onModelReset()
{
- beginResetModel();
- endResetModel();
-
LinesWidget *w = static_cast<LinesWidget *>(parent());
QItemSelectionModel *sm = w->selectionModel();
+ const QModelIndex prevIndex = sm->currentIndex();;
+
+ beginResetModel();
+ endResetModel();
+
if(sm->hasSelection()) {
if(!sm->currentIndex().isValid()) {
const QModelIndex idx = index(sm->selection().first().top());
@@ -332,6 +334,13 @@ LinesModel::onModelReset()
sm->select(QItemSelection(first, last), QItemSelectionModel::ClearAndSelect);
}
sm->setCurrentIndex(first, QItemSelectionModel::Rows);
+ } else {
+ if(prevIndex.isValid() && !sm->currentIndex().isValid()) {
+ // model reset should invalidate current index and prevent signals
+ QSignalBlocker s(sm); // make sure nothing fires anyway
+ sm->setCurrentIndex(prevIndex, QItemSelectionModel::Rows);
+ }
+ sm->clear();
}
if(w->scrollFollowsModel())
diff --git a/src/gui/treeview/linesselectionmodel.cpp b/src/gui/treeview/linesselectionmodel.cpp
index 2dc14d5..9a1ccd2 100644
--- a/src/gui/treeview/linesselectionmodel.cpp
+++ b/src/gui/treeview/linesselectionmodel.cpp
@@ -28,7 +28,8 @@ LinesSelectionModel::LinesSelectionModel(LinesModel *model)
void
LinesSelectionModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
{
- m_currentLine = static_cast<LinesModel *>(model())->subtitle()->line(index.row());
+ Subtitle *sub = static_cast<LinesModel *>(model())->subtitle();
+ m_currentLine = sub ? sub->line(index.row()) : nullptr;
QItemSelectionModel::setCurrentIndex(index, command);
}
@@ -50,6 +51,9 @@ LinesSelectionModel::select(const QItemSelection &selection, QItemSelectionModel
m_selection.clear();
const Subtitle *subtitle = static_cast<LinesModel *>(model())->subtitle();
+ if(!subtitle)
+ return;
+
QModelIndexList sel = selection.indexes();
while(!sel.empty()) {
const SubtitleLine *line = subtitle->line(sel.takeFirst().row());
@@ -83,11 +87,16 @@ LinesSelectionModel::reset()
QItemSelectionModel::reset();
m_resetInProgress = false;
- if(m_currentLine)
- QItemSelectionModel::setCurrentIndex(model()->index(m_currentLine->index(), 0), QItemSelectionModel::Current);
-
const LinesModel *model = static_cast<LinesModel *>(this->model());
Subtitle *subtitle = model->subtitle();
+ if(!subtitle) {
+ QItemSelectionModel::clear();
+ return;
+ }
+
+ if(m_currentLine)
+ QItemSelectionModel::setCurrentIndex(model->index(m_currentLine->index(), 0), QItemSelectionModel::Current);
+
const int lastCol = model->columnCount() - 1;
for(auto it = m_selection.cbegin(); it != m_selection.cend(); ++it) {
const SubtitleLine *line = *it;
--
GitLab

View File

@ -1,3 +1,52 @@
-------------------------------------------------------------------
Mon Nov 6 17:44:47 UTC 2023 - Luigi Baldoni <aloisio@gmx.com>
- Update to version 0.8.0
* Fixed video player on GLES only hardware
* Fixed skewed video on video player
* Fixed closing fullscreen video player
* Fixed subtitles under fullscreen video toolbar
* Fixed video player media state notifications
* Fixed subtitle video overlay font size accuracy
* Fixed deadlock/crash while changing audio stream on
paused/stopped media
* Improved Waveform widget performance
* Fixed waveform misalignment due to rounding error
* Fixed waveform widget drawing on null image and painting of
removed lines
* Fixed waveform default zoom scale
* Fixed subtitle text line separator draw on LinesWidget
* Fixed unbreak lines (newline searches in QTextDocument)
* Fixed crash in split lines
* Fixed VobSub import ignoring Text styles
* Fixed VobSub crash when moving to previous image
* Fixed YouTubeCaptions format parsing/saving
* Fixed undo/redo actions creation order, incorrect state
* Fixed some memory and saving issues
* Fixed embedded ASS decoding
* Fixed example remove hearing impaired script
* Fixed broken about dialog
* Added Qt6 support
* Added WebVTT format support
* Added subtitle positioning UI and support
* Added subtitle class/comments/voice UI and support
* Improved rich text editing/preview
* Rich text rendering on waveform/video/editors
* Added DeepL translate engine
* Added Google Cloud translate engine
* Recreated translation interface
* Added/improved ffmpeg 5 support
* Subtitle lines are always time sorted; remove sort lines
menu action
* Replaced Kross with QJSEngine, removed ruby and python
support
* Improved script manager and tools menu
- Drop subtitlecomposer-ARM_GLES.patch,
subtitlecomposer-fix_empty_lines_crash.patch,
0001-Fix-compilation-with-ffmpeg5-63.patch,
0001-VideoPlayer-Fix-usage-of-deprecated-removed-AVCodec-.patch,
and 0001-Use-non-deprecated-ffmpeg-api.patch (merged upstream)
-------------------------------------------------------------------
Tue May 9 08:28:01 UTC 2023 - Christophe Marin <christophe@krop.fr>

View File

@ -17,7 +17,7 @@
Name: subtitlecomposer
Version: 0.7.1
Version: 0.8.0
Release: 0
Summary: A text-based subtitle editor
License: GPL-2.0-or-later
@ -26,16 +26,6 @@ URL: https://invent.kde.org/multimedia/subtitlecomposer
Source0: https://download.kde.org/stable/subtitlecomposer/%{name}-%{version}.tar.xz
Source1: https://download.kde.org/stable/subtitlecomposer/%{name}-%{version}.tar.xz.sig
Source2: subtitlecomposer.keyring
# PATCH-FIX-UPSTREAM subtitlecomposer-ARM_GLES.patch
Patch0: subtitlecomposer-ARM_GLES.patch
# PATCH-FIX-UPSTREAM subtitlecomposer-fix_empty_lines_crash.patch
Patch1: subtitlecomposer-fix_empty_lines_crash.patch
# PATCH-FIX-UPSTREAM Fix build with ffmpeg 5
Patch2: 0001-Fix-compilation-with-ffmpeg5-63.patch
# PATCH-FIX-UPSTREAM Fix video player
Patch3: 0001-VideoPlayer-Fix-usage-of-deprecated-removed-AVCodec-.patch
# PATCH-FIX-UPSTREAM
Patch4: 0001-Use-non-deprecated-ffmpeg-api.patch
BuildRequires: cmake >= 3.10
BuildRequires: extra-cmake-modules
BuildRequires: libQt5Widgets-private-headers-devel
@ -55,6 +45,7 @@ BuildRequires: cmake(KF5WidgetsAddons)
BuildRequires: cmake(KF5XmlGui)
BuildRequires: cmake(Qt5Core)
BuildRequires: cmake(Qt5Gui)
BuildRequires: cmake(Qt5Qml)
BuildRequires: cmake(Qt5Test)
BuildRequires: cmake(Qt5Widgets)
BuildRequires: pkgconfig(icu-i18n)
@ -64,6 +55,7 @@ BuildRequires: pkgconfig(libavformat) >= 57.83.100
BuildRequires: pkgconfig(libavutil)
BuildRequires: pkgconfig(libswscale)
BuildRequires: pkgconfig(openal)
BuildRequires: pkgconfig(openssl)
%if 0%{?suse_version} > 1500
%ifnarch ppc64 s390x
BuildRequires: pkgconfig(pocketsphinx) >= 5
@ -80,18 +72,6 @@ has speech Recognition using PocketSphinx.
%prep
%autosetup -p1
# We build kross-interpreters without python support anyway, so we can
# remove the python examples to remove an useless dependency on python2
rm src/scripting/examples/*.py
# Fix shebang
sed -i '1s|%{_bindir}/env ruby|%{_bindir}/ruby|' \
src/scripting/examples/*.rb
# Fix shebang in newly created files
sed -i 's,#!/usr/bin/env ruby,#!%{_bindir}/ruby,' \
src/scripting/scriptsmanager.cpp
%build
%cmake_kf5 -d build
%cmake_build
@ -99,8 +79,6 @@ sed -i 's,#!/usr/bin/env ruby,#!%{_bindir}/ruby,' \
%install
%kf5_makeinstall -C build
# Fix permissions
chmod 755 %{buildroot}%{_kf5_appsdir}/%{name}/scripts/*.rb
# Fix rpmlint error (devel-file-in-non-devel-package) and install header files as doc (since they are installed just for help)
mkdir files_for_doc
cp -a %{buildroot}%{_kf5_appsdir}/%{name}/scripts/api/ files_for_doc/
@ -123,7 +101,6 @@ perl -pi -e "s|'api'|'%{_docdir}/subtitlecomposer/api'|" %{buildroot}%{_kf5_apps
%{_kf5_appstreamdir}/org.kde.%{name}.appdata.xml
%{_kf5_bindir}/%{name}
%{_kf5_iconsdir}/hicolor/*/*/*
%{_kf5_kxmlguidir}/%{name}/
%{_kf5_sharedir}/mime/packages/%{name}.xml
%if 0%{?suse_version} > 1500
%ifnarch ppc64 s390x