树莓派编译FFmpeg 5.0遇aacps_tablegen系列错误求助
树莓派编译FFmpeg 5.0失败,aacps_tablegen相关报错
问题背景
两年前在树莓派4 B+(Raspberry Pi OS Buster 32bit)用相同脚本成功编译过FFmpeg,现在编译FFmpeg 5.0版本时持续失败。先后尝试10余次,更换过Raspberry Pi OS Buster 32bit、Bullseye 32bit、Bullseye 64bit多个系统版本,也试过多个第三方编译脚本,最终都出现相同错误,报错集中在libavcodec/aacps_tablegen.h和libavcodec/aacps_tablegen_template.c文件。
编译错误信息
./config.h:594: warning: "CONFIG_HARDCODED_TABLES" redefined #define CONFIG_HARDCODED_TABLES 1 In file included from libavcodec/aacps_tablegen.c:24: libavcodec/aacps_tablegen_template.c:25: note: this is the location of the previous definition #define CONFIG_HARDCODED_TABLES 0 In file included from libavcodec/aacps_tablegen_template.c:39, from libavcodec/aacps_tablegen.c:24: libavcodec/aacps_tablegen.h:46:24: error: expected declaration specifiers or ‘...’ before numeric constant static DECLARE_ALIGNED(16, float, f20_0_8) [ 8][8][2]; ^~ libavcodec/aacps_tablegen.h:46:35: error: unknown type name ‘f20_0_8’ static DECLARE_ALIGNED(16, float, f20_0_8) [ 8][8][2]; ^~~~~~~ libavcodec/aacps_tablegen.h:47:24: error: expected declaration specifiers or ‘...’ before numeric constant static DECLARE_ALIGNED(16, float, f34_0_12)[12][8][2]; ^~ libavcodec/aacps_tablegen.h:47:35: error: unknown type name ‘f34_0_12’ static DECLARE_ALIGNED(16, float, f34_0_12)[12][8][2]; ^~~~~~~~ libavcodec/aacps_tablegen.h:48:24: error: expected declaration specifiers or ‘...’ before numeric constant static DECLARE_ALIGNED(16, float, f34_1_8) [ 8][8][2]; ^~ libavcodec/aacps_tablegen.h:48:35: error: unknown type name ‘f34_1_8’ static DECLARE_ALIGNED(16, float, f34_1_8) [ 8][8][2]; ^~~~~~~ libavcodec/aacps_tablegen.h:49:24: error: expected declaration specifiers or ‘...’ before numeric constant static DECLARE_ALIGNED(16, float, f34_2_4) [ 4][8][2]; ^~ libavcodec/aacps_tablegen.h:49:35: error: unknown type name ‘f34_2_4’ static DECLARE_ALIGNED(16, float, f34_2_4) [ 4][8][2]; ^~~~~~~ libavcodec/aacps_tablegen.h:50:36: error: expected declaration specifiers or ‘...’ before numeric constant static TABLE_CONST DECLARE_ALIGNED(16, float, Q_fract_allpass)[2][50][3][2]; ^~ libavcodec/aacps_tablegen.h:50:47: error: unknown type name ‘Q_fract_allpass’ static TABLE_CONST DECLARE_ALIGNED(16, float, Q_fract_allpass)[2][50][3][2]; ^~~~~~~~~~~~~~~ libavcodec/aacps_tablegen.h:51:24: error: expected declaration specifiers or ‘...’ before numeric constant static DECLARE_ALIGNED(16, float, phi_fract)[2][50][2]; ^~ libavcodec/aacps_tablegen.h:51:35: error: unknown type name ‘phi_fract’ static DECLARE_ALIGNED(16, float, phi_fract)[2][50][2]; ^~~~~~~~~ libavcodec/aacps_tablegen.h: In function ‘ps_tableinit’: libavcodec/aacps_tablegen.h:187:13: error: ‘Q_fract_allpass’ undeclared (first use in this function) Q_fract_allpass[0][k][m][0] = cos(theta); ^~~~~~~~~~~~~~~ libavcodec/aacps_tablegen.h:187:13: note: each undeclared identifier is reported only once for each function it appears in libavcodec/aacps_tablegen.h:191:9: error: ‘phi_fract’ undeclared (first use in this function) phi_fract[0][k][0] = cos(theta); ^~~~~~~~~ libavcodec/aacps_tablegen.h:210:29: error: ‘f20_0_8’ undeclared (first use in this function) make_filters_from_proto(f20_0_8, g0_Q8, 8); ^~~~~~~ libavcodec/aacps_tablegen.h:211:29: error: ‘f34_0_12’ undeclared (first use in this function) make_filters_from_proto(f34_0_12, g0_Q12, 12); ^~~~~~~~ libavcodec/aacps_tablegen.h:212:29: error: ‘f34_1_8’ undeclared (first use in this function) make_filters_from_proto(f34_1_8, g1_Q8, 8); ^~~~~~~ libavcodec/aacps_tablegen.h:213:29: error: ‘f34_2_4’ undeclared (first use in this function) make_filters_from_proto(f34_2_4, g2_Q4, 4); ^~~~~~~ In file included from libavcodec/aacps_tablegen.c:24: libavcodec/aacps_tablegen_template.c: In function ‘main’: libavcodec/aacps_tablegen_template.c:88:28: error: ‘f20_0_8’ undeclared (first use in this function) ARRAY_RENAME(3d_array)(f20_0_8, 8, 8, 2); ^~~~~~~ libavcodec/aacps_tablegen_template.c:91:28: error: ‘f34_0_12’ undeclared (first use in this function) ARRAY_RENAME(3d_array)(f34_0_12, 12, 8, 2); ^~~~~~~~ libavcodec/aacps_tablegen_template.c:94:28: error: ‘f34_1_8’ undeclared (first use in this function) ARRAY_RENAME(3d_array)(f34_1_8, 8, 8, 2); ^~~~~~~ libavcodec/aacps_tablegen_template.c:97:28: error: ‘f34_2_4’ undeclared (first use in this function) ARRAY_RENAME(3d_array)(f34_2_4, 4, 8, 2); ^~~~~~~ libavcodec/aacps_tablegen_template.c:101:28: error: ‘Q_fract_allpass’ undeclared (first use in this function) ARRAY_RENAME(4d_array)(Q_fract_allpass, 2, 50, 3, 2); ^~~~~~~~~~~~~~~ libavcodec/aacps_tablegen_template.c:104:28: error: ‘phi_fract’ undeclared (first use in this function) ARRAY_RENAME(3d_array)(phi_fract, 2, 50, 2); ^~~~~~~~~ make: *** [ffbuild/common.mak:201: libavcodec/aacps_tablegen.o] Error 1 make: *** Waiting for unfinished jobs....
解决方案
1. 修复宏重复定义问题
报错开头的CONFIG_HARDCODED_TABLES重复定义是核心触发点,模板文件与config.h中的定义冲突导致头文件逻辑混乱。
编辑libavcodec/aacps_tablegen_template.c,找到第25行的#define CONFIG_HARDCODED_TABLES 0,将其注释或删除:
// #define CONFIG_HARDCODED_TABLES 0
这样编译时会统一使用config.h中定义的1值,避免宏冲突。
2. 修正数组声明格式
如果仍报错,检查DECLARE_ALIGNED宏的展开是否正常。可手动将报错的数组声明替换为GCC对齐语法:
// 原声明 static DECLARE_ALIGNED(16, float, f20_0_8) [ 8][8][2]; // 替换为 static float f20_0_8[8][8][2] __attribute__((aligned(16)));
对所有类似报错的数组声明执行相同修改。
3. 切换到FFmpeg 5.0稳定版源码
当前使用的git最新分支可能包含未稳定的改动,直接下载FFmpeg 5.0稳定版发布包重新编译:
wget https://ffmpeg.org/releases/ffmpeg-5.0.tar.bz2 tar -xjvf ffmpeg-5.0.tar.bz2 cd ffmpeg-5.0 # 执行你的编译脚本或配置命令
4. 检查编译脚本参数
确认编译脚本中没有手动设置与CONFIG_HARDCODED_TABLES冲突的参数,避免config生成时出现矛盾。
内容的提问来源于stack exchange,提问作者gaamaa
相关产品推荐
相关产品推荐

