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 BE780442E6 for ; Thu, 5 Jan 2023 08:15:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 09EEF68BCE6; Thu, 5 Jan 2023 10:14:51 +0200 (EET) Received: from out203-205-221-202.mail.qq.com (out203-205-221-202.mail.qq.com [203.205.221.202]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A691C68B752 for ; Thu, 5 Jan 2023 10:14:43 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1672906480; bh=ppcE7V+fIq3/Lx1xE28sEjSpaYVVLHD+gFerPaVzeY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N9cfETqxcnT2SHVaisvz4EsJ8Y7cjmMh2WJ8W2w/B4wbVmmvYVTNNl5Mojs/awc8a JZYN1yrzgxgMDtO0DrxiJlpL6YV/pNAX/yAhonQwyPyG1Ey1u8OJtMKlb2hOtAqXnj 6PrxEor7FAeqDidn0LYbGKcelhMpW8mfCuraW0mY= Received: from localhost.localdomain ([59.37.125.102]) by newxmesmtplogicsvrsza2-0.qq.com (NewEsmtp) with SMTP id 39F0DCCA; Thu, 05 Jan 2023 16:14:31 +0800 X-QQ-mid: xmsmtpt1672906474ts0ppfxpk Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjpTM4SEa2iYd6Zi1Ffc16NEIf+47I+OQXHtbXzqjAXzIJ6yBkDt jlc3cR+19GXxp7tGiwvswDIhBGVrkJWTojVDIfSn/ANk2PXvsrunfOepqe6b8QhWSWuOsVkN3rW9 OdzSMF+B0UyK/rA2nU5P/HlZmk2+pP2TxVo35+CPY/gsOe/zIaASWBZ75SbYMiB/XJ2/ewcrWnxM JB3S4x5gg/NDRr+zepL1TzRSpbtJ27JPt3DpsEkcLgTAsMFhYL6yJQjBP5qWnS7n9rLPa9ARVU80 W9VWe0+BXuPB0tN22LwjkiP3bAfDKA7yRh8vVr98gOT/6iy/BGPLuuCgJIerMZ/52qzzthiHN/Bu IGYM+jgyu6DB5nMVmPZz9f8tnE7MSf4PFgnXxfn3k8Z6/Vj3muX2HZniaqmi93g9U5bo8Z4QxPnw h64wc6T+Dkn3TUJHiIntlYWdVcXc3/GaA42IAI7GM6VcAfZN3LrhzvlqnFFf0LsD2jz1DkT0L12B MB7GswLsngub8oNrFtKyxyONHXNvCZqFlAj4ek88baA2AgrFTshE2hMoUyDyIXDH0gIjwaT+bE3i IMHnLsL+tbm/hmTDEbXDcKETvFtSVW+LxWybJs3KDZenp9QU7dFjfOitHlD3pyRnUg3uVKWL1fhn 5nPI3ksZ8pdG5YECl7puS94DtEJC/+M4WEISS143hu7bZdAjLQmgW8ad0t4I9b7YTYYbcclMjmQw r8BqYdT70JxO7sztNrezGfvww3Q9yh8r59H9G2Ibb8RUEGJo8X8005MJAWeGHWcq/kuxBFi/Rcfj sQkMGKj3yCwZ3A3gx8o5dI7/I7GH5+XQNIPDvkbJLEJGJxEqQ3NjqzGl1W2EWQwpmlsSpV7lbRHb d7P2H73F3p4ZyrujH7Yg4335aSSLqFWKmU+s3DlJdwzKKovWRGxtjAInIEiTKRPDv5Xn4KEmLUi0 Jx7zatcQMamgqRySEf+Qg+b9h2DR2IaAPkRLYu4ypRvcifd7KaCVebuwD8lvug From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Jan 2023 00:14:16 +0800 X-OQ-MSGID: <20230105161416.194463-5-quinkblack@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230105161416.194463-1-quinkblack@foxmail.com> References: <20230105161416.194463-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [RFC PATCH 4/4] avcodec/h265_metadata_bsf: add nuh_layer_id option 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: Zhao Zhili 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: From: Zhao Zhili Extract NALUs with the specified nuh_layer_id and rewrite as base layer. For example, to extract alpha layer with nuh_layer_id equal to 1: ./ffmpeg -i alpha.mp4 \ -an -c:v copy \ -bsf:v hevc_mp4toannexb,hevc_metadata=nuh_layer_id=1 \ alpha.hevc --- doc/bitstream_filters.texi | 5 +++++ libavcodec/h265_metadata_bsf.c | 25 +++++++++++++++++++++++++ libavcodec/version.h | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index c63c20370f..8cb5bee644 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -443,6 +443,11 @@ The argument must be the name of a level (for example, @samp{5.1}), a or the special name @samp{auto} indicating that the filter should attempt to guess the level from the input stream properties. +@item nuh_layer_id + +Extract NALUs with the specified nuh_layer_id and rewrite as base layer. +All other NALUs are dropped except VPS. + @end table @section hevc_mp4toannexb diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c index 6787bd14a1..fdaab27186 100644 --- a/libavcodec/h265_metadata_bsf.c +++ b/libavcodec/h265_metadata_bsf.c @@ -62,6 +62,8 @@ typedef struct H265MetadataContext { int level; int level_guess; int level_warned; + + int nuh_layer_id; } H265MetadataContext; @@ -328,6 +330,25 @@ static int h265_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, H265MetadataContext *ctx = bsf->priv_data; int err, i; + if (ctx->nuh_layer_id >= 0) { + H265RawNALUnitHeader *header; + for (i = 0; i < au->nb_units; i++) { + if (au->units[i].type == HEVC_NAL_VPS) { + H265RawVPS *vps = au->units[i].content; + vps->vps_extension_flag = 0; + continue; + } + + header = au->units[i].content; + if (header->nuh_layer_id != ctx->nuh_layer_id) { + ff_cbs_delete_unit(au, i); + i--; + continue; + } + header->nuh_layer_id = 0; + } + } + // If an AUD is present, it must be the first NAL unit. if (au->nb_units && au->units[0].type == HEVC_NAL_AUD) { if (ctx->aud == BSF_ELEMENT_REMOVE) @@ -478,6 +499,10 @@ static const AVOption h265_metadata_options[] = { { LEVEL("8.5", 255) }, #undef LEVEL + { "nuh_layer_id", "Extract NALUs with the specified nuh_layer_id and rewrite as base layer", + OFFSET(nuh_layer_id), AV_OPT_TYPE_INT, + { .i64 = -1 }, -1, 62, FLAGS }, + { NULL } }; diff --git a/libavcodec/version.h b/libavcodec/version.h index 15f7c3fe3d..734a4fe097 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVCODEC_VERSION_MINOR 56 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 2.25.1 _______________________________________________ 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".