From patchwork Fri Jan 6 15:52:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 39894 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp958185pzb; Thu, 5 Jan 2023 23:53:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXvXJ3qYXi5BH/5NZVrcPj4pY4Tc6ksjLJ6qgUqAycIapBwNj78UBhq7KHwfhJl0vvRROLi4 X-Received: by 2002:a17:906:2a49:b0:812:d53e:11f6 with SMTP id k9-20020a1709062a4900b00812d53e11f6mr45172541eje.70.1672991601461; Thu, 05 Jan 2023 23:53:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672991601; cv=none; d=google.com; s=arc-20160816; b=dzOvyEJowCgNjOh5N9JIaL+DF78jED3iYBdGGHa7EJiDhUH6Bgfynp8T0b923Gak9q ztjIFN7lLcrfxsefa7/hzBwTGX/Or4LSS50jvwpGPvrggD2YCEagmGKIMsuww02ZUq/d AlNFC251dMcc6bdP0SmICih33jmOt3kSi/6LNNybxATxhNR5/IePG/DFesWtmIjg1oKC XNMU341DQkyPIhV6RpO9oMv0dhlYF2lxWuzHQQH7Xqq9G2R3zBRz98MdKOCddPNJXXku tlhV3/1srLRtpHG17bM64nCXKvqG658riuk5ZiBz7884DRDiGKD0pwsy+03CGQmlp7xc YNNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=z5mXXj1DDRwXWX004IZO7krmkPascoeR2kEbgvjS+fw=; b=HaGgY47cUC+5SD6WeHa+bLHH89nkdwIin/zzoMptEwFl2jcxg/ZOOaGQd7cXj4PuB7 gN/fJebe/YSwGGt9j553e9C+5HpkcHAXjl1bSZoBGCrDBH2zNeCKeojgxQ56tjuozfXP 8alhT4Ti5v/suc5CtltXK7Yrphf1+B4nUUwVCikmE18ea2YG2qM3tu7qO0rFaAoeNyyZ Js8YAgo5/bH8pyr/qNr5B0nIRiFR1049abXUjvwG5lsGMFAuQdIx91SN+9fbCpddSbfZ GvjKdFYushbyPiCUhaUHppNab6j1lJb6eOXjxq6tMM/W1QrS3fP73W02OByzdCTsKMJf CxsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=V2y9ebJQ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a18-20020a1709062b1200b007c1b8be3723si448142ejg.197.2023.01.05.23.53.21; Thu, 05 Jan 2023 23:53:21 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=V2y9ebJQ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BA58568BCEB; Fri, 6 Jan 2023 09:52:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-173.mail.qq.com (out203-205-221-173.mail.qq.com [203.205.221.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A21E868BAE4 for ; Fri, 6 Jan 2023 09:52:37 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1672991551; bh=ydUqQneqlMkSJ3gjv0MmQmHMF0tQikWy022RGCW0vvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V2y9ebJQY2nga/m3pTB49MlTyL8wJFdA/ikguHaKcPxOUdtqRmcHfkkfhnyNCGT3r YiHe+/sJ8g+XZ5oHnCJ/CJU/jhRfXJo+ZfGG/z+ISO8B1fIyLg/zEsMoYZjZdWfsXH 9HWjlW4woFETE29zkVRErelNl7uznZo3prStiG1c= Received: from localhost.localdomain ([59.37.125.102]) by newxmesmtplogicsvrsza2-0.qq.com (NewEsmtp) with SMTP id D1E058B1; Fri, 06 Jan 2023 15:52:30 +0800 X-QQ-mid: xmsmtpt1672991551ticak0rs2 Message-ID: X-QQ-XMAILINFO: N26DAMVpW7UEPrxRPJ+lAZw56Ci/K8iRmiwPC1M8GIRjWUoa4el5wvUDFoDgZF 6k9ei+SlPwZ8TcFOkYqTJFIG/XEQfhBiQIlpUpwBPgKixZLqlhnRws1gb2cImiJUaZaA3jwLXqaV hoJeZMfcXJMkhM7bnSM1xshQ0jH3+9N5aDWZIy4YF7KLIbA0Kh+jifnA9KWm5haNHZn/Vmqz4uUC qaX9YaE+roHmMcLgXR20YvrNJd40VwoYJtX/fnAtucpCzLNg61V7IH67pNILQGvKA5EStOEplYHW +NHntpfZYeU0n8FfpsAr1CXjSAkpOzPA5C2cvjeYLKZjrszxqYBAYkovVVpGvj4WU5krYII6M1rg l39SmQ0OvEizoFm9QJE9WzHRTLnp8jQ0HVfJ6EJ3GayEZ+C4gY+2jkXpaaDcxcF8RydD1/Jk7bew wPTBTihKIMCyISt/DDOSa0/Lpnaj4zr0KZ4bGLeiAvT5X4+P+l9ooisvBHlCvNGp159EMowrAf7g Z6K++bkas18tOKpqfzpVkN3dUj2/2BylG+L9H7vlfUaZ7PNPPJBDu26M5gvEzudC3ulwUVAULhLV BV/WKj0Hb/hh/82Kb7yJOEMLwzyfW+XNfYsMUuWpuTHHWas/ZXCvdbNsV6II+XLfMb7CDJXxKPrN HEss05gcdTc6k9B3Hu4bmL8i1Hy6lq1QRKMcO5nMs6dQcLUk/UQ5wGoBt45gvaiM+VgB5lgJgWV2 Mi/OElnpuXFvPSOq1bGHbfAZL490IY3umcXJkFWaIs9zW+XAsWe1rjgFb4HWycNPt/dRXjAtkhO0 lVEiMsR0ymSwmhPCvZfuFetk3bYt5WiNaRDOtBMCbekk6sCw027zcCWbmFaVcJlaLRa6AEJkXf2c XhpTHAFEog2vDBvY+e4mEhQ6dXPNtKyK0gmQaFDBQmVlcY2t0CyiVY+XtPUmbV39xygCNCYDxrcx UKUfRLWmHba44zexfGqDkcUeIxTh8z7gQSq+7gEGg= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Jan 2023 23:52:27 +0800 X-OQ-MSGID: <20230106155230.487282-2-quinkblack@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106155230.487282-1-quinkblack@foxmail.com> References: <20230106155230.487282-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/4] avcodec/hevc_parse: keep nal->nuh_layer_id > 0 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YX/RpHCSHZOP From: Zhao Zhili Signed-off-by: Zhao Zhili --- libavcodec/hevc_parse.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c index 29dfd479f3..dddb293df6 100644 --- a/libavcodec/hevc_parse.c +++ b/libavcodec/hevc_parse.c @@ -37,8 +37,6 @@ static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, HEVCParamSets for (i = 0; i < pkt.nb_nals; i++) { H2645NAL *nal = &pkt.nals[i]; - if (nal->nuh_layer_id > 0) - continue; /* ignore everything except parameter sets and VCL NALUs */ switch (nal->type) { From patchwork Fri Jan 6 15:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 39893 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp958120pzb; Thu, 5 Jan 2023 23:53:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXssg4c8Yhw9SYSmlPRj7bg/xLpQvgIVFRDxxGRah6NuLf1n4yxFkZ9pMlF2dh3vG/PaxkCc X-Received: by 2002:aa7:d653:0:b0:47e:15ec:155e with SMTP id v19-20020aa7d653000000b0047e15ec155emr44380949edr.26.1672991592647; Thu, 05 Jan 2023 23:53:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672991592; cv=none; d=google.com; s=arc-20160816; b=Q2BUkwXH56mTkFFpzdZaT9NI3VG583UjOeCt4+SN8MWmaHQQpl35vROxTywx/kFOXH 1t5pgK4nyEe+Eu8s5KMWtDXFf0o0A/kzT3jOfYVg/Oo+DSSFuTsDcJ83N6YWJYkAEXeO T4BkuLC8eoabDL3gBNVjLkvK5c1YGfGGYzntOMD89x0rn5Dp0atlgS1LKaonRRRD/K/D fm4h9vskWO1wtNIeMbDLLTsueZC7UGauEjNipl4R3n5jUakbkCS52rRaQDTr2swk4cOP 8gN7eLxM74yOQif+pej8u1ccsJYHvDzlnYxygUpQTPS5WvMLUT549uYkCNReUj8QYOx1 m5sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=QvIbKsEZFmXKyyeFMqTfJ0vXheSTXTfsQJQibuLh+RU=; b=T6la+DfVBedKCJv9DAYIxQ1Nxz5sgpFiaZdzWYg68AYxMyFR/tvGfJq3NI6NYYcK5f BQJ16/QhdWjMfXVF5AhpVvDfL4kVvlAh66I+linc7IK9/a9GW1rCrUnlKCR4tURTuRYp Uiv41/CWDPIR0PC/8468TiZxV7lf4EU0cZdg/hst9mWt5m0VJNgiZbIsRX3+8XokEimo yvUKizrI8KZQL9RmQTYJvPy126klGnsYLTV197LI0cRODDk+7WRk4wOboJB4Es7i7f+/ DLze7rlTIGTURqEkIP/vPgGPUsyEIPjhqxRnHeLQxEt3UrZAPcxI/yC2M9DPEYunJ0Hc /EDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=ad0Ltc2i; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x13-20020a05640226cd00b0048caa16a5c7si972841edd.465.2023.01.05.23.53.11; Thu, 05 Jan 2023 23:53:12 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=ad0Ltc2i; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5A0368BCCD; Fri, 6 Jan 2023 09:52:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-57-252.mail.qq.com (out162-62-57-252.mail.qq.com [162.62.57.252]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A517768BC58 for ; Fri, 6 Jan 2023 09:52:37 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1672991552; bh=3o0BgrB2hWsi+NFBvCkiyDu1HjIhFAOlucubcMh0BbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ad0Ltc2i572XluauVWHtkMaga5xvaS22e8ywNR73y3cuNMfVcrNWCvzNFLXqIuSI3 afuanT68Y8TYi2hqTiX+qOHzT/L16a3nChPGAju1/C0pu/nU6SUV7XIdF13uH67qPr H1QG6mu6vbWyQlDb6GgNtkEQIQ7NcI67cGBWGv98= Received: from localhost.localdomain ([59.37.125.102]) by newxmesmtplogicsvrsza2-0.qq.com (NewEsmtp) with SMTP id D1E058B1; Fri, 06 Jan 2023 15:52:30 +0800 X-QQ-mid: xmsmtpt1672991551tfvhn2qi0 Message-ID: X-QQ-XMAILINFO: N7pVCJF/rxxTmSk6IMnondMVbgTbGm2HRdGD3XbhCvtRGD7xeRG114Z9UbMuEW lmrvAb2i31J9c4h/ofuWTo9LHc0Cn55qJaFlsRCvjTeqcCfk/RPFGs9NrPfSuGnAXw3qDgdRjmdP h+fO5SyQwtU18rFd7gvv0F0jV92sUjyPiyzZiqtgcVYU4Gnp65O9rHO5rcMuZv4kzDroqKoUJA3o 8ePAFZsI29IMV4SXd74bGR/ZMO87pns3NGIj/b+8BnbTpwUIE3UIYyAxLl32WI/ZgaCvnyspJTfL oQ8kTc6BsATMWs7GKXGozdd1zWrDptWv2Bp5DL6lfyzTRc0RDzO5anHMLhpM0+cjKQrZ/tH8tdll bsMr0gjpu011SCwtA3LUG+z/W6wQLnj8kx/DDKRKbWiognwDJw+bCO32EUhDyM/fGdZhXBVopwvH jgdBcapHOmFw2+K4NrfInH5N4+73y5l4872z7BTvupc7YPguJUMRI6ccmSGeuDtKo+JjQQdBvn+T TNeTMSAbXpz+7vchOk7v/3CSab8m82lhjRAwebej+I5CKolND81i4/jxOYugKl+HwvNSMz3OKYfA Pd2l3pTGJ+UguHpo6QDmQjwhwOzmktYCDisiUI7Mkp/62KsaSnlPI6BxZ8S7OayojWQM2HrgvmRM 0XmyiAJsXc0RFLnvFDx1EuYlx6upu+FdBQLB80mF5uUbdVLjntNHm100FjH5i72fMJC/82GN/bOc 50ZmXFw2zPnQEwbjU/By4KzYFVQsSvXMjFViHDipC8cCwL+XbEMqva+wFvB1DLtJel3WQ3ker4yC NrfVLA56Zh4lF0YlR8/oUJKh68fiDF0nWlSOX3Oltodn6ohe6B7jNwKHJDykVGZ9ZbawfcBX6tca vXyXT4k2tXJcMFobH+ThiLoWuTkidz/Jt+/AMMvs/XRZqUQhJeoxSGecRpBQ0EQVjTLJSIepo10z 0LxehM774M3CoX8Tn7+w9bcDqs3LI8 From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Jan 2023 23:52:28 +0800 X-OQ-MSGID: <20230106155230.487282-3-quinkblack@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106155230.487282-1-quinkblack@foxmail.com> References: <20230106155230.487282-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/4] avcodec/cbs_h2645: keep nal->nuh_layer_id > 0 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CdMeQBMEOQhZ From: Zhao Zhili Signed-off-by: Zhao Zhili --- libavcodec/cbs_h2645.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 4ee06003c3..b12abede29 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -477,9 +477,6 @@ static int cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx, AVBufferRef *ref; size_t size = nal->size; - if (nal->nuh_layer_id > 0) - continue; - // Remove trailing zeroes. while (size > 0 && nal->data[size - 1] == 0) --size; From patchwork Fri Jan 6 15:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 39892 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp958054pzb; Thu, 5 Jan 2023 23:53:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXuHAopSoo6vAmCkGpcMTJpDEcD7imgC4Sk+QbW/9ng01gSrp4DTbj4t95uclzMkW9HgC/7x X-Received: by 2002:a17:907:c516:b0:7c1:e78:11ed with SMTP id tq22-20020a170907c51600b007c10e7811edmr49863997ejc.0.1672991582787; Thu, 05 Jan 2023 23:53:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672991582; cv=none; d=google.com; s=arc-20160816; b=CdwEihtQSLGq3u0qCyG1/Ag1T+I++Rl5YlNR9zcCRjlWqkIey0y88eVNd+h3464IDe 3J9YVa8zgc0C1QolzCQM5T5bpDAfl2AJ5MOcbE92BIfNRdm0/NDu7aceF+ErGfM0nCdb bOu3qgzDY/bh084ycxM7qlnP0wrodMCaCJJVrVaYa4t+VPXfHqcb70Y1j8OMgFiO5LtB /Zg7RjbBIzlWu2KnqU/n7EJnrK3ElT9K02tp4VDpu9LaFJuxshVcw0DI5V65YMRAtqa9 yylwR/GJGwlR4L6+ihuu3Gk6AEv+fr4+wdeyRAGKtjLybKnPAb9jMjBbDVxr+lRIdJG1 +P2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=Q/5YYpq7jkzQ0dzdvQkU84IrtiXQkpD+nFiEQJYE2u0=; b=GBgZ2q2XnU9AU2Kccvt3Gr/Q1m3onWuI3tkFhLxRrQ/4nMIHnhaN6lgMgfWnnLlxT1 F7yffJY/KxUk/Hjx1vAEnfwvLImnLbMnDC8JRKuVVxOMBa6R6vyKcbiYuh/kf092gGWb jM4sniPaTfKd5kRBnqs5sej4KCM3CxxJ+k3+OthcVpI7f2C5TM5qVG6PTXKVBr6uDNJ1 lwsbekVW9fgmJwTBHiJmooCZgILnLVDgkCBwGHGLaV/i2ryjW3aaxaEvv8QhK1Ts3sM6 d+R3NSlX+Z3TrneTtXWrh21iXST9jTQKeSLRic7jPMaLZG5ITYhVSljfBgxNVunwzSHe qLzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=FPhgSq4Z; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ds12-20020a170907724c00b007ea638b5670si608528ejc.485.2023.01.05.23.53.02; Thu, 05 Jan 2023 23:53:02 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=FPhgSq4Z; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B531F68B9F1; Fri, 6 Jan 2023 09:52:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-58-216.mail.qq.com (out162-62-58-216.mail.qq.com [162.62.58.216]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9FED368B9F1 for ; Fri, 6 Jan 2023 09:52:37 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1672991553; bh=RwkMnxXYNQW2ABBw7hrgj318Bbj/DdfLubJek59duaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FPhgSq4ZtDZ8e3lIgWEHICFQ5Mh13TbuW+R2Le1qn/dTuSjYE0BZBh3jcvYpeUsng k74NWU+cqxeXr0EdIurw7PGa5E7IXGn4kwS2VPy2gXHhlVu97dcCXHH5p2KXCm8F4a J6zaREy9IrrUed15pJaIOkAPYv86oc5naeiVBJVg= Received: from localhost.localdomain ([59.37.125.102]) by newxmesmtplogicsvrsza2-0.qq.com (NewEsmtp) with SMTP id D1E058B1; Fri, 06 Jan 2023 15:52:30 +0800 X-QQ-mid: xmsmtpt1672991552t2r5h3rcz Message-ID: X-QQ-XMAILINFO: ORuEwgb9eurk7oh+SXQYkGiZeOmo2/fyraSEarrb4M1WSYv3wgRHO4dsHtE5Yc Tqyv28PAJTiJdrzwdKXw+Jrsi6UXJSDtObZ2wOZ2iwP1idb+WuVW+rfbzDL7JXbKRtVNt8po5/dM CYzIiD58biZkyrjg/oovsN68r6A8oCbhTsoQB79Pl537Wsk52bKqnuE5MOPYngXRz6wKMcaL5BKq nndhio/jlmkxRuZmnkzSRVECRr+LW7UZPD+6en3pXm2eNx9raLvPk7qAjPAS9+2SpJHBHTsAhX3F PQkpLwma/ixVaWBgHERhXl7fwS9Tayp745i85cC3sO1LE2HOOJYdSXUuMrn9QaTL2xUd6yvtXLfE E/r2+CKB+dxV4opGWrCyfNfrVBC3czrRmgv9xuwiBs9jAUfw5/XunPJYACxlUf3g2tCaOGgSN+wl VbONaby2D2GPLD6yq95eyGg3eycp2g7iH+Ub3JFXejsT9Yb7S7WC8ANzajoZDQZfAyJ+0i5MpK86 iBgQ2KFVwJgPA+hMuXkEw955GeRGf8525yoY3CSv+sutmYugAUkqc2kmahbVd8+3HNLAEPzgsZro HObNKFa0UAbt66fjfGxlwbr1Wx5zzZr9bAHjCYOyczEog/huKwlB/6OHz6JR5GTJJahj0/14fek/ q+aH/qj1LPMYHMA/TZ1p9NwYTfdcbMnS5xO9JE9ZTQgDdcyr49UHBFsuYBQYkp8P1xs4+dqiq5o8 W0aHp+ZZTmoGPA8ksmMVLA5Xo5wy3uUyFgu4EifMglxfOwHnRyRkm2rgLuC8ePym87XBP+j0+5qC oLgcItj+Ob0iPyPnCeDpxXwY6RtgifGscoyDRWjnFC4Q3zYoxqnRJy3sX+VtXpkJpryymwxdE01a 9Kdm7RocS1NGrm7pZTc4lETT5nL3VUQmFsxtO0hPRPfr2Ft0rcHKy7kdDRM4Au9bRO8ZUMJa8tYa 3TAFgmQtOaTTeNM1YwPf9DDDOmRCyjFe46b8hw40k= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Jan 2023 23:52:29 +0800 X-OQ-MSGID: <20230106155230.487282-4-quinkblack@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106155230.487282-1-quinkblack@foxmail.com> References: <20230106155230.487282-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/4] avcodec/hevcdec: 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: SufzToKb3osj From: Zhao Zhili It can be used to decode selected independent non-base layer. One use case is alpha layer decoding. Partially fix #7965. Signed-off-by: Zhao Zhili --- libavcodec/hevcdec.c | 56 +++++++++++++++++++++++++++++++++++++++++++- libavcodec/version.h | 2 +- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 567e8d81d4..0b3d4e84d4 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2956,6 +2956,35 @@ static int hevc_frame_end(HEVCContext *s) return 0; } +static int check_layer(HEVCContext *s) +{ + const HEVCVPS *vps; + + if (!s->nuh_layer_id) + return 0; + + for (int i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++) { + if (!s->ps.vps_list[i]) + continue; + + vps = (const HEVCVPS *)s->ps.vps_list[i]->data; + if (vps->vps_max_layers == 1) { + av_log(s->avctx, AV_LOG_ERROR, + "Specified nuh_layer_id is %d but vps_max_layers is 1.\n", + s->nuh_layer_id); + // Keep going for now. + } else if (s->nuh_layer_id > vps->vps_max_layer_id) { + av_log(s->avctx, AV_LOG_ERROR, + "Specified nuh_layer_id is %d but vps_max_layer_id is %d.\n", + s->nuh_layer_id, vps->vps_max_layer_id); + // It's a known issue that Apple videotoolbox encoder doesn't set + // vps_max_layer_id correctly. Keep going on purpose. + } + } + + return 0; +} + static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) { HEVCLocalContext *lc = s->HEVClc; @@ -2977,6 +3006,9 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) goto fail; } ret = ff_hevc_decode_nal_vps(gb, s->avctx, &s->ps); + if (ret < 0) + goto fail; + ret = check_layer(s); if (ret < 0) goto fail; break; @@ -3216,7 +3248,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) if (s->avctx->skip_frame >= AVDISCARD_ALL || (s->avctx->skip_frame >= AVDISCARD_NONREF - && ff_hevc_nal_is_nonref(nal->type)) || nal->nuh_layer_id > 0) + && ff_hevc_nal_is_nonref(nal->type)) || + nal->nuh_layer_id != s->nuh_layer_id) continue; ret = decode_nal_unit(s, nal); @@ -3315,6 +3348,10 @@ static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length, int f if (ret < 0) return ret; + ret = check_layer(s); + if (ret < 0) + return ret; + /* export stream parameters from the first SPS */ for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) { if (first && s->ps.sps_list[i]) { @@ -3637,6 +3674,21 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx) HEVCContext *s = avctx->priv_data; int ret; + if (s->nuh_layer_id > 0) { + if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { + av_log(avctx, AV_LOG_ERROR, + "Decoding selected nuh_layer_id is under development. " + "Use -strict experimental to use it anyway.\n"); + return AVERROR(EINVAL); + } + + if (avctx->hwaccel) { + av_log(avctx, AV_LOG_ERROR, + "Decoding selected nuh_layer_id doesn't work with hwaccel.\n"); + return AVERROR(EINVAL); + } + } + if (avctx->active_thread_type & FF_THREAD_SLICE) { s->threads_number = avctx->thread_count; ret = ff_slice_thread_init_progress(avctx); @@ -3691,6 +3743,8 @@ static const AVOption options[] = { AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, PAR }, { "strict-displaywin", "stricly apply default display window size", OFFSET(apply_defdispwin), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, PAR }, + { "nuh_layer_id", "Select which nuh_layer_id to decode (only works with INBL)", OFFSET(nuh_layer_id), + AV_OPT_TYPE_INT, {.i64 = 0}, 0, 62, PAR }, { NULL }, }; diff --git a/libavcodec/version.h b/libavcodec/version.h index 6b8a1dbb79..15f7c3fe3d 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 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ From patchwork Fri Jan 6 15:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 39891 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp957960pzb; Thu, 5 Jan 2023 23:52:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXt+puttJnDJ+ifB+tmego0DYFoyPKdsXZeB7hztvGtA/P6PrpOBmii/7D84MmE+o2aFZr33 X-Received: by 2002:a05:6402:375:b0:46d:ea1e:fed0 with SMTP id s21-20020a056402037500b0046dea1efed0mr58116353edw.40.1672991571157; Thu, 05 Jan 2023 23:52:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672991571; cv=none; d=google.com; s=arc-20160816; b=FDl4IEOQhG6aE3fFiA7mkCtWgNbRDAp8x80GLFGDvqi/zuAy5VGP+IXaJlajnp5X0A ea3lP9zhkaI1o7ON0dQ8NzGpbZCmGcJjGPHcqrMsUL8AaHq7f9bKDItQderVLYprmI5B L/3K1obyYVc8vPDJEbo/rdNC4b1UwoOo1BzCHixW7rmEQVs0iDFAZ7ZQIW0z/JrfUEHz a8hDxqzrWzK7JvnWvfHgCyoYMWSjW/w8/hDQrKLJht0bDYjOfiPjfsdrZAPeDim9Xuu9 rm4ijVt3f/wAQZmBVT1zTRjKN/mxsViCHEDMgA2ireLjcvozbb2yC/OPHFaByaGjQjRm nj8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=bfkP3cJ5PMVXVjjuiG/mgn35e6h/WggfN8lIq4bO2Xc=; b=Wd08Rp7U2TIKQoRGejK9moPf5xPM5Swe0K91DIheRboxK3w2gv52NySWdT3Vtn9T+m br8ieHRJlpcL+reWOJ2jqAjtODGPKaxVw22R+2nUp0FABYnhsx8T6pe02IrRBkIomXwp M+35qwLlpPHNgx8Fql/On9WrDIanxfju9NrIE6QMRNTUibto2KJdvMLUuHeaeHlPUPcE XwgFAyMgTnr6X2rg7gcuHaXcEg4e7fXFSohIs+nhc0/GNdB/g+0NVZb41Dw4QkuNTPXu CTwWDsfixfe451qWW4jsL0qJkUbDwobwfILEulBYBBYxC3faskjy1i1cdPV3xUfzOMgE Ma8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=Oq865TkO; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y5-20020aa7ccc5000000b0048bffdbb775si918016edt.202.2023.01.05.23.52.50; Thu, 05 Jan 2023 23:52:51 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=Oq865TkO; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5C63268BC9F; Fri, 6 Jan 2023 09:52:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-57-49.mail.qq.com (out162-62-57-49.mail.qq.com [162.62.57.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A7AF268BC64 for ; Fri, 6 Jan 2023 09:52:36 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1672991553; bh=edK49j2aZ/mQow0f+ysgHUbxV746OBNgBAYorHabn4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Oq865TkOya0d+r6hEv5ROVfACo60vVH2AQ2kNosg7ku7sj4UhP40odRJUOqaeadMD Hwo7uncuwtE1DntWrYnRu0khTFoSOr/3UDXRcKxLbUbWiALdZyd801g6MM4gJ/22yx 4MPHcI9hB10uyI6eVxSCiyvMcF7/1wEPaHkgL41s= Received: from localhost.localdomain ([59.37.125.102]) by newxmesmtplogicsvrsza2-0.qq.com (NewEsmtp) with SMTP id D1E058B1; Fri, 06 Jan 2023 15:52:30 +0800 X-QQ-mid: xmsmtpt1672991552tmxcfj693 Message-ID: X-QQ-XMAILINFO: MFWpArBVhhGTqY4JTEdMnSnl7C+f4XzRtqbaz/EJk2klYXVDthzhBaKn9uvsdq ivuiykr8aRRsqpb1xLaLcmLUnmjIZKXHbWMwcIwiW33cQ+820LZJpF6wfP0k7FEC948vc4NWoXXm dTfz1s+SuKawlMN4x7LOPjc5OuupIRwEXq0SJeLwo2l0vkzFMR6PE1d/hnI3saCfpT3tOtHmmdrc IeXIyKJPpMYJEHlOlulgmHZwLzPqB2IjxKrU4YQPEdeh3vtbrOlMQ00NLtpsq+SjkyYzvZsPieTE 6684qrhPnsQ5EY2+AIY/sVywyJB1/YV6ka8wSe5FPltui9vbTjFaQpXplOhILO77xpI5NIQGjka/ 8uCmOBxTG8W3KOzRr6gShj9CcqODKWKpZpXWoF6udpRA9YvMJ0UV/Dp2DveRr6pwExH989HbXFqZ JLNZPsZ8EP7w6Jt0w1AntHIyUifQ6ZsFh81HzENS2HSxSR71tUCMTrRfTH/UugSWtCvATWkiQW6c OqhbL7iwL8mxnkVRDCGGiz+VLNCfhQV9g7LatoAEFIxl88R4ZX+Yddoe9OEn8ax1suJ12WXCOBaj +PR4PGSKY3AvZyNPBHgYzgx+4eKZYNkYuhIAAmP07w9jkxSPR3x6G9BxqoCLrBBhuWhaybkYgKVf NXv80CEgSnz7ggJEdD/6cZysb9w8f0cMbT/IyVVeEDL8hZhxY/1AqPXOqFl4iRba520M8C7JPixG +WLaYarRVAgHVP7MmGczQf7NRzvRVFBo7g6vW+EWCYrsDA01RrNbOg6X6HPjej7wMWuv1Cy5vVuo j6mR3qFC7ZSzJP2S++Uz5sc5lNB2/ubUQ7/zSNqYCSOOEgwO7Rf3bJ2kMnX0Ei/ycqV8d3z6YIEO hku8Co4R0MddJB+Ea3UMcYkVVoXt1JF72mXMj7ycN+74Bo+0E1PtyWQWGwrM5F1eQ17919gEmyLH fGeGnpHDm3/1SldL5AxfZvcrdwbtX80ylUn17hKbIn8hokPp0ttPTJ9VNGC6JfanhPT6ljnWs= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 6 Jan 2023 23:52:30 +0800 X-OQ-MSGID: <20230106155230.487282-5-quinkblack@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106155230.487282-1-quinkblack@foxmail.com> References: <20230106155230.487282-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/4] avcodec: add hevc_extract_layer bsf 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /nWOQ5F6v2nI From: Zhao Zhili For example, to extract alpha layer with nuh_layer_id equal to 1: ./ffmpeg -i alpha.mp4 \ -an -c:v copy \ -bsf:v hevc_extract_layer=nuh_layer_id=1 \ output.mp4 Signed-off-by: Zhao Zhili --- configure | 1 + doc/bitstream_filters.texi | 12 +++ libavcodec/Makefile | 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/hevc_extract_layer_bsf.c | 126 ++++++++++++++++++++++++++++ libavcodec/version.h | 4 +- 6 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 libavcodec/hevc_extract_layer_bsf.c diff --git a/configure b/configure index 870d426b0e..a398b28790 100755 --- a/configure +++ b/configure @@ -3278,6 +3278,7 @@ filter_units_bsf_select="cbs" h264_metadata_bsf_deps="const_nan" h264_metadata_bsf_select="cbs_h264" h264_redundant_pps_bsf_select="cbs_h264" +hevc_extract_layer_bsf_select="cbs_h265" hevc_metadata_bsf_select="cbs_h265" mjpeg2jpeg_bsf_select="jpegtables" mpeg2_metadata_bsf_select="cbs_mpeg2" diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index c63c20370f..55ed8d91f9 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -382,6 +382,18 @@ This applies a specific fixup to some Blu-ray streams which contain redundant PPSs modifying irrelevant parameters of the stream which confuse other transformations which require correct extradata. +@section hevc_extract_layer + +Extract NALUs with the specified nuh_layer_id and rewrite as base +layer. Only works with INBL (independent non-base layer). + +@table @option + +@item nuh_layer_id +Which layer to extract. + +@end table + @section hevc_metadata Modify metadata embedded in an HEVC stream. diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3ab448dd49..f27d169741 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1208,6 +1208,7 @@ OBJS-$(CONFIG_H264_METADATA_BSF) += h264_metadata_bsf.o h264_levels.o \ OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF) += h264_mp4toannexb_bsf.o OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o OBJS-$(CONFIG_HAPQA_EXTRACT_BSF) += hapqa_extract_bsf.o hap.o +OBJS-$(CONFIG_HEVC_EXTRACT_LAYER_BSF) += hevc_extract_layer_bsf.o OBJS-$(CONFIG_HEVC_METADATA_BSF) += h265_metadata_bsf.o h265_profile_level.o \ h2645data.o OBJS-$(CONFIG_HEVC_MP4TOANNEXB_BSF) += hevc_mp4toannexb_bsf.o diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index a3bebefe5f..ac013e8072 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -40,6 +40,7 @@ extern const FFBitStreamFilter ff_h264_metadata_bsf; extern const FFBitStreamFilter ff_h264_mp4toannexb_bsf; extern const FFBitStreamFilter ff_h264_redundant_pps_bsf; extern const FFBitStreamFilter ff_hapqa_extract_bsf; +extern const FFBitStreamFilter ff_hevc_extract_layer_bsf; extern const FFBitStreamFilter ff_hevc_metadata_bsf; extern const FFBitStreamFilter ff_hevc_mp4toannexb_bsf; extern const FFBitStreamFilter ff_imx_dump_header_bsf; diff --git a/libavcodec/hevc_extract_layer_bsf.c b/libavcodec/hevc_extract_layer_bsf.c new file mode 100644 index 0000000000..84c1c87a80 --- /dev/null +++ b/libavcodec/hevc_extract_layer_bsf.c @@ -0,0 +1,126 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" +#include "libavutil/opt.h" + +#include "bsf.h" +#include "bsf_internal.h" +#include "cbs.h" +#include "cbs_bsf.h" +#include "cbs_h265.h" +#include "hevc.h" + +typedef struct HevcExtractLayerContext { + CBSBSFContext common; + + int nuh_layer_id; +} HevcExtractLayerContext; + +static int hevc_update_vps(AVBSFContext *bsf, H265RawVPS *vps) +{ + HevcExtractLayerContext *ctx = bsf->priv_data; + + if (ctx->nuh_layer_id > 0) { + if (vps->vps_max_layers_minus1 == 0) + av_log(bsf, AV_LOG_ERROR, + "vps_max_layers_minus1 is zero, only base layer is available.\n"); + else if (ctx->nuh_layer_id > vps->vps_max_layer_id) + // It's a known issue that Apple videotoolbox encoder doesn't set + // vps_max_layer_id correctly. So this can be a false positive. + av_log(bsf, AV_LOG_ERROR, "Specified nuh_layer_id %d is larger than vps_max_layer_id %d, " + "this might leading to empty output\n", + ctx->nuh_layer_id, vps->vps_max_layer_id); + } + + vps->vps_max_layers_minus1 = 0; + vps->vps_max_layer_id = 0; + // TODO: update vps_extension to reflect the layer changes, other than + // drop it entirely. + vps->vps_extension_flag = 0; + + return 0; +} + +static int hevc_update_fragment(AVBSFContext *bsf, AVPacket *pkt, + CodedBitstreamFragment *au) +{ + HevcExtractLayerContext *ctx = bsf->priv_data; + H265RawNALUnitHeader *header; + int ret; + + for (int i = 0; i < au->nb_units; i++) { + if (au->units[i].type == HEVC_NAL_VPS) { + ret = hevc_update_vps(bsf, au->units[i].content); + if (ret) + return ret; + 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; + } + + return 0; +} + +static const CBSBSFType hevc_extract_layer_type = { + .codec_id = AV_CODEC_ID_HEVC, + .fragment_name = "access unit", + .unit_name = "NAL unit", + .update_fragment = &hevc_update_fragment, +}; + +static int hevc_extract_layer_init(AVBSFContext *bsf) +{ + return ff_cbs_bsf_generic_init(bsf, &hevc_extract_layer_type); +} + +#define OFFSET(x) offsetof(HevcExtractLayerContext, x) +#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM) +static const AVOption hevc_extract_layer_options[] = { + { "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 = 0 }, 0, 62, FLAGS }, + { NULL } +}; + +static const AVClass hevc_extract_layer_class = { + .class_name = "hevc_extract_layer_bsf", + .item_name = av_default_item_name, + .option = hevc_extract_layer_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const enum AVCodecID hevc_extract_layer_codec_ids[] = { + AV_CODEC_ID_HEVC, AV_CODEC_ID_NONE, +}; + +const FFBitStreamFilter ff_hevc_extract_layer_bsf = { + .p.name = "hevc_extract_layer", + .p.codec_ids = hevc_extract_layer_codec_ids, + .p.priv_class = &hevc_extract_layer_class, + .priv_data_size = sizeof(HevcExtractLayerContext), + .init = &hevc_extract_layer_init, + .close = &ff_cbs_bsf_generic_close, + .filter = &ff_cbs_bsf_generic_filter, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index 15f7c3fe3d..dfd3d5d7e5 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,8 +29,8 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 56 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MINOR 57 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \