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 08BFD42C44 for ; Sun, 29 Jan 2023 12:30:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 14AF568BC80; Sun, 29 Jan 2023 14:30:51 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E3E986808E8 for ; Sun, 29 Jan 2023 14:30:44 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 81BA6E8682 for ; Sun, 29 Jan 2023 13:30:43 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZS0J-pIsWkUN for ; Sun, 29 Jan 2023 13:30:39 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 8A3E0E85CB for ; Sun, 29 Jan 2023 13:30:39 +0100 (CET) Date: Sun, 29 Jan 2023 13:30:39 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20230127211841.59628-1-jpcoiner@gmail.com> Message-ID: References: <20230127211841.59628-1-jpcoiner@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] libavformat/mpegtsenc.c -- correctly re-emit extradata ahead of IDR pictures 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 Fri, 27 Jan 2023, John Coiner wrote: > From: John Coiner > > This is the proposed fix for https://trac.ffmpeg.org/ticket/10148 > > Very sorry to send the same patch 3 times; this time with `git send-email' so it should be legal :) > > --- > libavformat/mpegtsenc.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c > index 48d39e6a7d..6cb398f99c 100644 > --- a/libavformat/mpegtsenc.c > +++ b/libavformat/mpegtsenc.c > @@ -1886,17 +1886,21 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt) > if (extradd && AV_RB24(st->codecpar->extradata) > 1) > extradd = 0; > > - do { > + while (p < buf_end > + && extradd > 0 > + && (state & 0x1f) != 5 // IDR picture > + && (state & 0x1f) != 1 // non-IDR picture > + ) { > p = avpriv_find_start_code(p, buf_end, &state); > av_log(s, AV_LOG_TRACE, "nal %"PRId32"\n", state & 0x1f); > - if ((state & 0x1f) == 7) > + if ((state & 0x1f) == 7) // SPS NAL > extradd = 0; > - } while (p < buf_end && (state & 0x1f) != 9 && > - (state & 0x1f) != 5 && (state & 0x1f) != 1); > - > - if ((state & 0x1f) != 5) > + } > + if ((state & 0x1f) != 5) { > + // Not an IDR picture > extradd = 0; > - if ((state & 0x1f) != 9) { // AUD NAL > + } > + if (extradd > 0) { This does not look right, because AFAIK you always want to insert an AUD unless it is already there. I guess that is why current code works as it is, it assumes if an AUD is already present, then IDR-s are already prefixed with SPS/PPS, and no magic is needed. I wonder if the issue is indeed caused by this: https://patchwork.ffmpeg.org/project/ffmpeg/patch/tencent_EE0E40DE9A569FE5AB454E6E700A2DA79A08@qq.com/ Because if it is, then maybe nothing need to be fixed in the mpegts muxer. Regards, Marton _______________________________________________ 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".