From 3f65eff408f78f9f71f250530f20e5870eb49b0c Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 14 Oct 2012 00:27:26 +0100 Subject: [PATCH 1/6] Include sys/time.h before sys/resource.h Some systems require sys/time.h being explicitly included before sys/resource.h. The configure check already does this. Signed-off-by: Mans Rullgard --- avconv.c | 1 + cmdutils.c | 1 + 2 files changed, 2 insertions(+) diff --git a/avconv.c b/avconv.c index 759e1c0ce8..6f6771186a 100644 --- a/avconv.c +++ b/avconv.c @@ -53,6 +53,7 @@ # include "libavfilter/buffersink.h" #if HAVE_SYS_RESOURCE_H +#include #include #include #elif HAVE_GETPROCESSTIMES diff --git a/cmdutils.c b/cmdutils.c index 34c52ca136..6570968526 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -49,6 +49,7 @@ #include "libavformat/network.h" #endif #if HAVE_SYS_RESOURCE_H +#include #include #endif From da0d0ae9a4294fcc42b7159b902c8950ad1abb54 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 14 Oct 2012 18:00:05 +0100 Subject: [PATCH 2/6] network: add fallbacks for INADDR_LOOPBACK and INET_ADDRSTRLEN Signed-off-by: Mans Rullgard --- libavformat/network.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavformat/network.h b/libavformat/network.h index da9d9263ab..51607673e2 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -188,6 +188,14 @@ const char *ff_gai_strerror(int ecode); #define gai_strerror ff_gai_strerror #endif +#ifndef INADDR_LOOPBACK +#define INADDR_LOOPBACK 0x7f000001 +#endif + +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 +#endif + #ifndef INET6_ADDRSTRLEN #define INET6_ADDRSTRLEN INET_ADDRSTRLEN #endif From c3e73100af9b685be796bcd3e68786130d45ea24 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 14 Oct 2012 20:24:51 +0100 Subject: [PATCH 3/6] network: use getservbyport() only if available The absence of this function will only give a less informative string back from our fallback implementation of getnameinfo(). Signed-off-by: Mans Rullgard --- configure | 2 ++ libavformat/os_support.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/configure b/configure index 996c7169e4..e1524fbf21 100755 --- a/configure +++ b/configure @@ -1190,6 +1190,7 @@ HAVE_LIST=" GetProcessTimes GetSystemTimeAsFileTime getrusage + getservbyport gettimeofday gnu_as ibm_asm @@ -3158,6 +3159,7 @@ if enabled network; then check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len check_type netinet/sctp.h "struct sctp_event_subscribe" check_func getaddrinfo $network_extralibs + check_func getservbyport $network_extralibs # Prefer arpa/inet.h over winsock2 if check_header arpa/inet.h ; then check_func closesocket diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 7618708283..451801ff70 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -235,8 +235,10 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen, if (serv && servlen > 0) { struct servent *ent = NULL; +#if HAVE_GETSERVBYPORT if (!(flags & NI_NUMERICSERV)) ent = getservbyport(sin->sin_port, flags & NI_DGRAM ? "udp" : "tcp"); +#endif if (ent) snprintf(serv, servlen, "%s", ent->s_name); From fab0a8b2c6caa0e6478915bb42904995d70c4b3f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 13 Oct 2012 22:54:53 +0100 Subject: [PATCH 4/6] libm: add fallbacks for various single-precision functions Signed-off-by: Mans Rullgard --- configure | 8 ++++++++ libavcodec/aacps_tablegen.h | 1 + libavutil/libm.h | 40 +++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/configure b/configure index e1524fbf21..35cf34f776 100755 --- a/configure +++ b/configure @@ -1125,20 +1125,28 @@ HAVE_LIST_PUB=' ' MATH_FUNCS=" + atanf + atan2f cbrtf + cosf exp2 exp2f + expf isinf isnan + ldexpf llrint llrintf log2 log2f + log10f lrint lrintf + powf rint round roundf + sinf trunc truncf " diff --git a/libavcodec/aacps_tablegen.h b/libavcodec/aacps_tablegen.h index bd4e695568..0c610edaf2 100644 --- a/libavcodec/aacps_tablegen.h +++ b/libavcodec/aacps_tablegen.h @@ -31,6 +31,7 @@ #include "libavcodec/aacps_tables.h" #else #include "libavutil/common.h" +#include "libavutil/libm.h" #include "libavutil/mathematics.h" #include "libavutil/mem.h" #define NR_ALLPASS_BANDS20 30 diff --git a/libavutil/libm.h b/libavutil/libm.h index 8305b7c61b..d6c2cf8623 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -29,6 +29,21 @@ #include "attributes.h" #include "intfloat.h" +#if !HAVE_ATANF +#undef atanf +#define atanf(x) ((float)atan(x)) +#endif + +#if !HAVE_ATAN2F +#undef atan2f +#define atan2f(y, x) ((float)atan2(y, x)) +#endif + +#if !HAVE_POWF +#undef powf +#define powf(x, y) ((float)pow(x, y)) +#endif + #if !HAVE_CBRTF static av_always_inline float cbrtf(float x) { @@ -36,6 +51,16 @@ static av_always_inline float cbrtf(float x) } #endif +#if !HAVE_COSF +#undef cosf +#define cosf(x) ((float)cos(x)) +#endif + +#if !HAVE_EXPF +#undef expf +#define expf(x) ((float)exp(x)) +#endif + #if !HAVE_EXP2 #undef exp2 #define exp2(x) exp((x) * 0.693147180559945) @@ -66,6 +91,11 @@ static av_always_inline av_const int isnan(float x) } #endif /* HAVE_ISNAN */ +#if !HAVE_LDEXPF +#undef ldexpf +#define ldexpf(x, exp) ((float)ldexp(x, exp)) +#endif + #if !HAVE_LLRINT #undef llrint #define llrint(x) ((long long)rint(x)) @@ -86,6 +116,16 @@ static av_always_inline av_const int isnan(float x) #define log2f(x) ((float)log2(x)) #endif /* HAVE_LOG2F */ +#if !HAVE_LOG10F +#undef log10f +#define log10f(x) ((float)log10(x)) +#endif + +#if !HAVE_SINF +#undef sinf +#define sinf(x) ((float)sin(x)) +#endif + #if !HAVE_RINT static inline double rint(double x) { From a805cefd8b81e551ab7dfb6a7ae8b5a1512e7893 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sun, 14 Oct 2012 00:26:15 +0100 Subject: [PATCH 5/6] swscale: avoid pointless use of compound literals Some compilers (e.g. old gcc) have trouble with these. Signed-off-by: Mans Rullgard --- libswscale/swscale_unscaled.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index 70eff72183..5efc647b08 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -396,6 +396,11 @@ static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[], uint8_t *dst[], int dstStride[]) { int alpha_first = 0; + const uint8_t *src102[] = { src[1], src[0], src[2] }; + const uint8_t *src201[] = { src[2], src[0], src[1] }; + int stride102[] = { srcStride[1], srcStride[0], srcStride[2] }; + int stride201[] = { srcStride[2], srcStride[0], srcStride[1] }; + if (c->srcFormat != AV_PIX_FMT_GBRP) { av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n", av_get_pix_fmt_name(c->srcFormat), @@ -405,15 +410,13 @@ static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[], switch (c->dstFormat) { case AV_PIX_FMT_BGR24: - gbr24ptopacked24((const uint8_t *[]) { src[1], src[0], src[2] }, - (int []) { srcStride[1], srcStride[0], srcStride[2] }, + gbr24ptopacked24(src102, stride102, dst[0] + srcSliceY * dstStride[0], dstStride[0], srcSliceH, c->srcW); break; case AV_PIX_FMT_RGB24: - gbr24ptopacked24((const uint8_t *[]) { src[2], src[0], src[1] }, - (int []) { srcStride[2], srcStride[0], srcStride[1] }, + gbr24ptopacked24(src201, stride201, dst[0] + srcSliceY * dstStride[0], dstStride[0], srcSliceH, c->srcW); break; @@ -421,8 +424,7 @@ static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[], case AV_PIX_FMT_ARGB: alpha_first = 1; case AV_PIX_FMT_RGBA: - gbr24ptopacked32((const uint8_t *[]) { src[2], src[0], src[1] }, - (int []) { srcStride[2], srcStride[0], srcStride[1] }, + gbr24ptopacked32(src201, stride201, dst[0] + srcSliceY * dstStride[0], dstStride[0], srcSliceH, alpha_first, c->srcW); break; @@ -430,8 +432,7 @@ static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[], case AV_PIX_FMT_ABGR: alpha_first = 1; case AV_PIX_FMT_BGRA: - gbr24ptopacked32((const uint8_t *[]) { src[1], src[0], src[2] }, - (int []) { srcStride[1], srcStride[0], srcStride[2] }, + gbr24ptopacked32(src102, stride102, dst[0] + srcSliceY * dstStride[0], dstStride[0], srcSliceH, alpha_first, c->srcW); break; From 80521c1997a23e148edf89e11b939ab8646297ca Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Mon, 15 Oct 2012 04:05:03 +0100 Subject: [PATCH 6/6] build: allow targets to specify extra objects to link with executables This allows targets to include special objects when linking executables without including them in (shared) libraries. Signed-off-by: Mans Rullgard --- Makefile | 8 ++++---- configure | 1 + library.mak | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3202f5d71a..07df53871a 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ PROGS-$(CONFIG_AVPROBE) += avprobe PROGS-$(CONFIG_AVSERVER) += avserver PROGS := $(PROGS-yes:%=%$(EXESUF)) -OBJS = cmdutils.o +OBJS = cmdutils.o $(EXEOBJS) OBJS-avconv = avconv_opt.o avconv_filter.o TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64 HOSTPROGS := $(TESTTOOLS:%=tests/%) doc/print_options @@ -90,8 +90,8 @@ FF_DEP_LIBS := $(DEP_LIBS) all: $(PROGS) -$(TOOLS): %$(EXESUF): %.o - $(LD) $(LDFLAGS) $(LD_O) $< $(ELIBS) +$(TOOLS): %$(EXESUF): %.o $(EXEOBJS) + $(LD) $(LDFLAGS) $(LD_O) $^ $(ELIBS) tools/cws2fws$(EXESUF): ELIBS = $(ZLIB) @@ -124,7 +124,7 @@ endef $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D)))) define DOPROG -OBJS-$(1) += $(1).o cmdutils.o +OBJS-$(1) += $(1).o cmdutils.o $(EXEOBJS) $(1)$(EXESUF): $$(OBJS-$(1)) $$(OBJS-$(1)): CFLAGS += $(CFLAGS-$(1)) $(1)$(EXESUF): LDFLAGS += $(LDFLAGS-$(1)) diff --git a/configure b/configure index 35cf34f776..f597cafe99 100755 --- a/configure +++ b/configure @@ -3737,6 +3737,7 @@ ZLIB=$($ldflags_filter -lz) LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD EXTRALIBS=$extralibs COMPAT_OBJS=$compat_objs +EXEOBJS=$exeobjs INSTALL=install LIBTARGET=${LIBTARGET} SLIBNAME=${SLIBNAME} diff --git a/library.mak b/library.mak index b36593504c..cbfa0d48e1 100644 --- a/library.mak +++ b/library.mak @@ -36,7 +36,7 @@ define RULES $(EXAMPLES) $(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB)) $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME) -$(EXAMPLES) $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o +$(EXAMPLES) $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $(EXEOBJS) $$(LD) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS) $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)