aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/qp_table.h
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-02 00:24:54 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-05 19:59:00 +0200
commit2b6e008577fa444fc8d1b3a7b985c600633f4ee4 (patch)
tree3a30556ed3a67dfee908eee1a3d2e4210fccf895 /libavfilter/qp_table.h
parentb75dc8bd70ae479452da36e2dcaad6ef007a553f (diff)
downloadffmpeg-2b6e008577fa444fc8d1b3a7b985c600633f4ee4.tar.gz
avfilter/internal: Move ff_norm_qscale() to qp_table.h
It is the natural header for it. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavfilter/qp_table.h')
-rw-r--r--libavfilter/qp_table.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavfilter/qp_table.h b/libavfilter/qp_table.h
index a552fe2e64..4758ee8538 100644
--- a/libavfilter/qp_table.h
+++ b/libavfilter/qp_table.h
@@ -22,6 +22,7 @@
#include <stdint.h>
#include "libavutil/frame.h"
+#include "libavcodec/internal.h"
/**
* Extract a libpostproc-compatible QP table - an 8-bit QP value per 16x16
@@ -30,4 +31,20 @@
int ff_qp_table_extract(AVFrame *frame, int8_t **table, int *table_w, int *table_h,
int *qscale_type);
+/**
+ * Normalize the qscale factor
+ * FIXME the H264 qscale is a log based scale, mpeg1/2 is not, the code below
+ * cannot be optimal
+ */
+static inline int ff_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;
+}
+
#endif // AVFILTER_QP_TABLE_H