From patchwork Thu Sep 5 18:27:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 14932 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9A5AC44A314 for ; Thu, 5 Sep 2019 21:36:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7E57468099D; Thu, 5 Sep 2019 21:36:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DC272680468 for ; Thu, 5 Sep 2019 21:35:56 +0300 (EEST) Received: by mail-ot1-f66.google.com with SMTP id c10so3176884otd.9 for ; Thu, 05 Sep 2019 11:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JjAzgBxHz6MDrP3gfUyK5uSAbfZKflPVPnRjHgkfciE=; b=glAnLlLp3mRxUwWxrRCtTJw++gLBGhURQ+csl9Ucyj6emeu6wVKofvmE0iPpaGbA5e 7NltR80gHGQ0XNyyCe5jBwbJXDncmUWjl5HLbZ+a90Obdlymm1jYusALKa8X2co4wzCb uzZ26loc4VbI5tXDQs37/HK7CC80u12iq3aOt0Qs+HJbjs2agn2EOzASCczOWiGdTvrb jwOb+lTwSGfTPxVw7U0/SIvgPDlLmXiUszxgXISIiAF6Qz1padL1CQxeanb37yrt1ldi 62v9YUmu+h+VS5w2GmeUmVlnrQ9FhoMS4qXPxpqFNKW0byfpe0NMQztlRH11FF5HThA9 5X9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=JjAzgBxHz6MDrP3gfUyK5uSAbfZKflPVPnRjHgkfciE=; b=EwBiC+MwHX46zp+KV3wRhW9dTMu72pz7x8/AIc8EOPZyMqa1z0FQqfajw51PmS/cNL beCQkTf6tjRDC2CWm0/tGLkymDf2FR9xlFhh/hl7KTHMFaouZL+fAvdByZ1sD9woIPoY RSg2immSdHdWKU0NrEsK5/z4p5KbKj3Z1FRivriDUr5Zw9BIPOawqS/HU1tY9MpJ0t76 vaghXdU5W010BqfpLxbX+aJOaL9efWRDwC89se2I0ouyCwC5aTeKLqohCfLJ5LikaBcE Qe6L8JZvbCTq7U4LbziqIpnHlhVY34p5+/ITcV+t5sublRpetX/f6PP9UF7un2i39vRw o4VQ== X-Gm-Message-State: APjAAAUNCvuKlxBH9nj4IXahn193PHMarwCXJNTkLybLBE0CQ8cuhe+J 5j+Kc/mxm3+S6XzkcOTJDnJZZ+r9gmXYCw== X-Google-Smtp-Source: APXvYqweVrdrjtyMA1VxLvpn94eXdw7cdHVBJsc9MSMj+WZ/hiTvNpg8NOi4vxPsWUREp0oTh7K9ig== X-Received: by 2002:a9d:198c:: with SMTP id k12mr4118351otk.154.1567708067516; Thu, 05 Sep 2019 11:27:47 -0700 (PDT) Received: from tmm1-imac.lan (ip184-189-221-177.sb.sd.cox.net. [184.189.221.177]) by smtp.gmail.com with ESMTPSA id z33sm993614otb.75.2019.09.05.11.27.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Sep 2019 11:27:46 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Sep 2019 11:27:34 -0700 Message-Id: <20190905182735.65987-5-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190905182735.65987-1-ffmpeg@tmm1.net> References: <20190905182735.65987-1-ffmpeg@tmm1.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/6] avcodec/mediacodecdec_common: ensure current input buffer is always used correctly 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: matthieu.bouron@gmail.com, Aman Gupta Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta The loop may mutate the input buffer, so re-fetch it to ensure the current one is always used. Signed-off-by: Aman Gupta --- libavcodec/mediacodecdec_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index c538a00775..b9465244a3 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -569,7 +569,6 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, int offset = 0; int need_draining = 0; uint8_t *data; - ssize_t index = s->current_input_buffer; size_t size; FFAMediaCodec *codec = s->codec; int status; @@ -591,6 +590,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s, } while (offset < pkt->size || (need_draining && !s->draining)) { + ssize_t index = s->current_input_buffer; if (index < 0) { index = ff_AMediaCodec_dequeueInputBuffer(codec, input_dequeue_timeout_us); if (ff_AMediaCodec_infoTryAgainLater(codec, index)) {