diff mbox series

[FFmpeg-devel] avutil: make lzo always compile

Message ID 20220226145211.1905-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] avutil: make lzo always compile | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_fate_armv7_RPi4 fail Make fate failed
andriy/make_armv7_RPi4 warning New warnings during build

Commit Message

James Almer Feb. 26, 2022, 2:52 p.m. UTC
Having optionally installed headers is a bad idea as there's no way to know
if they are present or not (unless a define is added to avconfig.h, but that's
just ugly).
Since configure allows the user to disable lzo, ensure the symbol is always
present even if the functionality is not there.

Signed-off-by: James Almer <jamrial@gmail.com>
---
av_lzo1x_decode() does not return AVERROR values on failure, meaning i can't
use ENOSYS, so I decided to just return the most generic error from those
defined in the header.

 libavutil/Makefile | 5 ++---
 libavutil/lzo.c    | 7 +++++++
 2 files changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/Makefile b/libavutil/Makefile
index d17876df1a..b867d3b362 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -52,6 +52,7 @@  HEADERS = adler32.h                                                     \
           intreadwrite.h                                                \
           lfg.h                                                         \
           log.h                                                         \
+          lzo.h                                                         \
           macros.h                                                      \
           mathematics.h                                                 \
           mastering_display_metadata.h                                  \
@@ -87,8 +88,6 @@  HEADERS = adler32.h                                                     \
           tx.h                                                          \
           film_grain_params.h                                           \
 
-HEADERS-$(CONFIG_LZO)                   += lzo.h
-
 ARCH_HEADERS = bswap.h                                                  \
                intmath.h                                                \
                intreadwrite.h                                           \
@@ -139,6 +138,7 @@  OBJS = adler32.o                                                        \
        lls.o                                                            \
        log.o                                                            \
        log2_tab.o                                                       \
+       lzo.o                                                            \
        mathematics.o                                                    \
        mastering_display_metadata.o                                     \
        md5.o                                                            \
@@ -180,7 +180,6 @@  OBJS-$(CONFIG_CUDA)                     += hwcontext_cuda.o
 OBJS-$(CONFIG_D3D11VA)                  += hwcontext_d3d11va.o
 OBJS-$(CONFIG_DXVA2)                    += hwcontext_dxva2.o
 OBJS-$(CONFIG_LIBDRM)                   += hwcontext_drm.o
-OBJS-$(CONFIG_LZO)                      += lzo.o
 OBJS-$(CONFIG_MACOS_KPERF)              += macos_kperf.o
 OBJS-$(CONFIG_MEDIACODEC)               += hwcontext_mediacodec.o
 OBJS-$(CONFIG_OPENCL)                   += hwcontext_opencl.o
diff --git a/libavutil/lzo.c b/libavutil/lzo.c
index bcbe2c861d..39088340bc 100644
--- a/libavutil/lzo.c
+++ b/libavutil/lzo.c
@@ -29,6 +29,7 @@ 
 #include "macros.h"
 #include "mem.h"
 
+#if CONFIG_LZO
 /// Define if we may write up to 12 bytes beyond the output buffer.
 #define OUTBUF_PADDED 1
 /// Define if we may read up to 8 bytes beyond the input buffer.
@@ -205,3 +206,9 @@  int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
     *outlen = c.out_end - c.out;
     return c.error;
 }
+#else
+int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
+{
+    return AV_LZO_ERROR;
+}
+#endif