From patchwork Fri Jun 7 13:01:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 49646 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1009415vqo; Fri, 7 Jun 2024 06:05:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWeDw0kF3SWK2Fi/hXab/VR8UrHBlm8Ou6i13nizzu9NTFsIy5nnZwmh9833msV9me6lIoqPwqFF/thBcSXc2nDVMjpmCTFSJ3t6w== X-Google-Smtp-Source: AGHT+IFly0Yv4zyfr/bUcZo5saPRjU1pG6noiWReAk11srqg+uyA1H7aANWMhp4KHuYAAhIqk1Ce X-Received: by 2002:a17:906:f80c:b0:a62:2cae:c02 with SMTP id a640c23a62f3a-a6cdacfeda4mr149743266b.61.1717765527861; Fri, 07 Jun 2024 06:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717765527; cv=none; d=google.com; s=arc-20160816; b=wFQ9NjVZd3iiEY3s7SvUR4S8y1Pe7T00mlwFN1/l3/vDtjK6YX+82gfiLoeEtV7Iyq XMIxL4VC5oMQUmE5Cy9XB+xCKvXQU5NYjO5+cr0lcJN2KIFBtGurhOxzMi5FQwlYOKvi hS7sLTNuTpIwIBN/vVCpXwz42Y+rn+fVJebhNYtW0/O7sS6OSnemFr9y2KvhEmh76Fr4 dVUhel7yma365kFTeK01+5aAwS57VkMtiH5KEb3POzEMDIbTXE5r2AiIiNL1vmSF5xBg Jqy3GLUHSRFXIEXACHtzhWKpL0IyAPw9JScxmWna3DuBlMzV8GiX4bmavxhKZ7ynxVcM sWUQ== 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=qzJoYGLeR26LHEzp5SR9XR2ScV4QwfqWz3lX08s5tM4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=OZZJc1wZwex18J/XrWPkWUN6OIhSPrdM92J/htZzSyUu3TBQMFfjNYoWyQe/pG4VRu w9XMxzfx8ogtgv14zf41GbXekxlcDWg2aMEjecF606fKd70s4PKS9VbY7hHTupPG96zQ er5TcvGbCVAAX61oWjeYKjqNEgHUELvG1XDb0XbBo3y/Z5PF1SEmI06IvRSRpEIUjsJY VqWl9Uprsbr1HIGRktyVw7SJt3dCBkgo3Vr8yOAAy0kyAqgQETjwOXyKs8P4EAfyS8aM abOvFPB6jPSNrOrayQVTeorLs7Nuz5/oETnixSIAR8bbgd92dJl9JP+i01qLJXuvYPXA 2rAw==; 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="qF/tG2m/"; 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-a6c80708549si179430466b.645.2024.06.07.06.05.27; Fri, 07 Jun 2024 06:05:27 -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="qF/tG2m/"; 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 322D268CEC6; Fri, 7 Jun 2024 16:04:02 +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 49E1B68D761 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=qF/tG2m/; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 25F4C4DF4 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 WqTt3D9klxwx for ; Fri, 7 Jun 2024 15:03:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1717765422; bh=QLZMs344g7ynd5imVo3boYR8omPulKpWIwWBpv1qLyI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qF/tG2m/waMqeuRkEG3juiuhPcwneUGp7ckNkHxQnB/X95fF4PG80Jo006NlqWKl2 Ay2N9quXcQ2BR7T2zfBIAbUtbtfl1moLVFDoRUbJ+SXaNxpWIFWZz/sGK+FnMVwnnH a6AJwrdytutQP5iER2OhLGfXjkmD7n9CptyCqrhdkt042Z83KFwHiOLNMJt3YBG/AH buwjURyZeqIqA9mV8ggq2k9i2AcWHhxOBr6rFAiPV75p1Iset4Up1JFLBgay20tNxu q0wfZZvmuilFqXr2akrq5j7juO3H5NzJRCWjDSrzBHExYR/lzQMEze/dmhQIr+v7dE Q/CcELZXonrvg== 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 55A334E02 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 667E53A180F 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:19 +0200 Message-ID: <20240607130135.9088-23-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 23/39] lavc/hevcdec: drop redundant HEVCContext.threads_{type, number} 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: xyveLeYP9Rad They are useless duplicates of corresponding AVCodecContext fields. --- libavcodec/hevc/filter.c | 6 +++--- libavcodec/hevc/hevcdec.c | 36 +++++++++++++----------------------- libavcodec/hevc/hevcdec.h | 3 --- libavcodec/hevc/mvs.c | 4 ++-- libavcodec/hevc/refs.c | 2 +- 5 files changed, 19 insertions(+), 32 deletions(-) diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c index 081b3a3898..56e354b486 100644 --- a/libavcodec/hevc/filter.c +++ b/libavcodec/hevc/filter.c @@ -892,15 +892,15 @@ void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCPPS *pps, sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y); if (y && x_end) { sao_filter_CTB(lc, s, pps, sps, x, y - ctb_size); - if (s->threads_type & FF_THREAD_FRAME ) + if (s->avctx->active_thread_type & FF_THREAD_FRAME ) ff_progress_frame_report(&s->cur_frame->tf, y); } if (x_end && y_end) { sao_filter_CTB(lc, s, pps, sps, x , y); - if (s->threads_type & FF_THREAD_FRAME ) + if (s->avctx->active_thread_type & FF_THREAD_FRAME ) ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size); } - } else if (s->threads_type & FF_THREAD_FRAME && x_end) + } else if (s->avctx->active_thread_type & FF_THREAD_FRAME && x_end) ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size - 4); } diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index e3773a6147..f867fdbea5 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -968,8 +968,6 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) unsigned val = get_bits_long(gb, offset_len); sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size } - if (s->threads_number > 1 && (pps->num_tile_rows > 1 || pps->num_tile_columns > 1)) - s->threads_number = 1; } } @@ -1870,7 +1868,7 @@ static void chroma_mc_bi(HEVCLocalContext *lc, static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref, const Mv *mv, int y0, int height) { - if (s->threads_type == FF_THREAD_FRAME ) { + if (s->avctx->active_thread_type == FF_THREAD_FRAME ) { int y = FFMAX(0, (mv->y >> 2) + y0 + height + 9); ff_progress_frame_await(&ref->tf, y); @@ -2631,7 +2629,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) return ctb_addr_ts; } -static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, +static int hls_decode_entry_wpp(AVCodecContext *avctx, void *hevc_lclist, int job, int self_id) { HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id]; @@ -2643,7 +2641,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, int ctb_row = job; int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((sps->width + ctb_size - 1) >> sps->log2_ctb_size); int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs]; - int thread = ctb_row % s->threads_number; + int thread = ctb_row % avctx->thread_count; const uint8_t *data = s->data + s->sh.offset[ctb_row]; const size_t data_size = s->sh.size[ctb_row]; @@ -2736,8 +2734,8 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) return AVERROR_INVALIDDATA; } - if (s->threads_number > s->nb_local_ctx) { - HEVCLocalContext *tmp = av_malloc_array(s->threads_number, sizeof(*s->local_ctx)); + if (s->avctx->thread_count > s->nb_local_ctx) { + HEVCLocalContext *tmp = av_malloc_array(s->avctx->thread_count, sizeof(*s->local_ctx)); if (!tmp) return AVERROR(ENOMEM); @@ -2746,7 +2744,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) av_free(s->local_ctx); s->local_ctx = tmp; - for (unsigned i = s->nb_local_ctx; i < s->threads_number; i++) { + for (unsigned i = s->nb_local_ctx; i < s->avctx->thread_count; i++) { tmp = &s->local_ctx[i]; memset(tmp, 0, sizeof(*tmp)); @@ -2756,7 +2754,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) tmp->common_cabac_state = &s->cabac; } - s->nb_local_ctx = s->threads_number; + s->nb_local_ctx = s->avctx->thread_count; } offset = s->sh.data_offset; @@ -2795,7 +2793,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) s->data = data; - for (i = 1; i < s->threads_number; i++) { + for (i = 1; i < s->nb_local_ctx; i++) { s->local_ctx[i].first_qp_group = 1; s->local_ctx[i].qp_y = s->local_ctx[0].qp_y; } @@ -3157,7 +3155,9 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal) goto fail; } - if (s->threads_number > 1 && s->sh.num_entry_point_offsets > 0) + 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); @@ -3282,7 +3282,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length) } fail: - if (s->cur_frame && s->threads_type == FF_THREAD_FRAME) + if (s->cur_frame && s->avctx->active_thread_type == FF_THREAD_FRAME) ff_progress_frame_report(&s->cur_frame->tf, INT_MAX); return ret; @@ -3610,9 +3610,6 @@ static int hevc_update_thread_context(AVCodecContext *dst, s->is_nalff = s0->is_nalff; s->nal_length_size = s0->nal_length_size; - s->threads_number = s0->threads_number; - s->threads_type = s0->threads_type; - s->film_grain_warning_shown = s0->film_grain_warning_shown; if (s0->eos) { @@ -3660,17 +3657,10 @@ static av_cold int hevc_decode_init(AVCodecContext *avctx) int ret; if (avctx->active_thread_type & FF_THREAD_SLICE) { - s->threads_number = avctx->thread_count; ret = ff_slice_thread_init_progress(avctx); if (ret < 0) return ret; - } else - s->threads_number = 1; - - if((avctx->active_thread_type & FF_THREAD_FRAME) && avctx->thread_count > 1) - s->threads_type = FF_THREAD_FRAME; - else - s->threads_type = FF_THREAD_SLICE; + } ret = hevc_init_context(avctx); if (ret < 0) diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index 22367602aa..75026a8deb 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -453,9 +453,6 @@ typedef struct HEVCContext { HEVCLocalContext *local_ctx; unsigned nb_local_ctx; - uint8_t threads_type; - uint8_t threads_number; - /** 1 if the independent slice segment header was successfully parsed */ uint8_t slice_initialized; diff --git a/libavcodec/hevc/mvs.c b/libavcodec/hevc/mvs.c index 3fd7be5b32..772fedceeb 100644 --- a/libavcodec/hevc/mvs.c +++ b/libavcodec/hevc/mvs.c @@ -248,7 +248,7 @@ static int temporal_luma_motion_vector(const HEVCContext *s, const HEVCSPS *sps, x < sps->width) { x &= ~15; y &= ~15; - if (s->threads_type == FF_THREAD_FRAME) + if (s->avctx->active_thread_type == FF_THREAD_FRAME) ff_progress_frame_await(&ref->tf, y); x_pu = x >> sps->log2_min_pu_size; y_pu = y >> sps->log2_min_pu_size; @@ -262,7 +262,7 @@ static int temporal_luma_motion_vector(const HEVCContext *s, const HEVCSPS *sps, y = y0 + (nPbH >> 1); x &= ~15; y &= ~15; - if (s->threads_type == FF_THREAD_FRAME) + if (s->avctx->active_thread_type == FF_THREAD_FRAME) ff_progress_frame_await(&ref->tf, y); x_pu = x >> sps->log2_min_pu_size; y_pu = y >> sps->log2_min_pu_size; diff --git a/libavcodec/hevc/refs.c b/libavcodec/hevc/refs.c index 5bd5eab9f1..48fc4d27da 100644 --- a/libavcodec/hevc/refs.c +++ b/libavcodec/hevc/refs.c @@ -435,7 +435,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) frame->sequence = HEVC_SEQUENCE_COUNTER_INVALID; frame->flags = 0; - if (s->threads_type == FF_THREAD_FRAME) + if (s->avctx->active_thread_type == FF_THREAD_FRAME) ff_progress_frame_report(&frame->tf, INT_MAX); return frame;