[FFmpeg-devel] [PATCH 5/5] wmaprolossless: switching back to C dsp function

Christophe Gisquet christophe.gisquet at gmail.com
Wed May 8 16:51:51 CEST 2013


The DSP function is only guaranteed to handle a number of samples that is a
multiple of 16, but this codec may only guarantees multiples of 8.

However, no such sample is known to date, so rather than not use the
optimized DSP function, whenever such a troublesome case is encountered, the
DSP function pointer is set back to the C one.
---
 libavcodec/dsputil.c        | 4 ++--
 libavcodec/dsputil.h        | 3 +++
 libavcodec/wmalosslessdec.c | 8 ++++++++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index b434589..a6a54a8 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -2562,7 +2562,7 @@ static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int
     return res;
 }
 
-static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul)
+int32_t ff_scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul)
 {
     int res = 0;
     while (order--) {
@@ -2877,7 +2877,7 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
 
     c->vector_clipf = vector_clipf_c;
     c->scalarproduct_int16 = scalarproduct_int16_c;
-    c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
+    c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_c;
     c->apply_window_int16 = apply_window_int16_c;
     c->vector_clip_int32 = vector_clip_int32_c;
 
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index 83a4e48..5e017e6 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -320,6 +320,9 @@ attribute_deprecated void dsputil_init(DSPContext* c, AVCodecContext *avctx);
 
 int ff_check_alignment(void);
 
+int32_t ff_scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2,
+                                          const int16_t *v3, int order, int mul);
+
 void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
 
 void ff_dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx);
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index cff02a8..1e09b9a 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -453,6 +453,14 @@ static int decode_cdlms(WmallDecodeCtx *s)
                 s->cdlms[0][0].order = 0;
                 return AVERROR_INVALIDDATA;
             }
+            if(s->cdlms[c][i].order & 8) {
+                static int warned;
+                s->dsp.scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_c;
+                if(!warned)
+                    av_log_ask_for_sample(s->avctx, "CSLMS of order %d",
+                                          s->cdlms[c][i].order);
+                warned = 1;
+            }
         }
 
         for (i = 0; i < s->cdlms_ttl[c]; i++)
-- 
1.8.0.msysgit.0



More information about the ffmpeg-devel mailing list