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;
}
相关推荐
程序员老陆13 小时前
FFmpeg libswresample 模块的关键函数swr_convert 到底在干嘛?
ffmpeg·音视频·格式转换·音频重采样
海兰14 小时前
ffmpeg-wasm 完整安装指南(Ubuntu 24.04)
ubuntu·ffmpeg·wasm
≮傷£≯√2 天前
QT配置FFmpeg
开发语言·qt·ffmpeg
Everbrilliant892 天前
Android FFmpeg 实战:从基础到播放器的完整技术解析
android·ffmpeg·ffmepg实战·音视频同步实现·ffmpegpractices·ffmpegpractice·opengl 视频渲染
苏灿烤鱼2 天前
从微信公众号内容到视频号视频:自动化视频生成的技术实现
人工智能·python·ffmpeg
桐桐桐2 天前
视频画面裁剪与尺寸压缩实战:ffmpeg crop/scale 用法与在线替代
ffmpeg·音视频·视频
程序员老陆3 天前
音频为什么不编码成“声卡格式”(例如S16)?因为声卡只负责响,编码器只负责省
ffmpeg·音视频
cpp_learner3 天前
FFmpeg 硬件解码全流程解析
ffmpeg
星花月3 天前
视频压缩为什么会变糊?从码率、分辨率到 H.264/H.265 的参数选择指南
ffmpeg·音视频·h.265·视频编解码·视频
cpp_learner4 天前
FFmpeg 像素格式转换与图像缩放实战
ffmpeg