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 23744450CB for ; Thu, 5 Jan 2023 21:49:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8F29868BD96; Thu, 5 Jan 2023 23:49:09 +0200 (EET) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 877E168BD84 for ; Thu, 5 Jan 2023 23:49:03 +0200 (EET) Received: by mail-wm1-f50.google.com with SMTP id p1-20020a05600c1d8100b003d8c9b191e0so2365708wms.4 for ; Thu, 05 Jan 2023 13:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=W/+h/1Bfdw0Cnx8d+tnWRVRkwbrD3/mgZJbwwVQWbTk=; b=inVxJ/eLQD0S53T2dDCp6frH7QpdzqPPB4ftnS9IahtPLbWwIg5KNQgSQ5xSSYfzKf b8dK0rOy63zp0b4B+XwINiSihuia2atLcGmdOIQZMlPGhYGrTqaB3ze+MvSA+j2Q1k+O f/FGtBh1vgJMir9fVnN42UpPsGt2ZwtYT35R5yB1twdh6YjO+si1W8Ezmh7NpbGB4ZzW 09mDDHE0rnuEk4/XKSl/+XhEgrjMyA/ssEjt3HsCScPz2hX84FUcn1kY3LWeEINhE2lc 1O9miJFQY8az4HZE8sp2TFqHuH0BJGe9/9pRUgNRVkvcVnhiPMmc6m3xCKtK8bwxzX+g AWKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W/+h/1Bfdw0Cnx8d+tnWRVRkwbrD3/mgZJbwwVQWbTk=; b=AMAjtn2N9qA6RFpkJpEXv81Dz1XIYCWOrlhYSrZmDKr9qMQjX3ew6k7Rrn4KiHa1EL bUI82GIsW9OZBsRGz25cp7MTTuluvM6o3N1iIzsVxASm+di6EsoipX92kmWxAtBui6C3 UgMBtAPcuwWgcz/iDynqOIyyR+EZKFIcZgdDnyOB9ILOqYOBWiwyVgIB1mucPhcrhUvd phpREaOJ5EeiCjnt5ewds6hLblOnQ0IkoegQuuP5bxgJAoS9TdZgsHGnVehbZDEjj3rd mGn+z5a61HC0amnqKjLbOAAkTg5VY/XRB3dNNTmPmtc/wVEzyvEyi7v4zVWsdZS+6dG7 LPgw== X-Gm-Message-State: AFqh2kpKOjiQ5G1pjgte5SJ3dwfwzsx5y9OgDIerYaaPej+J3aI46Jl0 e28wuTVtvZ5KfiVPlSbJcObX4dTVvYS+7iQ7 X-Google-Smtp-Source: AMrXdXusmyWrJTbjbSSleBAj+9QMXro5AwG/ppegH+q0xHy0Bh7k4ZFf+FOLwzZThJnnOif6EVN5NA== X-Received: by 2002:a05:600c:35c4:b0:3d9:8635:a90a with SMTP id r4-20020a05600c35c400b003d98635a90amr24481191wmq.23.1672955342757; Thu, 05 Jan 2023 13:49:02 -0800 (PST) Received: from [192.168.0.14] (cpc91224-cmbg18-2-0-cust209.5-4.cable.virginm.net. [81.106.228.210]) by smtp.gmail.com with ESMTPSA id n9-20020a05600c4f8900b003d96b8e9bcasm4375399wmq.32.2023.01.05.13.49.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Jan 2023 13:49:02 -0800 (PST) Message-ID: Date: Thu, 5 Jan 2023 21:48:38 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20230105161416.194463-1-quinkblack@foxmail.com> From: Mark Thompson In-Reply-To: Subject: Re: [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 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 05/01/2023 16:14, Zhao Zhili wrote: > 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(-) Rest of series looks sensible to me. This doesn't have anything to do with metadata, though? IMO make a new BSF (extractlayer?) for this; the amount of boilerplate is quite small. > 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; > + } What is this change doing? Does the VPS also need to be edited to fix the layer references? (The intended input presumably has a VPS saying there are two layers which are both included, but after this change there aren't.) > + > + 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; > + } > + } Not required, but some error messages for bad cases would be nice - you can know from the VPS if the asked-for layer doesn't exist at all and stop early, and you can know later that there was no output and warn the user about it (bonus points if you also tell them which layers are present!). > + > // 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 } > }; Thanks, - Mark _______________________________________________ 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".