From patchwork Tue Dec 10 21:59:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 16709 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 21A1144A835 for ; Wed, 11 Dec 2019 00:00:39 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08FF068B692; Wed, 11 Dec 2019 00:00:39 +0200 (EET) 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 C6D3A68B1DD for ; Wed, 11 Dec 2019 00:00:34 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id d73so1625061wmd.1 for ; Tue, 10 Dec 2019 14:00:34 -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=RLm6b7emV7pA39Sx7cojOwxAfgPCKt1mvA7P3EoNT0Y=; b=uKTAmZ1saEYi9/MmocIjrd3mwyTSo6V1MfWbLqX2wq/U/FujYEG114IHTF5Qd6LVdW FkeQmBuE64DpDQqnR8T4emPphVYkNp47YefDAaocTmYcegOH3nxNX/bDYggwZ8KvDEOb EE67vXLOHqqbf8I4olQkDVU2P2nOroXnJzjkrOXp2XWrGTBqIm/pzv6fsnXBVaheh1f5 zozWOcCtP/I5WC6+y6Y7zcTVVztgaGbb4RIa/KRe4dRaQNTErYI/1EmMimSc8XDeSqrH e1A3tX0O25TxoZP0Ub/pRsSmr9hGBIKGuLJAVewxLTgjqzKR32p5sF0vsk7HyRnxr8HC pcIA== 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=RLm6b7emV7pA39Sx7cojOwxAfgPCKt1mvA7P3EoNT0Y=; b=DHpXACV0PKm+dHrRW8pq1f4c65tJzVCvgY8x1UEoYcv8hfxMcTpzj3eyo+GNu+vKYy IOI+mGCqPqlFCKrFc672xnJn0NSlEl9wuLtBKhPabyHAWzh9XgKR58uTKxWU4JIzBfT3 HTBasfrFVO/KVLlOT4l9vfxAbQBhrjQit/bSQYUvIJEnGZtQy6aiuUXCgxDE8xFvTW5g 8wB+khM50IGEpmetUDPRbO/uXXTEV+duEfgyhsZs2CqG4S/MgudlXPhDU0OOyj7CsgIu cJBH00RmE6im2zO/7J8Us/4lj/MyRkoBEBKMy+JMj06JOjpVODZc3CF0eGWgZgdKJSE9 gwDg== X-Gm-Message-State: APjAAAUHevGnamAlvoQWLoBBf1zEzJWtGZsGYYeLaIrkGjTP/eRvVpjQ 5TQ8rArefT0xJQH7BREpBimF53qt X-Google-Smtp-Source: APXvYqyFcQYYut70ycuESuq31UeS/Bc6bSwJMqLoGFkwDG9y3gSOLqn57Z/6fXFqsIPC2ROUu4Aicg== X-Received: by 2002:a05:600c:54b:: with SMTP id k11mr7474302wmc.63.1576015233891; Tue, 10 Dec 2019 14:00:33 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08e23.dynamic.kabel-deutschland.de. [188.192.142.35]) by smtp.gmail.com with ESMTPSA id n129sm3876381wmb.1.2019.12.10.14.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 14:00:33 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Dec 2019 22:59:54 +0100 Message-Id: <20191210215955.11178-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191210215955.11178-1-andreas.rheinhardt@gmail.com> References: <20191210215955.11178-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/11] avformat: Don't free old extradata before ff_allocate/get_extradata 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" These functions already free it themselves before they allocate the new extradata. Signed-off-by: Andreas Rheinhardt --- libavformat/avidec.c | 2 -- libavformat/cafdec.c | 7 ++----- libavformat/concatdec.c | 4 ---- libavformat/flic.c | 1 - libavformat/flvdec.c | 1 - libavformat/matroskaenc.c | 1 - libavformat/mov.c | 4 ---- libavformat/nuv.c | 4 ---- libavformat/oggparseogm.c | 1 - libavformat/oggparseopus.c | 1 - libavformat/riffdec.c | 2 -- libavformat/rtpdec_latm.c | 1 - libavformat/rtpdec_mpeg4.c | 2 +- libavformat/rtpdec_qdm2.c | 2 +- libavformat/rtpdec_svq3.c | 4 ---- libavformat/utils.c | 1 - libavformat/wavdec.c | 1 - libavformat/xmv.c | 2 -- 18 files changed, 4 insertions(+), 37 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 21871feb8d..ae0c227bb9 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -770,7 +770,6 @@ FF_ENABLE_DEPRECATION_WARNINGS st->codecpar->extradata_size = size - 10 * 4; if (st->codecpar->extradata) { av_log(s, AV_LOG_WARNING, "New extradata in strf chunk, freeing previous one.\n"); - av_freep(&st->codecpar->extradata); } ret = ff_get_extradata(s, st->codecpar, pb, st->codecpar->extradata_size); @@ -932,7 +931,6 @@ FF_ENABLE_DEPRECATION_WARNINGS if (size<(1<<30)) { if (st->codecpar->extradata) { av_log(s, AV_LOG_WARNING, "New extradata in strd chunk, freeing previous one.\n"); - av_freep(&st->codecpar->extradata); } if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0) return ret; diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 85356ec439..d0f942f3e4 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -135,7 +135,6 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size) return AVERROR_INVALIDDATA; } - av_freep(&st->codecpar->extradata); if ((ret = ff_alloc_extradata(st->codecpar, ALAC_HEADER)) < 0) return ret; @@ -175,10 +174,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size) return AVERROR_PATCHWELCOME; } avio_skip(pb, size); - } else { - av_freep(&st->codecpar->extradata); - if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0) - return ret; + } else if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0) { + return ret; } return 0; diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index b80294efbf..e826821241 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -171,10 +171,6 @@ static int copy_stream_props(AVStream *st, AVStream *source_st) if (st->codecpar->codec_id || !source_st->codecpar->codec_id) { if (st->codecpar->extradata_size < source_st->codecpar->extradata_size) { - if (st->codecpar->extradata) { - av_freep(&st->codecpar->extradata); - st->codecpar->extradata_size = 0; - } ret = ff_alloc_extradata(st->codecpar, source_st->codecpar->extradata_size); if (ret < 0) diff --git a/libavformat/flic.c b/libavformat/flic.c index 4ba72fb037..615d6b25c5 100644 --- a/libavformat/flic.c +++ b/libavformat/flic.c @@ -175,7 +175,6 @@ static int flic_read_header(AVFormatContext *s) avio_seek(pb, 12, SEEK_SET); /* send over abbreviated FLIC header chunk */ - av_freep(&st->codecpar->extradata); if ((ret = ff_alloc_extradata(st->codecpar, 12)) < 0) return ret; memcpy(st->codecpar->extradata, header, 12); diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 03b0c22f9d..7c3e5b06c6 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -799,7 +799,6 @@ static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size) if (!size) return 0; - av_freep(&st->codecpar->extradata); if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0) return ret; st->internal->need_context_update = 1; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 570f361351..469b604de6 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2264,7 +2264,6 @@ static int mkv_check_new_extra_data(AVFormatContext *s, AVPacket *pkt) return ret; if (!output_sample_rate) output_sample_rate = track->sample_rate; // Space is already reserved, so it's this or a void element. - av_freep(&par->extradata); ret = ff_alloc_extradata(par, side_data_size); if (ret < 0) return ret; diff --git a/libavformat/mov.c b/libavformat/mov.c index dd903f71a0..890c6e85b8 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1838,7 +1838,6 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->codecpar->codec_id == AV_CODEC_ID_QDMC || st->codecpar->codec_id == AV_CODEC_ID_SPEEX) { // pass all frma atom to codec, needed at least for QDMC and QDM2 - av_freep(&st->codecpar->extradata); ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size); if (ret < 0) return ret; @@ -1905,7 +1904,6 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_log(c->fc, AV_LOG_WARNING, "ignoring multiple glbl\n"); return 0; } - av_freep(&st->codecpar->extradata); ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size); if (ret < 0) return ret; @@ -1938,7 +1936,6 @@ static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; avio_seek(pb, 6, SEEK_CUR); - av_freep(&st->codecpar->extradata); ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size - 7); if (ret < 0) return ret; @@ -1966,7 +1963,6 @@ static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR_INVALIDDATA; avio_skip(pb, 40); - av_freep(&st->codecpar->extradata); ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size - 40); if (ret < 0) return ret; diff --git a/libavformat/nuv.c b/libavformat/nuv.c index 612f845b4b..bef0ae4860 100644 --- a/libavformat/nuv.c +++ b/libavformat/nuv.c @@ -83,10 +83,6 @@ static int get_codec_data(AVFormatContext *s, AVIOContext *pb, AVStream *vst, avio_skip(pb, 6); size = PKTSIZE(avio_rl32(pb)); if (vst && subtype == 'R') { - if (vst->codecpar->extradata) { - av_freep(&vst->codecpar->extradata); - vst->codecpar->extradata_size = 0; - } if ((ret = ff_get_extradata(NULL, vst->codecpar, pb, size)) < 0) return ret; size = 0; diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c index f25efb8c2a..469b229995 100644 --- a/libavformat/oggparseogm.c +++ b/libavformat/oggparseogm.c @@ -109,7 +109,6 @@ ogm_header(AVFormatContext *s, int idx) size -= 52; if (bytestream2_get_bytes_left(&p) < size) return AVERROR_INVALIDDATA; - av_freep(&st->codecpar->extradata); if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0) return ret; bytestream2_get_buffer(&p, st->codecpar->extradata, st->codecpar->extradata_size); diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c index 38908dc2dd..56b53e74e8 100644 --- a/libavformat/oggparseopus.c +++ b/libavformat/oggparseopus.c @@ -63,7 +63,6 @@ static int opus_header(AVFormatContext *avf, int idx) /*gain = AV_RL16(packet + 16);*/ /*channel_map = AV_RL8 (packet + 18);*/ - av_freep(&st->codecpar->extradata); if ((ret = ff_alloc_extradata(st->codecpar, os->psize)) < 0) return ret; diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index 5523b31adc..070c42eee3 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -145,7 +145,6 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, size -= 22; } if (cbSize > 0) { - av_freep(&par->extradata); if (ff_get_extradata(s, par, pb, cbSize) < 0) return AVERROR(ENOMEM); size -= cbSize; @@ -158,7 +157,6 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, int nb_streams, i; size -= 4; - av_freep(&par->extradata); if (ff_get_extradata(s, par, pb, size) < 0) return AVERROR(ENOMEM); nb_streams = AV_RL16(par->extradata + 4); diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index de18e81ea9..104a00af18 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -115,7 +115,6 @@ static int parse_fmtp_config(AVStream *st, const char *value) ret = AVERROR_PATCHWELCOME; goto end; } - av_freep(&st->codecpar->extradata); ret = ff_alloc_extradata(st->codecpar, (get_bits_left(&gb) + 7)/8); if (ret < 0) { goto end; diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c index 45569c18d1..34c7950bcc 100644 --- a/libavformat/rtpdec_mpeg4.c +++ b/libavformat/rtpdec_mpeg4.c @@ -113,7 +113,7 @@ static int parse_fmtp_config(AVCodecParameters *par, const char *value) { /* decode the hexa encoded parameter */ int len = ff_hex_to_data(NULL, value), ret; - av_freep(&par->extradata); + if ((ret = ff_alloc_extradata(par, len)) < 0) return ret; ff_hex_to_data(par->extradata, value); diff --git a/libavformat/rtpdec_qdm2.c b/libavformat/rtpdec_qdm2.c index a6a746becb..1eec2da5b4 100644 --- a/libavformat/rtpdec_qdm2.c +++ b/libavformat/rtpdec_qdm2.c @@ -105,7 +105,7 @@ static int qdm2_parse_config(PayloadContext *qdm, AVStream *st, case 4: /* stream with extradata */ if (item_len < 30) return AVERROR_INVALIDDATA; - av_freep(&st->codecpar->extradata); + ret = ff_alloc_extradata(st->codecpar, 26 + item_len); if (ret < 0) { return ret; diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c index 77164dd6f9..ffe21ac4c4 100644 --- a/libavformat/rtpdec_svq3.c +++ b/libavformat/rtpdec_svq3.c @@ -58,10 +58,6 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, len -= 2; if (config_packet) { - - av_freep(&st->codecpar->extradata); - st->codecpar->extradata_size = 0; - if (len < 2 || ff_alloc_extradata(st->codecpar, len + 8)) return AVERROR_INVALIDDATA; diff --git a/libavformat/utils.c b/libavformat/utils.c index bf248aea3b..eb7efeacf7 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -5479,7 +5479,6 @@ int ff_generate_avci_extradata(AVStream *st) if (!size) return 0; - av_freep(&st->codecpar->extradata); if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0) return ret; memcpy(st->codecpar->extradata, data, size); diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index cfaf3d61fe..575c667452 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -220,7 +220,6 @@ static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream **st) avpriv_set_pts_info(*st, 64, 1, (*st)->codecpar->sample_rate); avio_seek(pb, -size, SEEK_CUR); - av_freep(&(*st)->codecpar->extradata); if ((ret = ff_get_extradata(s, (*st)->codecpar, pb, size)) < 0) return ret; diff --git a/libavformat/xmv.c b/libavformat/xmv.c index 7f12956458..0c69d267de 100644 --- a/libavformat/xmv.c +++ b/libavformat/xmv.c @@ -397,8 +397,6 @@ static int xmv_process_packet_header(AVFormatContext *s) av_assert0(xmv->video.stream_index < s->nb_streams); if (vst->codecpar->extradata_size < 4) { - av_freep(&vst->codecpar->extradata); - if ((ret = ff_alloc_extradata(vst->codecpar, 4)) < 0) return ret; }