diff mbox series

[FFmpeg-devel,08/12] vf_spp: drop the option to use frame-attached QP tables

Message ID 20200224123739.31154-9-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/12] fifo: uninline av_fifo_peek2() on the next major bump
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Anton Khirnov Feb. 24, 2020, 12:37 p.m. UTC
This API has been deprecated for five years.
---
 doc/filters.texi     |   7 +--
 libavfilter/vf_spp.c | 100 +++++++++++--------------------------------
 libavfilter/vf_spp.h |   3 --
 3 files changed, 26 insertions(+), 84 deletions(-)
diff mbox series

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index 3b1470ed0f..5fa1663426 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17221,8 +17221,7 @@  that value the speed drops by a factor of approximately 2.  Default value is
 @code{3}.
 
 @item qp
-Force a constant quantization parameter. If not set, the filter will use the QP
-from the video stream (if available).
+Force a constant quantization parameter.
 
 @item mode
 Set thresholding mode. Available modes are:
@@ -17234,10 +17233,6 @@  Set hard thresholding (default).
 Set soft thresholding (better de-ringing effect, but likely blurrier).
 @end table
 
-@item use_bframe_qp
-Enable the use of the QP from the B-Frames if set to @code{1}. Using this
-option may cause flicker since the B-Frames have often larger QP. Default is
-@code{0} (not enabled).
 @end table
 
 @subsection Commands
diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c
index 7381938f7f..ba6138f08e 100644
--- a/libavfilter/vf_spp.c
+++ b/libavfilter/vf_spp.c
@@ -64,7 +64,6 @@  static const AVOption spp_options[] = {
     { "mode", "set thresholding mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MODE_HARD}, 0, NB_MODES - 1, FLAGS, "mode" },
         { "hard", "hard thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_HARD}, INT_MIN, INT_MAX, FLAGS, "mode" },
         { "soft", "soft thresholding", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_SOFT}, INT_MIN, INT_MAX, FLAGS, "mode" },
-    { "use_bframe_qp", "use B-frames' QP", OFFSET(use_bframe_qp), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
     { NULL }
 };
 
@@ -232,7 +231,7 @@  static inline void add_block(uint16_t *dst, int linesize, const int16_t block[64
 
 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)
+                   int is_luma, int depth)
 {
     int x, y, i;
     const int count = 1 << p->log2_count;
@@ -266,15 +265,8 @@  static void filter(SPPContext *p, uint8_t *dst, uint8_t *src,
     for (y = 0; y < height + 8; y += 8) {
         memset(p->temp + (8 + y) * linesize, 0, 8 * linesize * sizeof(*p->temp));
         for (x = 0; x < width + 8; x += 8) {
-            int qp;
-
-            if (p->qp) {
-                qp = p->qp;
-            } 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, ff_norm_qscale(qp, p->qscale_type));
-            }
+            int qp = p->qp;
+
             for (i = 0; i < count; i++) {
                 const int x1 = x + offset[i + count - 1][0];
                 const int y1 = y + offset[i + count - 1][1];
@@ -357,77 +349,36 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     SPPContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
     AVFrame *out = in;
-    int qp_stride = 0;
-    const int8_t *qp_table = NULL;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
     const int depth = desc->comp[0].depth;
 
-    /* if we are not in a constant user quantizer mode and we don't want to use
-     * the quantizers from the B-frames (B-frames often have a higher QP), we
-     * need to save the qp table from the last non B-frame; this is what the
-     * following code block does */
-    if (!s->qp) {
-        qp_table = av_frame_get_qp_table(in, &qp_stride, &s->qscale_type);
-
-        if (qp_table && !s->use_bframe_qp && in->pict_type != AV_PICTURE_TYPE_B) {
-            int w, h;
-
-            /* if the qp stride is not set, it means the QP are only defined on
-             * a line basis */
-            if (!qp_stride) {
-                w = AV_CEIL_RSHIFT(inlink->w, 4);
-                h = 1;
-            } else {
-                w = qp_stride;
-                h = AV_CEIL_RSHIFT(inlink->h, 4);
-            }
-
-            if (w * h > s->non_b_qp_alloc_size) {
-                int ret = av_reallocp_array(&s->non_b_qp_table, w, h);
-                if (ret < 0) {
-                    s->non_b_qp_alloc_size = 0;
-                    return ret;
-                }
-                s->non_b_qp_alloc_size = w * h;
-            }
-
-            av_assert0(w * h <= s->non_b_qp_alloc_size);
-            memcpy(s->non_b_qp_table, qp_table, w * h);
-        }
-    }
-
     if (s->log2_count && !ctx->is_disabled) {
-        if (!s->use_bframe_qp && s->non_b_qp_table)
-            qp_table = s->non_b_qp_table;
-
-        if (qp_table || s->qp) {
-            const int cw = AV_CEIL_RSHIFT(inlink->w, s->hsub);
-            const int ch = AV_CEIL_RSHIFT(inlink->h, s->vsub);
-
-            /* get a new frame if in-place is not possible or if the dimensions
-             * are not multiple of 8 */
-            if (!av_frame_is_writable(in) || (inlink->w & 7) || (inlink->h & 7)) {
-                const int aligned_w = FFALIGN(inlink->w, 8);
-                const int aligned_h = FFALIGN(inlink->h, 8);
-
-                out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
-                if (!out) {
-                    av_frame_free(&in);
-                    return AVERROR(ENOMEM);
-                }
-                av_frame_copy_props(out, in);
-                out->width  = in->width;
-                out->height = in->height;
+        const int cw = AV_CEIL_RSHIFT(inlink->w, s->hsub);
+        const int ch = AV_CEIL_RSHIFT(inlink->h, s->vsub);
+
+        /* get a new frame if in-place is not possible or if the dimensions
+         * are not multiple of 8 */
+        if (!av_frame_is_writable(in) || (inlink->w & 7) || (inlink->h & 7)) {
+            const int aligned_w = FFALIGN(inlink->w, 8);
+            const int aligned_h = FFALIGN(inlink->h, 8);
+
+            out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
+            if (!out) {
+                av_frame_free(&in);
+                return AVERROR(ENOMEM);
             }
+            av_frame_copy_props(out, in);
+            out->width  = in->width;
+            out->height = in->height;
+        }
 
-            filter(s, out->data[0], in->data[0], out->linesize[0], in->linesize[0], inlink->w, inlink->h, qp_table, qp_stride, 1, depth);
+        filter(s, out->data[0], in->data[0], out->linesize[0], in->linesize[0], inlink->w, inlink->h, 1, depth);
 
-            if (out->data[2]) {
-                filter(s, out->data[1], in->data[1], out->linesize[1], in->linesize[1], cw,        ch,        qp_table, qp_stride, 0, depth);
-                filter(s, out->data[2], in->data[2], out->linesize[2], in->linesize[2], cw,        ch,        qp_table, qp_stride, 0, depth);
-            }
-            emms_c();
+        if (out->data[2]) {
+            filter(s, out->data[1], in->data[1], out->linesize[1], in->linesize[1], cw,        ch,    0, depth);
+            filter(s, out->data[2], in->data[2], out->linesize[2], in->linesize[2], cw,        ch,    0, depth);
         }
+        emms_c();
     }
 
     if (in != out) {
@@ -494,7 +445,6 @@  static av_cold void uninit(AVFilterContext *ctx)
         av_freep(&s->avctx);
     }
     av_freep(&s->dct);
-    av_freep(&s->non_b_qp_table);
 }
 
 static const AVFilterPad spp_inputs[] = {
diff --git a/libavfilter/vf_spp.h b/libavfilter/vf_spp.h
index c03073a4e1..f038201e53 100644
--- a/libavfilter/vf_spp.h
+++ b/libavfilter/vf_spp.h
@@ -40,9 +40,6 @@  typedef struct SPPContext {
     uint16_t *temp;
     AVCodecContext *avctx;
     AVDCT *dct;
-    int8_t *non_b_qp_table;
-    int non_b_qp_alloc_size;
-    int use_bframe_qp;
     int hsub, vsub;
 
     void (*store_slice)(uint8_t *dst, const int16_t *src,