History

Merge "add static_assert.h"

James Zern committed 6 years ago

Commit 7adcbf22 parents b78d3b2 bc9b7f54 files · +37 −36Browse files

Unified · Split

4 files
  1. vp8/vp8_cx_iface.c +3 −18
  2. vp9/vp9_cx_iface.c +3 −18
  3. vpx_ports/static_assert.h +30 −0
  4. vpx_ports/vpx_ports.mk +1 −0
vp8/vp8_cx_iface.c+3−18
@@ -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
150static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,135static 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));
vp9/vp9_cx_iface.c+3−18
@@ -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
179static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,164static 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));
vpx_ports/static_assert.h+30−0
@@ -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_
vpx_ports/vpx_ports.mk+1−0
@@ -14,6 +14,7 @@ PORTS_SRCS-yes += vpx_ports.mk · 13 unmodified lines
14PORTS_SRCS-yes += bitops.h14PORTS_SRCS-yes += bitops.h
15PORTS_SRCS-yes += mem.h15PORTS_SRCS-yes += mem.h
16PORTS_SRCS-yes += msvc.h16PORTS_SRCS-yes += msvc.h
17PORTS_SRCS-yes += static_assert.h
17PORTS_SRCS-yes += system_state.h18PORTS_SRCS-yes += system_state.h
18PORTS_SRCS-yes += vpx_timer.h19PORTS_SRCS-yes += vpx_timer.h
19 20

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