[FFmpeg-devel] [PATCH 2/6] avfilter/qp_table: Stop using FF_QSCALE_TYPE_*

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Mar 22 14:34:29 EET 2022


All FF_QSCALE_TYPE values used by libavfilter originate
from libavfilter (namely from ff_qp_table_extract());
no value is exchanged between libavcodec and libavutil.
The values that are exchanged (and used in libavfilter)
are of type enum AVVideoEncParamsType.

Therefore this patch stops using said FF_QSCALE_TYPE_*
in libavfilter and uses enum AVVideoEncParamsType
directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavfilter/qp_table.c     |  7 ++-----
 libavfilter/qp_table.h     | 11 ++++++-----
 libavfilter/vf_codecview.c |  3 ++-
 libavfilter/vf_fspp.h      |  3 ++-
 libavfilter/vf_pp7.h       |  3 ++-
 libavfilter/vf_spp.h       |  3 ++-
 libavfilter/vf_uspp.c      |  3 ++-
 7 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/libavfilter/qp_table.c b/libavfilter/qp_table.c
index 33812b708d..8137dc019f 100644
--- a/libavfilter/qp_table.c
+++ b/libavfilter/qp_table.c
@@ -18,9 +18,6 @@
 
 #include <stdint.h>
 
-// for FF_QSCALE_TYPE_*
-#include "libavcodec/internal.h"
-
 #include "libavutil/frame.h"
 #include "libavutil/mem.h"
 #include "libavutil/video_enc_params.h"
@@ -28,7 +25,7 @@
 #include "qp_table.h"
 
 int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table_h,
-                        int *qscale_type)
+                        enum AVVideoEncParamsType *qscale_type)
 {
     AVFrameSideData *sd;
     AVVideoEncParams *par;
@@ -55,7 +52,7 @@ int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table
     if (table_h)
         *table_h = mb_h;
     if (qscale_type)
-        *qscale_type = FF_QSCALE_TYPE_MPEG2;
+        *qscale_type = par->type;
 
     if (par->nb_blocks == 0) {
         memset(*table, par->qp, nb_mb);
diff --git a/libavfilter/qp_table.h b/libavfilter/qp_table.h
index 169a7a7fea..4407bacb0e 100644
--- a/libavfilter/qp_table.h
+++ b/libavfilter/qp_table.h
@@ -22,23 +22,24 @@
 #include <stdint.h>
 
 #include "libavutil/frame.h"
-#include "libavcodec/internal.h"
+#include "libavutil/video_enc_params.h"
 
 /**
  * Extract a libpostproc-compatible QP table - an 8-bit QP value per 16x16
  * macroblock, stored in raster order - from AVVideoEncParams side data.
  */
 int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table_h,
-                        int *qscale_type);
+                        enum AVVideoEncParamsType *qscale_type);
 
 /**
  * Normalize the qscale factor
+ * FIXME Add support for other values of enum AVVideoEncParamsType
+ * besides AV_VIDEO_ENC_PARAMS_MPEG2.
  */
-static inline int ff_norm_qscale(int qscale, int type)
+static inline int ff_norm_qscale(int qscale, enum AVVideoEncParamsType type)
 {
     switch (type) {
-    case FF_QSCALE_TYPE_MPEG1: return qscale;
-    case FF_QSCALE_TYPE_MPEG2: return qscale >> 1;
+    case AV_VIDEO_ENC_PARAMS_MPEG2: return qscale >> 1;
     }
     return qscale;
 }
diff --git a/libavfilter/vf_codecview.c b/libavfilter/vf_codecview.c
index aac038edef..cddb3e5368 100644
--- a/libavfilter/vf_codecview.c
+++ b/libavfilter/vf_codecview.c
@@ -227,7 +227,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     AVFilterLink *outlink = ctx->outputs[0];
 
     if (s->qp) {
-        int qstride, qp_type, ret;
+        enum AVVideoEncParamsType qp_type;
+        int qstride, ret;
         int8_t *qp_table;
 
         ret = ff_qp_table_extract(frame, &qp_table, &qstride, NULL, &qp_type);
diff --git a/libavfilter/vf_fspp.h b/libavfilter/vf_fspp.h
index 6623af450c..ee7de3ffef 100644
--- a/libavfilter/vf_fspp.h
+++ b/libavfilter/vf_fspp.h
@@ -23,6 +23,7 @@
 #ifndef AVFILTER_FSPP_H
 #define AVFILTER_FSPP_H
 
+#include "libavutil/video_enc_params.h"
 #include "avfilter.h"
 
 #define BLOCKSZ 12
@@ -61,7 +62,7 @@ typedef struct FSPPContext {
     int vsub;
     int temp_stride;
     int qp;
-    int qscale_type;
+    enum AVVideoEncParamsType qscale_type;
     int prev_q;
     uint8_t *src;
     int16_t *temp;
diff --git a/libavfilter/vf_pp7.h b/libavfilter/vf_pp7.h
index 9aa8d732c1..b7cbb020bb 100644
--- a/libavfilter/vf_pp7.h
+++ b/libavfilter/vf_pp7.h
@@ -22,6 +22,7 @@
 #ifndef AVFILTER_PP7_H
 #define AVFILTER_PP7_H
 
+#include "libavutil/video_enc_params.h"
 #include "avfilter.h"
 
 typedef struct PP7Context {
@@ -30,7 +31,7 @@ typedef struct PP7Context {
 
     int qp;
     int mode;
-    int qscale_type;
+    enum AVVideoEncParamsType qscale_type;
     int hsub;
     int vsub;
     int temp_stride;
diff --git a/libavfilter/vf_spp.h b/libavfilter/vf_spp.h
index 76c0c34ab2..0a8b2b512e 100644
--- a/libavfilter/vf_spp.h
+++ b/libavfilter/vf_spp.h
@@ -22,6 +22,7 @@
 #ifndef AVFILTER_SPP_H
 #define AVFILTER_SPP_H
 
+#include "libavutil/video_enc_params.h"
 #include "libavcodec/avdct.h"
 #include "avfilter.h"
 
@@ -33,7 +34,7 @@ typedef struct SPPContext {
     int log2_count;
     int qp;
     int mode;
-    int qscale_type;
+    enum AVVideoEncParamsType qscale_type;
     int temp_linesize;
     uint8_t *src;
     uint16_t *temp;
diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c
index c61a2a0705..051de00771 100644
--- a/libavfilter/vf_uspp.c
+++ b/libavfilter/vf_uspp.c
@@ -32,6 +32,7 @@
 #include "libavutil/mem_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/video_enc_params.h"
 #include "libavcodec/avcodec.h"
 #include "internal.h"
 #include "qp_table.h"
@@ -45,7 +46,7 @@ typedef struct USPPContext {
     int log2_count;
     int hsub, vsub;
     int qp;
-    int qscale_type;
+    enum AVVideoEncParamsType qscale_type;
     int temp_stride[3];
     uint8_t *src[3];
     uint16_t *temp[3];
-- 
2.32.0



More information about the ffmpeg-devel mailing list