Unified · Split
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include "vpx/internal/vpx_codec_internal.h" |
| 17 | 17 | #include "vpx_version.h" |
| 18 | 18 | #include "vpx_mem/vpx_mem.h" |
| 19 | +#include "vpx_ports/static_assert.h" | |
| 19 | 20 | #include "vpx_ports/system_state.h" |
| 20 | 21 | #include "vpx_ports/vpx_once.h" |
| 21 | 22 | #include "vpx_util/vpx_timestamp.h" |
| @@ -131,22 +132,6 @@ static vpx_codec_err_t update_error_state( · 109 unmodified lines | ||
| 131 | 132 | if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ |
| 132 | 133 | } while (0) |
| 133 | 134 | |
| 134 | −#if defined(_MSC_VER) | |
| 135 | −#define COMPILE_TIME_ASSERT(boolexp) \ | |
| 136 | − do { \ | |
| 137 | − char compile_time_assert[(boolexp) ? 1 : -1]; \ | |
| 138 | − (void)compile_time_assert; \ | |
| 139 | − } while (0) | |
| 140 | −#else /* !_MSC_VER */ | |
| 141 | −#define COMPILE_TIME_ASSERT(boolexp) \ | |
| 142 | − do { \ | |
| 143 | − struct { \ | |
| 144 | − unsigned int compile_time_assert : (boolexp) ? 1 : -1; \ | |
| 145 | − } compile_time_assert; \ | |
| 146 | − (void)compile_time_assert; \ | |
| 147 | − } while (0) | |
| 148 | −#endif /* _MSC_VER */ | |
| 149 | − | |
| 150 | 135 | static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, |
| 151 | 136 | const vpx_codec_enc_cfg_t *cfg, |
| 152 | 137 | const struct vp8_extracfg *vp8_cfg, |
| @@ -751,8 +736,8 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, · 598 unmodified lines | ||
| 751 | 736 | /* Convert duration parameter from stream timebase to microseconds */ |
| 752 | 737 | uint64_t duration_us; |
| 753 | 738 | |
| 754 | − COMPILE_TIME_ASSERT(TICKS_PER_SEC > 1000000 && | |
| 755 | − (TICKS_PER_SEC % 1000000) == 0); | |
| 739 | + VPX_STATIC_ASSERT(TICKS_PER_SEC > 1000000 && | |
| 740 | + (TICKS_PER_SEC % 1000000) == 0); | |
| 756 | 741 | |
| 757 | 742 | duration_us = duration * (uint64_t)ctx->timestamp_ratio.num / |
| 758 | 743 | (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000)); |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | #include "vpx/vpx_encoder.h" |
| 16 | 16 | #include "vpx_dsp/psnr.h" |
| 17 | 17 | #include "vpx_ports/vpx_once.h" |
| 18 | +#include "vpx_ports/static_assert.h" | |
| 18 | 19 | #include "vpx_ports/system_state.h" |
| 19 | 20 | #include "vpx_util/vpx_timestamp.h" |
| 20 | 21 | #include "vpx/internal/vpx_codec_internal.h" |
| @@ -160,22 +161,6 @@ static vpx_codec_err_t update_error_state( · 139 unmodified lines | ||
| 160 | 161 | if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ |
| 161 | 162 | } while (0) |
| 162 | 163 | |
| 163 | −#if defined(_MSC_VER) | |
| 164 | −#define COMPILE_TIME_ASSERT(boolexp) \ | |
| 165 | − do { \ | |
| 166 | − char compile_time_assert[(boolexp) ? 1 : -1]; \ | |
| 167 | − (void)compile_time_assert; \ | |
| 168 | − } while (0) | |
| 169 | −#else // !_MSC_VER | |
| 170 | −#define COMPILE_TIME_ASSERT(boolexp) \ | |
| 171 | − do { \ | |
| 172 | − struct { \ | |
| 173 | − unsigned int compile_time_assert : (boolexp) ? 1 : -1; \ | |
| 174 | − } compile_time_assert; \ | |
| 175 | − (void)compile_time_assert; \ | |
| 176 | − } while (0) | |
| 177 | −#endif // _MSC_VER | |
| 178 | − | |
| 179 | 164 | static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, |
| 180 | 165 | const vpx_codec_enc_cfg_t *cfg, |
| 181 | 166 | const struct vp9_extracfg *extra_cfg) { |
| @@ -968,8 +953,8 @@ static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, · 786 unmodified lines | ||
| 968 | 953 | // Convert duration parameter from stream timebase to microseconds. |
| 969 | 954 | uint64_t duration_us; |
| 970 | 955 | |
| 971 | − COMPILE_TIME_ASSERT(TICKS_PER_SEC > 1000000 && | |
| 972 | − (TICKS_PER_SEC % 1000000) == 0); | |
| 956 | + VPX_STATIC_ASSERT(TICKS_PER_SEC > 1000000 && | |
| 957 | + (TICKS_PER_SEC % 1000000) == 0); | |
| 973 | 958 | |
| 974 | 959 | duration_us = duration * (uint64_t)ctx->timestamp_ratio.num / |
| 975 | 960 | (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000)); |
| @@ -0,0 +1,30 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2020 The WebM project authors. All Rights Reserved. | |
| 3 | + * | |
| 4 | + * Use of this source code is governed by a BSD-style license | |
| 5 | + * that can be found in the LICENSE file in the root of the source | |
| 6 | + * tree. An additional intellectual property rights grant can be found | |
| 7 | + * in the file PATENTS. All contributing project authors may | |
| 8 | + * be found in the AUTHORS file in the root of the source tree. | |
| 9 | + */ | |
| 10 | + | |
| 11 | +#ifndef VPX_VPX_PORTS_STATIC_ASSERT_H_ | |
| 12 | +#define VPX_VPX_PORTS_STATIC_ASSERT_H_ | |
| 13 | + | |
| 14 | +#if defined(_MSC_VER) | |
| 15 | +#define VPX_STATIC_ASSERT(boolexp) \ | |
| 16 | + do { \ | |
| 17 | + char vpx_static_assert[(boolexp) ? 1 : -1]; \ | |
| 18 | + (void)vpx_static_assert; \ | |
| 19 | + } while (0) | |
| 20 | +#else // !_MSC_VER | |
| 21 | +#define VPX_STATIC_ASSERT(boolexp) \ | |
| 22 | + do { \ | |
| 23 | + struct { \ | |
| 24 | + unsigned int vpx_static_assert : (boolexp) ? 1 : -1; \ | |
| 25 | + } vpx_static_assert; \ | |
| 26 | + (void)vpx_static_assert; \ | |
| 27 | + } while (0) | |
| 28 | +#endif // _MSC_VER | |
| 29 | + | |
| 30 | +#endif // VPX_VPX_PORTS_STATIC_ASSERT_H_ | |
| @@ -14,6 +14,7 @@ PORTS_SRCS-yes += vpx_ports.mk · 13 unmodified lines | ||
| 14 | 14 | PORTS_SRCS-yes += bitops.h |
| 15 | 15 | PORTS_SRCS-yes += mem.h |
| 16 | 16 | PORTS_SRCS-yes += msvc.h |
| 17 | +PORTS_SRCS-yes += static_assert.h | |
| 17 | 18 | PORTS_SRCS-yes += system_state.h |
| 18 | 19 | PORTS_SRCS-yes += vpx_timer.h |
| 19 | 20 | |