From patchwork Fri Apr 12 11:35:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 48015 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp203070pzb; Fri, 12 Apr 2024 04:37:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXPRNwIKPK3IsVztkZ5Wb9HMPBcUsPBBiuGZP99ZcNlEfcX+ocdouVMMdKbf5Luh55qDPcGs0ON68ICv1c/2yd6roNXV5Fpid/MGQ== X-Google-Smtp-Source: AGHT+IGuyewzs+6FVVP+ShIaYf+ZwC5ZZTI2nTreKGwUYHzYG2ew1N3vtaMaM81oepTGp63z4Q7E X-Received: by 2002:a17:907:928a:b0:a52:3d34:bde5 with SMTP id bw10-20020a170907928a00b00a523d34bde5mr560222ejc.1.1712921865398; Fri, 12 Apr 2024 04:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712921865; cv=none; d=google.com; s=arc-20160816; b=t5tjYpyc0kGc/6Wy2R66R5T9FojbuxzXDi8o/2Kuz5AYfpxyp79wyl6wHkQJ0wgw4I T87Nmb8F8THJDzdLWS2qGuktTaSPa3b5Dg9MxTNcf/2rSeosbaUiuoNnNiRcm3nVJ6GH S2w+lAp4YxbPPwh1JQ/cNP0AXdyPICWcioUBHh9GLf9tY2Un2q3Aca0G5+wfxM0uTjLL sAG6m0Qccn7M10BzQGuUQ5wjKkkx8+TqONALRz1FrQI5JSSo2wPEgE1UTsdKLmJL16SG DEqFROxBRU8apdFWEhxZ13qJstLkrL/hVjDR+/hkzSUOGhk6jaJZoR5NpTArclnVvMnW XbSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=U5AfgH3w8w7/FPw7DC98GUqaGmUs9WazTb/50tK1OWU=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=EPdoNSeJEudKPpa0a/FIfWnz7YpAYangQvGtxcdS8kq+fUSNRb8B63c5Sp8n6fEic3 xHGNqYQzDUV5oGuqDsZNUspqfn73W2pw0Knd9b7pHXs9czU5Ks2lo5CNaXXPbui00M// zyRMC4RwYoNhiQwE0rGx/GEpdjR/o667cWAXh3ziLromYlXNNTzEa0YvxbRM/8FzGx87 bYXXg7yFcmJHKOLvU0cEooAtgS599plYCk7YMpZpH4k4NwwWk1SQ83Inde2a0fgET8Rn dp7uCnkqwirmsqugWmxCUdvMemdz89XG54fA1LKRo6dBPGXjXLXe7PHIv6pIUR6FHYIV 3vbA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=aU4EiUvJ; 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 hd44-20020a17090796ac00b00a522434c766si1469923ejc.290.2024.04.12.04.37.45; Fri, 12 Apr 2024 04:37:45 -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=@haasn.xyz header.s=mail header.b=aU4EiUvJ; 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 0891968D2CE; Fri, 12 Apr 2024 14:36:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B74668D222 for ; Fri, 12 Apr 2024 14:36:24 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712921783; bh=/6JPQaqNDsRUydZteFg6OxE8yULFQyhiY3BUFmX/lB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aU4EiUvJYH/xN+E54EVrCVhcYf7K3c67Afpc4Bf7VIGC0UJ1TyCl7XiWMqe+iXbjm HvdgtjUQjn6j7/1I3qwujGM3oyACiQQ1lHWmyMxfWApYWGX/BA2yBe4swHLH4giYuI MRe7PoXjXGN4v7zcLDr00mPAmuxgwhNcnUllHnSM= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id CC6C643065; Fri, 12 Apr 2024 13:36:23 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 12 Apr 2024 13:35:18 +0200 Message-ID: <20240412113620.84013-5-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240412113620.84013-1-ffmpeg@haasn.xyz> References: <20240412113620.84013-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 04/13] avcodec/dovi_rpu: expose guess_profile(), clarify semantics 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7TtwJrMgpQAG From: Niklas Haas To allow internally re-using it for both the encoder and decoder. This is based on HEVC only, H.264/AV1 use their own (hopefully correctly signalled) profiles (and in particular, the AV1 decoders implicitly default the correct profile in the absence of a configuration record). --- libavcodec/dovi_rpu.c | 4 ++-- libavcodec/dovi_rpu.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libavcodec/dovi_rpu.c b/libavcodec/dovi_rpu.c index 267e52ceb6..77fef8c496 100644 --- a/libavcodec/dovi_rpu.c +++ b/libavcodec/dovi_rpu.c @@ -121,7 +121,7 @@ int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame) return 0; } -static int guess_profile(const AVDOVIRpuDataHeader *hdr) +int ff_dovi_guess_profile_hevc(const AVDOVIRpuDataHeader *hdr) { switch (hdr->vdr_rpu_profile) { case 0: @@ -510,7 +510,7 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, use_prev_vdr_rpu = get_bits1(gb); use_nlq = (hdr->rpu_format & 0x700) == 0 && !hdr->disable_residual_flag; - profile = s->cfg.dv_profile ? s->cfg.dv_profile : guess_profile(hdr); + profile = s->cfg.dv_profile ? s->cfg.dv_profile : ff_dovi_guess_profile_hevc(hdr); if (profile == 5 && use_nlq) { av_log(s->logctx, AV_LOG_ERROR, "Profile 5 RPUs should not use NLQ\n"); goto fail; diff --git a/libavcodec/dovi_rpu.h b/libavcodec/dovi_rpu.h index 9a68e45bf1..a866bbfebe 100644 --- a/libavcodec/dovi_rpu.h +++ b/libavcodec/dovi_rpu.h @@ -87,6 +87,10 @@ void ff_dovi_ctx_flush(DOVIContext *s); * DOVIContext struct. * * Returns 0 or an error code. + * + * Note: `DOVIContext.cfg` should be initialized before calling into this + * function. If not done, the profile will be guessed according to HEVC + * semantics. */ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, int err_recognition); @@ -96,4 +100,11 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, */ int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame); +/** + * Internal helper function to guess the correct DV profile for HEVC. + * + * Returns the profile number or 0 if unknown. + */ +int ff_dovi_guess_profile_hevc(const AVDOVIRpuDataHeader *hdr); + #endif /* AVCODEC_DOVI_RPU_H */