From patchwork Sat May 30 16:05:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 20013 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 4F0E344AA6F for ; Sat, 30 May 2020 19:10:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BC9BF68B03C; Sat, 30 May 2020 19:06:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AA3B568B0B2 for ; Sat, 30 May 2020 19:06:42 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id c71so6673377wmd.5 for ; Sat, 30 May 2020 09:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DVWWFW107OK7Z0Mjw9eU1wtAFw2sLWk371W2iN85b08=; b=tk5ChCWafp/rY9qtBAKvT3whm/ENtuNEa76iPlP+W3rL2YBWpm1W1HkhKpUikEC2J7 XXf5NBxY/PARsjhjPk1GcJrbAF6lsSwlq6WUADHN+NesLuYKjTDaIAAK2+wgdxAa9LrV 7ZdFber1UfhTiw4owdcl0eIkBtv7j4dr/BLo3bqlMi6GlZFDf3h6b+tsc/3VEy6dEcIc KPp5RfzpK4C2nqdVUSXErW9AIqmW6Sy9enrg1pxPfuEbtgfOMyWPaytOL2+DMevK1kKh Q9ywUI2Xh6LLGx1+3+5OPdHE57xNUozLtY/MpZz6b4zoRZoDt7ysDTQ8mMI6PBMVoLyl T3iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DVWWFW107OK7Z0Mjw9eU1wtAFw2sLWk371W2iN85b08=; b=Y+irVRvejXVkiW6OZnRRX/WI6/4bm8EWTb6POgmYdPN6T0pR5/LXsaglnlalOxHmQF HCOxVVh/2iGw8Bgrh2z4/q5X+L5O409cXb1exefcxSl5oRNFeiANpcfz48Vj9fkFvIqx yGVgQsHBiqX/vWhNO2gF2Z32gt7CJjY/FSJuP8WX9ePHA4Kkd6WrqMelf4ckPNcoya56 vZYWcTT05zDPYlth7W4le8PEscUefMkfE5ebKdWKxL6PwmMqQ8in6TOK62fG+k4RCQTd WkdeF2f9n8ulsrpO1q1fXwyKXaNzt95R00eI+XTqJvxd7Av86fm4prG2t68TP2S7a7uc +9Ww== X-Gm-Message-State: AOAM5328fMJmZht9g/pw8UJ9ohjt11+I9kW/Kc44sEQ7NTPl33pQtS++ w7j3lEuheHomDthZEv5Wn8HQJkLk X-Google-Smtp-Source: ABdhPJwe064RtOJVP/AGNvkvvtvYrfthbJTXzo7nM7epQW83CzSa4rCGTO1JeDTSX5BD4o2Sme9vmA== X-Received: by 2002:a1c:6884:: with SMTP id d126mr13549926wmc.121.1590854801683; Sat, 30 May 2020 09:06:41 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id v27sm15186517wrv.81.2020.05.30.09.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 09:06:40 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 May 2020 18:05:30 +0200 Message-Id: <20200530160541.29517-25-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> References: <20200530160541.29517-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/36] avcodec/hevc_mp4toannexb_bsf: Remove intermediate packet 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This commit ends using separate packets for in- and output. Instead, the input is read directly into the packet destined for output via ff_bsf_get_packet_ref() and only the buffer-related fields are modified; the others are not touched. Signed-off-by: Andreas Rheinhardt --- libavcodec/hevc_mp4toannexb_bsf.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c index 731ff2e7d3..9450efe2c8 100644 --- a/libavcodec/hevc_mp4toannexb_bsf.c +++ b/libavcodec/hevc_mp4toannexb_bsf.c @@ -116,20 +116,18 @@ static int hevc_mp4toannexb_init(AVBSFContext *ctx) return 0; } -static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) +static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *pkt) { HEVCBSFContext *s = ctx->priv_data; PutByteContext pb; - AVPacket *in; + AVBufferRef *out = NULL; int ret; - ret = ff_bsf_get_packet(ctx, &in); + ret = ff_bsf_get_packet_ref(ctx, pkt); if (ret < 0) return ret; if (!s->extradata_parsed) { - av_packet_move_ref(out, in); - av_packet_free(&in); return 0; } @@ -138,7 +136,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) uint64_t out_size = 0; int got_irap = 0; - bytestream2_init(&gb, in->data, in->size); + bytestream2_init(&gb, pkt->data, pkt->size); while (bytestream2_get_bytes_left(&gb)) { uint32_t nalu_size = 0; @@ -181,7 +179,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) ret = AVERROR(ERANGE); goto fail; } - ret = av_new_packet(out, out_size); + ret = ff_buffer_padded_realloc(&out, out_size); if (ret < 0) goto fail; @@ -189,14 +187,11 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) } } - ret = av_packet_copy_props(out, in); - if (ret < 0) - goto fail; + ff_packet_replace_buffer(pkt, out); fail: if (ret < 0) - av_packet_unref(out); - av_packet_free(&in); + av_packet_unref(pkt); return ret; }