diff mbox series

[FFmpeg-devel] libx264: Do not explicitly set X264_API_IMPORTS

Message ID CAHVN4mh8cZrCCRver6CSkyMzZ6qt6PKb7ZU3m_bhqNgJbwgZAg@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] libx264: Do not explicitly set X264_API_IMPORTS
Related show

Checks

Context Check Description
andriy/configurex86 warning Failed to apply patch
andriy/configureppc warning Failed to apply patch

Commit Message

Matt Oliver Oct. 30, 2021, 3:16 a.m. UTC
Setting X264_API_IMPORTS only affects msvc builds and it breaks linking to
static builds (although is required for shared builds). This flag is set by
x264 in its pkgconfig as required since build 158
(a615f027ed172e2dd5380e736d487aa858a0c4ff) from July 2019. So this patch
updates configure to require a newer x264 build that correctly sets the
imports flag.

Alternatively we can detect the x264 build version in configure and keep
the fallback of manually setting the flag on older x264 builds that aren't
using pkgconfig (to keep the old behaviour) but that requires some complex
configure changes that I'm not sure how best to do (assistance welcome).

Signed-off-by: Matt Oliver <protogonoi@gmail.com>
---
 configure            | 8 +++-----
 libavcodec/libx264.c | 4 ----
 2 files changed, 3 insertions(+), 9 deletions(-)

--

Comments

Matt Oliver Dec. 1, 2021, 4:18 a.m. UTC | #1
On Sat, 30 Oct 2021 at 14:16, Matt Oliver <protogonoi@gmail.com> wrote:

> Setting X264_API_IMPORTS only affects msvc builds and it breaks linking to
> static builds (although is required for shared builds). This flag is set by
> x264 in its pkgconfig as required since build 158
> (a615f027ed172e2dd5380e736d487aa858a0c4ff) from July 2019. So this patch
> updates configure to require a newer x264 build that correctly sets the
> imports flag.
>
> Alternatively we can detect the x264 build version in configure and keep
> the fallback of manually setting the flag on older x264 builds that aren't
> using pkgconfig (to keep the old behaviour) but that requires some complex
> configure changes that I'm not sure how best to do (assistance welcome).
>
> Signed-off-by: Matt Oliver <protogonoi@gmail.com>
> ---
>  configure            | 8 +++-----
>  libavcodec/libx264.c | 4 ----
>  2 files changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/configure b/configure
> index ede8f9777b..b35728aace 100755
> --- a/configure
> +++ b/configure
> @@ -6535,11 +6535,9 @@ enabled libvpx            && {
>  enabled libwebp           && {
>      enabled libwebp_encoder      && require_pkg_config libwebp "libwebp
> >= 0.2.0" webp/encode.h WebPGetEncoderVersion
>      enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder
> "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
> -enabled libx264           && { check_pkg_config libx264 x264 "stdint.h
> x264.h" x264_encoder_encode ||
> -                               { require libx264 "stdint.h x264.h"
> x264_encoder_encode "-lx264 $pthreads_extralibs $libm_extralibs" &&
> -                                 warn "using libx264 without pkg-config";
> } } &&
> -                             require_cpp_condition libx264 x264.h
> "X264_BUILD >= 118" &&
> -                             check_cpp_condition libx262 x264.h
> "X264_MPEG2"
> +enabled libx264           && check_pkg_config libx264 x264 "stdint.h
> x264.h" x264_encoder_encode &&
> +                             require_cpp_condition libx264 x264.h
> "X264_BUILD >= 158" &&
> +                             check_cpp_condition libx264 x264.h
> "X264_MPEG2"
>  enabled libx265           && require_pkg_config libx265 x265 x265.h
> x265_api_get &&
>                               require_cpp_condition libx265 x265.h
> "X265_BUILD >= 70"
>  enabled libxavs           && require libxavs "stdint.h xavs.h"
> xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 21f434d06d..efbc9608c7 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -34,10 +34,6 @@
>  #include "atsc_a53.h"
>  #include "sei.h"
>
> -#if defined(_MSC_VER)
> -#define X264_API_IMPORTS 1
> -#endif
> -
>  #include <x264.h>
>  #include <float.h>
>  #include <math.h>
> --
>

Ping for review. I'm pretty sure the change here to requiring x264 build
158 or newer might be an issue for some (although I could be wrong)
diff mbox series

Patch

diff --git a/configure b/configure
index ede8f9777b..b35728aace 100755
--- a/configure
+++ b/configure
@@ -6535,11 +6535,9 @@  enabled libvpx            && {
 enabled libwebp           && {
     enabled libwebp_encoder      && require_pkg_config libwebp "libwebp >=
0.2.0" webp/encode.h WebPGetEncoderVersion
     enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder
"libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
-enabled libx264           && { check_pkg_config libx264 x264 "stdint.h
x264.h" x264_encoder_encode ||
-                               { require libx264 "stdint.h x264.h"
x264_encoder_encode "-lx264 $pthreads_extralibs $libm_extralibs" &&
-                                 warn "using libx264 without pkg-config";
} } &&
-                             require_cpp_condition libx264 x264.h
"X264_BUILD >= 118" &&
-                             check_cpp_condition libx262 x264.h
"X264_MPEG2"
+enabled libx264           && check_pkg_config libx264 x264 "stdint.h
x264.h" x264_encoder_encode &&
+                             require_cpp_condition libx264 x264.h
"X264_BUILD >= 158" &&
+                             check_cpp_condition libx264 x264.h
"X264_MPEG2"
 enabled libx265           && require_pkg_config libx265 x265 x265.h
x265_api_get &&
                              require_cpp_condition libx265 x265.h
"X265_BUILD >= 70"
 enabled libxavs           && require libxavs "stdint.h xavs.h"
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 21f434d06d..efbc9608c7 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -34,10 +34,6 @@ 
 #include "atsc_a53.h"
 #include "sei.h"

-#if defined(_MSC_VER)
-#define X264_API_IMPORTS 1
-#endif
-
 #include <x264.h>
 #include <float.h>
 #include <math.h>