[FFmpeg-cvslog] postproc: add basic deblock filter visualization support

Michael Niedermayer git at videolan.org
Wed Sep 24 17:11:29 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Sep 19 15:21:36 2014 +0200| [ac682955e90a29de9b515004af7e24d06bfa6994] | committer: Michael Niedermayer

postproc: add basic deblock filter visualization support

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ac682955e90a29de9b515004af7e24d06bfa6994
---

 doc/APIchanges                     |    3 +++
 libpostproc/postprocess.c          |   20 +++++++++++++++++++-
 libpostproc/postprocess_internal.h |    1 +
 libpostproc/postprocess_template.c |   14 ++++++++++----
 libpostproc/version.h              |    2 +-
 5 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index b257b21..8c16eea 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2014-09-24 - xxxxxxx - libpostproc 53.1.100
+  Add vissualization support
+
 2014-09-xx - xxxxxxx - lavc 56.1.101 - dv_profile.h
   deprecate avpriv_dv_frame_profile2(), which was made public by accident.
 
diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c
index e06c29b..bb6a3b4 100644
--- a/libpostproc/postprocess.c
+++ b/libpostproc/postprocess.c
@@ -151,6 +151,7 @@ static const struct PPFilter filters[]=
     {"tn", "tmpnoise",              1, 7, 8, TEMP_NOISE_FILTER},
     {"fq", "forcequant",            1, 0, 0, FORCE_QUANT},
     {"be", "bitexact",              1, 0, 0, BITEXACT},
+    {"vi", "visualize",             1, 0, 0, VISUALIZE},
     {NULL, NULL,0,0,0,0} //End Marker
 };
 
@@ -430,7 +431,7 @@ 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, const PPContext *c)
+                                            int stride, const PPContext *c, int mode)
 {
     int y;
     const int QP= c->QP;
@@ -485,6 +486,16 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step,
                 sums[8] = sums[7] - src[3*step] + last;
                 sums[9] = sums[8] - src[4*step] + last;
 
+                if (mode & VISUALIZE) {
+                    src[0*step] =
+                    src[1*step] =
+                    src[2*step] =
+                    src[3*step] =
+                    src[4*step] =
+                    src[5*step] =
+                    src[6*step] =
+                    src[7*step] = 128;
+                }
                 src[0*step]= (sums[0] + sums[2] + 2*src[0*step])>>4;
                 src[1*step]= (sums[1] + sums[3] + 2*src[1*step])>>4;
                 src[2*step]= (sums[2] + sums[4] + 2*src[2*step])>>4;
@@ -516,6 +527,13 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step,
                     d = FFMAX(d, q);
                 }
 
+                if ((mode & VISUALIZE) && d) {
+                    d= (d < 0) ? 32 : -32;
+                    src[3*step]= av_clip_uint8(src[3*step] - d);
+                    src[4*step]= av_clip_uint8(src[4*step] + d);
+                    d = 0;
+                }
+
                 src[3*step]-= d;
                 src[4*step]+= d;
             }
diff --git a/libpostproc/postprocess_internal.h b/libpostproc/postprocess_internal.h
index 43aaf84..1ebd974 100644
--- a/libpostproc/postprocess_internal.h
+++ b/libpostproc/postprocess_internal.h
@@ -69,6 +69,7 @@
 #define TEMP_NOISE_FILTER               0x100000
 #define FORCE_QUANT                     0x200000
 #define BITEXACT                        0x1000000
+#define VISUALIZE                       0x2000000
 
 //use if you want a faster postprocessing code
 //cannot differentiate between chroma & luma filters (both on or both off)
diff --git a/libpostproc/postprocess_template.c b/libpostproc/postprocess_template.c
index 4a3b4d0..6722f96 100644
--- a/libpostproc/postprocess_template.c
+++ b/libpostproc/postprocess_template.c
@@ -2544,7 +2544,7 @@ Switch between
 /**
  * accurate deblock filter
  */
-static av_always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int stride, const PPContext *c){
+static av_always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int stride, const PPContext *c, int mode){
     int64_t dc_mask, eq_mask, both_masks;
     int64_t sums[10*8*2];
     src+= step*3; // src points to begin of the 8x8 Block
@@ -3272,6 +3272,12 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
     uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;
     //const int mbWidth= isColor ? (width+7)>>3 : (width+15)>>4;
 
+    if (mode & VISUALIZE){
+        if(!(mode & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {
+            av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n");
+        }
+    }
+
 #if TEMPLATE_PP_MMX
     for(i=0; i<57; i++){
         int offset= ((i*c.ppMode.baseDcDiff)>>8) + 1;
@@ -3566,7 +3572,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
                     else if(t==2)
                         RENAME(doVertDefFilter)(dstBlock, stride, &c);
                 }else if(mode & V_A_DEBLOCK){
-                    RENAME(do_a_deblock)(dstBlock, stride, 1, &c);
+                    RENAME(do_a_deblock)(dstBlock, stride, 1, &c, mode);
                 }
             }
 
@@ -3587,7 +3593,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
                     else if(t==2)
                         RENAME(doVertDefFilter)(tempBlock1, 16, &c);
                 }else if(mode & H_A_DEBLOCK){
-                        RENAME(do_a_deblock)(tempBlock1, 16, 1, &c);
+                        RENAME(do_a_deblock)(tempBlock1, 16, 1, &c, mode);
                 }
 
                 RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16);
@@ -3619,7 +3625,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
                         RENAME(doHorizDefFilter)(dstBlock-4, stride, &c);
 #endif
                 }else if(mode & H_A_DEBLOCK){
-                    RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c);
+                    RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c, mode);
                 }
 #endif //TEMPLATE_PP_MMX
                 if(mode & DERING){
diff --git a/libpostproc/version.h b/libpostproc/version.h
index dab1965..59bba10 100644
--- a/libpostproc/version.h
+++ b/libpostproc/version.h
@@ -29,7 +29,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBPOSTPROC_VERSION_MAJOR  53
-#define LIBPOSTPROC_VERSION_MINOR   0
+#define LIBPOSTPROC_VERSION_MINOR   1
 #define LIBPOSTPROC_VERSION_MICRO 100
 
 #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list