From patchwork Mon Dec 12 03:23:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 1761 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.86 with SMTP id o83csp1459841vsa; Sun, 11 Dec 2016 19:23:24 -0800 (PST) X-Received: by 10.194.222.202 with SMTP id qo10mr77040890wjc.115.1481513003986; Sun, 11 Dec 2016 19:23:23 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k141si26706108wmd.133.2016.12.11.19.23.23; Sun, 11 Dec 2016 19:23:23 -0800 (PST) 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 D47FA689E67; Mon, 12 Dec 2016 05:23:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5C260689DD5 for ; Mon, 12 Dec 2016 05:23:08 +0200 (EET) Received: by mail-qt0-f194.google.com with SMTP id n34so8368636qtb.3 for ; Sun, 11 Dec 2016 19:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=tLNbn5g6BaOH5v8lUUoRTZH5l3Z3m6FLr1pxhwiJBHo=; b=MRg2pj87kDsQmQWB+v2VGq8fEm6dyquQ4/jWOc4Cf6R4a5QOA7SyBwn4466b2+sRYv 77Hoe5bPNad2m6/HadZINGlko3Yzj9Q4hkC0E4yQWyIoHCKRr3Rmb5tRjtrV0N9BP7em rx63cgUsWFnzDLHM3i8KaU4GfgUiyPVo/bV3y3WjLzJY/CdXXVaf1KddjxM7WOiTIAlP pKFhyQOk6lbO1ZXHracmbgAkmbiB7fpNyVdCfxPPk9BhOesKOd1t512YLoRm2l17Mr3J KX9orSwZIdV3aF/nPHMM1jKEzo2rroG/zvCj5zGnlGMADmXfZgbel7CeLqtfmkpZLFtG Bkmw== 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; bh=tLNbn5g6BaOH5v8lUUoRTZH5l3Z3m6FLr1pxhwiJBHo=; b=doeNF6yZBlwxlJubK364dV6nzN/TE2F3vhYCKNxDkiJbbFohV0MHuJDwnHFfw2UziZ BeyqHS+oSXOFl6OmCRGzaFacCCxKa0mwZvZnskZ3hepdlSrzOx05bVFo36OhsoAq47fS a4MoFZBiOVSUqvRLYp7kAF8xOxsgKpuKPt4aKS27MrSsShHOICG5xAPcoUZQla6Uc/lB Kd55Q5AFEARiPv2sKlAh1zw8Hqrau2xdzY7CnmyZFdhXO72ya32cDZobZFSAzJYn9iR2 IGTf3VNjB7oN2t9hIGR2rSjYUlBAmfvNdy5bWELT92R0CXoLFdWv2ywIVqCUUyMyMetu YvOg== X-Gm-Message-State: AKaTC02yF6GKtO+8E1vghNdzZATrOjCt8JLMtdD/rA0S0zfzrZ+LXwBWz+q+rftYKR4IPA== X-Received: by 10.200.39.43 with SMTP id g40mr90282295qtg.58.1481512991644; Sun, 11 Dec 2016 19:23:11 -0800 (PST) Received: from localhost.localdomain ([181.22.26.31]) by smtp.gmail.com with ESMTPSA id y44sm25542192qtc.45.2016.12.11.19.23.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 11 Dec 2016 19:23:11 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Dec 2016 00:23:00 -0300 Message-Id: <20161212032301.2272-1-jamrial@gmail.com> X-Mailer: git-send-email 2.10.2 Subject: [FFmpeg-devel] [PATCH 1/2] avutil/replaygain: add av_replaygain_alloc() 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" Signed-off-by: James Almer --- TODO: APIChanges entry and version bump. libavutil/replaygain.c | 38 ++++++++++++++++++++++++++++++++++++++ libavutil/replaygain.h | 10 ++++++++++ 2 files changed, 48 insertions(+) create mode 100644 libavutil/replaygain.c diff --git a/libavutil/replaygain.c b/libavutil/replaygain.c new file mode 100644 index 0000000..2715cb2 --- /dev/null +++ b/libavutil/replaygain.c @@ -0,0 +1,38 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include "mem.h" +#include "replaygain.h" + +AVReplayGain *av_replaygain_alloc(size_t *size) +{ + AVReplayGain *replaygain = av_mallocz(sizeof(AVReplayGain)); + if (!replaygain) + return NULL; + + replaygain->track_gain = + replaygain->album_gain = INT32_MIN; + + if (size) + *size = sizeof(*replaygain); + + return replaygain; +} diff --git a/libavutil/replaygain.h b/libavutil/replaygain.h index b49bf1a..2ad6de6 100644 --- a/libavutil/replaygain.h +++ b/libavutil/replaygain.h @@ -19,6 +19,7 @@ #ifndef AVUTIL_REPLAYGAIN_H #define AVUTIL_REPLAYGAIN_H +#include #include /** @@ -47,4 +48,13 @@ typedef struct AVReplayGain { uint32_t album_peak; } AVReplayGain; +/** + * Allocate an AVReplayGain structure and set its fields to default values. + * The resulting struct can be freed using av_freep(). + * + * @param size pointer for AVReplayGain structure size to store (optional) + * @return An AVReplayGain filled with default values or NULL on failure. + */ +AVReplayGain *av_replaygain_alloc(size_t *size); + #endif /* AVUTIL_REPLAYGAIN_H */