From patchwork Thu Sep 5 18:27:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 14929 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 A2D5E44A28D for ; Thu, 5 Sep 2019 21:34:16 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 89D8F68098D; Thu, 5 Sep 2019 21:34:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6574068035C for ; Thu, 5 Sep 2019 21:34:10 +0300 (EEST) Received: by mail-ot1-f52.google.com with SMTP id r20so3201850ota.5 for ; Thu, 05 Sep 2019 11:34:10 -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=4brmqYPsUS3jF4rULfbzzvz0jFPyM2EMNToLi83AKnE=; b=XgfHdflWRVnBT1T2rPoTX/K8DNOFAVsqWba1zBWosA8tAZUXwKwHtx2LNw0JGKEja8 Mf9CIbcYt0N4P403v0M2j//+Ra6S4RTumrYzG9EWMcuIfkXunw9TFG/TMtcGvMtlNCq+ hpdLU1pEGhvXrOZHrC9uZLM8knllcLUeLJFpv5wUTYsSR2VywqBYR1gTOE8I1Hnv31Tp 3ufHpKKd3buEXsCNY9JLVriCffgb2MrOxBijLyXAz/WFbC5zxXJZiiKOrTPGXmZ9TSLI 6HP3V2RJIJk/Vp86xSy5iPMTFcm7OZFIefCKOoA3eVbuCbtK+0Pca8a8cnHHBiRYd1wJ hLKA== 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=4brmqYPsUS3jF4rULfbzzvz0jFPyM2EMNToLi83AKnE=; b=ePN1yJ+Cv2s4apRSwEhiyOJpfAuTSyGdXZJT19tXW0LyxPyr9ASJzThcZGLVDgfLlr kyDUMK8QIKxZpsd+Qe509M/fvat35fwv4IwthcNSGvPb25BA4/Rv62k5k5AQvAX/eo7l yipdceOvKfB/TVj1EpMEZg1qWWWlNy2m+Dho9zvWn0dKWekXxT+r+BMdKu72aFAdlh+y 8mZzcBplX98id8c0v5Rj7ScfOYvAY5iF1UZyCWhj2FEZgfVJjjghQHyKsLmSO7inOxsM XFzCHX7uaCYR+G+S96dQVesogvM6QicwONwz9I4NNX0bGXFH83+r8y9wZSD6OdTgPIEN MWtA== X-Gm-Message-State: APjAAAXceWb71/aK8kSSKcNeW3DPYYBUEcg4jgwzPFhbFXj+6zC+P4DE NWn4T8jTWo0EzzZODuE3JKxQa+fiHf6USg== X-Google-Smtp-Source: APXvYqxYj6tA1grLmu03yIaSFLnLe2E61DCpIGPpgnAXvsnM9pv3PAOyxwsT93zqhY7jJ+vA7aI1dw== X-Received: by 2002:a9d:6e93:: with SMTP id a19mr3893116otr.29.1567708062788; Thu, 05 Sep 2019 11:27:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Sep 2019 11:27:42 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Sep 2019 11:27:31 -0700 Message-Id: <20190905182735.65987-2-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 2/6] avcodec/mediacodecdec: warn when input buffers are not configured with proper size 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 In rare circumstances, if the codec is not configured with the proper parameters the input buffers can be allocated with a size that's too small to hold an individual packet. Since MediaCodec expects exactly one incoming buffer with a given PTS, it is not valid to split data for a given PTS across two input buffers. See https://developer.android.com/reference/android/media/MediaCodec#data-processing: > Do not submit multiple input buffers with the same timestamp Signed-off-by: Aman Gupta --- libavcodec/mediacodecdec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index e353e34bd5..f5771bffb1 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -440,8 +440,13 @@ static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame) if (ret >= 0) { s->buffered_pkt.size -= ret; s->buffered_pkt.data += ret; - if (s->buffered_pkt.size <= 0) + if (s->buffered_pkt.size <= 0) { av_packet_unref(&s->buffered_pkt); + } else { + av_log(avctx, AV_LOG_WARNING, + "could not send entire packet in single input buffer (%d < %d)\n", + ret, s->buffered_pkt.size+ret); + } } else if (ret < 0 && ret != AVERROR(EAGAIN)) { return ret; }