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;
}
相关推荐
superconvert7 小时前
主流流媒体的综合性能大 PK ( smart_rtmpd, srs, zlm, nginx rtmp )
websocket·ffmpeg·webrtc·hevc·rtmp·h264·hls·dash·rtsp·srt·flv
cuijiecheng201813 小时前
音视频入门基础:AAC专题(8)——FFmpeg源码中计算AAC裸流AVStream的time_base的实现
ffmpeg·音视频·aac
0点51 胜13 小时前
[ffmpeg] 视频格式转换
ffmpeg
Jerry 二河小鱼17 小时前
在Linux中安装FFmpeg
linux·运维·服务器·ffmpeg
0点51 胜2 天前
[ffmpeg] 音视频编码
ffmpeg·音视频
0点51 胜2 天前
[ffmpeg]音频格式转换
开发语言·c++·ffmpeg
PlumCarefree2 天前
基于鸿蒙API10的RTSP播放器(五:拖动底部视频滑轨实现跳转)
华为·ffmpeg·音视频
LuckyInn2 天前
从安装ffmpeg开始,把一个视频按照每秒30帧fps剪切为图片
ffmpeg·音视频
cuijiecheng20183 天前
FFmpeg源码:skip_bits、skip_bits1、show_bits函数分析
ffmpeg
__Destiny__3 天前
视频格式转为mp4(使用ffmpeg)
ffmpeg·视频编解码