diff mbox

[FFmpeg-devel] vf_spp: only assign function pointers if permutation matches expectations.

Message ID 1498230127-8896-1-git-send-email-rsbultje@gmail.com
State Accepted
Commit 97f7f831691f2a2bddbd258bcbe332516d64a91b
Headers show

Commit Message

Ronald S. Bultje June 23, 2017, 3:02 p.m. UTC
---
 libavfilter/x86/vf_spp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer June 24, 2017, 1:16 a.m. UTC | #1
On Fri, Jun 23, 2017 at 11:02:07AM -0400, Ronald S. Bultje wrote:
> ---
>  libavfilter/x86/vf_spp.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

LGTM

thx

[...]
Ronald S. Bultje June 24, 2017, 11:54 a.m. UTC | #2
Hi,

On Fri, Jun 23, 2017 at 9:16 PM, Michael Niedermayer <michael@niedermayer.cc
> wrote:

> On Fri, Jun 23, 2017 at 11:02:07AM -0400, Ronald S. Bultje wrote:
> > ---
> >  libavfilter/x86/vf_spp.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
>
> LGTM


Pushed.

Ronald
diff mbox

Patch

diff --git a/libavfilter/x86/vf_spp.c b/libavfilter/x86/vf_spp.c
index 45a9eb0..7d5da61 100644
--- a/libavfilter/x86/vf_spp.c
+++ b/libavfilter/x86/vf_spp.c
@@ -21,6 +21,7 @@ 
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
+#include "libavutil/crc.h"
 #include "libavutil/mem.h"
 #include "libavutil/x86/asm.h"
 #include "libavfilter/vf_spp.h"
@@ -223,10 +224,15 @@  av_cold void ff_spp_init_x86(SPPContext *s)
     int cpu_flags = av_get_cpu_flags();
 
     if (cpu_flags & AV_CPU_FLAG_MMX) {
+        static const uint32_t mmx_idct_perm_crc = 0xe5e8adc4;
+        uint32_t idct_perm_crc =
+            av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0,
+                   s->dct->idct_permutation,
+                   sizeof(s->dct->idct_permutation));
         int64_t bps;
         s->store_slice = store_slice_mmx;
         av_opt_get_int(s->dct, "bits_per_sample", 0, &bps);
-        if (bps <= 8) {
+        if (bps <= 8 && idct_perm_crc == mmx_idct_perm_crc) {
             switch (s->mode) {
             case 0: s->requantize = hardthresh_mmx; break;
             case 1: s->requantize = softthresh_mmx; break;