1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
From be426ad76c3e486f1364dd292cf8e1c633c80e91 Mon Sep 17 00:00:00 2001
From: Vincent Davis Jr <vince@underview.tech>
Date: Thu, 8 Dec 2022 10:39:47 -0600
Subject: [PATCH] libavdevice: opengl_enc.c update dynamic function loader
Upstream-Status: Inappropriate
RPI-Distro repo clones original ffmpeg and applies patches to enable
raspiberry pi support.
For meta-raspberrypi ffmpeg builds, when opengl
is enabled do_compile will fail. Reasion is that
glGetProcAddress is undefined in either GLES2/gl2.h
or GLES2/gl2ext.h.
define SelectedGetProcAddress to SDL_GL_GetProcAddress
if sdl2 is included. If not included, define function
pointers at compile time versus runtime.
Signed-off-by: Vincent Davis Jr <vince@underview.tech>
---
libavdevice/opengl_enc.c | 44 ++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c
index 2bdb8da7..eabc1bf8 100644
--- a/libavdevice/opengl_enc.c
+++ b/libavdevice/opengl_enc.c
@@ -37,12 +37,13 @@
#include <OpenGL/gl3.h>
#elif HAVE_ES2_GL_H
#include <ES2/gl.h>
-#else
-#include <GL/gl.h>
-#include <GL/glext.h>
#endif
#if HAVE_GLXGETPROCADDRESS
#include <GL/glx.h>
+#else
+#define GL_GLEXT_PROTOTYPES
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
#endif
#if CONFIG_SDL2
@@ -493,8 +494,14 @@ static int av_cold opengl_load_procedures(OpenGLContext *opengl)
#if HAVE_GLXGETPROCADDRESS
#define SelectedGetProcAddress glXGetProcAddress
+#define CAN_DYNAMIC_LOAD 1
#elif HAVE_WGLGETPROCADDRESS
#define SelectedGetProcAddress wglGetProcAddress
+#elif CONFIG_SDL2
+#define SelectedGetProcAddress SDL_GL_GetProcAddress
+#define CAN_DYNAMIC_LOAD 1
+#else
+#define CAN_DYNAMIC_LOAD 0
#endif
#define LOAD_OPENGL_FUN(name, type) \
@@ -504,7 +511,8 @@ static int av_cold opengl_load_procedures(OpenGLContext *opengl)
return AVERROR(ENOSYS); \
}
-#if CONFIG_SDL2
+#if CAN_DYNAMIC_LOAD
+#if CONFIG_SDL2
if (!opengl->no_window)
return opengl_sdl_load_procedures(opengl);
#endif
@@ -534,9 +542,37 @@ static int av_cold opengl_load_procedures(OpenGLContext *opengl)
LOAD_OPENGL_FUN(glGetShaderInfoLog, FF_PFNGLGETSHADERINFOLOGPROC)
LOAD_OPENGL_FUN(glEnableVertexAttribArray, FF_PFNGLENABLEVERTEXATTRIBARRAYPROC)
LOAD_OPENGL_FUN(glVertexAttribPointer, FF_PFNGLVERTEXATTRIBPOINTERPROC)
+#else
+ procs->glActiveTexture = glActiveTexture;
+ procs->glGenBuffers = glGenBuffers;
+ procs->glDeleteBuffers = glDeleteBuffers;
+ procs->glBufferData = glBufferData;
+ procs->glBindBuffer = glBindBuffer;
+ procs->glGetAttribLocation = glGetAttribLocation;
+ procs->glGetUniformLocation = glGetUniformLocation;
+ procs->glUniform1f = glUniform1f;
+ procs->glUniform1i = glUniform1i;
+ procs->glUniformMatrix4fv = glUniformMatrix4fv;
+ procs->glCreateProgram = glCreateProgram;
+ procs->glDeleteProgram = glDeleteProgram;
+ procs->glUseProgram = glUseProgram;
+ procs->glLinkProgram = glLinkProgram;
+ procs->glGetProgramiv = glGetProgramiv;
+ procs->glGetProgramInfoLog = glGetProgramInfoLog;
+ procs->glAttachShader = glAttachShader;
+ procs->glCreateShader = glCreateShader;
+ procs->glDeleteShader = glDeleteShader;
+ procs->glCompileShader = glCompileShader;
+ procs->glShaderSource = glShaderSource;
+ procs->glGetShaderiv = glGetShaderiv;
+ procs->glGetShaderInfoLog = glGetShaderInfoLog;
+ procs->glEnableVertexAttribArray = glEnableVertexAttribArray;
+ procs->glVertexAttribPointer = (FF_PFNGLVERTEXATTRIBPOINTERPROC) glVertexAttribPointer;
+#endif
return 0;
+#undef CAN_DYNAMIC_LOAD
#undef SelectedGetProcAddress
#undef LOAD_OPENGL_FUN
}
--
2.38.1
|