meta-raspberrypi/recipes-multimedia/rpidistro-ffmpeg/files/2002-libavdevice-opengl_enc-update-dynamic-function-loader.patch
Vincent Davis Jr 1f33240549 rpidistro-ffmpeg: upgrade 4.3.2 -> 4.3.4
Upgrades version of ffmpeg to 4.3.4
* Reason for not upgrading to 4.3.5 all ported raspberrypi
  team patches may not be included in that version/commit.
* SRCREV set to 246e1a55a0eca931537d8706acd8b133c07beb05

Updates to PACKAGECONFIG
* Only include --enable-opengl flag when opengl is set in
  DISTRO_FEATURES
* Add new flag --enable-epoxy required by vout-egl
* vout-egl requires both libepoxy and x11. Only
  enable vout-egl if x11 contained in DISTRO_FEATURES.
* The remaining RPI-Distro related flags added
  through patches. Are only enabled if vc4graphics
  is disabled and userland graphics enabled. As an
  attempt to keep ffmpeg ./configure generic unless
  specified other wise.

Removes TARGET_CFLAGS:append as include flags are set in
./configure via the 2001-configure-setup-for-OE-core-usage.patch
patch.

Replaces patches with updated patches used in actual commit.
Adds four new patches to fix ./configure, compile, runtime bugs.

PATCHES:
- 2001-configure-setup-for-OE-core-usage.patch
* The ./configure stage fails if neither x11 or wayland defined
  in DISTRO_FEATURES. When opengl enabled ./configure checks for
  relevant headers. The last header it checks for is ES2/gl.h which
  doesn't exists. Neither do the others if certain perameters
  are not meet. Patch addes check for GLES2/gl2.h which does
  exists. We use utilize GLESv2 to compile and link with.
  Patch also replaces where compiler find mmal and omx headers
  and libs.

- 2002-libavdevice-opengl_enc-update-dynamic-function-loader.patch
* After configure stage succeeds the compile stage fails as
  SelectedGetProcAddress isn't defined. It can't be define as
  if x11 isn't enabled. Patch defines SelectedGetProcAddress
  if x11 not enabled, but sdl2 enabled to SDL_GL_GetProcAddress.
  If neither sdl2 or x11 is enabled patch loads GL functions
  pointers at compile time versus dynamically at runtime.

- 2003-libavcodec-fix-v4l2_req_devscan.patch
* v412_req_devscan.h function definitions where different
  from v412_req_devscan.c function implementations.

- 2004-libavcodec-omx-replace-opt-vc-path-with-usr-lib.patch
* Fixes where libbcm_host.so and libopenmaxil.so are loaded from.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
2022-12-13 02:32:11 +00:00

112 lines
3.6 KiB
Diff

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