[FFmpeg-devel] [PATCH] postproc: add basic deblock filter visualization support
Michael Niedermayer
michaelni at gmx.at
Fri Sep 19 15:44:31 CEST 2014
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libpostproc/postprocess.c | 36 +++++++++++++++++++++++++++++++++++-
libpostproc/postprocess_internal.h | 1 +
libpostproc/postprocess_template.c | 14 ++++++++++----
3 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c
index b6da294..de95745 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,32 @@ 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] = av_clip_uint8(src[0*step]+32);
+// src[1*step] = av_clip_uint8(src[1*step]-32);
+// src[2*step] = av_clip_uint8(src[2*step]+32);
+// src[3*step] = av_clip_uint8(src[3*step]-32);
+// src[4*step] = av_clip_uint8(src[4*step]+32);
+// src[5*step] = av_clip_uint8(src[5*step]-32);
+// src[6*step] = av_clip_uint8(src[6*step]+32);
+// src[7*step] = av_clip_uint8(src[7*step]-32);
+ 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]= av_clip_uint8((-sums[0] - sums[2] + 22*src[0*step])>>3);
+// src[1*step]= av_clip_uint8((-sums[1] - sums[3] + 22*src[1*step])>>3);
+// src[2*step]= av_clip_uint8((-sums[2] - sums[4] + 22*src[2*step])>>3);
+// src[3*step]= av_clip_uint8((-sums[3] - sums[5] + 22*src[3*step])>>3);
+// src[4*step]= av_clip_uint8((-sums[4] - sums[6] + 22*src[4*step])>>3);
+// src[5*step]= av_clip_uint8((-sums[5] - sums[7] + 22*src[5*step])>>3);
+// src[6*step]= av_clip_uint8((-sums[6] - sums[8] + 22*src[6*step])>>3);
+// src[7*step]= av_clip_uint8((-sums[7] - sums[9] + 22*src[7*step])>>3);
+ }
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 +543,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 7eddb22..aee0a74 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, PPContext *c){
+static av_always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int stride, 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){
--
1.7.9.5
More information about the ffmpeg-devel
mailing list