aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_showinfo.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2018-12-04 21:39:32 +0100
committerPaul B Mahol <onemda@gmail.com>2018-12-09 18:46:36 +0100
commit8be56ee211f9ee4c8f44f0a95b18bb2fffc44602 (patch)
tree2e9b711fa7e7f910088f36a89e4a49797a64a03e /libavfilter/vf_showinfo.c
parent5ecd4f24f00bdeb1daeef64aeb5ab8fa1827a892 (diff)
downloadffmpeg-8be56ee211f9ee4c8f44f0a95b18bb2fffc44602.tar.gz
avfilter/vf_showinfo: allow checksums calculation to be disabled
Fixes #6987.
Diffstat (limited to 'libavfilter/vf_showinfo.c')
-rw-r--r--libavfilter/vf_showinfo.c56
1 files changed, 40 insertions, 16 deletions
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 37e73b60aa..9e84197a55 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -28,6 +28,7 @@
#include "libavutil/display.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
+#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/spherical.h"
#include "libavutil/stereo3d.h"
@@ -38,6 +39,21 @@
#include "internal.h"
#include "video.h"
+typedef struct ShowInfoContext {
+ const AVClass *class;
+ int calculate_checksums;
+} ShowInfoContext;
+
+#define OFFSET(x) offsetof(ShowInfoContext, x)
+#define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption showinfo_options[] = {
+ { "checksum", "calculate checksums", OFFSET(calculate_checksums), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, VF },
+ { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(showinfo);
+
static void dump_spherical(AVFilterContext *ctx, AVFrame *frame, AVFrameSideData *sd)
{
AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
@@ -141,13 +157,14 @@ static void update_sample_stats(const uint8_t *src, int len, int64_t *sum, int64
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
{
AVFilterContext *ctx = inlink->dst;
+ ShowInfoContext *s = ctx->priv;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
uint32_t plane_checksum[4] = {0}, checksum = 0;
int64_t sum[4] = {0}, sum2[4] = {0};
int32_t pixelcount[4] = {0};
int i, plane, vsub = desc->log2_chroma_h;
- for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++) {
+ for (plane = 0; plane < 4 && s->calculate_checksums && frame->data[plane] && frame->linesize[plane]; plane++) {
uint8_t *data = frame->data[plane];
int h = plane == 1 || plane == 2 ? AV_CEIL_RSHIFT(inlink->h, vsub) : inlink->h;
int linesize = av_image_get_linesize(frame->format, frame->width, plane);
@@ -167,8 +184,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
av_log(ctx, AV_LOG_INFO,
"n:%4"PRId64" pts:%7s pts_time:%-7s pos:%9"PRId64" "
- "fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c "
- "checksum:%08"PRIX32" plane_checksum:[%08"PRIX32,
+ "fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c ",
inlink->frame_count_out,
av_ts2str(frame->pts), av_ts2timestr(frame->pts, &inlink->time_base), frame->pkt_pos,
desc->name,
@@ -177,19 +193,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
!frame->interlaced_frame ? 'P' : /* Progressive */
frame->top_field_first ? 'T' : 'B', /* Top / Bottom */
frame->key_frame,
- av_get_picture_type_char(frame->pict_type),
- checksum, plane_checksum[0]);
-
- for (plane = 1; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
- av_log(ctx, AV_LOG_INFO, " %08"PRIX32, plane_checksum[plane]);
- av_log(ctx, AV_LOG_INFO, "] mean:[");
- for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
- av_log(ctx, AV_LOG_INFO, "%"PRId64" ", (sum[plane] + pixelcount[plane]/2) / pixelcount[plane]);
- av_log(ctx, AV_LOG_INFO, "\b] stdev:[");
- for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
- av_log(ctx, AV_LOG_INFO, "%3.1f ",
- sqrt((sum2[plane] - sum[plane]*(double)sum[plane]/pixelcount[plane])/pixelcount[plane]));
- av_log(ctx, AV_LOG_INFO, "\b]\n");
+ av_get_picture_type_char(frame->pict_type));
+
+ if (s->calculate_checksums) {
+ av_log(ctx, AV_LOG_INFO,
+ "checksum:%08"PRIX32" plane_checksum:[%08"PRIX32,
+ checksum, plane_checksum[0]);
+
+ for (plane = 1; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
+ av_log(ctx, AV_LOG_INFO, " %08"PRIX32, plane_checksum[plane]);
+ av_log(ctx, AV_LOG_INFO, "] mean:[");
+ for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
+ av_log(ctx, AV_LOG_INFO, "%"PRId64" ", (sum[plane] + pixelcount[plane]/2) / pixelcount[plane]);
+ av_log(ctx, AV_LOG_INFO, "\b] stdev:[");
+ for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++)
+ av_log(ctx, AV_LOG_INFO, "%3.1f ",
+ sqrt((sum2[plane] - sum[plane]*(double)sum[plane]/pixelcount[plane])/pixelcount[plane]));
+ av_log(ctx, AV_LOG_INFO, "\b]");
+ }
+ av_log(ctx, AV_LOG_INFO, "\n");
for (i = 0; i < frame->nb_side_data; i++) {
AVFrameSideData *sd = frame->side_data[i];
@@ -285,4 +307,6 @@ AVFilter ff_vf_showinfo = {
.description = NULL_IF_CONFIG_SMALL("Show textual information for each video frame."),
.inputs = avfilter_vf_showinfo_inputs,
.outputs = avfilter_vf_showinfo_outputs,
+ .priv_size = sizeof(ShowInfoContext),
+ .priv_class = &showinfo_class,
};