Unified · Split
| @@ -16,6 +16,7 @@ · 15 unmodified lines | |||
| 16 | #include "vpx/internal/vpx_codec_internal.h" | 16 | #include "vpx/internal/vpx_codec_internal.h" |
| 17 | #include "vpx_version.h" | 17 | #include "vpx_version.h" |
| 18 | #include "vpx_mem/vpx_mem.h" | 18 | #include "vpx_mem/vpx_mem.h" |
| 19 | #include "vpx_ports/static_assert.h" | ||
| 19 | #include "vpx_ports/system_state.h" | 20 | #include "vpx_ports/system_state.h" |
| 20 | #include "vpx_ports/vpx_once.h" | 21 | #include "vpx_ports/vpx_once.h" |
| 21 | #include "vpx_util/vpx_timestamp.h" | 22 | #include "vpx_util/vpx_timestamp.h" |
| @@ -131,22 +132,6 @@ static vpx_codec_err_t update_error_state( · 109 unmodified lines | |||
| 131 | if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ | 132 | if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ |
| 132 | } while (0) | 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 | static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, | 135 | static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, |
| 151 | const vpx_codec_enc_cfg_t *cfg, | 136 | const vpx_codec_enc_cfg_t *cfg, |
| 152 | const struct vp8_extracfg *vp8_cfg, | 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 | /* Convert duration parameter from stream timebase to microseconds */ | 736 | /* Convert duration parameter from stream timebase to microseconds */ |
| 752 | uint64_t duration_us; | 737 | uint64_t duration_us; |
| 753 | 738 | ||
| 754 | COMPILE_TIME_ASSERT(TICKS_PER_SEC > 1000000 && | 739 | VPX_STATIC_ASSERT(TICKS_PER_SEC > 1000000 && |
| 755 | (TICKS_PER_SEC % 1000000) == 0); | 740 | (TICKS_PER_SEC % 1000000) == 0); |
| 756 | 741 | ||
| 757 | duration_us = duration * (uint64_t)ctx->timestamp_ratio.num / | 742 | duration_us = duration * (uint64_t)ctx->timestamp_ratio.num / |
| 758 | (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000)); | 743 | (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000)); |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | |||
| 15 | #include "vpx/vpx_encoder.h" | 15 | #include "vpx/vpx_encoder.h" |
| 16 | #include "vpx_dsp/psnr.h" | 16 | #include "vpx_dsp/psnr.h" |
| 17 | #include "vpx_ports/vpx_once.h" | 17 | #include "vpx_ports/vpx_once.h" |
| 18 | #include "vpx_ports/static_assert.h" | ||
| 18 | #include "vpx_ports/system_state.h" | 19 | #include "vpx_ports/system_state.h" |
| 19 | #include "vpx_util/vpx_timestamp.h" | 20 | #include "vpx_util/vpx_timestamp.h" |
| 20 | #include "vpx/internal/vpx_codec_internal.h" | 21 | #include "vpx/internal/vpx_codec_internal.h" |
| @@ -160,22 +161,6 @@ static vpx_codec_err_t update_error_state( · 139 unmodified lines | |||
| 160 | if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ | 161 | if (!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean"); \ |
| 161 | } while (0) | 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 | static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, | 164 | static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, |
| 180 | const vpx_codec_enc_cfg_t *cfg, | 165 | const vpx_codec_enc_cfg_t *cfg, |
| 181 | const struct vp9_extracfg *extra_cfg) { | 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 | // Convert duration parameter from stream timebase to microseconds. | 953 | // Convert duration parameter from stream timebase to microseconds. |
| 969 | uint64_t duration_us; | 954 | uint64_t duration_us; |
| 970 | 955 | ||
| 971 | COMPILE_TIME_ASSERT(TICKS_PER_SEC > 1000000 && | 956 | VPX_STATIC_ASSERT(TICKS_PER_SEC > 1000000 && |
| 972 | (TICKS_PER_SEC % 1000000) == 0); | 957 | (TICKS_PER_SEC % 1000000) == 0); |
| 973 | 958 | ||
| 974 | duration_us = duration * (uint64_t)ctx->timestamp_ratio.num / | 959 | duration_us = duration * (uint64_t)ctx->timestamp_ratio.num / |
| 975 | (ctx->timestamp_ratio.den * (TICKS_PER_SEC / 1000000)); | 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 | PORTS_SRCS-yes += bitops.h | 14 | PORTS_SRCS-yes += bitops.h |
| 15 | PORTS_SRCS-yes += mem.h | 15 | PORTS_SRCS-yes += mem.h |
| 16 | PORTS_SRCS-yes += msvc.h | 16 | PORTS_SRCS-yes += msvc.h |
| 17 | PORTS_SRCS-yes += static_assert.h | ||
| 17 | PORTS_SRCS-yes += system_state.h | 18 | PORTS_SRCS-yes += system_state.h |
| 18 | PORTS_SRCS-yes += vpx_timer.h | 19 | PORTS_SRCS-yes += vpx_timer.h |
| 19 | 20 | ||