From patchwork Mon Dec 12 03:23:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 1762 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.86 with SMTP id o83csp1459884vsa; Sun, 11 Dec 2016 19:23:32 -0800 (PST) X-Received: by 10.194.86.104 with SMTP id o8mr15859712wjz.196.1481513012185; Sun, 11 Dec 2016 19:23:32 -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 oy7si42724953wjb.129.2016.12.11.19.23.31; Sun, 11 Dec 2016 19:23:32 -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 4B9B7689EF3; Mon, 12 Dec 2016 05:23:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 775C5689DD5 for ; Mon, 12 Dec 2016 05:23:09 +0200 (EET) Received: by mail-qk0-f193.google.com with SMTP id y205so9151833qkb.1 for ; Sun, 11 Dec 2016 19:23:14 -0800 (PST) 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=IDxyfcWmPkmK0SHa6KG5Nz6xvyXp0OgnHgl8PNwBQIs=; b=sFGLFW/E8XUBwo78UxTzZDwaiA/TidEDwIpFKcXD7KST1BrHmUSqsY6OiGjyqi9uF9 9+Wq4FwKK0hkEJLubzrii43Lh77KMteEZIEkHkKgfSgHHRcigFGqYUGmbiSH61JxDc42 mZpsyXoJ+D4FiXV3bvQG8P2CsepG5aKYxnHDAcXZtgd+lu8/dWUHjsaqsn1zLDj9r6CH c4PBq8ymNKpdXDccIsuBsCxpqEP5vhKbXJT8ERYzy0hrbthQ4jkIJ52VMopWc+jX5juf 2PXHvGGC27DkAU3WxlnUqXtnaW8mtiKCbv0Zeah0M+UQYHdB0cUusYvnrNKPoOz/puJO +Bfw== 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=IDxyfcWmPkmK0SHa6KG5Nz6xvyXp0OgnHgl8PNwBQIs=; b=Q6p2Id9Ksv95CjTjoonde1ZahSvkRc5vjO2MAHhg+D8H+kposPVGHkUsPW5vs63E1D qpoMpNWa/FMg1wRZI1Wa8SskXBpeqG5KWKGuJq1p0wocCr7bj+EKZZZ0ncTRUmlXOdmn 70f4sBOznjKn7oB87/cP+5QM9+NTOKgfi/p7+lmGiGy2JobuZ8KNdv/C2ByR4JaEnmmW w4qEzT7F5H35jquCMk2lrVbwT4UIv/yx/dcvuH0bAzO3caAXR+l/BpiDBg/ThQesxZ40 xFBKuQT7pHG8/UIys8qPTMq0Vc+Rlve5EosIlmkcDKagNLEqzGun9JUe44AJFCsr4z8b bmmQ== X-Gm-Message-State: AKaTC00FNue+z2T6FtFMLQrL3V37XadeS4uuP+JrkcDIbWnTNU6Lhn1UY3gieS9fMPLYGA== X-Received: by 10.55.31.2 with SMTP id f2mr22705123qkf.5.1481512992899; Sun, 11 Dec 2016 19:23:12 -0800 (PST) Received: from localhost.localdomain ([181.22.26.31]) by smtp.gmail.com with ESMTPSA id y44sm25542192qtc.45.2016.12.11.19.23.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 11 Dec 2016 19:23:12 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Dec 2016 00:23:01 -0300 Message-Id: <20161212032301.2272-2-jamrial@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161212032301.2272-1-jamrial@gmail.com> References: <20161212032301.2272-1-jamrial@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/replaygain: use 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 --- libavformat/replaygain.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/replaygain.c b/libavformat/replaygain.c index 707d3cd..b8658d6 100644 --- a/libavformat/replaygain.c +++ b/libavformat/replaygain.c @@ -71,12 +71,13 @@ int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp, int32_t ag, uint32_t ap) { AVReplayGain *replaygain; + size_t replaygain_size; + int ret; if (tg == INT32_MIN && ag == INT32_MIN) return 0; - replaygain = (AVReplayGain*)av_stream_new_side_data(st, AV_PKT_DATA_REPLAYGAIN, - sizeof(*replaygain)); + replaygain = av_replaygain_alloc(&replaygain_size); if (!replaygain) return AVERROR(ENOMEM); @@ -85,6 +86,13 @@ int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp, replaygain->album_gain = ag; replaygain->album_peak = ap; + ret = av_stream_add_side_data(st, AV_PKT_DATA_REPLAYGAIN, (uint8_t *)replaygain, + replaygain_size); + if (ret < 0) { + av_freep(&replaygain); + return ret; + } + return 0; }