[FFmpeg-devel] [PATCH 5/5] swscale: implement cpu runtime detection

Janne Grunau janne-ffmpeg
Tue Sep 28 00:25:03 CEST 2010


auto detection is only done if no SWS_CPU_CAPS are set in flags and
dsp_mask does not contain AV_CPU_FLAG_FORCE
---
 libswscale/utils.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 91989f5..e3d5d67 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -692,8 +692,12 @@ int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange
 
     c->dstFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[c->dstFormat]);
     c->srcFormatBpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[c->srcFormat]);
-    if (!(c->dsp_mask & AV_CPU_FLAG_FORCE))
+    if (!(c->dsp_mask & AV_CPU_FLAG_FORCE)) {
         c->dsp_mask = sws_cpu_caps2av_cpu_flags(update_flags_cpu(c->flags));
+        // only use autodetection if no SWS_CPU_CAPS_* is set
+        if (update_flags_cpu(c->flags) == strip_cpu_flags(c->flags))
+            c->dsp_mask = av_get_cpu_flags();
+    }
 
     ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, contrast, saturation);
     //FIXME factorize
@@ -795,6 +799,9 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter){
 
     if (c->dsp_mask & AV_CPU_FLAG_FORCE)
         dsp_mask = c->dsp_mask;
+    // only use autodetection if no SWS_CPU_CAPS_* is set
+    else if (update_flags_cpu(c->flags) == strip_cpu_flags(c->flags))
+        dsp_mask = c->dsp_mask = av_get_cpu_flags();
     else
         dsp_mask = c->dsp_mask = sws_cpu_caps2av_cpu_flags(update_flags_cpu(c->flags));
 
-- 
1.7.3




More information about the ffmpeg-devel mailing list