From patchwork Sun Feb 19 13:35:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 2603 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.22 with SMTP id n22csp449232vsb; Sun, 19 Feb 2017 05:36:05 -0800 (PST) X-Received: by 10.28.20.144 with SMTP id 138mr12980727wmu.41.1487511365369; Sun, 19 Feb 2017 05:36:05 -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 v91si4191615wrc.94.2017.02.19.05.36.04; Sun, 19 Feb 2017 05:36:05 -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; 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 0F4BE6899B9; Sun, 19 Feb 2017 15:35:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7A40B680764 for ; Sun, 19 Feb 2017 15:35:47 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 32CF510175B; Sun, 19 Feb 2017 14:35:54 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id utMHjQ63U7vb; Sun, 19 Feb 2017 14:35:53 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id AA8E2100B4F; Sun, 19 Feb 2017 14:35:52 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Feb 2017 14:35:42 +0100 Message-Id: <20170219133542.4302-1-cus@passwd.hu> X-Mailer: git-send-email 2.10.2 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCHv2] avcodec/utils: do not reallocate packet buffer for AV_CODEC_ID_WRAPPED_AVFRAME 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Reallocating a wrapped avframe invalidates internal pointers, such as extended data. FFmpeg has another way of passing AVFrames to muxers, but it seems the API (av_write_uncoded_frame) is not implemented in the ffmpeg CLI yet. Signed-off-by: Marton Balint --- libavcodec/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index f4085bf..184821a 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1820,7 +1820,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, AVFrame *padded_frame = NULL; int ret; AVPacket user_pkt = *avpkt; - int needs_realloc = !user_pkt.data; + int needs_realloc = !user_pkt.data && avctx->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME; *got_packet_ptr = 0; @@ -1964,7 +1964,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, { int ret; AVPacket user_pkt = *avpkt; - int needs_realloc = !user_pkt.data; + int needs_realloc = !user_pkt.data && avctx->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME; *got_packet_ptr = 0;