avcodec/arm/mpegvideo_arm: Use static_assert to check offsets

Also move AV_CHECK_OFFSET to its only user, namely
lavc/arm/mpegvideo_arm.c and rename it to CHECK_OFFSET.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2024-03-28 19:58:47 +01:00
parent 790f793844
commit e4e6377afc
2 changed files with 12 additions and 16 deletions

View File

@ -18,8 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <assert.h>
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
#include "libavutil/arm/cpu.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/mpegvideo.h"
@ -27,13 +28,16 @@
#include "asm-offsets.h"
#if HAVE_NEON
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);
#define CHECK_OFFSET(s, m, o) \
static_assert(offsetof(s, m) == o, \
"Hardcoded ASM offset of " #s " field " #o " needs to be updated.");
CHECK_OFFSET(MpegEncContext, y_dc_scale, Y_DC_SCALE);
CHECK_OFFSET(MpegEncContext, c_dc_scale, C_DC_SCALE);
CHECK_OFFSET(MpegEncContext, ac_pred, AC_PRED);
CHECK_OFFSET(MpegEncContext, block_last_index, BLOCK_LAST_INDEX);
CHECK_OFFSET(MpegEncContext, inter_scantable.raster_end,
INTER_SCANTAB_RASTER_END);
CHECK_OFFSET(MpegEncContext, h263_aic, H263_AIC);
#endif
void ff_dct_unquantize_h263_inter_neon(MpegEncContext *s, int16_t *block,

View File

@ -76,14 +76,6 @@
#define FF_MEMORY_POISON 0x2a
/* 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 FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p)))
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_calloc(nelem, sizeof(*p)))