Browse code

postproc: add basic deblock filter visualization support

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

Michael Niedermayer authored on 2014/09/19 22:21:36
Showing 5 changed files
... ...
@@ -15,6 +15,9 @@ libavutil:     2014-08-09
15 15
 
16 16
 API changes, most recent first:
17 17
 
18
+2014-09-24 - xxxxxxx - libpostproc 53.1.100
19
+  Add vissualization support
20
+
18 21
 2014-09-xx - xxxxxxx - lavc 56.1.101 - dv_profile.h
19 22
   deprecate avpriv_dv_frame_profile2(), which was made public by accident.
20 23
 
... ...
@@ -151,6 +151,7 @@ static const struct PPFilter filters[]=
151 151
     {"tn", "tmpnoise",              1, 7, 8, TEMP_NOISE_FILTER},
152 152
     {"fq", "forcequant",            1, 0, 0, FORCE_QUANT},
153 153
     {"be", "bitexact",              1, 0, 0, BITEXACT},
154
+    {"vi", "visualize",             1, 0, 0, VISUALIZE},
154 155
     {NULL, NULL,0,0,0,0} //End Marker
155 156
 };
156 157
 
... ...
@@ -430,7 +431,7 @@ static inline void horizX1Filter(uint8_t *src, int stride, int QP)
430 430
  * accurate deblock filter
431 431
  */
432 432
 static av_always_inline void do_a_deblock_C(uint8_t *src, int step,
433
-                                            int stride, const PPContext *c)
433
+                                            int stride, const PPContext *c, int mode)
434 434
 {
435 435
     int y;
436 436
     const int QP= c->QP;
... ...
@@ -485,6 +486,16 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step,
485 485
                 sums[8] = sums[7] - src[3*step] + last;
486 486
                 sums[9] = sums[8] - src[4*step] + last;
487 487
 
488
+                if (mode & VISUALIZE) {
489
+                    src[0*step] =
490
+                    src[1*step] =
491
+                    src[2*step] =
492
+                    src[3*step] =
493
+                    src[4*step] =
494
+                    src[5*step] =
495
+                    src[6*step] =
496
+                    src[7*step] = 128;
497
+                }
488 498
                 src[0*step]= (sums[0] + sums[2] + 2*src[0*step])>>4;
489 499
                 src[1*step]= (sums[1] + sums[3] + 2*src[1*step])>>4;
490 500
                 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,
516 516
                     d = FFMAX(d, q);
517 517
                 }
518 518
 
519
+                if ((mode & VISUALIZE) && d) {
520
+                    d= (d < 0) ? 32 : -32;
521
+                    src[3*step]= av_clip_uint8(src[3*step] - d);
522
+                    src[4*step]= av_clip_uint8(src[4*step] + d);
523
+                    d = 0;
524
+                }
525
+
519 526
                 src[3*step]-= d;
520 527
                 src[4*step]+= d;
521 528
             }
... ...
@@ -69,6 +69,7 @@
69 69
 #define TEMP_NOISE_FILTER               0x100000
70 70
 #define FORCE_QUANT                     0x200000
71 71
 #define BITEXACT                        0x1000000
72
+#define VISUALIZE                       0x2000000
72 73
 
73 74
 //use if you want a faster postprocessing code
74 75
 //cannot differentiate between chroma & luma filters (both on or both off)
... ...
@@ -2544,7 +2544,7 @@ Switch between
2544 2544
 /**
2545 2545
  * accurate deblock filter
2546 2546
  */
2547
-static av_always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int stride, const PPContext *c){
2547
+static av_always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int stride, const PPContext *c, int mode){
2548 2548
     int64_t dc_mask, eq_mask, both_masks;
2549 2549
     int64_t sums[10*8*2];
2550 2550
     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[
3272 3272
     uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32;
3273 3273
     //const int mbWidth= isColor ? (width+7)>>3 : (width+15)>>4;
3274 3274
 
3275
+    if (mode & VISUALIZE){
3276
+        if(!(mode & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) {
3277
+            av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n");
3278
+        }
3279
+    }
3280
+
3275 3281
 #if TEMPLATE_PP_MMX
3276 3282
     for(i=0; i<57; i++){
3277 3283
         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[
3566 3566
                     else if(t==2)
3567 3567
                         RENAME(doVertDefFilter)(dstBlock, stride, &c);
3568 3568
                 }else if(mode & V_A_DEBLOCK){
3569
-                    RENAME(do_a_deblock)(dstBlock, stride, 1, &c);
3569
+                    RENAME(do_a_deblock)(dstBlock, stride, 1, &c, mode);
3570 3570
                 }
3571 3571
             }
3572 3572
 
... ...
@@ -3587,7 +3593,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
3587 3587
                     else if(t==2)
3588 3588
                         RENAME(doVertDefFilter)(tempBlock1, 16, &c);
3589 3589
                 }else if(mode & H_A_DEBLOCK){
3590
-                        RENAME(do_a_deblock)(tempBlock1, 16, 1, &c);
3590
+                        RENAME(do_a_deblock)(tempBlock1, 16, 1, &c, mode);
3591 3591
                 }
3592 3592
 
3593 3593
                 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[
3619 3619
                         RENAME(doHorizDefFilter)(dstBlock-4, stride, &c);
3620 3620
 #endif
3621 3621
                 }else if(mode & H_A_DEBLOCK){
3622
-                    RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c);
3622
+                    RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c, mode);
3623 3623
                 }
3624 3624
 #endif //TEMPLATE_PP_MMX
3625 3625
                 if(mode & DERING){
... ...
@@ -29,7 +29,7 @@
29 29
 #include "libavutil/avutil.h"
30 30
 
31 31
 #define LIBPOSTPROC_VERSION_MAJOR  53
32
-#define LIBPOSTPROC_VERSION_MINOR   0
32
+#define LIBPOSTPROC_VERSION_MINOR   1
33 33
 #define LIBPOSTPROC_VERSION_MICRO 100
34 34
 
35 35
 #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \