From patchwork Mon Sep 5 11:18:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Burt P X-Patchwork-Id: 425 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp48398vsd; Mon, 5 Sep 2016 04:19:10 -0700 (PDT) X-Received: by 10.194.89.9 with SMTP id bk9mr29706966wjb.181.1473074350393; Mon, 05 Sep 2016 04:19:10 -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 xw9si21199878wjc.295.2016.09.05.04.19.09; Mon, 05 Sep 2016 04:19:10 -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 F3D87689F9E; Mon, 5 Sep 2016 14:18:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f43.google.com (mail-it0-f43.google.com [209.85.214.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 13297689F98 for ; Mon, 5 Sep 2016 14:18:49 +0300 (EEST) Received: by mail-it0-f43.google.com with SMTP id i184so141578386itf.1 for ; Mon, 05 Sep 2016 04:18:58 -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=1GzIL3dNljnDH4lc5YZShV40XxT0MGWKRYlBT4vPqtQ=; b=e/ZtVt0/3rfOvnbso28nCXWvqO34l9J2I5YdJk+Rzm9yn1Q5d0ruj65yq6AQMJCcwC gceHxMYb1FqDqE10eQlSxVL2zlvJWkuYIbUEabBnq9/1aLRpS/GYRWL7MzQSV+LRe0Ui 5Y1i00bfMZDBjKLILf1Av3Y6XfPQSfUdFPewuYZ9nXeEVS72o5ftmkfZHINcOJODq8WK 9dfRrSTgT4ADHt1k9HXxtqvhuaXooWBwueglhoZVbpDY4N8KFWVVrBeF5UkdEoSkOUU4 W2HAXLrr0m7cJzQINQVLuYFOFedO5QspCScdyn5xEXS9/9e+/799mr3ko3eROlV3Ykkn HkHw== 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=1GzIL3dNljnDH4lc5YZShV40XxT0MGWKRYlBT4vPqtQ=; b=kQ1tJ5h0Xu7FCtL/kx6Fibr0ZrUIbKa+2Vk+S8oNc08At7taHrmjqE8YGGBXOALHiF ZmwLT8Tzm5m9ykaGA9W+n+dDD77IBIhCacf8lp/tTPNe53SNmY+pkWokYk5Lp8kOeGZa Os3mboXTpxpWLLoIP8TRj8buEdGV9JcH8kGn5ahVsIrhzizWpHUSshrsKQInQocoGWPy wZyUgFuJcL32dov0KtbMPQe6VlH8M8DriwqwJsmYOGqD1rdf63Orp7S0KBhxVLqAIwEv viYLmZsAgL1cBvPIcve2T03PSIIl95gZ0pdzA28cnS2vLomiW5+xo0C4cYeONS5SIP9n 0OEg== X-Gm-Message-State: AE9vXwMUR2g8Y6w7YGu00po8ANaiE9cbIrKiqsenxTckT09rYVbPO3ul8uSXxVNatYYSjQ== X-Received: by 10.36.64.138 with SMTP id n132mr23267988ita.10.1473074336607; Mon, 05 Sep 2016 04:18:56 -0700 (PDT) Received: from localhost.localdomain ([216.16.66.181]) by smtp.gmail.com with ESMTPSA id e8sm10024609itc.15.2016.09.05.04.18.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Sep 2016 04:18:56 -0700 (PDT) From: Burt P To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Sep 2016 06:18:45 -0500 Message-Id: <1473074325-20959-6-git-send-email-pburt0@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473074325-20959-1-git-send-email-pburt0@gmail.com> References: <1473074325-20959-1-git-send-email-pburt0@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/5] af_hdcd: tweak hdcd_analyze_prepare() a bit 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" * use the actual sample rate * use a more sensible frequency for the tone * update fate test result Signed-off-by: Burt P --- libavfilter/af_hdcd.c | 9 ++++++--- tests/fate/filter-audio.mak | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c index 1487a0b..fde6b7b 100644 --- a/libavfilter/af_hdcd.c +++ b/libavfilter/af_hdcd.c @@ -871,6 +871,7 @@ typedef struct { * a code. -1 for timer never set. */ int count_sustain_expired; + int rate; /**< sampling rate */ int _ana_snb; /**< used in the analyze mode tone generator */ } hdcd_state; @@ -1026,6 +1027,7 @@ static void hdcd_reset(hdcd_state *state, unsigned rate, unsigned cdt_ms) state->max_gain = 0; state->count_sustain_expired = -1; + state->rate = rate; state->_ana_snb = 0; } @@ -1297,7 +1299,8 @@ static int hdcd_scan_stereo(HDCDContext *ctx, const int32_t *samples, int max) /** replace audio with solid tone, but save LSBs */ static void hdcd_analyze_prepare(hdcd_state *state, int32_t *samples, int count, int stride) { - int n; + int n, f = 300; + int so = state->rate / f; for (n = 0; n < count * stride; n += stride) { /* in analyze mode, the audio is replaced by a solid tone, and * amplitude is changed to signal when the specified feature is @@ -1306,9 +1309,9 @@ static void hdcd_analyze_prepare(hdcd_state *state, int32_t *samples, int count, * bit 1: Original sample was above PE level */ int32_t save = (abs(samples[n]) - PEAK_EXT_LEVEL >= 0) ? 2 : 0; /* above PE level */ save |= samples[n] & 1; /* save LSB for HDCD packets */ - samples[n] = TONEGEN16(state->_ana_snb, 277.18, 44100, 0.1); + samples[n] = TONEGEN16(state->_ana_snb, f, state->rate, 0.1); samples[n] = (samples[n] | 3) ^ ((~save) & 3); - if (++state->_ana_snb > 0x3fffffff) state->_ana_snb = 0; + if (++state->_ana_snb > so) state->_ana_snb = 0; } } diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak index 2066fa9..cf92ef6 100644 --- a/tests/fate/filter-audio.mak +++ b/tests/fate/filter-audio.mak @@ -242,7 +242,7 @@ FATE_AFILTER_SAMPLES-$(call FILTERDEMDECENCMUX, HDCD, FLAC, FLAC, PCM_S24LE, PCM fate-filter-hdcd-analyze: SRC = $(TARGET_SAMPLES)/filter/hdcd.flac fate-filter-hdcd-analyze: CMD = md5 -i $(SRC) -af hdcd=analyze_mode=pe -f s24le fate-filter-hdcd-analyze: CMP = oneline -fate-filter-hdcd-analyze: REF = 81a4f00f85a585bc0198e9a0670a8cde +fate-filter-hdcd-analyze: REF = 6e39dc4629c1e84321c0d8bc069b42f6 FATE_AFILTER_SAMPLES-$(call FILTERDEMDECENCMUX, HDCD, FLAC, FLAC, PCM_S24LE, PCM_S24LE) += fate-filter-hdcd-false-positive fate-filter-hdcd-false-positive: SRC = $(TARGET_SAMPLES)/filter/hdcd-false-positive.flac