From patchwork Tue Oct 8 15:28:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15582 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6E332447F20 for ; Tue, 8 Oct 2019 18:28:57 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 513F6687FA5; Tue, 8 Oct 2019 18:28:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6321A687FF6 for ; Tue, 8 Oct 2019 18:28:50 +0300 (EEST) Received: by mail-pf1-f196.google.com with SMTP id b128so10999374pfa.1 for ; Tue, 08 Oct 2019 08:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zqF+i/Sh+OoMIQgim0dyPVFTe8LiD12nbAkOTmL5ZYA=; b=iraTIl4UVVj+EPBGNeyKhu+OFj9cVvevSIiESwg4TlFxE0pO0vr+ukFQvo6JCJCvSe aEWqLUG/RjjOpqJqH5h5lfRtGsgcyiJeuqqeZohauoselA+eevhAACSpwN8R0cN5ZwVh BAuVNtAC484S067CsS8bVHEBTK6g2eUYfyFu5YSVTOpJ2zzRGma8DyW5lpqRdjWv32mN Sc/Tcorm87cU0fGyyXClFqt8/rK9cAoMlWWUJuZAZk439GS3zV2ReU4pow7Etc7uZqej 3ckSdSiV7Wi6h7J8qeg8Y6XypBcdv9tegOqJVTimncEK/pwnWt4qa78P9LSWRgMAamM/ D3DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zqF+i/Sh+OoMIQgim0dyPVFTe8LiD12nbAkOTmL5ZYA=; b=IoDtJOTGuWyTs6JoNQAVkO4gmLTxbKtumBLZqAh0gVgsHQUbTPXPLZL2Gx/V+0VriZ U/FWjutCCB6rvd83JOb+bSI/qcaEp452/y0XCg8oQVot92GvKjCAjP4meEjs763WYBeh dsTIa0SArwGLpyVLzWMv7WHFxoMQafc9TqRRlnpvgJ4223OfBCtkZ6NJs0gke/brxPQS GR+Pn+VD64QQE0XY3bRMrje98fcJ3AS3hYggQaZ154tDmHJscQcaQl+wXSSA2amo4zX1 44iBK/oqI63zBKDnc6KPqPdjbc87utl6BBMvSJYHhA1F3xwy7HJ0msldQ03wqoQNLEuQ WBsg== X-Gm-Message-State: APjAAAWAtrNUs6PMaF3ZloSQPmVQugiu1oNIxf17dwyEKLHBHsB/aJZn vmOzCx+hLs2AWmSNy2A7kL6BC9Sf X-Google-Smtp-Source: APXvYqwQi9QzZf0R+vSpWWpDvheF7hINIVEUav9UTkjdupgUJR/wDoEtEP9IkxT+bPEhW4KXU2H9zg== X-Received: by 2002:a17:90a:b289:: with SMTP id c9mr5337114pjr.1.1570548528294; Tue, 08 Oct 2019 08:28:48 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id 126sm7060768pgg.10.2019.10.08.08.28.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 08:28:47 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Oct 2019 23:28:37 +0800 Message-Id: <20191008152839.30375-2-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20191008152839.30375-1-lance.lmwang@gmail.com> References: <20190929132515.4093-1-lance.lmwang@gmail.com> <20191008152839.30375-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v4 2/4] avfilter/vf_framerate: if metadata lavfi.scd.mafd exists, we'll use it first X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Reviewed-by: Paul B Mahol Signed-off-by: Limin Wang --- libavfilter/vf_framerate.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c index 6c8d01c..8d16998 100644 --- a/libavfilter/vf_framerate.c +++ b/libavfilter/vf_framerate.c @@ -71,13 +71,20 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next if (crnt->height == next->height && crnt->width == next->width) { + AVDictionaryEntry *e_mafd = NULL; uint64_t sad; - double mafd, diff; + double mafd = HUGE_VAL, diff; + char *tail = NULL; ff_dlog(ctx, "get_scene_score() process\n"); - s->sad(crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height, &sad); - emms_c(); - mafd = (double)sad * 100.0 / (crnt->width * crnt->height) / (1 << s->bitdepth); + e_mafd = av_dict_get(next->metadata, "lavfi.scd.mafd", NULL, AV_DICT_MATCH_CASE); + if (e_mafd) + mafd = strtod(e_mafd->value, &tail); + if (*tail || mafd == HUGE_VAL) { + s->sad(crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height, &sad); + emms_c(); + mafd = (double)sad * 100.0 / (crnt->width * crnt->height) / (1 << s->bitdepth); + } diff = fabs(mafd - s->prev_mafd); ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); s->prev_mafd = mafd;