[FFmpeg-cvslog] lavfi: use ff_norm_qscale(), factorize

Stefano Sabatini git at videolan.org
Tue Jan 13 13:34:09 CET 2015


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Tue Jan 13 13:00:18 2015 +0100| [57ede2a5070f42fde19175ef666b63b101bcd983] | committer: Stefano Sabatini

lavfi: use ff_norm_qscale(), factorize

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

 libavfilter/vf_fspp.c |   14 +-------------
 libavfilter/vf_spp.c  |   14 +-------------
 libavfilter/vf_uspp.c |   15 +--------------
 3 files changed, 3 insertions(+), 40 deletions(-)

diff --git a/libavfilter/vf_fspp.c b/libavfilter/vf_fspp.c
index bce8fcc..fe15db0 100644
--- a/libavfilter/vf_fspp.c
+++ b/libavfilter/vf_fspp.c
@@ -40,7 +40,6 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
-#include "libavcodec/avcodec.h" //for reference to FF_QSCALE_TYPE
 #include "vf_fspp.h"
 
 #define OFFSET(x) offsetof(FSPPContext, x)
@@ -80,17 +79,6 @@ static const short custom_threshold[64] = {
      20,  27,  26,  23,  20,  15,  11,   5
 };
 
-static inline int norm_qscale(int qscale, int type)
-{
-    switch (type) {
-    case FF_QSCALE_TYPE_MPEG1: return qscale;
-    case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
-    case FF_QSCALE_TYPE_H264:  return qscale >> 2;
-    case FF_QSCALE_TYPE_VP56:  return (63 - qscale + 2) >> 2;
-    }
-    return qscale;
-}
-
 //This func reads from 1 slice, 1 and clears 0 & 1
 static void store_slice_c(uint8_t *dst, int16_t *src,
                           ptrdiff_t dst_stride, ptrdiff_t src_stride,
@@ -218,7 +206,7 @@ static void filter(FSPPContext *p, uint8_t *dst, uint8_t *src,
                     if (t < 0) t = 0;                   //t always < width-2
 
                     t = qp_store[qy + (t >> qpsh)];
-                    t = norm_qscale(t, p->qscale_type);
+                    t = ff_norm_qscale(t, p->qscale_type);
 
                     if (t != p->prev_q) p->prev_q = t, p->mul_thrmat((int16_t *)(&p->threshold_mtx_noq[0]), (int16_t *)(&p->threshold_mtx[0]), t);
                     p->column_fidct((int16_t *)(&p->threshold_mtx[0]), block + x * 8, block3 + x * 8, 8); //yes, this is a HOTSPOT
diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c
index bdc76ae..4235544 100644
--- a/libavfilter/vf_spp.c
+++ b/libavfilter/vf_spp.c
@@ -229,18 +229,6 @@ static inline void add_block(uint16_t *dst, int linesize, const int16_t block[64
     }
 }
 
-// XXX: export the function?
-static inline int norm_qscale(int qscale, int type)
-{
-    switch (type) {
-    case FF_QSCALE_TYPE_MPEG1: return qscale;
-    case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
-    case FF_QSCALE_TYPE_H264:  return qscale >> 2;
-    case FF_QSCALE_TYPE_VP56:  return (63 - qscale + 2) >> 2;
-    }
-    return qscale;
-}
-
 static void filter(SPPContext *p, uint8_t *dst, uint8_t *src,
                    int dst_linesize, int src_linesize, int width, int height,
                    const uint8_t *qp_table, int qp_stride, int is_luma, int depth)
@@ -284,7 +272,7 @@ static void filter(SPPContext *p, uint8_t *dst, uint8_t *src,
             } else{
                 const int qps = 3 + is_luma;
                 qp = qp_table[(FFMIN(x, width - 1) >> qps) + (FFMIN(y, height - 1) >> qps) * qp_stride];
-                qp = FFMAX(1, norm_qscale(qp, p->qscale_type));
+                qp = FFMAX(1, ff_norm_qscale(qp, p->qscale_type));
             }
             for (i = 0; i < count; i++) {
                 const int x1 = x + offset[i + count - 1][0];
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index 2974ebe..7ff4642 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -32,7 +32,6 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
-#include "libavcodec/avcodec.h"
 #include "avfilter.h"
 
 #define MAX_LEVEL 8 /* quality levels */
@@ -181,18 +180,6 @@ static void store_slice_c(uint8_t *dst, const uint16_t *src,
     }
 }
 
-static inline int norm_qscale(int qscale, int type)
-{
-    switch (type) {
-    case FF_QSCALE_TYPE_MPEG1: return qscale;
-    case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
-    case FF_QSCALE_TYPE_H264:  return qscale >> 2;
-    case FF_QSCALE_TYPE_VP56:  return (63 - qscale + 2) >> 2;
-    default: av_assert0(0);
-    }
-    return qscale;
-}
-
 static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
                    int dst_stride[3], int src_stride[3], int width,
                    int height, uint8_t *qp_store, int qp_stride)
@@ -237,7 +224,7 @@ static void filter(USPPContext *p, uint8_t *dst[3], uint8_t *src[3],
             for (x = 0; x < (width>>4); x++)
                 qpsum += qp_store[x + y * qp_stride];
         }
-        p->frame->quality = norm_qscale((qpsum + qpcount/2) / qpcount, p->qscale_type) * FF_QP2LAMBDA;
+        p->frame->quality = ff_norm_qscale((qpsum + qpcount/2) / qpcount, p->qscale_type) * FF_QP2LAMBDA;
     }
 //    init per MB qscale stuff FIXME
     p->frame->height = height;



More information about the ffmpeg-cvslog mailing list