History

avutil/common, macros: Move several macros from common.h to macros.h

common.h currently contains several things: Math macros, UTF-8 macros, other fundamental macros; furthermore it also contains miscellaneous math functions and it (directly and indirectly) includes lots of other headers. This commit moves the "other fundamental macros" to macros.h which is a more fitting place.

Andreas Rheinhardt committed 5 years ago

Commit 2dd8acb1 parent fd101c94 files · +36 −30Browse files

Unified · Split

4 files
  1. doc/APIchanges +5 −0
  2. libavutil/common.h +0 −29
  3. libavutil/macros.h +30 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+5−0
@@ -13,6 +13,11 @@ libavutil: 2021-04-27 · 12 unmodified lines
1313
1414
1515 API changes, most recent first:
16+
17+2021-07-23 - xxxxxxxxxx - lavu 57.3.100 - common.h macros.h
18+ Move several macros (AV_NE, FFDIFFSIGN, FFMAX, FFMAX3, FFMIN, FFMIN3,
19+ FFSWAP, FF_ARRAY_ELEMS, MKTAG, MKBETAG) from common.h to macros.h.
20+
1621 2021-07-22 - xxxxxxxxxx - lavu 57.2.100 - film_grain_params.h
1722 Add AV_FILM_GRAIN_PARAMS_H274, AVFilmGrainH274Params
1823
libavutil/common.h+0−29
@@ -42,13 +42,6 @@ · 41 unmodified lines
4242 #include "attributes.h"
4343 #include "macros.h"
4444 #include "version.h"
45−#include "libavutil/avconfig.h"
46−
47−#if AV_HAVE_BIGENDIAN
48−# define AV_NE(be, le) (be)
49−#else
50−# define AV_NE(be, le) (le)
51−#endif
5245
5346 //rounded division & shift
5447 #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
@@ -89,25 +82,6 @@ · 34 unmodified lines
8982 #define FFABSU(a) ((a) <= 0 ? -(unsigned)(a) : (unsigned)(a))
9083 #define FFABS64U(a) ((a) <= 0 ? -(uint64_t)(a) : (uint64_t)(a))
9184
92−/**
93− * Comparator.
94− * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0
95− * if x == y. This is useful for instance in a qsort comparator callback.
96− * Furthermore, compilers are able to optimize this to branchless code, and
97− * there is no risk of overflow with signed types.
98− * As with many macros, this evaluates its argument multiple times, it thus
99− * must not have a side-effect.
100− */
101−#define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y)))
102−
103−#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
104−#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
105−#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
106−#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
107−
108−#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
109−#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
110−
11185 /* misc math functions */
11286
11387 #ifdef HAVE_AV_CONFIG_H
@@ -475,9 +449,6 @@ static av_always_inline av_const int av_parity_c(uint32_t v) · 361 unmodified lines
475449 return av_popcount(v) & 1;
476450 }
477451
478−#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
479−#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
480−
481452 /**
482453 * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
483454 *
libavutil/macros.h+30−0
@@ -25,6 +25,36 @@ · 24 unmodified lines
2525 #ifndef AVUTIL_MACROS_H
2626 #define AVUTIL_MACROS_H
2727
28+#include "libavutil/avconfig.h"
29+
30+#if AV_HAVE_BIGENDIAN
31+# define AV_NE(be, le) (be)
32+#else
33+# define AV_NE(be, le) (le)
34+#endif
35+
36+/**
37+ * Comparator.
38+ * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0
39+ * if x == y. This is useful for instance in a qsort comparator callback.
40+ * Furthermore, compilers are able to optimize this to branchless code, and
41+ * there is no risk of overflow with signed types.
42+ * As with many macros, this evaluates its argument multiple times, it thus
43+ * must not have a side-effect.
44+ */
45+#define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y)))
46+
47+#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
48+#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
49+#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
50+#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
51+
52+#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
53+#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
54+
55+#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
56+#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
57+
2858 /**
2959 * @addtogroup preproc_misc Preprocessor String Macros
3060 *
libavutil/version.h+1−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 57
82−#define LIBAVUTIL_VERSION_MINOR 2
82+#define LIBAVUTIL_VERSION_MINOR 3
8383 #define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t