From patchwork Fri Jul 12 02:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Kai X-Patchwork-Id: 50494 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2298:b0:482:c625:d099 with SMTP id fp24csp545771vqb; Thu, 11 Jul 2024 19:49:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWGokaexAU+SeXEpn0tJ79GGI41l8vPc1eLiTciO+atY1ZTEb+tkxA4GOlijEzJAoW1UFF4SrW5iffuJY4z43zGLGzwwoOtCu1TuA== X-Google-Smtp-Source: AGHT+IG9uWVJ1DYU7hDjupYRPQN5zcurxEspLFp7X16S2ao0SCUNDm6bAv04fioOy2LWSidWrbWv X-Received: by 2002:a2e:9647:0:b0:2ee:8eb6:ff61 with SMTP id 38308e7fff4ca-2eeb30bca0amr64228321fa.2.1720752571605; Thu, 11 Jul 2024 19:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720752571; cv=none; d=google.com; s=arc-20160816; b=tHU6rxGa40Ym/IRPZ6XVsG3yQNWEnSCHMwsOZTV8X3tDw6MpVL9F9yFeDwe5EqSS9Q x0aOotzwfLnAy4mav9p3VCXf6Ylo1W2aLXOm2cRB9FJc85uXXOSPY2oD3Um0Yyzjk3+1 ILRfrGXjJv5b14C0ldQJ3zJvqJ/cxENPA9D6kFzheamc+EwNp/SWVNbE410n2Qm4d77x Dg7pW7JWcNlrYV0rDF68gtBWBdUcv8CRjkI+fGqRAq+vP46rHGwgv9kZm4fjjVp8UCeW gd5PDgOUMJ8YdWs9c4wGy71Fm0YryrwV+l4NJ5/umh3RwRJ07QZLY89ufOtuLo1H9ChK r70g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:message-id:date:from:mime-version :dkim-signature:delivered-to; bh=brfgIANLbeT4kw+SpuGGFI0yadP7Ugtl1c/viwQnSOE=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=SBjZF+uPnrniDeHMoN4DmcFXTTeRtl4Yywe3GyhzVykvDzkWkDLL3JBWIIuKi3SNk0 qTObtSEK8/Y5n8CgoJwjpZTC1cHvsI98t5LqF/nAb1FO0bZaUPGD8hx77QPLn2vK/hBm uCd/Q4EahKfRJeb23GbK8+ncOVIjtxXLulE8ylLdVls4J6pjvVkVTeOJE0nmVoyId6nP I37JZ2ztZQ5XkVhtvRFqierURO8wwKuiTCoWHfa5i5F8oquT7t//BrvmsOGd1817Dlow KPoUDwKSbHabZnl9bleKCIT2No3Up3uFUKi4Wj0yz6uqr11lbSvqIHqJyCqEdjfVpkyH 045w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="QMOLI/e/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2eeb349ee6bsi19772761fa.503.2024.07.11.19.49.31; Thu, 11 Jul 2024 19:49:31 -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=@gmail.com header.s=20230601 header.b="QMOLI/e/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EBD6268DBCE; Fri, 12 Jul 2024 05:49:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 79F1668D960 for ; Fri, 12 Jul 2024 05:49:19 +0300 (EEST) Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2ee90dc1dc1so15606541fa.3 for ; Thu, 11 Jul 2024 19:49:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720752558; x=1721357358; darn=ffmpeg.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=O9dpPWtMoECeGXGokECysC3Y9+tGnnqWNBekwzmlBIU=; b=QMOLI/e/uHFUSMRtFqpcgHs7RjeJOk9E9HvV/VUHbyNSOhnlnjWMnFof1YWe8hftPX i6b6GqvVu2vMc+tFbDM5+Pt7bBPIJWuDcWTRPzOmCP9D0f+pt/5+PNN8ANfROUVnrdy7 K1e3sS59iSS4w0Fhqn1zh3BOLS3v5Vog21lvzwWyTjd1u0CcCFH4lAlosfW2NK8O2NG1 Pt8XnWWiNpi+eAE0fSBDm7xp5n2c8RW08b0hORMW9v4zD/3g6Z6WKs2k2N6JN7lqIhWb 26vkxmr7+WCdpR1Lkl7BDiIoTzsujQfxpkDhv0g7Op61yEsWwiIGWrAc9fcAUy6LyH4k YoLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720752558; x=1721357358; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=O9dpPWtMoECeGXGokECysC3Y9+tGnnqWNBekwzmlBIU=; b=FKNbJ6RdBrsph48z09hLZU+R05PCpZcdZ5Hs/nqMRk3/FHwj7htC+1L1dBtSB8IhdI +ieo8/hSkDzZ6hoFc16VJXlSbvaCYLIRH8jnNXZjFSXS7jYzVQDQCbbxhd2VASDI0RWF 9TaVPQqe2GvqrEXOEZZPCB04PDJY3QyqCoCIsJmGFGuZpUuucRf4ccqJyaUftj0wesOr AcXMB18xStme/LNQwPOIbEjsJI+t0PBlpWnuK70lGLDwZSk83T+v5zEtbRQ5Zd9gkA1L Ret/JEu4JgMPdZjUWSsthLZ75+9YBGa0duUva77hwxGazUB/FT8oVHW9xYY0BXiBE3Cr 3mwg== X-Gm-Message-State: AOJu0YxP87xEL/JK7BmM7S6vbWVzxHHLCSphR5rjA8mNKMveFlg4P5Rh SIO724NP+sFsb7vntGTEgtWFLxLHnBWfhZ4g0/LXcgi825/hhdzG/FHdbsSDMeGLJHQWNFcgODE VItjIukIfIYaSNcNZz+erxlt7BAWVaFnv+q8= X-Received: by 2002:a2e:9bca:0:b0:2ec:5945:6301 with SMTP id 38308e7fff4ca-2eeb30e5de1mr68382401fa.18.1720752558051; Thu, 11 Jul 2024 19:49:18 -0700 (PDT) MIME-Version: 1.0 From: Li Kai Date: Fri, 12 Jul 2024 10:49:06 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH] avcodec/hevc: compatible with mixed use of annexb and hvcc on bitstream like h264dec 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: TB9bJg+FksD2 Hi: I found it's different actions with h264 and hevc when decoded. I try to make it same as blow. But I have no idea about the code: *libavcode/h264dec.c:609 * *AV_RB32(buf+5) > (unsigned)buf_size* I tried to find the answer in specs, but I failed. So I am not sure that it is valid in hevc. From: Li Kai Date: Fri, 12 Jul 2024 10:21:17 +0800 Subject: [PATCH] avcodec/hevc: compatible with mixed use of annexb and hvcc on bitstream like h264dec Signed-off-by: Li Kai --- libavcodec/hevc/hevcdec.c | 7 +++++++ 1 file changed, 7 insertions(+) /* split the input packet into NAL units, so we know the upper bound on the * number of slices in the frame */ ret = ff_h2645_packet_split(&s->pkt, buf, length, s->avctx, s->is_nalff, diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index fd143cddab..59e99493d5 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -3290,6 +3290,13 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) s->eos = 0; s->slice_initialized = 0; + if (s->nal_length_size == 4) { + if (length > 8 && AV_RB32(buf) == 1 && AV_RB32(buf+5) > (unsigned)length) { + s->is_nalff = 0; + } else if (length > 3 && AV_RB32(buf) > 1 && AV_RB32(buf) <= (unsigned)length) + s->is_nalff = 1; + } +