]> git.sesse.net Git - ffmpeg/blobdiff - libpostproc/postprocess.c
Merge commit '594d4d5df3c70404168701dd5c90b7e6e5587793'
[ffmpeg] / libpostproc / postprocess.c
index 732a8fffd7c1b8aba5a6aecd98f91bd2ed367927..afe3f13c68f4533afd3e9475ed6e1fb4f17c3c1c 100644 (file)
@@ -130,7 +130,7 @@ DECLARE_ASM_CONST(8, uint64_t, b80)= 0x8080808080808080LL;
 DECLARE_ASM_CONST(8, int, deringThreshold)= 20;
 
 
-static struct PPFilter filters[]=
+static const struct PPFilter filters[]=
 {
     {"hb", "hdeblock",              1, 1, 3, H_DEBLOCK},
     {"vb", "vdeblock",              1, 2, 4, V_DEBLOCK},
@@ -201,7 +201,7 @@ static inline void prefetcht2(void *p)
 /**
  * Check if the given 8x8 Block is mostly "flat"
  */
-static inline int isHorizDC_C(uint8_t src[], int stride, PPContext *c)
+static inline int isHorizDC_C(const uint8_t src[], int stride, const PPContext *c)
 {
     int numEq= 0;
     int y;
@@ -224,7 +224,7 @@ static inline int isHorizDC_C(uint8_t src[], int stride, PPContext *c)
 /**
  * Check if the middle 8x8 Block in the given 8x16 block is flat
  */
-static inline int isVertDC_C(uint8_t src[], int stride, PPContext *c)
+static inline int isVertDC_C(const uint8_t src[], int stride, const PPContext *c)
 {
     int numEq= 0;
     int y;
@@ -246,7 +246,7 @@ static inline int isVertDC_C(uint8_t src[], int stride, PPContext *c)
     return numEq > c->ppMode.flatnessThreshold;
 }
 
-static inline int isHorizMinMaxOk_C(uint8_t src[], int stride, int QP)
+static inline int isHorizMinMaxOk_C(const uint8_t src[], int stride, int QP)
 {
     int i;
     for(i=0; i<2; i++){
@@ -262,7 +262,7 @@ static inline int isHorizMinMaxOk_C(uint8_t src[], int stride, int QP)
     return 1;
 }
 
-static inline int isVertMinMaxOk_C(uint8_t src[], int stride, int QP)
+static inline int isVertMinMaxOk_C(const uint8_t src[], int stride, int QP)
 {
     int x;
     src+= stride*4;
@@ -275,7 +275,7 @@ static inline int isVertMinMaxOk_C(uint8_t src[], int stride, int QP)
     return 1;
 }
 
-static inline int horizClassify_C(uint8_t src[], int stride, PPContext *c)
+static inline int horizClassify_C(const uint8_t src[], int stride, const PPContext *c)
 {
     if( isHorizDC_C(src, stride, c) ){
         if( isHorizMinMaxOk_C(src, stride, c->QP) )
@@ -287,7 +287,7 @@ static inline int horizClassify_C(uint8_t src[], int stride, PPContext *c)
     }
 }
 
-static inline int vertClassify_C(uint8_t src[], int stride, PPContext *c)
+static inline int vertClassify_C(const uint8_t src[], int stride, const PPContext *c)
 {
     if( isVertDC_C(src, stride, c) ){
         if( isVertMinMaxOk_C(src, stride, c->QP) )
@@ -299,7 +299,7 @@ static inline int vertClassify_C(uint8_t src[], int stride, PPContext *c)
     }
 }
 
-static inline void doHorizDefFilter_C(uint8_t dst[], int stride, PPContext *c)
+static inline void doHorizDefFilter_C(uint8_t dst[], int stride, const PPContext *c)
 {
     int y;
     for(y=0; y<BLOCK_SIZE; y++){
@@ -338,7 +338,7 @@ static inline void doHorizDefFilter_C(uint8_t dst[], int stride, PPContext *c)
  * Do a horizontal low pass filter on the 10x8 block (dst points to middle 8x8 Block)
  * using the 9-Tap Filter (1,1,2,2,4,2,2,1,1)/16 (C version)
  */
-static inline void doHorizLowPass_C(uint8_t dst[], int stride, PPContext *c)
+static inline void doHorizLowPass_C(uint8_t dst[], int stride, const PPContext *c)
 {
     int y;
     for(y=0; y<BLOCK_SIZE; y++){
@@ -436,7 +436,9 @@ static inline void horizX1Filter(uint8_t *src, int stride, int QP)
 /**
  * accurate deblock filter
  */
-static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride, PPContext *c){
+static av_always_inline void do_a_deblock_C(uint8_t *src, int step,
+                                            int stride, const PPContext *c)
+{
     int y;
     const int QP= c->QP;
     const int dcOffset= ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
@@ -555,8 +557,13 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride,
 #        include "postprocess_template.c"
 #        define TEMPLATE_PP_3DNOW 1
 #        include "postprocess_template.c"
+#        define TEMPLATE_PP_SSE2 1
+#        include "postprocess_template.c"
 #    else
-#        if HAVE_MMXEXT_INLINE
+#        if HAVE_SSE2_INLINE
+#            define TEMPLATE_PP_SSE2 1
+#            include "postprocess_template.c"
+#        elif HAVE_MMXEXT_INLINE
 #            define TEMPLATE_PP_MMXEXT 1
 #            include "postprocess_template.c"
 #        elif HAVE_AMD3DNOW_INLINE
@@ -584,14 +591,17 @@ static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[]
 #if CONFIG_RUNTIME_CPUDETECT
 #if ARCH_X86 && HAVE_INLINE_ASM
         // ordered per speed fastest first
-        if      (c->cpuCaps & PP_CPU_CAPS_MMX2)     pp = postProcess_MMX2;
-        else if (c->cpuCaps & PP_CPU_CAPS_3DNOW)    pp = postProcess_3DNow;
-        else if (c->cpuCaps & PP_CPU_CAPS_MMX)      pp = postProcess_MMX;
+        if      (c->cpuCaps & AV_CPU_FLAG_SSE2)     pp = postProcess_SSE2;
+        else if (c->cpuCaps & AV_CPU_FLAG_MMXEXT)   pp = postProcess_MMX2;
+        else if (c->cpuCaps & AV_CPU_FLAG_3DNOW)    pp = postProcess_3DNow;
+        else if (c->cpuCaps & AV_CPU_FLAG_MMX)      pp = postProcess_MMX;
 #elif HAVE_ALTIVEC
-        if      (c->cpuCaps & PP_CPU_CAPS_ALTIVEC)  pp = postProcess_altivec;
+        if      (c->cpuCaps & AV_CPU_FLAG_ALTIVEC)  pp = postProcess_altivec;
 #endif
 #else /* CONFIG_RUNTIME_CPUDETECT */
-#if   HAVE_MMXEXT_INLINE
+#if     HAVE_SSE2_INLINE
+        pp = postProcess_SSE2;
+#elif   HAVE_MMXEXT_INLINE
         pp = postProcess_MMX2;
 #elif HAVE_AMD3DNOW_INLINE
         pp = postProcess_3DNow;
@@ -894,7 +904,6 @@ pp_context *pp_get_context(int width, int height, int cpuCaps){
 
     memset(c, 0, sizeof(PPContext));
     c->av_class = &av_codec_context_class;
-    c->cpuCaps= cpuCaps;
     if(cpuCaps&PP_FORMAT){
         c->hChromaSubSample= cpuCaps&0x3;
         c->vChromaSubSample= (cpuCaps>>4)&0x3;
@@ -902,6 +911,15 @@ pp_context *pp_get_context(int width, int height, int cpuCaps){
         c->hChromaSubSample= 1;
         c->vChromaSubSample= 1;
     }
+    if (cpuCaps & PP_CPU_CAPS_AUTO) {
+        c->cpuCaps = av_get_cpu_flags();
+    } else {
+        c->cpuCaps = 0;
+        if (cpuCaps & PP_CPU_CAPS_MMX)      c->cpuCaps |= AV_CPU_FLAG_MMX;
+        if (cpuCaps & PP_CPU_CAPS_MMX2)     c->cpuCaps |= AV_CPU_FLAG_MMXEXT;
+        if (cpuCaps & PP_CPU_CAPS_3DNOW)    c->cpuCaps |= AV_CPU_FLAG_3DNOW;
+        if (cpuCaps & PP_CPU_CAPS_ALTIVEC)  c->cpuCaps |= AV_CPU_FLAG_ALTIVEC;
+    }
 
     reallocBuffers(c, width, height, stride, qpStride);