[FFmpeg-devel] [PATCH 3/4] avutil: frame Update the existing QP API

Michael Niedermayer michael at niedermayer.cc
Sat Feb 29 14:21:55 EET 2020


This should extend the API to allow exporting internal tables for codecs
with block sizes different from 16x16 and different values per plane or
multiple values per block.

This is unfinished and only to demonstrate how such API (which maintains
API/ABI compatibility) would look
This API may allow some codecs to export their tables with 0 copy

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavutil/frame.c | 21 ++++++++++++++++++++
 libavutil/frame.h | 49 +++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 89089c6cc0..2cd680c886 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -100,6 +100,27 @@ int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type)
 
     return buf ? buf->data : NULL;
 }
+
+int av_get_qp_table_type_details(int type, int *block_size, int *independant_qps_per_block, int *dependant_qps_per_block,
+                                 int *independant_chroma_planes, int *dependant_chroma_planes, int *independant_alpha_planes, int *dependant_alpha_planes)
+{
+    *block_size = 16;
+    *independant_qps_per_block = 0;
+    *  dependant_qps_per_block = 0;
+    *independant_chroma_planes = 0;
+    *  dependant_chroma_planes = 0;
+    *independant_alpha_planes = 0;
+    *  dependant_alpha_planes = 0;
+    switch (type) {
+    case 0:
+    case 1:
+    case 2:
+    case 3:
+        return 0;
+    default:
+        return AVERROR(EINVAL);
+    }
+}
 #endif
 
 const char *av_get_colorspace_name(enum AVColorSpace val)
diff --git a/libavutil/frame.h b/libavutil/frame.h
index b966f37fe0..84ee94c7bb 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -715,12 +715,6 @@ attribute_deprecated
 int     av_frame_get_pkt_size(const AVFrame *frame);
 attribute_deprecated
 void    av_frame_set_pkt_size(AVFrame *frame, int val);
-#if FF_API_FRAME_QP
-attribute_deprecated
-int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type);
-attribute_deprecated
-int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type);
-#endif
 attribute_deprecated
 enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame);
 attribute_deprecated
@@ -731,6 +725,49 @@ attribute_deprecated
 void    av_frame_set_color_range(AVFrame *frame, enum AVColorRange val);
 #endif
 
+/**
+ * Get Quantization parameter table.
+ * This returns a 2D array of values representing the QP of the specified AVFrame.
+ * the array is organized in planes then rows then columns then QP per block.
+ *
+ * @param stride    bytes per row in the returned array
+ * @returns a 2D array of QP values, the pixels per block depend on the type.
+ *          the array is valid as long as the frame is not destroyed or a new
+ *          qp table set.
+ * @see av_frame_set_qp_table()
+ */
+int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type);
+
+/**
+ * Set Quantization parameter table.
+ * This returns a 2D array of values representing the QP of the specified AVFrame.
+ *
+ * @param stride    bytes per row in the set array
+ * @returns a 2D array of QP values, the pixels per block depend on the type.
+ * @see av_frame_set_qp_table()
+ */
+int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type);
+
+/**
+ * Returns the details, each QP represents.
+ *
+ * @param block_size    spatial size of the square, each QP represents.
+ * @param independant_qps_per_block number of independant QP parameters per block (stored for each block)
+ * @param   dependant_qps_per_block number of dependant QP parameters per block (stored for each plane)
+ * @param independant_chroma_planes number of independant planes for chroma, this can be 0, 1 or 2
+ *                      with 0, the luma plane is used for chroma, with 1 there is
+ *                      one QP plane for both chroma components, or 2 for seperate QP
+ *                      per Chroma channel.
+ * @param   dependant_chroma_planes number of dependant planes for chroma, for each
+ *                      dependant chroma plane a single offset parameter if stored relative to
+ *                      the previous plane
+ * @param independant_alpha_planes  number of independant alpha planes of QP components
+ * @param   dependant_alpha_planes  number of dependant alpha planes of QP components
+ */
+int av_get_qp_table_type_details(int type, int *block_size, int *independant_qps_per_block, int *dependant_qps_per_block,
+                                 int *independant_chroma_planes, int *dependant_chroma_planes, int *independant_alpha_planes, int *dependant_alpha_planes);
+
+
 /**
  * Get the name of a colorspace.
  * @return a static string identifying the colorspace; can be NULL.
-- 
2.17.1



More information about the ffmpeg-devel mailing list