From patchwork Tue Apr 24 20:59:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 8639 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp2282443jad; Tue, 24 Apr 2018 13:59:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx48yOuORT/uNT6PG60NSAUWYOY//LtHlG6poniLlpcuKlyvuLumyzzmfJclNfz3bGkXWxE1C X-Received: by 2002:adf:86d2:: with SMTP id 18-v6mr22838615wry.232.1524603581477; Tue, 24 Apr 2018 13:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524603581; cv=none; d=google.com; s=arc-20160816; b=HUUFMzhlZY9hDaDFa6RWfPFDPzEiL/wto9b2KtHXJTaF+DjphxTsqk6ZvaJRMIXSb4 aGv2VS4IvVSPqVr0NjP4QAxntNTBXLnWrPMKUhS7sEkambMHpBqz4Q2XpVlNx0wUtxVk Hds1zYBOOEm5e0axvcNDJPZmhgaOhTBQAXr2zkrK+DKf9k2JBbVSL/haFarcmX0gpb5E 4WxtP55BalI8Mtanug+OX/enPstBUboUQ+2syb7/PCLw3gK5kLpSOBzPuWUpIXcUAsh3 hx6APjMcpaJLk3e0d+c0ghADAeyEuzt4Xhe2GqMZ1W8Q9QJH5jAScRDGgcsMD5D6KLg4 1EMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=gKHgVBflHDz7wTL/0kQurqNX+UZyI7S6KAdilCOuLoU=; b=Mr/8MRsMqwjIL0rcrP2d7WD4mTQzC5KSVsWr4KaIT7F1mdI/JqcPVpfnOvtzcb3LRM Yj8PZDOKFXToqTp37gPiKa91KEdwTF9ioKK59byvdY1z/vvNmg4SMijvUGkOGCB94KD5 cseJHVFwNmHKJWxKG2fHlk5kASshbmROac4ouOwd2JnKdYXC0OVNtddMBpdHQoZWL9RK vYfeOaQx+1BmfFyTlMWB9UL+ZfMm/hPd0bFbjWH0UfhXpINiCXsxfAq/JPn7ECy/Qfhm IP6+DpBqjViVQmLjoDuu3fa9qFGhRzp4mZq7TZNVEkDh9LARolDa3KIyVjRdD3+9ch5b fSiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=qPhJj6TS; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 92-v6si13051201wrc.182.2018.04.24.13.59.40; Tue, 24 Apr 2018 13:59:41 -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=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=qPhJj6TS; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 87568689E21; Tue, 24 Apr 2018 23:59:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A5438689B4A for ; Tue, 24 Apr 2018 23:59:02 +0300 (EEST) Received: by mail-pf0-f195.google.com with SMTP id j5so13284634pfh.2 for ; Tue, 24 Apr 2018 13:59:32 -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; bh=xjit6w3P9yxLCn0M5HoFKQb6Jk0yx+ahVs5iTgx714w=; b=qPhJj6TSIh4REGbbhDTmnkual5CG0r2/7iEs30kb8Anheb3W4A3TQQ9574AejqP3ue UwDIDqHpvDybwL4ALIYF3trySSSBzVmNfVci1kIX7te9e54q1YH5cVcwznxmU+2O5Ygq btNRDNaW9IS2iy1Ph+nQFBszweGr7gENYZMuZnmq0PVepUXeR0H/UkEn4iQ/Go1yR15r eJA+bqCKXcZhXgVDBWqWGrOdn0CliRefDvhQHWtSdyNPFX9cx69rAeUwJtGLMNgu1oxY yLXs6SocV1H+v6pSZri3RYlKP7E8T6iPHrBJ+sbO7Qvuz9vT1uoYCfiSOtAK1J9b50pc /jSg== 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; bh=xjit6w3P9yxLCn0M5HoFKQb6Jk0yx+ahVs5iTgx714w=; b=RXQ2RA6C6h96h1F9YO6TVeRf+e12cH1L/03iHgPEHjQYPYAixnnanw/pE1XI4TuBRT ryOjZ38l8QujsHorKdgtPkB14PiOx120eXgKx+8IdADo3FBrXyqySGIHDc8D0olZHbQZ BjMVfAPQLyg9ooRxWskLSgtpQzDpdqOnxpyWAhqhkGvOKdr9RHR3rBdQp409AQS5BNyF smuYYom0Q7S2uKsoL41BHYZoXQTTsudBTvwonT/bEWZQrQ4Ffvy1cXC00X9WI0p/jXtZ FtxCBSG+qaDpMkQXX6N1zEca7eOTWBvOcIlWWzVffvxW+oYiEssdOeUGRobEbrXA2Rk1 VWNg== X-Gm-Message-State: ALQs6tBvWiP6L9hULkTrRTdfO5aaz9t90QrboVho6L1RiWpbB7GH3bIV uCs9NJ4YWZQ/wi57XRxc+TKbAx0h X-Received: by 2002:a17:902:5597:: with SMTP id g23-v6mr13053068pli.347.1524603570300; Tue, 24 Apr 2018 13:59:30 -0700 (PDT) Received: from localhost.localdomain (c-69-181-54-242.hsd1.ca.comcast.net. [69.181.54.242]) by smtp.gmail.com with ESMTPSA id h6sm26184534pfi.35.2018.04.24.13.59.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Apr 2018 13:59:29 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Apr 2018 13:59:23 -0700 Message-Id: <20180424205926.42027-1-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/mediacodecdec: clarify delay_flush specific code 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 , jeebjp@gmail.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta --- libavcodec/mediacodecdec.c | 24 +++--------------------- libavcodec/mediacodecdec_common.c | 12 ++++++++++++ 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 0d4a853f07..e5d3e6a0af 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -419,27 +419,9 @@ static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame) MediaCodecH264DecContext *s = avctx->priv_data; int ret; - /* - * MediaCodec.flush() discards both input and output buffers, thus we - * need to delay the call to this function until the user has released or - * renderered the frames he retains. - * - * After we have buffered an input packet, check if the codec is in the - * flushing state. If it is, we need to call ff_mediacodec_dec_flush. - * - * ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on - * the codec (because the user retains frames). The codec stays in the - * flushing state. - * - * ff_mediacodec_dec_flush returns 1 if the flush can actually be - * performed on the codec. The codec leaves the flushing state and can - * process again packets. - * - * ff_mediacodec_dec_flush returns a negative value if an error has - * occurred. - * - */ - if (ff_mediacodec_dec_is_flushing(avctx, s->ctx)) { + /* in delay_flush mode, wait until the user has released or rendered + all retained frames. */ + if (s->delay_flush && ff_mediacodec_dec_is_flushing(avctx, s->ctx)) { if (!ff_mediacodec_dec_flush(avctx, s->ctx)) { return AVERROR(EAGAIN); } diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index e59cf19aad..0c27624dea 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -764,6 +764,18 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx, MediaCodecDecContext *s, return AVERROR(EAGAIN); } +/* +* ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on +* the codec (because the user retains frames). The codec stays in the +* flushing state. +* +* ff_mediacodec_dec_flush returns 1 if the flush can actually be +* performed on the codec. The codec leaves the flushing state and can +* process again packets. +* +* ff_mediacodec_dec_flush returns a negative value if an error has +* occurred. +*/ int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s) { if (!s->surface || atomic_load(&s->refcount) == 1) {