From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 02E9B49892 for ; Sun, 21 Apr 2024 15:52:49 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9316068CFF4; Sun, 21 Apr 2024 18:52:46 +0300 (EEST) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AA67D68C4DD for ; Sun, 21 Apr 2024 18:52:39 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1e36b7e7dd2so30652865ad.1 for ; Sun, 21 Apr 2024 08:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713714757; x=1714319557; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=bLUuqysIFoGSgvylgwfmaDr1CXXbA+g1iy+DGtLyM/Q=; b=fvFwHev3zJM+APK07IuaiC6ZEXgIiSXJiQJ6/NfQ7R6CLdjrSkyvw5/PgXL1ZiWXGe lIZSjgbRBmjdg0o8eN6irQqJMpDulm2nr5WrZwuD1UKwfLfyiCEFXv9Dr8Q17VWdBv5v fLyBY7IWn12CoEDk882p1uia/sU2ySvyYgx1dBFTwMBpKpqaI9KCiPGyTghYQ4U355CP fBnfpPKaYkOjH8idAwsOAYsAjHXPKUU3Q7+ZpeRjMRSs0K5DR1A0dxS5W6cCOdxXDLR0 /lBFITyxOiakGi43Suu+MmM0r4Dv4J/o6OR8F3zOp96W/azpow1o02NRjpeS6z1pXTb0 7xXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713714757; x=1714319557; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bLUuqysIFoGSgvylgwfmaDr1CXXbA+g1iy+DGtLyM/Q=; b=tjrmHuW+i2fM9N5cqDFGtUXfAf7E4GpAW9okKXlIWzUmM5qB/EkKbxngYS9TACJ6pP ONdCnG1O84PIU86axoY0u5yxkV2h8u4K3Jc16gZqCF+PNktX7XUJ7cPwSB6EYCGsYYA+ 93HExveaAnUAnWmh7MZW+oxfP7scABVriWTIV/x/kdzHPUIUR4wOFDcGHiLOKqgGVZQm /DzVEHgg0QzYCStFttrDivbm6/b509PhUJK9ZJhrSg1KFmQ3riLopas5y0R5Jv06Vnix QI7xFlYQm0IRGBMJXbtlPdjohNPw52GlPCXP5teF82o0qyZy3RfLmWWA023OaknFcWDq 22zw== X-Gm-Message-State: AOJu0YzUEwQ+4IrgIn1FoBFA7qqWTnYFadvu2OvPSX1UJ8xvHrESmeuC 5dwjnFF28sOp3bIVsNphsyb9QbEaIzaF1IlPuZCLxZHuXL3g5SrDPusqGg== X-Google-Smtp-Source: AGHT+IEV7N9YnlpuguIP50Psq/arRKMudT1aO3go1EcVSqso0JtW+NJcWNd0/Ca+qqoyH0QkfAL7+w== X-Received: by 2002:a17:902:cec4:b0:1e2:74af:e166 with SMTP id d4-20020a170902cec400b001e274afe166mr9102649plg.63.1713714756766; Sun, 21 Apr 2024 08:52:36 -0700 (PDT) Received: from [192.168.0.10] ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id t6-20020a170902e84600b001e604438791sm6462614plg.156.2024.04.21.08.52.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 21 Apr 2024 08:52:36 -0700 (PDT) Message-ID: Date: Sun, 21 Apr 2024 12:52:41 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20240420234312.36464-2-jamrial@gmail.com> <20240421151851.1165-1-jamrial@gmail.com> Content-Language: en-US From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 2/2 v2] avformat/demux: extract extradata from packets when context update is requested 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 4/21/2024 12:32 PM, Andreas Rheinhardt wrote: > James Almer: >> If the demuxer doesn't set extradata in the stream's codecpar, a >> need_context_update request will delete the previously extracted extradata in >> the stream's internal AVCodecContext. >> As we can't ensure the old extradata is valid for the stream in its post >> context update request state, try to get extradata from the new packet instead >> of attempting to preserve the old in some form. >> >> Signed-off-by: James Almer >> --- >> libavformat/demux.c | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/libavformat/demux.c b/libavformat/demux.c >> index abfd5fee7d..39aa1cd4e3 100644 >> --- a/libavformat/demux.c >> +++ b/libavformat/demux.c >> @@ -1319,6 +1319,8 @@ fail: >> return ret; >> } >> >> +static int extract_extradata(FFFormatContext *si, AVStream *st, const AVPacket *pkt); >> + >> static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) >> { >> FFFormatContext *const si = ffformatcontext(s); >> @@ -1373,6 +1375,11 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) >> return ret; >> } >> >> + if (!sti->avctx->extradata && >> + (ret = extract_extradata(si, st, pkt)) < 0) { >> + av_packet_unref(pkt); >> + return ret; >> + } >> sti->codec_desc = avcodec_descriptor_get(sti->avctx->codec_id); >> >> sti->need_context_update = 0; >> @@ -2470,6 +2477,8 @@ static int extract_extradata(FFFormatContext *si, AVStream *st, const AVPacket * >> if (ret < 0) >> return ret; >> >> + av_bsf_flush(sti->extract_extradata.bsf); >> + >> ret = av_bsf_send_packet(sti->extract_extradata.bsf, pkt_ref); >> if (ret < 0) { >> av_packet_unref(pkt_ref); >> @@ -3090,7 +3099,8 @@ find_stream_info_err: >> err = codec_close(sti); >> if (err < 0 && ret >= 0) >> ret = err; >> - av_bsf_free(&sti->extract_extradata.bsf); >> + if (sti->extract_extradata.bsf) >> + av_bsf_flush(sti->extract_extradata.bsf); >> } >> if (ic->pb) { >> FFIOContext *const ctx = ffiocontext(ic->pb); > > This will keep the BSF around for longer than necessary, although only a > tiny minority of demuxers ever set need_context_update at all. It's not exactly a massive context, so i don't think it's a problem. But if you prefer, i could add an FF_INFMT_FLAG_ for this. _______________________________________________ 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".