* commit 'f1cd9b03f3fa875eb5e394281b4b688cec611658':
omx: Add support for broadcom OMX on raspberry pi
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
... | ... |
@@ -32,7 +32,7 @@ version <next>: |
32 | 32 |
- Wideband Single-bit Data (WSD) demuxer |
33 | 33 |
- VAAPI-accelerated H.264/HEVC/MJPEG encoding |
34 | 34 |
- DTS Express (LBR) decoder |
35 |
-- Generic OpenMAX IL encoder |
|
35 |
+- Generic OpenMAX IL encoder with support for Raspberry Pi |
|
36 | 36 |
|
37 | 37 |
version 3.0: |
38 | 38 |
- Common Encryption (CENC) MP4 encoding and decoding support |
... | ... |
@@ -162,6 +162,7 @@ Hardware-accelerated decoding/encoding: |
162 | 162 |
--enable-mmal enable decoding via MMAL [no] |
163 | 163 |
--enable-nvenc enable NVIDIA NVENC support [no] |
164 | 164 |
--enable-omx enable encoding via OpenMAX IL [no] |
165 |
+ --enable-omx-rpi enable encoding via OpenMAX IL for Raspberry Pi [no] |
|
165 | 166 |
|
166 | 167 |
Individual component options: |
167 | 168 |
--disable-everything disable all components listed below |
... | ... |
@@ -1552,6 +1553,7 @@ FEATURE_LIST=" |
1552 | 1552 |
ftrapv |
1553 | 1553 |
gray |
1554 | 1554 |
hardcoded_tables |
1555 |
+ omx_rpi |
|
1555 | 1556 |
runtime_cpudetect |
1556 | 1557 |
safe_bitstream_reader |
1557 | 1558 |
shared |
... | ... |
@@ -5730,12 +5732,17 @@ enabled opengl && { check_lib GL/glx.h glXGetProcAddress "-lGL" || |
5730 | 5730 |
check_lib2 ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" || |
5731 | 5731 |
die "ERROR: opengl not found." |
5732 | 5732 |
} |
5733 |
+enabled omx_rpi && enable omx |
|
5734 |
+enabled omx && { check_header OMX_Core.h || |
|
5735 |
+ { ! enabled cross_compile && enabled omx_rpi && { |
|
5736 |
+ add_cflags -isystem/opt/vc/include/IL ; } |
|
5737 |
+ check_header OMX_Core.h ; } || |
|
5738 |
+ die "ERROR: OpenMAX IL headers not found"; } |
|
5733 | 5739 |
enabled openssl && { use_pkg_config openssl openssl/ssl.h SSL_library_init || |
5734 | 5740 |
check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto || |
5735 | 5741 |
check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 || |
5736 | 5742 |
check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || |
5737 | 5743 |
die "ERROR: openssl not found"; } |
5738 |
-enabled omx && { check_header OMX_Core.h || die "ERROR: OpenMAX IL headers not found"; } |
|
5739 | 5744 |
enabled qtkit_indev && { check_header_objcc QTKit/QTKit.h || disable qtkit_indev; } |
5740 | 5745 |
|
5741 | 5746 |
# libdc1394 check |
... | ... |
@@ -19,6 +19,12 @@ |
19 | 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | 20 |
*/ |
21 | 21 |
|
22 |
+#include "config.h" |
|
23 |
+ |
|
24 |
+#if CONFIG_OMX_RPI |
|
25 |
+#define OMX_SKIP64BIT |
|
26 |
+#endif |
|
27 |
+ |
|
22 | 28 |
#include <dlfcn.h> |
23 | 29 |
#include <OMX_Core.h> |
24 | 30 |
#include <OMX_Component.h> |
... | ... |
@@ -69,6 +75,7 @@ static int64_t from_omx_ticks(OMX_TICKS value) |
69 | 69 |
|
70 | 70 |
typedef struct OMXContext { |
71 | 71 |
void *lib; |
72 |
+ void *lib2; |
|
72 | 73 |
OMX_ERRORTYPE (*ptr_Init)(void); |
73 | 74 |
OMX_ERRORTYPE (*ptr_Deinit)(void); |
74 | 75 |
OMX_ERRORTYPE (*ptr_ComponentNameEnum)(OMX_STRING, OMX_U32, OMX_U32); |
... | ... |
@@ -76,6 +83,7 @@ typedef struct OMXContext { |
76 | 76 |
OMX_ERRORTYPE (*ptr_FreeHandle)(OMX_HANDLETYPE); |
77 | 77 |
OMX_ERRORTYPE (*ptr_GetComponentsOfRole)(OMX_STRING, OMX_U32*, OMX_U8**); |
78 | 78 |
OMX_ERRORTYPE (*ptr_GetRolesOfComponent)(OMX_STRING, OMX_U32*, OMX_U8**); |
79 |
+ void (*host_init)(void); |
|
79 | 80 |
} OMXContext; |
80 | 81 |
|
81 | 82 |
static av_cold void *dlsym_prefixed(void *handle, const char *symbol, const char *prefix) |
... | ... |
@@ -86,8 +94,23 @@ static av_cold void *dlsym_prefixed(void *handle, const char *symbol, const char |
86 | 86 |
} |
87 | 87 |
|
88 | 88 |
static av_cold int omx_try_load(OMXContext *s, void *logctx, |
89 |
- const char *libname, const char *prefix) |
|
89 |
+ const char *libname, const char *prefix, |
|
90 |
+ const char *libname2) |
|
90 | 91 |
{ |
92 |
+ if (libname2) { |
|
93 |
+ s->lib2 = dlopen(libname2, RTLD_NOW | RTLD_GLOBAL); |
|
94 |
+ if (!s->lib2) { |
|
95 |
+ av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname); |
|
96 |
+ return AVERROR_ENCODER_NOT_FOUND; |
|
97 |
+ } |
|
98 |
+ s->host_init = dlsym(s->lib2, "bcm_host_init"); |
|
99 |
+ if (!s->host_init) { |
|
100 |
+ av_log(logctx, AV_LOG_WARNING, "bcm_host_init not found\n"); |
|
101 |
+ dlclose(s->lib2); |
|
102 |
+ s->lib2 = NULL; |
|
103 |
+ return AVERROR_ENCODER_NOT_FOUND; |
|
104 |
+ } |
|
105 |
+ } |
|
91 | 106 |
s->lib = dlopen(libname, RTLD_NOW | RTLD_GLOBAL); |
92 | 107 |
if (!s->lib) { |
93 | 108 |
av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname); |
... | ... |
@@ -106,6 +129,9 @@ static av_cold int omx_try_load(OMXContext *s, void *logctx, |
106 | 106 |
av_log(logctx, AV_LOG_WARNING, "Not all functions found in %s\n", libname); |
107 | 107 |
dlclose(s->lib); |
108 | 108 |
s->lib = NULL; |
109 |
+ if (s->lib2) |
|
110 |
+ dlclose(s->lib2); |
|
111 |
+ s->lib2 = NULL; |
|
109 | 112 |
return AVERROR_ENCODER_NOT_FOUND; |
110 | 113 |
} |
111 | 114 |
return 0; |
... | ... |
@@ -114,8 +140,12 @@ static av_cold int omx_try_load(OMXContext *s, void *logctx, |
114 | 114 |
static av_cold OMXContext *omx_init(void *logctx, const char *libname, const char *prefix) |
115 | 115 |
{ |
116 | 116 |
static const char * const libnames[] = { |
117 |
- "libOMX_Core.so", |
|
118 |
- "libOmxCore.so", |
|
117 |
+#if CONFIG_OMX_RPI |
|
118 |
+ "/opt/vc/lib/libopenmaxil.so", "/opt/vc/lib/libbcm_host.so", |
|
119 |
+#else |
|
120 |
+ "libOMX_Core.so", NULL, |
|
121 |
+ "libOmxCore.so", NULL, |
|
122 |
+#endif |
|
119 | 123 |
NULL |
120 | 124 |
}; |
121 | 125 |
const char* const* nameptr; |
... | ... |
@@ -126,14 +156,14 @@ static av_cold OMXContext *omx_init(void *logctx, const char *libname, const cha |
126 | 126 |
if (!omx_context) |
127 | 127 |
return NULL; |
128 | 128 |
if (libname) { |
129 |
- ret = omx_try_load(omx_context, logctx, libname, prefix); |
|
129 |
+ ret = omx_try_load(omx_context, logctx, libname, prefix, NULL); |
|
130 | 130 |
if (ret < 0) { |
131 | 131 |
av_free(omx_context); |
132 | 132 |
return NULL; |
133 | 133 |
} |
134 | 134 |
} else { |
135 |
- for (nameptr = libnames; *nameptr; nameptr++) |
|
136 |
- if (!(ret = omx_try_load(omx_context, logctx, *nameptr, prefix))) |
|
135 |
+ for (nameptr = libnames; *nameptr; nameptr += 2) |
|
136 |
+ if (!(ret = omx_try_load(omx_context, logctx, nameptr[0], prefix, nameptr[1]))) |
|
137 | 137 |
break; |
138 | 138 |
if (!*nameptr) { |
139 | 139 |
av_free(omx_context); |
... | ... |
@@ -141,6 +171,8 @@ static av_cold OMXContext *omx_init(void *logctx, const char *libname, const cha |
141 | 141 |
} |
142 | 142 |
} |
143 | 143 |
|
144 |
+ if (omx_context->host_init) |
|
145 |
+ omx_context->host_init(); |
|
144 | 146 |
omx_context->ptr_Init(); |
145 | 147 |
return omx_context; |
146 | 148 |
} |
... | ... |
@@ -298,6 +330,12 @@ static av_cold int find_component(OMXContext *omx_context, void *logctx, |
298 | 298 |
char **components; |
299 | 299 |
int ret = 0; |
300 | 300 |
|
301 |
+#if CONFIG_OMX_RPI |
|
302 |
+ if (av_strstart(role, "video_encoder.", NULL)) { |
|
303 |
+ av_strlcpy(str, "OMX.broadcom.video_encode", str_size); |
|
304 |
+ return 0; |
|
305 |
+ } |
|
306 |
+#endif |
|
301 | 307 |
omx_context->ptr_GetComponentsOfRole((OMX_STRING) role, &num, NULL); |
302 | 308 |
if (!num) { |
303 | 309 |
av_log(logctx, AV_LOG_WARNING, "No component for role %s found\n", role); |
... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
|
30 | 30 |
#define LIBAVCODEC_VERSION_MAJOR 57 |
31 | 31 |
#define LIBAVCODEC_VERSION_MINOR 41 |
32 |
-#define LIBAVCODEC_VERSION_MICRO 100 |
|
32 |
+#define LIBAVCODEC_VERSION_MICRO 101 |
|
33 | 33 |
|
34 | 34 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
35 | 35 |
LIBAVCODEC_VERSION_MINOR, \ |