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 96C134914E for ; Wed, 3 Jul 2024 21:05:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6768668D755; Thu, 4 Jul 2024 00:05:41 +0300 (EEST) Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 107B768D755 for ; Thu, 4 Jul 2024 00:05:34 +0300 (EEST) Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-6bce380eb9bso3492133a12.0 for ; Wed, 03 Jul 2024 14:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720040731; x=1720645531; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=s6tw5Sdb1RbXNMBunchYznlwv33Hm+z8mKNqBRFSLwM=; b=iC/0v6pcpoZ7VjFuvPGSeg//c3KBnKJctrpYUH7Ap7idbQ1zx8vJ4sxpSt+v0uZISX Dxe3ZE5/mGglO0uu9y7+4qihI1V7JSASp+ERey0cHdaQOysrpYxo5B+C4/I+RnMvb/+4 c+H7fB/5RfTZYQXJEzAqy7T1o9YyYrUdikwcEXOJOBcO/NPbHGneRnkKWwJ43Xh0Fx0/ TstpTSfSTB2KaRxPZapSxiGnEwfOQc2rjIlPZ6QaV7XgPFhs/j5BcwmXKTBW9KQY6aNM KaAPWiUu3BEIF7Gd48/eOTx34oyfVKtsHIKHgZ+ERaXFd8AhMzTSONbgeWvdEED1UXYT u59A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720040731; x=1720645531; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=s6tw5Sdb1RbXNMBunchYznlwv33Hm+z8mKNqBRFSLwM=; b=fAtdO78AbfVvhHMms81OcgNroTI6u3qeeCKJoYVNOjtlQwWE+S28L9mkl5OyADL5xh FgTWVccbWfdDKNYWADXDqSVG/BmFtNkIRz7rez2ZObDZwYqoaZoZM2ujF2GLEMIRP3PQ T4lkJ63Svd/m8iDScVPVZ/Z4FLLTzX/WMr72kGimxMSI63R7Nma1UNLHGIqLY9sedbb0 xdN1RjSXexmV4mfRI/CtN60on9n9vqssG/D6wx7zUaiko05wYYRtwiMhRSINSvJm2s/T eowcVee41+KpOkA8Dkdn9DTikek0woykR+IWEfQtuOvg6jFtNGSznsDw4e19oTvSjyBF 0Tcw== X-Gm-Message-State: AOJu0Yz6TR/kyenAjEhFq3wsDBZsDuBTpqS76tAu2K6AH3q5IHCd+OYB VwWQI/b+Zw6FBdNemCSGaJedBpWtbBfRj6G1RSpijQyhcTNp0PrKP/Qmng== X-Google-Smtp-Source: AGHT+IF4pcQX9HdvGtmsQepl3JUyWwEh9Zk2iZ8gD1QVH8h0ez2JjFoIaDCFL+01HdgPUGrzxjuYbA== X-Received: by 2002:a05:6a20:a106:b0:1bd:22e0:f725 with SMTP id adf61e73a8af0-1bef611b976mr17856393637.29.1720040731422; Wed, 03 Jul 2024 14:05:31 -0700 (PDT) Received: from gaia.lan (syn-076-176-004-046.res.spectrum.com. [76.176.4.46]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-72c6a31f5dfsm8448170a12.23.2024.07.03.14.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 14:05:30 -0700 (PDT) From: Josh Allmann To: ffmpeg-devel@ffmpeg.org Date: Wed, 3 Jul 2024 14:05:06 -0700 Message-Id: <20240703210506.75963-1-joshua.allmann@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 Subject: [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: 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. --- libavcodec/bsf/h264_mp4toannexb.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) { + 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; + } + } + /* prepend only to the first type 5 NAL unit of an IDR picture, if no sps/pps are already present */ if (new_idr && unit_type == H264_NAL_IDR_SLICE && !sps_seen && !pps_seen) { if (s->sps_size) -- 2.39.2 _______________________________________________ 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".