From patchwork Thu Mar 23 18:15:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 3079 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.13.202.146 with SMTP id m140csp364779ywd; Thu, 23 Mar 2017 11:21:25 -0700 (PDT) X-Received: by 10.223.128.202 with SMTP id 68mr3972689wrl.108.1490293285905; Thu, 23 Mar 2017 11:21:25 -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 65si12556137wmu.102.2017.03.23.11.21.25; Thu, 23 Mar 2017 11:21:25 -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 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 EAFA1689814; Thu, 23 Mar 2017 20:21:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f67.google.com (mail-oi0-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A2EFB689214 for ; Thu, 23 Mar 2017 20:20:54 +0200 (EET) Received: by mail-oi0-f67.google.com with SMTP id f81so6279746oih.2 for ; Thu, 23 Mar 2017 11:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=gG76FkxXFGzvbKH/Jdn9kyb6YC2gzEVUnlq0r2bqDsY=; b=mR1UFpSoG+ecTElMZtg2V5m69cg+vbKz20t1Ed5vYNVUgE7O9Tut3nHR+5vxKFJ3Qr 95LvzyE0oEV7guAI/VTjXWv5kefZvPETaUy9yvk6Z8p/PJKIDprQnHhU1IbkidCt2yUG Rb/anYFNnPMH8iz2qG22Q/Qk0WerzFYulzGA3Ke+nGku9gOWAT72Ev7m+lRo7cHiUfZC rcWWM9O5MjDjnX2ogAQkmXvBc5pNahDPYZk03S8NrZ9POpQZsnbTWBVVURMOf6j56v/w Z9r11ThAmXlpNwh8kadqPJcW35j6ZcpIVsJN3Hwmle2IACHYRsZa9NLcFi7KAi0Pj0yq boew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=gG76FkxXFGzvbKH/Jdn9kyb6YC2gzEVUnlq0r2bqDsY=; b=q6R0Ieftq0Aghow83zgyzvfVUBqg8azM+83Xkgg2e5l0vMSwFU1qYep71pTnXTxei3 MVlinU2wPS+7RSNcVEUkZhwuaPBUwEZ3kpZ7rI8LJx4tImn/znrvFoLlFq/RS72r01i2 BTdqdvT8ClZjtiWn1/dw13ZKQ4yaerWHJBeM+xcvGwgaPhkHM+l9W9icC3YVAyTvPTkF /eQi8dcuteYIEgr0ozI5ea5kQF/vFo8kNvxqQYCrNvrEj5Wlq8cyfUg+diB6UTY0R/uB bH2rzHky84OLLIFr8me0WhESsDpYJmHs/jU/6zvfx4kCuR99Wggnm8/F2wK5aot5JW9D WClw== X-Gm-Message-State: AFeK/H3eKIsu+eyEWLIkS9QdOnSuV/bgYmbJ+EJGrEaK8qjPL4nAnm3JOgkHLiXaf0a6IqeimRa7i3kYwS8Rrg== X-Received: by 10.202.245.70 with SMTP id t67mr1981004oih.145.1490292956865; Thu, 23 Mar 2017 11:15:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.72.129 with HTTP; Thu, 23 Mar 2017 11:15:56 -0700 (PDT) Received: by 10.74.72.129 with HTTP; Thu, 23 Mar 2017 11:15:56 -0700 (PDT) In-Reply-To: <20170322233412.6952-2-jamrial@gmail.com> References: <20170322233412.6952-1-jamrial@gmail.com> <20170322233412.6952-2-jamrial@gmail.com> From: Matthieu Bouron Date: Thu, 23 Mar 2017 19:15:56 +0100 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH 1/7] avcodec/mediacodec: convert to stdatomic 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" Le 23 mars 2017 12:35 AM, "James Almer" a écrit : Signed-off-by: James Almer --- Untested. libavcodec/mediacodec.c | 5 ++--- libavcodec/mediacodecdec.c | 1 - libavcodec/mediacodecdec_common.c | 14 ++++++-------- libavcodec/mediacodecdec_common.h | 5 +++-- 4 files changed, 11 insertions(+), 14 deletions(-) The underlying buffer is meant to be released once. Unless i miss something there, you could potentially release a later buffer using the same index or release an invalid buffer. A mediacodec buffer can only be released once. Once it is released it goes back to the decoder pool and it is not usable anymore unless it bas been returned by the decoder again. The buffer itself is represented by an index. Can you bring the original check back ? (released == 1) I dont have the time to review and test the entire patch (nor the machine, i m writing from my phone) as i am on holidays but i ll be back on monday (and i ll test the patch). Matthieu [...] diff --git a/libavcodec/mediacodec.c b/libavcodec/mediacodec.c index 4ad5921bc2..91f725621d 100644 --- a/libavcodec/mediacodec.c +++ b/libavcodec/mediacodec.c @@ -31,7 +31,6 @@ #include #include "libavcodec/avcodec.h" -#include "libavutil/atomic.h" #include "libavutil/mem.h" #include "ffjni.h" @@ -90,9 +89,9 @@ void av_mediacodec_default_free(AVCodecContext *avctx) int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render) { MediaCodecDecContext *ctx = buffer->ctx; - int released = avpriv_atomic_int_add_and_fetch(&buffer->released, 1); + atomic_int released = atomic_fetch_add(&buffer->released, 1); - if (released == 1) { + if (!released) { Hello,