diff mbox series

[FFmpeg-devel,5/7] lavfi/vf_pp7: convert to the video_enc_params API

Message ID 20201002180331.20416-5-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,1/7] mpegvideo: use the AVVideoEncParams API for exporting QP tables
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Anton Khirnov Oct. 2, 2020, 6:03 p.m. UTC
---
 libavfilter/Makefile        |  2 +-
 libavfilter/vf_pp7.c        | 14 +++++++++++---
 libavfilter/vf_pp7.h        |  1 -
 tests/fate/filter-video.mak |  4 ++--
 4 files changed, 14 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 2669d7b84b..dcbb867265 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -345,7 +345,7 @@  OBJS-$(CONFIG_PHOTOSENSITIVITY_FILTER)       += vf_photosensitivity.o
 OBJS-$(CONFIG_PIXDESCTEST_FILTER)            += vf_pixdesctest.o
 OBJS-$(CONFIG_PIXSCOPE_FILTER)               += vf_datascope.o
 OBJS-$(CONFIG_PP_FILTER)                     += vf_pp.o qp_table.o
-OBJS-$(CONFIG_PP7_FILTER)                    += vf_pp7.o
+OBJS-$(CONFIG_PP7_FILTER)                    += vf_pp7.o qp_table.o
 OBJS-$(CONFIG_PREMULTIPLY_FILTER)            += vf_premultiply.o framesync.o
 OBJS-$(CONFIG_PREWITT_FILTER)                += vf_convolution.o
 OBJS-$(CONFIG_PREWITT_OPENCL_FILTER)         += vf_convolution_opencl.o opencl.o \
diff --git a/libavfilter/vf_pp7.c b/libavfilter/vf_pp7.c
index 570a1c90b9..9e961fcd19 100644
--- a/libavfilter/vf_pp7.c
+++ b/libavfilter/vf_pp7.c
@@ -32,6 +32,7 @@ 
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "internal.h"
+#include "qp_table.h"
 #include "vf_pp7.h"
 
 enum mode {
@@ -240,7 +241,7 @@  static void filter(PP7Context *p, uint8_t *dst, uint8_t *src,
                 qp = p->qp;
             else {
                 qp = qp_store[ (FFMIN(x, width - 1) >> qps) + (FFMIN(y, height - 1) >> qps) * qp_stride];
-                qp = ff_norm_qscale(qp, p->qscale_type);
+                qp = ff_norm_qscale(qp, FF_QSCALE_TYPE_MPEG2);
             }
             for (; x < end; x++) {
                 const int index = x + y * stride + (8 - 3) * (1 + stride) + 8; //FIXME silly offset
@@ -324,8 +325,13 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     int qp_stride = 0;
     uint8_t *qp_table = NULL;
 
-    if (!pp7->qp)
-        qp_table = av_frame_get_qp_table(in, &qp_stride, &pp7->qscale_type);
+    if (!pp7->qp) {
+        int ret = ff_qp_table_extract(in, &qp_table, &qp_stride, NULL);
+        if (ret < 0) {
+            av_frame_free(&in);
+            return ret;
+        }
+    }
 
     if (!ctx->is_disabled) {
         const int cw = AV_CEIL_RSHIFT(inlink->w, pp7->hsub);
@@ -340,6 +346,7 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             out = ff_get_video_buffer(outlink, aligned_w, aligned_h);
             if (!out) {
                 av_frame_free(&in);
+                av_freep(&qp_table);
                 return AVERROR(ENOMEM);
             }
             av_frame_copy_props(out, in);
@@ -366,6 +373,7 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                                 inlink->w, inlink->h);
         av_frame_free(&in);
     }
+    av_freep(&qp_table);
     return ff_filter_frame(outlink, out);
 }
 
diff --git a/libavfilter/vf_pp7.h b/libavfilter/vf_pp7.h
index 9aa8d732c1..8ec816b468 100644
--- a/libavfilter/vf_pp7.h
+++ b/libavfilter/vf_pp7.h
@@ -30,7 +30,6 @@  typedef struct PP7Context {
 
     int qp;
     int mode;
-    int qscale_type;
     int hsub;
     int vsub;
     int temp_stride;
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 202c7f30d7..8231752276 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -570,9 +570,9 @@  fate-filter-pp4: CMD = video_filter "pp=be/ci"
 fate-filter-pp5: CMD = video_filter "pp=md"
 fate-filter-pp6: CMD = video_filter "pp=be/fd"
 
-#FATE_FILTER_VSYNTH-$(CONFIG_PP7_FILTER) += fate-filter-pp7
+FATE_FILTER_VSYNTH-$(CONFIG_PP7_FILTER) += fate-filter-pp7
 fate-filter-pp7: fate-vsynth1-mpeg4-qprd
-fate-filter-pp7: CMD = framecrc -flags bitexact -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp7"
+fate-filter-pp7: CMD = framecrc -flags bitexact -export_side_data venc_params -idct simple -i $(TARGET_PATH)/tests/data/fate/vsynth1-mpeg4-qprd.avi -frames:v 5 -flags +bitexact -vf "pp7"
 
 FATE_FILTER_VSYNTH-$(CONFIG_SPP_FILTER) += fate-filter-spp
 fate-filter-spp: fate-vsynth1-mpeg4-qprd