From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id E692B4E585 for ; Tue, 10 Jun 2025 13:39:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 6B59268D2FD; Tue, 10 Jun 2025 16:39:07 +0300 (EEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id C901F68CABE for ; Tue, 10 Jun 2025 16:39:00 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1A99444369 for ; Tue, 10 Jun 2025 13:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1749562740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Pv2nNVVFzFHz6eN0gMtoc4+HYFrDMDMbcSuBXot4NRA=; b=Gm9dmsyhfzAWxCCmaerjt72m8Zb6aZN38i4N9SEi5ukzPCYWYNstCQJ5XJrsn9qUDKuchA P7C7fmbwtHebOTRlqZryQ2TO3IiTO0WeiKQ5iTx9u+/PCgGMejVZ14EREtAkBobTFr/XV4 y8VED0aELgYC1wRoI8fQKxG3uSg78RVZJtP/da3RS+0hBAQ08RBBQNyEwcdl/ZLuiG1koB L2A6os0yzOsl01TXolZsYbDTMEKvNTFOW4taQBZwbCVtxPgaJOZ/731gaUdU201QbYxV5C j81ODt5VbKH1zHHj7udM3eq6+COZrkNNh+ijy2Y5KzD25Lmu2kYeN3vbU4xawQ== Date: Tue, 10 Jun 2025 15:38:59 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250610133859.GU29660@pb2> References: <20250610034528.30157-1-pkoshevoy@gmail.com> MIME-Version: 1.0 In-Reply-To: <20250610034528.30157-1-pkoshevoy@gmail.com> X-GND-State: clean X-GND-Score: -70 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddugddutdekudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdlfedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepieegkedtjeduffejhfetgeejtdegteetgfegtdfhjefgvefhteegkeejtddvhfevnecukfhppeeguddrieeirdeijedruddufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeguddrieeirdeijedruddufedphhgvlhhopehlohgtrghlhhhoshhtpdhmrghilhhfrhhomhepmhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtpdhnsggprhgtphhtthhopedupdhrtghpthhtohepfhhfmhhpvghgqdguvghvvghlsehffhhmphgvghdrohhrgh X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH] avformat/demux: Fix segfault due to avcodec_open2 failure (v2) X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: multipart/mixed; boundary="===============6554376272108398065==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============6554376272108398065== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="IRwg5Vcpx9ekzhpp" Content-Disposition: inline --IRwg5Vcpx9ekzhpp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 09, 2025 at 09:45:28PM -0600, Pavel Koshevoy wrote: > Fixes 'ffprobe 1_poc.mp4' segfault introduced with > commit 0021484d05f9b0f032fa319399de6e24eea0c04f >=20 > codec_close should not assume that the codec_id did not change. > --- > libavformat/demux.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) >=20 > diff --git a/libavformat/demux.c b/libavformat/demux.c > index ecd4f40da9..3749ab67a3 100644 > --- a/libavformat/demux.c > +++ b/libavformat/demux.c > @@ -1292,9 +1292,15 @@ static int codec_close(FFStream *sti) > { > AVCodecContext *avctx_new =3D NULL; > AVCodecParameters *par_tmp =3D NULL; > + const AVCodec *new_codec =3D NULL; > int ret; > =20 > - avctx_new =3D avcodec_alloc_context3(sti->avctx->codec); > + new_codec =3D > + (sti->avctx->codec_id !=3D sti->pub.codecpar->codec_id) ? > + avcodec_find_decoder(sti->pub.codecpar->codec_id) : > + sti->avctx->codec; > + > + avctx_new =3D avcodec_alloc_context3(new_codec); > if (!avctx_new) { > ret =3D AVERROR(ENOMEM); > goto fail; This is not about request_probe but about the mpegts demuxer randomly changeing codec id midstream I belive the patch should be reverted that causes this. I dont think applications expect such mid stream changes either I hope andreas can take a look and correct me if iam missing something but it looks a bit sketchy to me If a codec changes mid stream i belive a new AVStream should be created. It could be a audio stream switches to video or data or subtitle. If any stream as detected initially can become any other type later this complicates user applications and filter graphs Also the management of AVPackets is probably rather non trivial if the stream_index is not enough to identify which decoder it belongs to thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. --IRwg5Vcpx9ekzhpp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaEg1bwAKCRBhHseHBAsP q2OqAJ4zXhfa5o2e+JA9qes2q5/3RuhZRgCffGoUDf+VOdYmttMISUmF7X4pt30= =yb7r -----END PGP SIGNATURE----- --IRwg5Vcpx9ekzhpp-- --===============6554376272108398065== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============6554376272108398065==--