diff --git a/configure b/configure index 0acbdedc88..1958fa62cd 100755 --- a/configure +++ b/configure @@ -1188,6 +1188,7 @@ HAVE_LIST=" clock_gettime closesocket cmov + cpuid dcbzl dev_bktr_ioctl_bt848_h dev_bktr_ioctl_meteor_h @@ -1246,6 +1247,7 @@ HAVE_LIST=" MapViewOfFile memalign mkstemp + mm_empty mmap nanosleep netinet_sctp_h @@ -1256,6 +1258,7 @@ HAVE_LIST=" rdtsc round roundf + rweflags sched_getaffinity sdl sdl_video_size @@ -1300,6 +1303,7 @@ HAVE_LIST=" windows_h winsock2_h xform_asm + xgetbv xmm_clobbers yasm " @@ -3055,7 +3059,12 @@ elif enabled sparc; then elif enabled x86; then + check_code ld immintrin.h "__xgetbv(0)" "cc" && enable xgetbv + check_code ld intrin.h "int info[4]; __cpuid(info, 0)" "cc" && enable cpuid check_code ld intrin.h "__rdtsc()" "cc" && enable rdtsc + check_code ld intrin.h "unsigned int x = __readeflags()" "cc" && enable rweflags + + check_code ld mmintrin.h "_mm_empty()" "cc" && enable mm_empty enable local_aligned_8 local_aligned_16 diff --git a/libavcodec/mss1.c b/libavcodec/mss1.c index 6299037d01..302a5b84b1 100644 --- a/libavcodec/mss1.c +++ b/libavcodec/mss1.c @@ -499,7 +499,7 @@ static int decode_region_masked(MSS1Context *ctx, ArithCoder *acoder, dst += x + y * stride; mask += x + y * mask_stride; - if (mask[0] != 0xFF) + if (mask[0] == 0xFF) dst[0] = decode_top_left_pixel(acoder, pctx); for (j = 0; j < height; j++) { for (i = 0; i < width; i++) { diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 3e79265e3f..a553eb5630 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1527,7 +1527,8 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) if (st->codec->codec_id == CODEC_ID_RAWVIDEO) { st->codec->pix_fmt = descriptor->pix_fmt; if (st->codec->pix_fmt == PIX_FMT_NONE) { - pix_fmt_ul = mxf_get_codec_ul(ff_mxf_pixel_format_uls, &descriptor->essence_codec_ul); + pix_fmt_ul = mxf_get_codec_ul(ff_mxf_pixel_format_uls, + &descriptor->essence_codec_ul); st->codec->pix_fmt = pix_fmt_ul->id; if (st->codec->pix_fmt == PIX_FMT_NONE) { /* support files created before RP224v10 by defaulting to UYVY422 @@ -1972,7 +1973,7 @@ static int64_t mxf_set_current_edit_unit(MXFContext *mxf, int64_t current_offset * around this fixes the infinite loop on zzuf3.mxf */ av_log(mxf->fc, AV_LOG_ERROR, "next_ofs didn't change. not deriving packet timestamps\n"); - return - 1; + return -1; } if (next_ofs > current_offset) diff --git a/libavutil/internal.h b/libavutil/internal.h index 0569eb2699..57a9c96070 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -231,7 +231,7 @@ struct AVDictionary { # define ONLY_IF_THREADS_ENABLED(x) NULL #endif -#if HAVE_MMX +#if HAVE_MMX && HAVE_INLINE_ASM /** * Empty mmx state. * this must be called between any dsp function and float/double code. @@ -242,8 +242,11 @@ static av_always_inline void emms_c(void) if(av_get_cpu_flags() & AV_CPU_FLAG_MMX) __asm__ volatile ("emms" ::: "memory"); } +#elif HAVE_MMX && HAVE_MM_EMPTY +# include +# define emms_c _mm_empty #else /* HAVE_MMX */ -#define emms_c() +# define emms_c() #endif /* HAVE_MMX */ #endif /* AVUTIL_INTERNAL_H */ diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c index 663fb93e52..b1052247a0 100644 --- a/libavutil/x86/cpu.c +++ b/libavutil/x86/cpu.c @@ -25,6 +25,7 @@ #include "libavutil/x86_cpu.h" #include "libavutil/cpu.h" +#if HAVE_INLINE_ASM /* ebx saving is necessary for PIC. gcc seems unable to see it alone */ #define cpuid(index, eax, ebx, ecx, edx) \ __asm__ volatile ( \ @@ -33,9 +34,35 @@ "xchg %%"REG_b", %%"REG_S \ : "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) \ : "0" (index)) +#elif HAVE_CPUID +#include +#define cpuid(index, eax, ebx, ecx, edx) \ + do { \ + int info[4]; \ + __cpuid(info, index); \ + eax = info[0]; \ + ebx = info[1]; \ + ecx = info[2]; \ + edx = info[3]; \ + } while (0) +#endif /* HAVE_CPUID */ + +#if HAVE_INLINE_ASM #define xgetbv(index, eax, edx) \ __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index)) +#elif HAVE_XGETBV +#include + +#define xgetbv(index, eax, edx) \ + do { \ + uint64_t res = __xgetbv(index); \ + eax = res; \ + edx = res >> 32; \ + } while (0) +#endif /* HAVE_XGETBV */ + +#if HAVE_INLINE_ASM #define get_eflags(x) \ __asm__ volatile ("pushfl \n" \ @@ -47,6 +74,18 @@ "popfl \n" \ :: "r"(x)) +#elif HAVE_RWEFLAGS + +#include + +#define get_eflags(x) \ + x = __readeflags() + +#define set_eflags(x) \ + __writeeflags(x) + +#endif /* HAVE_INLINE_ASM */ + /* Function to test if multimedia instructions are supported... */ int ff_get_cpu_flags_x86(void) {