From patchwork Sat Sep 3 22:45:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Campbell X-Patchwork-Id: 409 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp2093557vsd; Sat, 3 Sep 2016 15:46:32 -0700 (PDT) X-Received: by 10.28.2.84 with SMTP id 81mr8539655wmc.72.1472942792277; Sat, 03 Sep 2016 15:46:32 -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 bh1si18226288wjb.229.2016.09.03.15.46.29; Sat, 03 Sep 2016 15:46:32 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D94A689DF7; Sun, 4 Sep 2016 01:46:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from p3plsmtpout002.prod.phx3.secureserver.net (p3plsmtpout002.prod.phx3.secureserver.net [208.109.80.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 53547689DCD for ; Sun, 4 Sep 2016 01:46:12 +0300 (EEST) Received: from ip-192-169-235-64.secureserver.net ([192.169.235.64]) by : HOSTING RELAY : with SMTP id gJgcbd9ep2KikgJgcbSiBv; Sat, 03 Sep 2016 15:45:18 -0700 x-originating-ip: 192.169.235.64 Received: from c-73-53-12-90.hsd1.wa.comcast.net ([73.53.12.90]:49877 helo=[192.168.250.88]) by ip-192-169-235-64.secureserver.net with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256) (Exim 4.82) (envelope-from ) id 1bgJgc-0005Aj-4Q for ffmpeg-devel@ffmpeg.org; Sat, 03 Sep 2016 15:45:18 -0700 Message-ID: <57CB527D.3060804@impactstudiopro.com> Date: Sat, 03 Sep 2016 15:45:17 -0700 From: Jonathan Campbell User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: FFmpeg development discussions and patches References: <20160902115034.GV4692@nb4> <57C9B49B.9020804@impactstudiopro.com> <20160902200148.GW4692@nb4> <57C9DD6D.8060406@impactstudiopro.com> <20160902205623.GY4692@nb4> <57CA05C8.30605@impactstudiopro.com> <20160902233718.GC4692@nb4> <57CA1022.9050304@impactstudiopro.com> <20160903002307.GE4692@nb4> <57CA19E7.7050802@impactstudiopro.com> <20160903003552.GF4692@nb4> <57CAAAF9.6000207@impactstudiopro.com> <84372637-0830-3957-e366-0be32089e74e@gmail.com> In-Reply-To: <84372637-0830-3957-e366-0be32089e74e@gmail.com> X-CMAE-Envelope: MS4wfOvygzZpSH1vMzXaTu51+pHxSg28KdxRjd8W8tEBHwYG3Rp0mcurIWaeCsyH3QrEojCOJ7PFRIbkO8fGCki/aNdCKaolTPMokSPpi95Yuprm5BBELLPx a6C36DjesSNtIxO5WiV5JKLpy+lovzwN3Dd2QXI2zD176A9bsT6ErJX3aZrtJ4vE4JjrAZ5Od0RHFZbQgcvBuBfcwO1ZPW17BH5EzNRC+O3eIQxAABIvVpyA Subject: Re: [FFmpeg-devel] CNG (consistent noise generation) patch for AC-3 decoder 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On 09/03/2016 07:07 AM, James Almer wrote: > On 9/3/2016 7:50 AM, Jonathan Campbell wrote: >> +int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length) { >> + unsigned int beg, end, segm; >> + const AVCRC *avcrc; >> + uint32_t crc = 1; >> + >> + c->index = 0; > > The AVLFG struct should IMO remain untouched if init is guaranteed to fail, > as it would be the case with an out or range length value, so move this after > that check. > >> + avcrc = av_crc_get_table(AV_CRC_32_IEEE); /* This can't fail. It's a well-defined table in crc.c */ > > You could also move this one below. > >> + >> + /* avoid integer overflow in the loop below. */ >> + if (length > (UINT_MAX / 128U)) return AVERROR(EINVAL); >> + >> + /* across 64 segments of the incoming data, >> + * do a running crc of each segment and store the crc as the state for that slot. >> + * this works even if the length of the segment is 0 bytes. */ >> + beg = 0; >> + for (segm = 0;segm < 64;segm++) { >> + end = (((segm + 1) * length) / 64); >> + crc = av_crc(avcrc, crc, data + beg, end - beg); > > The thing about speed made me wonder, wouldn't using adler32 be faster? > If so, this feature could maybe even be enabled by default with it. > >> + c->state[segm] = (unsigned int)crc; >> + beg = end; >> + } >> + >> + return 0; >> +} >> diff --git a/libavutil/lfg.h b/libavutil/lfg.h >> index ec90562..72eb673 100644 >> --- a/libavutil/lfg.h >> +++ b/libavutil/lfg.h >> @@ -22,6 +22,8 @@ >> #ifndef AVUTIL_LFG_H >> #define AVUTIL_LFG_H >> >> +#include /* uint8_t type */ >> + >> typedef struct AVLFG { >> unsigned int state[64]; >> int index; >> @@ -29,6 +31,13 @@ typedef struct AVLFG { >> >> void av_lfg_init(AVLFG *c, unsigned int seed); >> >> +/* > > This is meant for doxygen, so /** like in every other function. > >> + * Seed the state of the ALFG using binary data. >> + * >> + * Return value: 0 on success, negative value (AVERROR) on failure. >> + */ >> +int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length); >> + >> /** >> * Get the next random unsigned 32-bit number using an ALFG. >> * > > No more comments for me. > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > Here you go. Jonathan Campbell From 5de30d309fb48b26acd8d95f14ef4d4064450ddc Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Sat, 3 Sep 2016 03:20:41 -0700 Subject: [PATCH 1/4] libavutil version bump, av_lfg_init_from_data() incoming --- libavutil/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/version.h b/libavutil/version.h index 7d32c7b..60b58eb 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 29 +#define LIBAVUTIL_VERSION_MINOR 30 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \