From patchwork Fri Jul 29 17:36:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Burt P X-Patchwork-Id: 32 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp1468113vsd; Fri, 29 Jul 2016 10:55:11 -0700 (PDT) X-Received: by 10.194.82.164 with SMTP id j4mr44686735wjy.157.1469814911434; Fri, 29 Jul 2016 10:55:11 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 69si4534207wme.0.2016.07.29.10.55.11; Fri, 29 Jul 2016 10:55:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DB639689E43; Fri, 29 Jul 2016 20:55:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f65.google.com (mail-it0-f65.google.com [209.85.214.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 52DF1689CC0 for ; Fri, 29 Jul 2016 20:54:58 +0300 (EEST) Received: by mail-it0-f65.google.com with SMTP id u186so7526488ita.1 for ; Fri, 29 Jul 2016 10:55:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=hUKUMJNkbReMSO5+cXjB+l/9F2mojU6Lv7Ed4ddYVfU=; b=lZPzWZTe23KPVMw4ekoX0lPNgw9IeLtuacwlv4VYMKB3MDio7pP9ZzDn5fRpxgNmQr IJIBSytOErTGv2S7ZmRDtie1DFj/VTlY7soKRrKyQBdSyKqv0wMYZ1B7yXu7INybBbC8 hnq8sQZr/nKMSdfq39miAcQgaFIv578/p0Wm8sX+JZBwCEFGJUxTmaQhAdOnzCfCaJBY t0FvtCBxibLyozTeo8wUGD5JbqOJrJZRRHLaCF5OOU73/Oc0UVQR2o0zSskiiSqbpX+m ztRR6tBnJbKezs3F1da9iOxpJ0fU3nWZBP0Y3NHisk/mHNWF6CJz/7XUsK9ujYmfd8f/ dH8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=hUKUMJNkbReMSO5+cXjB+l/9F2mojU6Lv7Ed4ddYVfU=; b=XOEg8QX2/f7KqwECEGtR/tKKDJCoy8NWAbWLiaenb0lbAgKu9qW9y7B+o0TOMOCGJi HuIk4PcIVIvl65QNngU0ZtdJkwfPBFMfzsHYnrCuFNg3qO2E2x19D4rADqOBMK8oapDt by5lhNMarse+c/l4r5Uty3qEdFoYeCAE0wzcsOrD+JWo+SjBGkLmyIdm6oxpeu1li4p7 UmHfLtsXGPEfKK9Zn+reUGH+69pwqlUPSS3Dp1cAFFnv/We4tojpK3y027qckh/TshRA Wo2O5Ttv/3uMIrfjvBUneQfjBfaT5xW7atPDm5+mT2cHAR26YCMKQ3xtvpStpCc1PA8d +ewA== X-Gm-Message-State: AEkoouugeGRJRfmNeG+ykq7KkjeQWeLuA+p/e/pMTv8VWUa3vWbnWTA4GXksyed6vw+iRg== X-Received: by 10.36.17.20 with SMTP id 20mr27221412itf.94.1469813800048; Fri, 29 Jul 2016 10:36:40 -0700 (PDT) Received: from localhost.localdomain ([216.16.66.181]) by smtp.gmail.com with ESMTPSA id u7sm1720954ita.21.2016.07.29.10.36.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jul 2016 10:36:39 -0700 (PDT) From: Burt P To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Jul 2016 12:36:22 -0500 Message-Id: <1469813782-13305-8-git-send-email-pburt0@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469813782-13305-1-git-send-email-pburt0@gmail.com> References: <1469472876-7262-1-git-send-email-pburt0@gmail.com> <1469813782-13305-1-git-send-email-pburt0@gmail.com> Subject: [FFmpeg-devel] [PATCH 7/7] af_hdcd: Warn if there is any resampling or format conversion in the link chain 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" HDCD is only encoded in s16@44100Hz. Scan the chain of AVFilterLinks for any resampling or format conversion/truncation that might cause problems for the filter and issue warnings. Signed-off-by: Burt P --- libavfilter/af_hdcd.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c index d46c7bc..2d7fe8d 100644 --- a/libavfilter/af_hdcd.c +++ b/libavfilter/af_hdcd.c @@ -885,6 +885,11 @@ typedef struct HDCDContext { * default is off */ int force_pe; + /* config_input() and config_output() scan links for any resampling + * or format changes. If found, warnings are issued and bad_config + * is set. */ + int bad_config; + AVFilterContext *fctx; /* filter context for logging errors */ int sample_count; /* used in error logging */ int val_target_gain; /* last matching target_gain in both channels */ @@ -1519,25 +1524,29 @@ static av_cold void uninit(AVFilterContext *ctx) /* log the HDCD decode information */ if (s->hdcd_detected) av_log(ctx, AV_LOG_INFO, - "HDCD detected: yes, peak_extend: %s, max_gain_adj: %0.1f dB, transient_filter: %s, detectable errors: %d%s\n", + "HDCD detected: yes, peak_extend: %s, max_gain_adj: %0.1f dB, transient_filter: %s, detectable errors: %d%s%s\n", pe_str[s->peak_extend], s->max_gain_adjustment, (s->uses_transient_filter) ? "detected" : "not detected", - s->det_errors, (s->det_errors) ? " (try -v verbose)" : "" + s->det_errors, (s->det_errors) ? " (try -v verbose)" : "", + (s->bad_config) ? " (bad_config)" : "" ); else - av_log(ctx, AV_LOG_INFO, "HDCD detected: no\n"); + av_log(ctx, AV_LOG_INFO, "HDCD detected: no%s\n", + (s->bad_config) ? " (bad_config)" : "" + ); } + static av_cold int init(AVFilterContext *ctx) { - HDCDContext *s = ctx->priv; int c; s->max_gain_adjustment = 0.0; s->sample_count = 0; s->fctx = ctx; + s->bad_config = 0; for (c = 0; c < HDCD_MAX_CHANNELS; c++) { hdcd_reset(&s->state[c], 44100); @@ -1551,19 +1560,64 @@ static av_cold int init(AVFilterContext *ctx) return 0; } +static int config_input(AVFilterLink *inlink) { + AVFilterContext *ctx = inlink->dst; + HDCDContext *s = ctx->priv; + AVFilterLink *lk = inlink; + while(lk != NULL) { + AVFilterContext *nextf = lk->src; + if (lk->format != AV_SAMPLE_FMT_S16 || lk->sample_rate != 44100) { + av_log(ctx, AV_LOG_WARNING, "An input format is %s@%dHz at %s. It will truncated/resampled to s16@44100Hz.\n", + av_get_sample_fmt_name(lk->format), lk->sample_rate, + (nextf->name) ? nextf->name : "" + ); + s->bad_config = 1; + break; + } + lk = (nextf->inputs) ? nextf->inputs[0] : NULL; + } + /* more warning will appear after config_output() */ + return 0; +} + static const AVFilterPad avfilter_af_hdcd_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, .filter_frame = filter_frame, + .config_props = config_input, }, { NULL } }; +static int config_output(AVFilterLink *outlink) { + static const char hdcd_baduse[] = + "The HDCD filter is unlikely to produce a desirable result in this context."; + AVFilterContext *ctx = outlink->src; + HDCDContext *s = ctx->priv; + AVFilterLink *lk = outlink; + while(lk != NULL) { + AVFilterContext *nextf = lk->dst; + if (lk->format == AV_SAMPLE_FMT_S16 || lk->format == AV_SAMPLE_FMT_U8) { + av_log(ctx, AV_LOG_WARNING, "s24 output is being truncated to %s at %s. (Try -f s24le after the filter)\n", + av_get_sample_fmt_name(lk->format), + (nextf->name) ? nextf->name : "" + ); + s->bad_config = 1; + break; + } + lk = (nextf->outputs) ? nextf->outputs[0] : NULL; + } + if (s->bad_config) + av_log(ctx, AV_LOG_WARNING, "%s\n", hdcd_baduse); + return 0; +} + static const AVFilterPad avfilter_af_hdcd_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_output, }, { NULL } };