From patchwork Fri Jul 29 17:36:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Burt P X-Patchwork-Id: 29 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp1467343vsd; Fri, 29 Jul 2016 10:53:17 -0700 (PDT) X-Received: by 10.28.146.211 with SMTP id u202mr46301305wmd.54.1469814797798; Fri, 29 Jul 2016 10:53:17 -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 ci16si19900453wjb.254.2016.07.29.10.53.17; Fri, 29 Jul 2016 10:53:17 -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 BAE24689E0F; Fri, 29 Jul 2016 20:53:10 +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 B4456689DFF for ; Fri, 29 Jul 2016 20:53:03 +0300 (EEST) Received: by mail-it0-f65.google.com with SMTP id f6so7482410ith.2 for ; Fri, 29 Jul 2016 10:53:08 -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=6FUKVwVkh3QiM65W3TLuR2HCGU4FeyzwUdjm8AD+FSw=; b=UGeNKRdnOsfdfWvf38vbNgWVlKCfNtR8QB3pYSWWHMhr/tlRsvc9xDhLinVYs/4rmu aNjWqVb+W6w2HTAewX/mokSRVxQF4lAFAP9oRBC76/cTrr7ncycNZpIXcY79hbeCGD5j +4GAP9Wodgh/Nsp8rYT0jdb1QNWzaDy1TOMDVNrugbdQezVZQpi+TwIrIgTA2uu4zc5L no/WSwJQTjTaVot2jMp+aMIpdyIPrLcqJNCtEjkfRyf9iFFY91CpvT6tZ5TU6XZVMDgc nkijkY0Zqxd4l6AVEBtSSyGTlJyTqjIIWbqDKGDMxFXZMFo/KiX4UROf/U/+AIHK2L4N /Lnw== 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=6FUKVwVkh3QiM65W3TLuR2HCGU4FeyzwUdjm8AD+FSw=; b=Ks20oMrOBmWq3AqZU6RjXqUsBl3lxs1xnZcRaRsMUyS+9rxj7qlvU6G8CcRGEBQu9G T4WCMMZ51OeSdJqvV5ZL51GIcHMImoxrHoATEAuKbNq0nhdz6RQBkrggUBYELchNCfkb FKPQk/QYGoNNff2JpFcIT+Y3OOqtbxvHhXu0Y6+cwHty1C99GED8ULJICH2CHIAAVuoY BX2PiaMA3dNJgqWDFYoVynCBNaTOQjCcr8EcyGn3EBDBliAZhldqy1XWtp5ZVFvoL8RP KoKDo2u3v1xqLo8ZaYuHI0A/1aAeEzDWNvlJdQRyqm5KGDrfQYlP//gkF7gDShfKRtrG bKTg== X-Gm-Message-State: AEkoouseD6rm7TK2u2ywAOz7tEmno26Oia63a0kbZ8Zb9kKgTT0F/Ub8oPG8dgp1K1dvig== X-Received: by 10.36.43.74 with SMTP id h71mr30897541ita.60.1469813796679; Fri, 29 Jul 2016 10:36:36 -0700 (PDT) Received: from localhost.localdomain ([216.16.66.181]) by smtp.gmail.com with ESMTPSA id u7sm1720954ita.21.2016.07.29.10.36.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jul 2016 10:36:36 -0700 (PDT) From: Burt P To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Jul 2016 12:36:17 -0500 Message-Id: <1469813782-13305-3-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 2/7] af_hdcd: give cdt expired counter a value for never set 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" The counter is now -1 if the code detect timer was never set, and 0 if it was set but never expired. Signed-off-by: Burt P --- libavfilter/af_hdcd.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c index b860077..8498b35 100644 --- a/libavfilter/af_hdcd.c +++ b/libavfilter/af_hdcd.c @@ -846,7 +846,9 @@ typedef struct { * steps of 0.5, but no value below -6.0 dB should appear. */ int gain_counts[16]; /* for cursiosity, mostly */ int max_gain; - int count_sustain_expired; /* occurences of code detect timer expiring without detecting a code */ + /* occurences of code detect timer expiring without detecting + * a code. -1 for timer never set. */ + int count_sustain_expired; AVFilterContext *fctx; /* filter context for logging errors */ } hdcd_state_t; @@ -909,7 +911,7 @@ static void hdcd_reset(hdcd_state_t *state, unsigned rate) for(i = 0; i < 16; i++) state->gain_counts[i] = 0; state->max_gain = 0; - state->count_sustain_expired = 0; + state->count_sustain_expired = -1; } /* update the user info/counters */ @@ -991,6 +993,15 @@ static int hdcd_integrate(hdcd_state_t *state, int *flag, const int32_t *samples return result; } +static void hdcd_sustain_reset(hdcd_state_t *state) +{ + state->sustain = state->sustain_reset; + /* if this is the first reset then change + * from never set, to never expired */ + if (state->count_sustain_expired == -1) + state->count_sustain_expired = 0; +} + static int hdcd_scan(hdcd_state_t *state, const int32_t *samples, int max, int stride) { int cdt_active = 0; @@ -1011,7 +1022,7 @@ static int hdcd_scan(hdcd_state_t *state, const int32_t *samples, int max, int s result += consumed; if (flag > 0) { /* reset timer if code detected in channel */ - state->sustain = state->sustain_reset; + hdcd_sustain_reset(state); break; } samples += consumed * stride;