diff mbox series

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

Message ID 20201002180331.20416-7-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_codecview.c | 14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index be2c3e3156..119a9c513b 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -185,7 +185,7 @@  OBJS-$(CONFIG_CHROMAKEY_FILTER)              += vf_chromakey.o
 OBJS-$(CONFIG_CHROMANR_FILTER)               += vf_chromanr.o
 OBJS-$(CONFIG_CHROMASHIFT_FILTER)            += vf_chromashift.o
 OBJS-$(CONFIG_CIESCOPE_FILTER)               += vf_ciescope.o
-OBJS-$(CONFIG_CODECVIEW_FILTER)              += vf_codecview.o
+OBJS-$(CONFIG_CODECVIEW_FILTER)              += vf_codecview.o qp_table.o
 OBJS-$(CONFIG_COLORBALANCE_FILTER)           += vf_colorbalance.o
 OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)      += vf_colorchannelmixer.o
 OBJS-$(CONFIG_COLORKEY_FILTER)               += vf_colorkey.o
diff --git a/libavfilter/vf_codecview.c b/libavfilter/vf_codecview.c
index 331bfba777..bdcbe42162 100644
--- a/libavfilter/vf_codecview.c
+++ b/libavfilter/vf_codecview.c
@@ -33,6 +33,7 @@ 
 #include "libavutil/motion_vector.h"
 #include "libavutil/opt.h"
 #include "avfilter.h"
+#include "qp_table.h"
 #include "internal.h"
 
 #define MV_P_FOR  (1<<0)
@@ -219,8 +220,14 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     AVFilterLink *outlink = ctx->outputs[0];
 
     if (s->qp) {
-        int qstride, qp_type;
-        int8_t *qp_table = av_frame_get_qp_table(frame, &qstride, &qp_type);
+        int qstride, ret;
+        int8_t *qp_table;
+
+        ret = ff_qp_table_extract(frame, &qp_table, &qstride, NULL);
+        if (ret < 0) {
+            av_frame_free(&frame);
+            return ret;
+        }
 
         if (qp_table) {
             int x, y;
@@ -233,13 +240,14 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 
             for (y = 0; y < h; y++) {
                 for (x = 0; x < w; x++) {
-                    const int qp = ff_norm_qscale(qp_table[(y >> 3) * qstride + (x >> 3)], qp_type) * 128/31;
+                    const int qp = ff_norm_qscale(qp_table[(y >> 3) * qstride + (x >> 3)], FF_QSCALE_TYPE_MPEG2) * 128/31;
                     pu[x] = pv[x] = qp;
                 }
                 pu += lzu;
                 pv += lzv;
             }
         }
+        av_freep(&qp_table);
     }
 
     if (s->mv || s->mv_type) {