diff mbox series

[FFmpeg-devel,2/7] vf_showinfo: support AV_FRAME_DATA_VIDEO_ENC_PARAMS

Message ID 20200330114526.11086-2-anton@khirnov.net
State Superseded
Headers show
Series [FFmpeg-devel,1/7] libavutil: add API for exporting video frame quantizers
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Anton Khirnov March 30, 2020, 11:45 a.m. UTC
---
 libavfilter/vf_showinfo.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 71534d1fa8..0025ee63fc 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -36,6 +36,7 @@ 
 #include "libavutil/timestamp.h"
 #include "libavutil/timecode.h"
 #include "libavutil/mastering_display_metadata.h"
+#include "libavutil/video_enc_params.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -170,6 +171,25 @@  static void dump_content_light_metadata(AVFilterContext *ctx, AVFrameSideData *s
            metadata->MaxCLL, metadata->MaxFALL);
 }
 
+static void dump_video_enc_params(AVFilterContext *ctx, AVFrameSideData *sd)
+{
+    AVVideoEncParams *par = (AVVideoEncParams*)sd->data;
+    int plane, acdc;
+
+    av_log(ctx, AV_LOG_INFO, "video encoding parameters: type %d; ", par->type);
+    if (par->qp)
+        av_log(ctx, AV_LOG_INFO, "qp=%d; ", par->qp);
+    for (plane = 0; plane < FF_ARRAY_ELEMS(par->delta_qp); plane++)
+        for (acdc = 0; acdc < FF_ARRAY_ELEMS(par->delta_qp[plane]); acdc++) {
+            int delta_qp = par->delta_qp[plane][acdc];
+            if (delta_qp)
+                av_log(ctx, AV_LOG_INFO, "delta_qp[%d][%d]=%d; ",
+                       plane, acdc, delta_qp);
+        }
+    if (par->nb_blocks)
+        av_log(ctx, AV_LOG_INFO, "%u blocks; ", par->nb_blocks);
+}
+
 static void dump_color_property(AVFilterContext *ctx, AVFrame *frame)
 {
     const char *color_range_str     = av_color_range_name(frame->color_range);
@@ -351,6 +371,9 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
             av_log(ctx, AV_LOG_INFO, "GOP timecode - %s", tcbuf);
             break;
         }
+        case AV_FRAME_DATA_VIDEO_ENC_PARAMS:
+            dump_video_enc_params(ctx, sd);
+            break;
         default:
             av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)",
                    sd->type, sd->size);