From patchwork Sat Sep 14 10:45:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51600 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9fc3:0:b0:48e:c0f8:d0de with SMTP id k3csp331666vqy; Sat, 14 Sep 2024 05:29:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTC9dGD2nfKNEovQDZwmwZZ5OoJsLMbH4yTIOxdjqkgiZzLzK7VGK+ww7rtjNQ8+wEIMI5MsjS/xnRJ6sG+1ud@gmail.com X-Google-Smtp-Source: AGHT+IFAhFqlk4DbInE4bS9hgpgrz3S63CZJO2LIlGVB3mkTvJjldUoOt15hDO1JZZfqZW5179Wa X-Received: by 2002:a5d:58d4:0:b0:374:c7a5:d610 with SMTP id ffacd0b85a97d-378d6236b9cmr5002074f8f.43.1726316952532; Sat, 14 Sep 2024 05:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726316952; cv=none; d=google.com; s=arc-20240605; b=B2fkOhqfxNjam/NNShK/LvksTA3ygAfscFWbPq1f1oNnWGBSKH+CqHrcaFk3ZjqbF3 oQSLSK73HycmTqgyecLKIgpQy6mIGeO4nP5PvLfvdai8QtPmjCMUqb6z+97fIxKuRaQz yzv+5Z0KVC6IBhBVdDt1Dc3PtDni9/Z0z7us9pclzm6BO6x+3oRN9AS+tYaVRQCEKV3g IuxsDPdjUWCSAYrjt6d3OCmE7Iy9HB+m6v7mz3oLPgr+QaOEBsSDmuIB9bKJfkv5dpPI wjFwo39h0fTlzEtspfkb3hpX9rkW9p9WPrhh6nNcG+nisBoJoE1eDNfncIfoDTMfYWeW 6jcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=MIMIYzaO0QAhngZfzjsb/yBVkDhlFBQGDdIlDUwK2pc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Eefknjv4BTrAzcIPzslb0VlUWnCd8Is64WYYqb5MK2dSUe3m3Lq2jopdEdF1qSKyvx 0+QpLM1Nm99TR4Dj7vCIAWaTb8QGHkYFwPvAyfjoS1l/pCBBRnpKzVvMMn2aaN/jyo5i GWnKZeTblu88Ug+vS+ya1s/c/M97B+wkOL+S7Xu2G1o3pPdz9XfKhVuQ6lHUTwXdYEs8 mwQu9U3RJNimroKvcfrcgaW4jcpnoL67knBwfHYZAmJ7R76ywYvN3mTzLRUAF1yyUKlD Zffh72wbCA5E9TVzYJb+vjm8FGsuBAQbDpiFJBBbbcf1DZJOrflvFfdmtNoxam2mYOdA vLBQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=kH+KiQz9; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a90612b9b18si92460666b.331.2024.09.14.05.29.12; Sat, 14 Sep 2024 05:29:12 -0700 (PDT) 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=@khirnov.net header.s=mail header.b=kH+KiQz9; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8877068DE49; Sat, 14 Sep 2024 14:11:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6AFB068DC94 for ; Sat, 14 Sep 2024 14:10:53 +0300 (EEST) Authentication-Results: mail1.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=kH+KiQz9; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 5BCF54DEE for ; Sat, 14 Sep 2024 13:10:49 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id CsYfI97km49C for ; Sat, 14 Sep 2024 13:10:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1726312246; bh=km+mq1gtm4WOVAFt8t7hfh/b/meF5LaVs86scBONolg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kH+KiQz9Jnz05sla5Cuob3o7d2B0ASoFCGkDYIsIEcVU34kfGYMqEmQVR3KwBywbt 0uh92IreVZMwRMMPsLP5htiuq3KAw/piidCORhPfBSloQsWDkjyHIcA+2IP1I2Khy1 AOx074/tjNOPurcCAAwY140S4mfSzFq7pkJjj8nLrsJoatvP+9TCO1P0R+9uho8aXg Fu8LUvRIoqZPznCR/h2XNuoEcgGMv4gWWeiiI3PEXKkd69Szy1gGaQ/G/48oII6Dwd jSJZsPvqAX/vggXSK+maTKBXJYSQQ6Ah84jwIIwpXrjd8Wr++RLcqNfuWjdJKPS9Jj 6CElO/rcEbyAA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (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 "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 6F7234E11 for ; Sat, 14 Sep 2024 13:10:46 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 5A7233A1A81 for ; Sat, 14 Sep 2024 13:10:41 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 14 Sep 2024 12:45:36 +0200 Message-ID: <20240914111036.17164-12-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240914111036.17164-1-anton@khirnov.net> References: <20240914111036.17164-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/23] lavc/hevc/parser: only split packets on NALUs with 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: fC6eUwyQ/Rcz A packet should contain a full access unit, which for multilayer video should contain all the layers. --- libavcodec/hevc/parser.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc/parser.c b/libavcodec/hevc/parser.c index 8c7444a162..16b40e2b10 100644 --- a/libavcodec/hevc/parser.c +++ b/libavcodec/hevc/parser.c @@ -262,7 +262,7 @@ static int hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, int i; for (i = 0; i < buf_size; i++) { - int nut; + int nut, layer_id; pc->state64 = (pc->state64 << 8) | buf[i]; @@ -270,6 +270,11 @@ static int hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, continue; nut = (pc->state64 >> 2 * 8 + 1) & 0x3F; + + layer_id = (pc->state64 >> 11) & 0x3F; + if (layer_id > 0) + continue; + // Beginning of access unit if ((nut >= HEVC_NAL_VPS && nut <= HEVC_NAL_EOB_NUT) || nut == HEVC_NAL_SEI_PREFIX || (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {