aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-04-25 00:55:00 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-04-25 00:55:40 +0200
commit06e664366a66a373358aacacde8e86348d55bd22 (patch)
tree420f5a64cc848964341ab5e9358634d9c5ef3e29
parent5ac10d40fb9b65e476d1d591a892e0ff51cda6d5 (diff)
parenta88e1d1c598e641eecd5d43730211d91c82787c6 (diff)
downloadffmpeg-06e664366a66a373358aacacde8e86348d55bd22.tar.gz
Merge commit 'a88e1d1c598e641eecd5d43730211d91c82787c6'
* commit 'a88e1d1c598e641eecd5d43730211d91c82787c6': lavu: add CHK_OFFS as AV_CHECK_OFFSET to check struct member offsets Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/arm/asm-offsets.h7
-rw-r--r--libavcodec/arm/mpegvideo_arm.c14
-rw-r--r--libavutil/internal.h7
3 files changed, 15 insertions, 13 deletions
diff --git a/libavcodec/arm/asm-offsets.h b/libavcodec/arm/asm-offsets.h
index 5cfc5cb10c..37a67975fd 100644
--- a/libavcodec/arm/asm-offsets.h
+++ b/libavcodec/arm/asm-offsets.h
@@ -21,13 +21,6 @@
#ifndef AVCODEC_ARM_ASM_OFFSETS_H
#define AVCODEC_ARM_ASM_OFFSETS_H
-#ifndef __ASSEMBLER__
-#include <stddef.h>
-#define CHK_OFFS(s, m, o) struct check_##o { \
- int x_##o[offsetof(s, m) == o? 1: -1]; \
- }
-#endif
-
/* MpegEncContext */
#define Y_DC_SCALE 0xa8
#define C_DC_SCALE 0xac
diff --git a/libavcodec/arm/mpegvideo_arm.c b/libavcodec/arm/mpegvideo_arm.c
index 656679809b..5f5473d28c 100644
--- a/libavcodec/arm/mpegvideo_arm.c
+++ b/libavcodec/arm/mpegvideo_arm.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/internal.h"
#include "libavutil/arm/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/mpegvideo.h"
@@ -25,12 +26,13 @@
#include "asm-offsets.h"
#if HAVE_NEON
-CHK_OFFS(MpegEncContext, y_dc_scale, Y_DC_SCALE);
-CHK_OFFS(MpegEncContext, c_dc_scale, C_DC_SCALE);
-CHK_OFFS(MpegEncContext, ac_pred, AC_PRED);
-CHK_OFFS(MpegEncContext, block_last_index, BLOCK_LAST_INDEX);
-CHK_OFFS(MpegEncContext, inter_scantable.raster_end, INTER_SCANTAB_RASTER_END);
-CHK_OFFS(MpegEncContext, h263_aic, H263_AIC);
+AV_CHECK_OFFSET(MpegEncContext, y_dc_scale, Y_DC_SCALE);
+AV_CHECK_OFFSET(MpegEncContext, c_dc_scale, C_DC_SCALE);
+AV_CHECK_OFFSET(MpegEncContext, ac_pred, AC_PRED);
+AV_CHECK_OFFSET(MpegEncContext, block_last_index, BLOCK_LAST_INDEX);
+AV_CHECK_OFFSET(MpegEncContext, inter_scantable.raster_end,
+ INTER_SCANTAB_RASTER_END);
+AV_CHECK_OFFSET(MpegEncContext, h263_aic, H263_AIC);
#endif
void ff_dct_unquantize_h263_inter_neon(MpegEncContext *s, int16_t *block,
diff --git a/libavutil/internal.h b/libavutil/internal.h
index c6c0aa8d38..9a04fa5a2f 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -93,6 +93,13 @@
// 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.
+ */
+#define AV_CHECK_OFFSET(s, m, o) struct check_##o { \
+ 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)