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 178484B95C for ; Thu, 1 Aug 2024 07:59:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 43EB168D056; Thu, 1 Aug 2024 10:59:00 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5361C68D056 for ; Thu, 1 Aug 2024 10:58:54 +0300 (EEST) Authentication-Results: mail0.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=cDWvjkja; dkim-atps=neutral Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 04092240DB7; Thu, 1 Aug 2024 09:58:54 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id kk6Nl8WapLnR; Thu, 1 Aug 2024 09:58:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1722499133; bh=v2XGIazxtS8KiYaTU0pgqZ0zMfiDzeRe0qs5vuiSbO4=; h=Subject:From:To:Cc:In-Reply-To:References:Date:From; b=cDWvjkjaG2xY3Jk1LXMyNJJNUWHHG53e7sxARKW8/t946jwrY/adBopxIbKU89nlc OULUYEQS5FLSzaOYDQFomMAoGVMFi27Qn9KLyI+1WRUMArPWVc/D7patgMbXS5vKDz 363Hiv8agPH00AR1aTlm5mVxELHCv9ScYgHznnkZYKaLvAJzD2luOy80j05fLVdRSS Vm54EDdo+Sek+UatJFucUS0jEH+WPp2ioEF7Mjjt5WppOzszLUc3G6B/PSQwPAngS7 S9vMOxMKvmn2gzoD4XoH4u3pDh4muAD4hcq1Jqr++VX3xUjY+5022+h3A/R8LcOHx+ ETNYjN7FVX0hQ== Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 3360D240695; Thu, 1 Aug 2024 09:58:53 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id 109A81601B9; Thu, 1 Aug 2024 09:58:53 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20240709190547.99246-1-joshua.allmann@gmail.com> References: <20240709190547.99246-1-joshua.allmann@gmail.com> Mail-Followup-To: FFmpeg development discussions and patches , Josh Allmann Date: Thu, 01 Aug 2024 09:58:53 +0200 Message-ID: <172249913303.21344.17598597604771690214@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avcodec/h264_mp4toannexb: Prepend SPS/PPS to buffering period SEI 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 Cc: Josh Allmann Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Quoting Josh Allmann (2024-07-09 21:05:47) > Encoders may emit a buffering period SEI without a corresponding > SPS/PPS if the SPS/PPS is carried out-of-band, eg with avcc. > > During Annex B conversion, this may result in the SPS/PPS being > inserted *after* the buffering period SEI but before the IDR NAL. > > Since the buffering period SEI references the SPS, the SPS/PPS > needs to come first. > --- > > Notes: > v2: Updated FATE test refs > > libavcodec/bsf/h264_mp4toannexb.c | 13 +++++++++++++ > tests/ref/fate/h264-bsf-mp4toannexb | 2 +- > tests/ref/fate/h264_mp4toannexb_ticket2991 | 18 +++++++++--------- > tests/ref/fate/segment-mp4-to-ts | 12 ++++++------ > 4 files changed, 29 insertions(+), 16 deletions(-) > > diff --git a/libavcodec/bsf/h264_mp4toannexb.c b/libavcodec/bsf/h264_mp4toannexb.c > index 92af6a6881..6607f1e91a 100644 > --- a/libavcodec/bsf/h264_mp4toannexb.c > +++ b/libavcodec/bsf/h264_mp4toannexb.c > @@ -363,6 +363,19 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *opkt) > if (!new_idr && unit_type == H264_NAL_IDR_SLICE && (buf[1] & 0x80)) > new_idr = 1; > > + /* If this is a buffering period SEI without a corresponding sps/pps > + * then prepend any existing sps/pps before the SEI */ > + if (unit_type == H264_NAL_SEI && buf[1] == 0 && !sps_seen && !pps_seen) { That 0 should be SEI_TYPE_BUFFERING_PERIOD, right? > + if (s->sps_size) { > + count_or_copy(&out, &out_size, s->sps, s->sps_size, PS_OUT_OF_BAND, j); > + sps_seen = 1; > + } > + if (s->pps_size) { > + count_or_copy(&out, &out_size, s->pps, s->pps_size, PS_OUT_OF_BAND, j); > + pps_seen = 1; > + } Is there a reason to insert the PPS? IIUC only the SPS is needed. -- Anton Khirnov _______________________________________________ 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".