From patchwork Fri Jan 24 22:48:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 17521 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 98C6F449962 for ; Sat, 25 Jan 2020 00:48:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C96F68AEBC; Sat, 25 Jan 2020 00:48:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 61AFA68A101 for ; Sat, 25 Jan 2020 00:48:44 +0200 (EET) Received: by mail-wm1-f68.google.com with SMTP id q9so985830wmj.5 for ; Fri, 24 Jan 2020 14:48:44 -0800 (PST) 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=YchjTbmUZaVi0ULNqTgHZF2wR6w+RpluCcQyUJqKBqk=; b=CcLOEMPpQYG2f6aQcUGZ7SSPLT6ptaCUJxyidwa6Ikam3NNj5itrS58JVwZBi0/Zc9 B6HEPp5/vie/j7LllQ3Cvaij4jtMC47zCWhwTi5o6nj4CZVCVXQNsyXohHxaWh9EfVb3 P3Uj5tCu2URBihLOPOBnCYSXi/UqkDXBeTKo9fk9voP02eumTh8ioCsDFAcIAC7OhnNi dxfhsswpoJ5Q+LHs796ax9Om6jjZNQMiI0bJTBRKypLVuIq5oeaaqd/tuEYzZHVMs1uO R2j4gR4gHAj23O2mf8m6TQ+y3tGckY3NtkzvyTN7psOz2gQyqlOoCNn9Db3zW2lbbc0H SPWA== 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=YchjTbmUZaVi0ULNqTgHZF2wR6w+RpluCcQyUJqKBqk=; b=T6j65VMXI9F8zJJEDWVs4iWLQEgjeJ4fZtwPC0vgCtVVAXc0Cxlla84qbXh38f5r55 3VLamm9Hle0tk//G45YpuVVQka8YprhPR3FNVJtk2abFezT34I0wzERpp/iZlwQ7dZoR 5XTaYcQjNsEc/WK4JOlxtNxLIBd3wDJmE9iqU0EHNkL+zWkQw16wYu+hp5AqPyjTRoz3 8p33W1S5Byrti1frlpL6ZWl9W7f0Vc3HM7UE3BGk/0j/+TGwKuC2Co0bn9u8EhXFbD07 iTcYMX19cRBTrCkv531RbRtzBGIVV/z+SpzBZL5vv34rVNT+qfSw1n8iJ13UIv9sRYV6 VSHQ== X-Gm-Message-State: APjAAAWgYmVGgI68h8IFhV9oXuqaU1FzWz1QfpOG+ucxjG24NUN6dwgB LLSo9Y6rJDICxSGD0BEF06xur3x8 X-Google-Smtp-Source: APXvYqyN/3Q+/Fiv4pD340UA6GsjuWdwErTsL4go/SrEpMXVqbOnjW2ju/wiAJ2usePJanEFG/q58Q== X-Received: by 2002:a05:600c:2215:: with SMTP id z21mr1246374wml.55.1579906123615; Fri, 24 Jan 2020 14:48:43 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08bbf.dynamic.kabel-deutschland.de. [188.192.139.191]) by smtp.gmail.com with ESMTPSA id z25sm8977594wmf.14.2020.01.24.14.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2020 14:48:43 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 24 Jan 2020 23:48:28 +0100 Message-Id: <20200124224833.17579-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200123160832.2020-1-andreas.rheinhardt@gmail.com> References: <20200123160832.2020-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/12] avformat/av1, avc, hevc: Remove av_freep() 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" ff_av1_filter_obus_buf() and ff_avc_parse_nal_units_buf() both have a pointer-to-pointer parameter which they use to pass a newly allocated buffer to the caller. And both functions freed what this pointer points to before overwriting it. But no caller of these functions used this feature, but some had to initialize the pointer just because of this. So remove it and update the documentation of ff_av1_filter_obus_buf() wrt this fact. ff_hevc_annexb2mp4_buf in contrast did not free the pointer. This has been documented, too. Signed-off-by: Andreas Rheinhardt --- libavformat/av1.c | 1 - libavformat/av1.h | 1 + libavformat/avc.c | 3 +-- libavformat/hevc.h | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/av1.c b/libavformat/av1.c index 80c049f62f..07b399efcc 100644 --- a/libavformat/av1.c +++ b/libavformat/av1.c @@ -82,7 +82,6 @@ int ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out, int *size) memset(buf + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); - av_freep(out); *out = buf; *size = len; diff --git a/libavformat/av1.h b/libavformat/av1.h index acba12612c..52d0814e86 100644 --- a/libavformat/av1.h +++ b/libavformat/av1.h @@ -68,6 +68,7 @@ int ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size); * * @return 0 in case of success, a negative AVERROR code in case of failure. * On failure, out and size are unchanged + * @note *out will be treated as unintialized on input and will not be freed. */ int ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out, int *size); diff --git a/libavformat/avc.c b/libavformat/avc.c index e4e82e1864..cd15ac3cdb 100644 --- a/libavformat/avc.c +++ b/libavformat/avc.c @@ -101,7 +101,6 @@ int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size) ff_avc_parse_nal_units(pb, buf_in, *size); - av_freep(buf); *size = avio_close_dyn_buf(pb, buf); return 0; } @@ -109,7 +108,7 @@ int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size) int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len) { AVIOContext *sps_pb = NULL, *pps_pb = NULL, *sps_ext_pb = NULL; - uint8_t *buf = NULL, *end, *start = NULL; + uint8_t *buf, *end, *start; uint8_t *sps, *pps, *sps_ext; uint32_t sps_size = 0, pps_size = 0, sps_ext_size = 0; int ret, nb_sps = 0, nb_pps = 0, nb_sps_ext = 0; diff --git a/libavformat/hevc.h b/libavformat/hevc.h index bb144397c0..0f56325c1c 100644 --- a/libavformat/hevc.h +++ b/libavformat/hevc.h @@ -73,6 +73,7 @@ int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in, * parameter set NAL units shall be written, may be NULL * @return 0 in case of success, a negative value corresponding to an AVERROR * code in case of failure + * @note *buf_out will be treated as uninitialized on input and won't be freed. */ int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, int *size, int filter_ps, int *ps_count);