Error: impossible constraint in ‘asm‘

错误如下:

我在windows下编译ffmpeg源码时,出现了如下的错误:

cpp 复制代码
./libavcodec/x86/mathops.h:127:5: warning: 'asm' operand 1 probably does not match constraints
  127 |     __asm__ ("shrl %1, %0\n\t"
      |     ^~~~~~~
./libavcodec/x86/mathops.h:127:5: error: impossible constraint in 'asm'
make: *** [ffbuild/common.mak:60:libavformat/adtsenc.o] 错误 1
make: *** 正在等待未完成的任务....
CC      libavformat/anm.o
In file included from ./libavutil/common.h:488,
                 from ./libavutil/avutil.h:296,
                 from ./libavutil/samplefmt.h:24,
                 from ./libavcodec/avcodec.h:31,
                 from libavformat/avformat.h:319,
                 from libavformat/anm.c:28:

解决:

将ffmpeg源码中 mathops.h 中的如下代码做一个修改,其实在新版本的ffmpeg中已经修复了这个问题,可以去查看一下最新版的ffmpeg中 libavcodec/x86/mathops.h 中的修改,然后将我们的mathops.h 修改为如下:

cpp 复制代码
#define MULL MULL
static av_always_inline av_const int MULL(int a, int b, unsigned shift)
{
    int rt, dummy;
    __asm__ (
        "imull %3               \n\t"
        "shrdl %4, %%edx, %%eax \n\t"
        :"=a"(rt), "=d"(dummy)
        :"a"(a), "rm"(b), "c"((uint8_t)shift)
    );
    return rt;
}
cpp 复制代码
#define NEG_SSR32 NEG_SSR32
static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
    __asm__ ("sarl %1, %0\n\t"
         : "+r" (a)
         : "c" ((uint8_t)(-s))
    );
    return a;
}

#define NEG_USR32 NEG_USR32
static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
    __asm__ ("shrl %1, %0\n\t"
         : "+r" (a)
         : "c" ((uint8_t)(-s))
    );
    return a;
}
相关推荐
betazhou18 小时前
mysql shell8.4.10+mysql 8.4.10搭建MySQL replicaset主从
数据库·mysql·ffmpeg·replicaset·mysql shell
DogDaoDao1 天前
Windows 开发提效工具全景指南:60+ 工具的工程化分层配置
windows·git·程序员·开发工具·powershell·everything·msys2
VidDown2 天前
# VP9 还是 H.265?一次压缩选型翻车后的复盘
ffmpeg·音视频·h.265·视频编解码·视频·vp9
heqingchun162 天前
RK3568 交叉编译与部署:MPP + FFmpeg 硬解全流程
ffmpeg·视频编解码
云贝贝贝3 天前
OceanBase 生产运维 7 个高频现场:从连不上到误删兜底
运维·ffmpeg·oceanbase
≮傷£≯√3 天前
ffmpeg 2个图片合并为视频
ffmpeg·音视频
zone_z6 天前
07 · 等待事件与 OWI 方法:从 OSW 到 BUG 的完整破案实录
linux·数据库·oracle·ffmpeg·bug·troubleshooting
'2067 天前
**写了个自动整理下载视频的脚本:按片名归档、自动重命名、生成目录索引
开发语言·python·ffmpeg·音视频·cctv
殷忆枫7 天前
嵌入式Linux下基于FFmpeg实现MP4解码为JPG图片(SSD202D交叉编译实战)
linux·运维·ffmpeg
≮傷£≯√8 天前
图片合并成视频 img2video ffmpeg
ffmpeg·音视频