X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Finternal.h;h=7cd36ff742805b3785479932f27170460ca416f2;hb=ef6a9e5e311f09fa8032974fa4d0c1e166a959bb;hp=06bd561e82c0cf8a6106528a3a59e1dc77279c1d;hpb=64425e005edf3bdd77c34c078c3e74ab5ecef557;p=ffmpeg diff --git a/libavutil/internal.h b/libavutil/internal.h index 06bd561e82c..7cd36ff7428 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -43,7 +43,6 @@ #include "cpu.h" #include "dict.h" #include "macros.h" -#include "mem.h" #include "pixfmt.h" #include "version.h" @@ -52,7 +51,7 @@ #endif #ifndef emms_c -# define emms_c() while(0) +# define emms_c() do {} while(0) #endif #ifndef attribute_align_arg @@ -92,10 +91,6 @@ type av_##name##_get_##field(const str *s) { return s->field; } \ void av_##name##_set_##field(str *s, type v) { s->field = v; } -// Some broken preprocessors need a second expansion -// to be forced to tokenize __VA_ARGS__ -#define E1(x) x - /* Check if the hard coded offset of a struct member still matches reality. * Induce a compilation failure if not. */ @@ -103,75 +98,11 @@ int x_##o[offsetof(s, m) == o? 1: -1]; \ } -#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \ - uint8_t la_##v[sizeof(t s o) + (a)]; \ - t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a) - -#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \ - DECLARE_ALIGNED(a, t, la_##v) s o; \ - t (*v) o = la_##v - -#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_##a(t, v, __VA_ARGS__) - -#if HAVE_LOCAL_ALIGNED -# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_D(4, t, v, __VA_ARGS__,,)) -#else -# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,)) -#endif - -#if HAVE_LOCAL_ALIGNED -# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,)) -#else -# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,)) -#endif - -#if HAVE_LOCAL_ALIGNED -# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,)) -#else -# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,)) -#endif - -#if HAVE_LOCAL_ALIGNED -# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,)) -#else -# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,)) -#endif - -#define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ -{\ - p = av_malloc(size);\ - if (!(p) && (size) != 0) {\ - av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ - goto label;\ - }\ -} - -#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\ -{\ - p = av_mallocz(size);\ - if (!(p) && (size) != 0) {\ - av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ - goto label;\ - }\ -} -#define FF_ALLOC_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)\ -{\ - p = av_malloc_array(nelem, elsize);\ - if (!p) {\ - av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ - goto label;\ - }\ -} +#define FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p))) +#define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_mallocz_array(nelem, sizeof(*p))) -#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)\ -{\ - p = av_mallocz_array(nelem, elsize);\ - if (!p) {\ - av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ - goto label;\ - }\ -} +#define FF_PTR_ADD(ptr, off) ((off) ? (ptr) + (off) : (ptr)) #include "libm.h" @@ -353,20 +284,12 @@ void ff_check_pixfmt_descriptors(void); /** * Set a dictionary value to an ISO-8601 compliant timestamp string. * - * @param s AVFormatContext + * @param dict pointer to a pointer to a dictionary struct. If *dict is NULL + * a dictionary struct is allocated and put in *dict. * @param key metadata key * @param timestamp unix timestamp in microseconds * @return <0 on error */ int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp); -// Helper macro for AV_PIX_FMT_FLAG_PSEUDOPAL deprecation. Code inside FFmpeg -// should always use FF_PSEUDOPAL. Once the public API flag gets removed, all -// code using it is dead code. -#if FF_API_PSEUDOPAL -#define FF_PSEUDOPAL AV_PIX_FMT_FLAG_PSEUDOPAL -#else -#define FF_PSEUDOPAL 0 -#endif - #endif /* AVUTIL_INTERNAL_H */