From patchwork Fri Jun 7 13:01:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 49657 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1010828vqo; Fri, 7 Jun 2024 06:07:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVqMmsca86ndg4qBTB0KijSmB6tl1EFXfIA5XFx9fRfihYUr0utrVmAkT/8ffTk2cYGQ6aWfee2IzAQHOzPE1I1bkbY+uxxLGNGfw== X-Google-Smtp-Source: AGHT+IErXCvZ8XNEHOhRsgp+NGH5zJ1eESHUX5to2VRQ4uEXsCC3is4zW2xIq6KNxAyA+Jd4hYZv X-Received: by 2002:a50:cd82:0:b0:57c:614c:56e7 with SMTP id 4fb4d7f45d1cf-57c614c5752mr361081a12.18.1717765645893; Fri, 07 Jun 2024 06:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717765645; cv=none; d=google.com; s=arc-20160816; b=NR2rlQuC/lYI1JH6+nZm33W4u+VanefnZ0lM26xjY9qWc4LJZnkxKuR2gli/8nrBrE uA/P9wMwnCGou4UC8UtOuzpstwyImhnvQlSU178OZSiGcLvtdBBCZnXB/3VTSbRTLiW6 L23gJ06lN0VCevTpZa4eE7nhTbDPV++gtK3dEZ+l2SCsCwMhocoTuJ81IjoBwmUR3q/B eZlURsvt6lIL5P2sfjmS3yUw4fhMDE6kbBrvTfDERxkwxEqeOY+PGJdirX5VewOyNzqx wxgRXcUVFeo9RoVVzh51j0cqOSWCYdM/68XWrgYnU7OommY56Dv31lLr3sVZoCRXcnBO UIZQ== 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:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=sXM5tR2PZtQ95qfGvNhAHpTFt20XAazhkFBa31+ObLw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=L03zICpqttmdnOn+b2qi9Q7Tiuj5yQA4AXH0jXExsAp0zZu+nl3VK9zZ2eBQR+607x LYhNKcMm+au80pfNN8rP/fhxfUoRpfcykNpDOPdaYjcGUEPT5hjme72P5sMxiKSgrOjA v7hIugfmWSPThEtzU+n51KqE4paFJr3aDm6me5bm9cJPrqMn0imM0YcYjrDMEs/6fOQk /Y8dydvPY59QVn+ciKsi5VHffjztesG47gB4cFTz3hxLdhXcT+vBzTbyN/aWCJZn22yZ pf/lYd1cayoZG+NQbz2TKebTPoPt6XymbY246Oq+WHPOZwAkCgETns+i3HC4m1gxoI4Y YVIQ==; 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="rtez/uZ6"; 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 4fb4d7f45d1cf-57aae1fdfb9si1753232a12.280.2024.06.07.06.07.24; Fri, 07 Jun 2024 06:07:25 -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="rtez/uZ6"; 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 CC79568D81E; Fri, 7 Jun 2024 16:04:15 +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 AFF8068D763 for ; Fri, 7 Jun 2024 16:03:50 +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=rtez/uZ6; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id DCABD4D76 for ; Fri, 7 Jun 2024 15:03:49 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id XM4rraa_yi5p for ; Fri, 7 Jun 2024 15:03:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1717765422; bh=bN7AiHHSk3eoJwmWkocnm6OVR/kHvMeuHHhTP04JRtg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rtez/uZ6I5e2Tf7QgMTBH4Yd9IfqR5GMzmn9EZDCDR6T5QVw4tnQ/luPqGcObPJzk EVK9Ayyf/JK8OnsqK8YsHs88gEAu0DCiqGaBF8ma2zUoREzplVlZDG7JXpgXW6AHJS 03atHU7KUxZ67F6epQZXzLD6l9Sae3S70Ndl+cmC/m//dgOHsMid8uj6OGrNatfT9s ucjgyn/iy6tJGoPMUifVu6ipWk21RYoEHAdXtyL+JrRBJzDyV5h4Wun3Ul3AbFqiXu NoUyE7t8G+aU/ebGyoj7LE/jYp990CS3W9yMDlAdaMz4WUtFrszyJFId6aftOw8Jpd Vsg8gWUxEjZOA== 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 7CD184E08 for ; Fri, 7 Jun 2024 15:03:42 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 883763A1A22 for ; Fri, 07 Jun 2024 15:03:35 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 15:01:22 +0200 Message-ID: <20240607130135.9088-26-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240607130135.9088-1-anton@khirnov.net> References: <20240607130135.9088-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 26/39] lavc/hevcdec: move slice decoding dispatch to its own function 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: VeKbQhTB0as1 Also move there a sanity check from hls_decode_entry() that should also be performed when WPP is active (note that the check is not moved to hls_slice_header() because it requires the HEVCContext.tab_slice_address to be set up). --- libavcodec/hevc/hevcdec.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index 9c1d879953..bbcaa350c7 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -2578,14 +2578,6 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; int ret; - if (s->sh.dependent_slice_segment_flag) { - int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1]; - if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) { - av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n"); - return AVERROR_INVALIDDATA; - } - } - while (more_data && ctb_addr_ts < sps->ctb_size) { int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts]; @@ -2813,6 +2805,27 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) return res; } +static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext *gb) +{ + const HEVCPPS *pps = s->pps; + + if (s->sh.dependent_slice_segment_flag) { + int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; + int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1]; + if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) { + av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n"); + return AVERROR_INVALIDDATA; + } + } + + if (s->avctx->active_thread_type == FF_THREAD_SLICE && + s->sh.num_entry_point_offsets > 0 && + pps->num_tile_rows == 1 && pps->num_tile_columns == 1) + return hls_slice_data_wpp(s, nal); + + return hls_decode_entry(s, gb); +} + static int set_side_data(HEVCContext *s) { AVFrame *out = s->cur_frame->f; @@ -3152,12 +3165,7 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) goto fail; } - if (s->avctx->active_thread_type == FF_THREAD_SLICE && - s->sh.num_entry_point_offsets > 0 && - s->pps->num_tile_rows == 1 && s->pps->num_tile_columns == 1) - ctb_addr_ts = hls_slice_data_wpp(s, nal); - else - ctb_addr_ts = hls_decode_entry(s, &gb); + ctb_addr_ts = decode_slice_data(s, nal, &gb); if (ctb_addr_ts >= s->cur_frame->ctb_count) { ret = hevc_frame_end(s); if (ret < 0)