Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LibAVQt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Silas Della Contrada
LibAVQt
Commits
a755149f
Verified
Commit
a755149f
authored
3 years ago
by
Silas Della Contrada
Browse files
Options
Downloads
Patches
Plain Diff
Fixed FallbackFrameMapper for OpenGL ES
parent
053968f8
No related branches found
Branches containing commit
No related tags found
1 merge request
!17
Draft: Resolve "Migrate frame passing to libProcessingGraph"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
AVQt/src/renderers/FallbackFrameMapper.cpp
+30
-11
30 additions, 11 deletions
AVQt/src/renderers/FallbackFrameMapper.cpp
AVQt/src/renderers/FallbackFrameMapper.hpp
+1
-0
1 addition, 0 deletions
AVQt/src/renderers/FallbackFrameMapper.hpp
with
31 additions
and
11 deletions
AVQt/src/renderers/FallbackFrameMapper.cpp
+
30
−
11
View file @
a755149f
...
...
@@ -22,9 +22,11 @@
//
#include
"FallbackFrameMapper.hpp"
#include
"global.hpp"
#include
"private/FallbackFrameMapper_p.hpp"
#include
"global.hpp"
#include
"renderers/OpenGLFrameMapperFactory.hpp"
extern
"C"
{
#include
<libavutil/imgutils.h>
#include
<libavutil/pixdesc.h>
...
...
@@ -32,7 +34,22 @@ extern "C" {
#include
<memory>
#include
<GL/gl.h>
#include
<QOpenGLDebugLogger>
namespace
AVQt
{
const
api
::
OpenGLFrameMapperInfo
&
FallbackFrameMapper
::
info
()
{
static
const
api
::
OpenGLFrameMapperInfo
info
{
.
metaObject
=
FallbackFrameMapper
::
staticMetaObject
,
.
name
=
"SW"
,
.
platforms
=
{
common
::
Platform
::
All
},
.
supportedInputPixelFormats
=
{},
.
isSupported
=
[]()
{
return
true
;
},
};
return
info
;
}
FallbackFrameMapper
::
FallbackFrameMapper
(
QObject
*
parent
)
:
QThread
(
parent
),
d_ptr
(
new
FallbackFrameMapperPrivate
(
this
))
{
loadResources
();
...
...
@@ -75,8 +92,8 @@ namespace AVQt {
shaderVersionString
=
"#version 330 core
\n
"
;
}
QFile
vsh
{
":/shaders/texture
s
.vsh"
};
QFile
fsh
{
":/shaders/texture
s
.fsh"
};
QFile
vsh
{
":/shaders/texture.vsh"
};
QFile
fsh
{
":/shaders/texture.fsh"
};
vsh
.
open
(
QIODevice
::
ReadOnly
);
fsh
.
open
(
QIODevice
::
ReadOnly
);
QByteArray
vertexShader
=
vsh
.
readAll
().
prepend
(
shaderVersionString
);
...
...
@@ -264,7 +281,7 @@ namespace AVQt {
d
->
pSwsContext
.
reset
(
sws_getContext
(
swFrame
->
width
,
swFrame
->
height
,
(
AVPixelFormat
)
swFrame
->
format
,
swFrame
->
width
,
swFrame
->
height
,
AV_PIX_FMT_
BGR
A
,
AV_PIX_FMT_
RGB
A
,
0
,
nullptr
,
nullptr
,
nullptr
));
if
(
!
d
->
pSwsContext
)
{
qWarning
()
<<
"Failed to create sws context"
;
...
...
@@ -272,8 +289,6 @@ namespace AVQt {
}
}
QOpenGLTexture
::
PixelType
pixelType
=
QOpenGLTexture
::
UInt8
;
QOpenGLTexture
::
TextureFormat
textureFormat
=
QOpenGLTexture
::
RGBA8_UNorm
;
// switch (swFrame->format) {
// case AV_PIX_FMT_YUV420P10:
// case AV_PIX_FMT_YUV420P12:
...
...
@@ -308,7 +323,7 @@ namespace AVQt {
}
frame
->
width
=
swFrame
->
width
;
frame
->
height
=
swFrame
->
height
;
frame
->
format
=
AV_PIX_FMT_
BGR
A
;
frame
->
format
=
AV_PIX_FMT_
RGB
A
;
frame
->
pts
=
swFrame
->
pts
;
if
(
av_frame_get_buffer
(
frame
.
get
(),
1
)
<
0
)
{
qWarning
()
<<
"Failed to allocate frame buffer"
;
...
...
@@ -328,13 +343,13 @@ namespace AVQt {
if
(
!
d
->
texture
)
{
d
->
texture
.
reset
(
new
QOpenGLTexture
(
QOpenGLTexture
::
Target2D
));
d
->
texture
->
setFormat
(
textureF
orm
at
);
d
->
texture
->
setFormat
(
QOpenGLTexture
::
RGBA8_UN
orm
);
d
->
texture
->
setSize
(
frame
->
width
,
frame
->
height
);
d
->
texture
->
setAutoMipMapGenerationEnabled
(
false
);
d
->
texture
->
setMinificationFilter
(
QOpenGLTexture
::
Linear
);
d
->
texture
->
setMagnificationFilter
(
QOpenGLTexture
::
Linear
);
d
->
texture
->
setWrapMode
(
QOpenGLTexture
::
ClampToEdge
);
d
->
texture
->
allocateStorage
();
d
->
texture
->
allocateStorage
(
QOpenGLTexture
::
RGBA
,
QOpenGLTexture
::
UInt8
);
}
if
(
!
d
->
fboPool
)
{
...
...
@@ -342,7 +357,8 @@ namespace AVQt {
}
d
->
texture
->
bind
(
0
);
d
->
texture
->
setData
(
QOpenGLTexture
::
BGRA
,
pixelType
,
const_cast
<
const
uint8_t
*>
(
frame
->
data
[
0
]));
d
->
texture
->
setData
(
0
,
0
,
QOpenGLTexture
::
RGBA
,
QOpenGLTexture
::
UInt8
,
const_cast
<
const
uint8_t
*>
(
frame
->
data
[
0
]));
d
->
texture
->
release
();
auto
fbo
=
d
->
fboPool
->
getFBO
(
1000
);
if
(
!
fbo
)
{
...
...
@@ -411,7 +427,6 @@ namespace AVQt {
void
FallbackFrameMapperPrivate
::
destroySwsContext
(
SwsContext
*
swsContext
)
{
if
(
swsContext
)
{
sws_freeContext
(
swsContext
);
swsContext
=
nullptr
;
}
}
...
...
@@ -422,3 +437,7 @@ namespace AVQt {
}
}
}
// namespace AVQt
static_block
{
AVQt
::
OpenGLFrameMapperFactory
::
getInstance
().
registerRenderer
(
AVQt
::
FallbackFrameMapper
::
info
());
}
This diff is collapsed.
Click to expand it.
AVQt/src/renderers/FallbackFrameMapper.hpp
+
1
−
0
View file @
a755149f
...
...
@@ -36,6 +36,7 @@ namespace AVQt {
Q_DECLARE_PRIVATE
(
FallbackFrameMapper
)
Q_INTERFACES
(
AVQt
::
api
::
IOpenGLFrameMapper
)
public:
static
const
api
::
OpenGLFrameMapperInfo
&
info
();
Q_INVOKABLE
explicit
FallbackFrameMapper
(
QObject
*
parent
=
nullptr
);
~
FallbackFrameMapper
()
override
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment