From patchwork Fri Jan 27 18:12:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 2340 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp369400vsb; Fri, 27 Jan 2017 10:22:18 -0800 (PST) X-Received: by 10.223.133.4 with SMTP id 4mr8733764wrh.176.1485541338300; Fri, 27 Jan 2017 10:22:18 -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 b203si2561342wmf.125.2017.01.27.10.22.17; Fri, 27 Jan 2017 10:22:18 -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 sp=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 8F87668A9FC; Fri, 27 Jan 2017 20:22:14 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFA7268A9EF for ; Fri, 27 Jan 2017 20:22:07 +0200 (EET) Received: by mail-pf0-f194.google.com with SMTP id e4so18981752pfg.0 for ; Fri, 27 Jan 2017 10:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QQp4C/Gvm3yfSpvmIZTdPnVnxVVINC0Ahmd1EipIumw=; b=Iys8eG+Dr1ySSUuv+Ejd1dMVZMHTJvlzsJ7GqFhze11+92iHlFSuB+hXkyGcPxCKhn 4Nrdw9C92memeBqdT+l5BQKkGFjMZ030GijqB+E+05d9TNnR5MPbReqqte1e7SNawysJ TRGGl0klW2K4C0ItGAWEQtUJPxTP65XEoWHMV0aBdhKlNh5IwaTkU1GCtbk8REpmm5CY +V3yVI33nzyssLezN4ghu9YwHACsIQSUdH1O94ct7oeGuC/LxjUhQEHZBNEPgu1B7TP2 jo+kbFwzDxrDKbtuMwiCv5KxyKX9168gc9OrZp3mPt9/pm1p06MW9Qru27wNJSrIeX9k y+Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QQp4C/Gvm3yfSpvmIZTdPnVnxVVINC0Ahmd1EipIumw=; b=Dcstxk43pftp4bN4ZGsabGbvMN/Kx2h9Of8hgUkgwu3D1eCefT5GB7W5IuB++N/PHf stzjBCGX9TPaA6u7QFRww3ERc/IpQZtTnzj/kREozL1QFr/8QinoETr9w8s0F/FV+aJw bxEBOfF2X3Na01rUsYWUMGKdq11pIocrdHcjjLXVWL14KbcLd2WHFiZI7gyvPkim+vW8 9aM9TR93okS+khoPYoXRSsFOFMJtoQCo6i4Zr9/vIvE8EztLT5X5hI8s9PRsP3cgCodT RhIt8ZxnHUc8puLt9o674T9Nt+ixG6rK20UftCTLIb6cLKBuYeGiMeVSoxfwHD1oSxJM COTA== X-Gm-Message-State: AIkVDXJ7DWdDwsuDUfGqbXMytb9nWH1aPgOjBCcaEO/pSh2nDD4/c75vRJaD//DxR9I9Wg== X-Received: by 10.99.136.198 with SMTP id l189mr10835834pgd.45.1485540868871; Fri, 27 Jan 2017 10:14:28 -0800 (PST) Received: from localhost.localdomain.localdomain ([202.67.46.249]) by smtp.gmail.com with ESMTPSA id v4sm13015020pfb.36.2017.01.27.10.14.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2017 10:14:28 -0800 (PST) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Jan 2017 01:12:24 +0700 Message-Id: <1485540744-13947-1-git-send-email-mfcc64@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH] avfilter: do not write to unwritable frame 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 Cc: Muhammad Faiz MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" affect filters that set partial_buf_size test-case ffplay -i lavfi 'aevalsrc=sin(1000*t*t), aformat=sample_fmts=fltp, asplit [a][b]; [a] firequalizer=fixed=on, showcqt=s=1280x360 [a1]; [b] firequalizer=fixed=on, showcqt=s=1280x360 [b1]; [a1][b1] vstack' Signed-off-by: Muhammad Faiz --- libavfilter/avfilter.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index c12d491..9b28842 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -1235,6 +1235,22 @@ static int take_samples(AVFilterLink *link, unsigned min, unsigned max, frame = ff_framequeue_peek(&link->fifo, 0); av_samples_copy(buf->extended_data, frame->extended_data, p, 0, n, link->channels, link->format); + + if (!av_frame_is_writable(frame)) { + AVFrame *new = ff_get_audio_buffer(link, frame->nb_samples); + if (!new) + return AVERROR(ENOMEM); + ret = av_frame_copy_props(new, frame); + if (ret < 0) { + av_frame_free(&new); + return ret; + } + av_frame_copy(new, frame); + av_frame_unref(frame); + av_frame_move_ref(frame, new); + av_frame_free(&new); + } + frame->nb_samples -= n; av_samples_copy(frame->extended_data, frame->extended_data, 0, n, frame->nb_samples, link->channels, link->format);