From patchwork Sun Feb 19 01:00:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 2602 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.22 with SMTP id n22csp276230vsb; Sat, 18 Feb 2017 17:01:02 -0800 (PST) X-Received: by 10.223.176.221 with SMTP id j29mr1862273wra.8.1487466062228; Sat, 18 Feb 2017 17:01:02 -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 6si18635343wrz.292.2017.02.18.17.01.01; Sat, 18 Feb 2017 17:01:02 -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 1A4CA687EC0; Sun, 19 Feb 2017 03:00:51 +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 2F64D680163 for ; Sun, 19 Feb 2017 03:00:44 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1660E100BE0; Sun, 19 Feb 2017 02:00:51 +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 3XQ23Aw-u3ev; Sun, 19 Feb 2017 02:00:48 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id C71BB100B5B; Sun, 19 Feb 2017 02:00:47 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Feb 2017 02:00:40 +0100 Message-Id: <20170219010040.15581-1-cus@passwd.hu> X-Mailer: git-send-email 2.10.2 Subject: [FFmpeg-devel] [PATCH] 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..d09384a 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1926,7 +1926,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, } if (!ret) { - if (needs_realloc && avpkt->data) { + if (needs_realloc && avpkt->data && avctx->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) { ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); if (ret >= 0) avpkt->data = avpkt->buf->data; @@ -2027,7 +2027,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, else if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) avpkt->pts = avpkt->dts = frame->pts; - if (needs_realloc && avpkt->data) { + if (needs_realloc && avpkt->data && avctx->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) { ret = av_buffer_realloc(&avpkt->buf, avpkt->size + AV_INPUT_BUFFER_PADDING_SIZE); if (ret >= 0) avpkt->data = avpkt->buf->data;