From patchwork Fri Jun 7 13:01:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 49664 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1011699vqo; Fri, 7 Jun 2024 06:08:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXmI3x+j74UiC7y4JzHwh8OkuUlqimBuPt6p8FCmZnniy9pGoGQpFfvLMt8xNUW3ZB6MUubSXRByQ97LMzMAnOh8vfruj66jv6kAQ== X-Google-Smtp-Source: AGHT+IGG2cHx+7m1gKwP53OSq1EIXDaf3YDe19lUeRMEBUOTh7mNj9iuLTD1yiVYMXL6geBqIekZ X-Received: by 2002:a50:a415:0:b0:57a:2400:6fb9 with SMTP id 4fb4d7f45d1cf-57c50926b51mr1605642a12.20.1717765715661; Fri, 07 Jun 2024 06:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717765715; cv=none; d=google.com; s=arc-20160816; b=Nn0TJO5DgPuX6yHUlqm1YrHKwAu6Q4RUZEYT5TsCLr0EIVDSiYxMSS3Uv6j60Jigd9 XLMsxOKBa5AJl6d2UScJbcga271x80+LGAxB1m1lk/1tLaOfj+2rTPr7zO6QHoZYy+pc ncT1dKO93AagGojogPIaTCWKxiPNLSDu0xApTDRyEIpq7ixXoJKkLVvTXfPglItQksgD hS0fqPsqTCqBAdbr+2cXOIywktooDnU47vN+sZzGfITit6FTIElJxrymrKOJIKDTN31V jofVR9GYnpIwfklvGGBt+t5lXqN5PzbZ6t+FPxXKew0V953FtDLX5uYt/2L5gCjc7oFa UJVw== 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=eGfVxkgzmGMpQminiAg/jt7g+GmKSnnGf9gp85PwAeU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=sAEUiAb/o6ocV/UNwtao9fTZq0gPTPLYKJECQhj9O4V9YN8J7o2GRl6um9cyYnMbmT 49BLx6zAuSlqOH3eCnls2OYH8cX5ADP3oRYzRY/5+fXve1FSv/aLZrou/eDjo8TQ68SJ 62otJuoOHu93WAaA1qWlcPHeMIBkmxt1ajtQYVmwAD3lCEijfI1totI3FOnOGgvw88Q4 lm+CCg0b7mlSQ//4NEQkigcWAse28ZFd5DathmzYH2e6ph7IPJcPFrQH8e6MznA2weWw VFjPUNfzX9F8xmRZ7phyfh8s5htjr8buip9DXXkYwI6glqOEQo3sPgoDK6FE9M+C1hNF C4rg==; 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=cGbSMI8p; 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-57c5f24ad96si442303a12.195.2024.06.07.06.08.35; Fri, 07 Jun 2024 06:08:35 -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=cGbSMI8p; 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 5BE2068D842; Fri, 7 Jun 2024 16:04:25 +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 8F78568D7B3 for ; Fri, 7 Jun 2024 16:03:51 +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=cGbSMI8p; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 7986C4D76 for ; Fri, 7 Jun 2024 15:03:51 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id AzOtRJtwHdap for ; Fri, 7 Jun 2024 15:03:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1717765422; bh=nkhomVhzMfOqaIl57qMjt1QZ2bvZSSK4dF+uRSh56PQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cGbSMI8p43ioqMJDgatvhAPfm+9Po34O1JH39vVmwd/SGFUY/ULz0ugRAKc0EDWtI k8ub4kgWVziCS/7VBaZVUvBbJudAIHTELeVokLQ1Gx3YVQ7LHfNqT0xYA4eg4KexvG n8xjQYoBMqc1x4M8uxhl0Aac9xbhc/pcxyH5GkXdHS2DG273dJb9QBXPSpwiIxg9lA M2I4wAzdc32hr/sdPiMIp4U/c33aGsaYzoKg901MFb6NezAwpNbbB65WbHsL38aAOO Js7md6gIZ+fKod3qFw3wgUhSZyt4OWpTOxCI+9ld7hpiUROQn6+GEmBTbY34vE/g9S Fg8tbnUQnCXNw== 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 D3CDC4E0C 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 B72483A1A61 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:26 +0200 Message-ID: <20240607130135.9088-30-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 30/39] lavc/hevcdec: move constructing slice RPL to decode_slice_data() 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: etSqSjZ4NvmC --- libavcodec/hevc/hevcdec.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index c148244361..804cceac3e 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -665,11 +665,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) if (!sh->dependent_slice_segment_flag) { sh->slice_addr = sh->slice_segment_addr; - s->slice_idx++; } } else { sh->slice_segment_addr = sh->slice_addr = 0; - s->slice_idx = 0; s->slice_initialized = 0; } @@ -2801,6 +2799,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext *gb) { const HEVCPPS *pps = s->pps; + int ret; if (s->sh.dependent_slice_segment_flag) { int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; @@ -2811,6 +2810,15 @@ static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext } } + if (!s->sh.dependent_slice_segment_flag && s->sh.slice_type != HEVC_SLICE_I) { + ret = ff_hevc_slice_rpl(s); + if (ret < 0) { + av_log(s->avctx, AV_LOG_WARNING, + "Error constructing the reference lists for the current slice.\n"); + return ret; + } + } + if (s->avctx->hwaccel) return FF_HW_CALL(s->avctx, decode_slice, nal->raw_data, nal->raw_size); @@ -2828,6 +2836,8 @@ static int decode_slice_data(HEVCContext *s, const H2645NAL *nal, GetBitContext s->local_ctx[0].tu.cu_qp_offset_cb = 0; s->local_ctx[0].tu.cu_qp_offset_cr = 0; + s->slice_idx += !s->sh.dependent_slice_segment_flag; + 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) @@ -2938,6 +2948,7 @@ static int hevc_frame_start(HEVCContext *s) memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address)); s->is_decoded = 0; + s->slice_idx = 0; s->first_nal_type = s->nal_unit_type; s->poc = s->sh.poc; @@ -3151,16 +3162,6 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) return AVERROR_INVALIDDATA; } - if (!s->sh.dependent_slice_segment_flag && - s->sh.slice_type != HEVC_SLICE_I) { - ret = ff_hevc_slice_rpl(s); - if (ret < 0) { - av_log(s->avctx, AV_LOG_WARNING, - "Error constructing the reference lists for the current slice.\n"); - goto fail; - } - } - ctb_addr_ts = decode_slice_data(s, nal, &gb); if (ctb_addr_ts >= s->cur_frame->ctb_count) { ret = hevc_frame_end(s);