ffmpeg编译 Error: operand type mismatch for `shr‘

错误如下:

D:\msys2\tmp\ccUxvBjQ.s: Assembler messages:
D:\msys2\tmp\ccUxvBjQ.s:345: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:410: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:470: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:645: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:713: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:781: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:866: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:951: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:1036: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:1133: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:1405: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:1514: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:1638: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:1797: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:2137: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:2242: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:2368: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:2553: Error: operand type mismatch for `shr'
D:\msys2\tmp\ccUxvBjQ.s:2703: Error: operand type mismatch for `shr'
make: *** [ffbuild/common.mak:60: libavformat/adtsenc.o] Error 1
make 编译过程中的出现上面错误

分析:

这些错误是由于汇编代码中存在类型不匹配的错误,导致无法通过汇编阶段编译。
具体是因为什么我也不是太清楚,我是在Windows下的MSYS2中make编译,我猜测是gcc版本的问题,我的ffmpeg源码比较老,是2018年的,我通过MSYS2下载了 mingw64 编译工具链,其中的gcc版本为:13.2.0在这里插入图片描述

解决方法一:

将ffmpeg源码中 mathops.h 中的如下代码做一个修改。

#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), "ci"((uint8_t)shift)
        :"a"(a), "rm"(b), "i"(shift & 0x1F)
    );
    return rt;
}
#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)
        //  : "ic" ((uint8_t)(-s))
         : "i" (-s & 0x1F)
    );
    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)
        //  : "ic" ((uint8_t)(-s))
         : "i" (-s & 0x1F)
    );
    return a;
}

参考链接:https://fftrac-bg.ffmpeg.org/ticket/10405

解决方法二:

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

#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;
}
#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;
}
  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

21岁被迫秃头

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值