History

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.

Andreas Rheinhardt committed 2 years ago

Commit e4e63771 parent 790f7932 files · +12 −16Browse files

Showing the changes to libavcodec/arm (1 of 2 files). Show all

Unified · Split

libavcodec/arm/mpegvideo_arm.c+12−8
@@ -18,8 +18,9 @@ · 17 unmodified lines
1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919 */
2020
21+#include <assert.h>
22+
2123 #include "libavutil/attributes.h"
22−#include "libavutil/internal.h"
2324 #include "libavutil/arm/cpu.h"
2425 #include "libavcodec/avcodec.h"
2526 #include "libavcodec/mpegvideo.h"
@@ -27,13 +28,16 @@ · 1 unmodified line
2728 #include "asm-offsets.h"
2829
2930 #if HAVE_NEON
30−AV_CHECK_OFFSET(MpegEncContext, y_dc_scale, Y_DC_SCALE);
31−AV_CHECK_OFFSET(MpegEncContext, c_dc_scale, C_DC_SCALE);
32−AV_CHECK_OFFSET(MpegEncContext, ac_pred, AC_PRED);
33−AV_CHECK_OFFSET(MpegEncContext, block_last_index, BLOCK_LAST_INDEX);
34−AV_CHECK_OFFSET(MpegEncContext, inter_scantable.raster_end,
35− INTER_SCANTAB_RASTER_END);
36−AV_CHECK_OFFSET(MpegEncContext, h263_aic, H263_AIC);
31+#define CHECK_OFFSET(s, m, o) \
32+ static_assert(offsetof(s, m) == o, \
33+ "Hardcoded ASM offset of " #s " field " #o " needs to be updated.");
34+CHECK_OFFSET(MpegEncContext, y_dc_scale, Y_DC_SCALE);
35+CHECK_OFFSET(MpegEncContext, c_dc_scale, C_DC_SCALE);
36+CHECK_OFFSET(MpegEncContext, ac_pred, AC_PRED);
37+CHECK_OFFSET(MpegEncContext, block_last_index, BLOCK_LAST_INDEX);
38+CHECK_OFFSET(MpegEncContext, inter_scantable.raster_end,
39+ INTER_SCANTAB_RASTER_END);
40+CHECK_OFFSET(MpegEncContext, h263_aic, H263_AIC);
3741 #endif
3842
3943 void ff_dct_unquantize_h263_inter_neon(MpegEncContext *s, int16_t *block,

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