From patchwork Sun Jul 28 10:25:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50792 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:16f:b0:489:2eb3:e4c4 with SMTP id h47csp588970vqi; Sun, 28 Jul 2024 03:51:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJ9MJbOUUMialkunhpVTkRvLK9M3JAMrDcnuCetCsTYyfphAgXoSLgN6NJ4NOF0wiRI11sPqxhkVzIs/YecO+Wg9xdBSF1t+jd0A== X-Google-Smtp-Source: AGHT+IFnbf9gWq76OHAK3IOihou4LplNjaKwktbt6oDTlSRvn8c0gLUyaMc/rru2DA2ztBMm9NGm X-Received: by 2002:a2e:be86:0:b0:2ee:84af:dfc4 with SMTP id 38308e7fff4ca-2f12ee2eedemr34916441fa.43.1722163916837; Sun, 28 Jul 2024 03:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722163916; cv=none; d=google.com; s=arc-20160816; b=R9d12eynUZBiNl8yf9Nww7c+qNnyDTuG9+FOaKFyiKF0JLhn2zhQ4aehsfKJ8HmHcb aDHYE09kdxQqrgqJ/E7CZkanFKpKFPvzluqw6RS1r/ZOAg53tPV52warcchTy2vNxKOJ X4ZbWuxNlafYCwQcLVdswpR/3a26myR8XB6zFMsOFZL4eeCKn4zerOZV/HGIr9IHXUrE jcu07HlgPgasOdCyMt5PWXmd29MIiJ6Ion9uLSwMVGaKO1uYa8l9rjHQGxFmZRPvjr79 aXeWhlznziH7Tb4ERkFCPVA83P9cCPvTvUvMazlGKd4gl7ZTNXytZsbY6L4WijNJ9U/J oVxA== 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=7h9sSfyF4WB2qkIuCkzyTyvmMuQcaDpv0S+shW8NrGk=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=DRl80WDcejoO9PFHbTR4e/TovzbH5h/qT6TcXA35KnwjfI2jWVMwPQebVZnvflrdsl zGABzraUeTpkeS0CDk1U8HMcZmYnrwzj0LsMeV5rhmMjVMLQHYs5FZX+07P8p/GWk88w wQ4VKmKWS8aahdpa8cNsUAPNEwVEslfi4Yk87zi6Gvmkj2HSGbKQqhRITklWiK+afA90 m0MYHSBXyDLIexY1j2D4HfcMRlZiNQmeNcknmHb8p8rojCopi0MeiCoQsI1tkSf+8k8u 74Gxs0lurc6Nej5IAOlaWU6FhvaGIuWKSzIQzfV7P0PcfMHgeE5tiCEPQITKDNQ9YVey O9Rw==; 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=k8IS0clQ; 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-5ac6339b099si4970955a12.27.2024.07.28.03.51.56; Sun, 28 Jul 2024 03:51:56 -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=k8IS0clQ; 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 587A168D99A; Sun, 28 Jul 2024 13:26:07 +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 9008268D913 for ; Sun, 28 Jul 2024 13:25:41 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1722162337; bh=voQab6xmBjyq5+6kBfb+KGWiD4JUhVhz4D1GfIp45UE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k8IS0clQngZ9n2zsSHhytcPq4kjS4J08f0TSQwTLV3EqVLe/hiBK+NKoj9Gosok3r GhEBs7E4MK23wbANw64zO8ksewMUyGPFD6J+KeDCMExX7EdIpkIkDBj9+GWi7uJ8Pr J1wqU7QnpsPU4LedRKwFX8crbPDAbwQSrwOfGC1c= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 90DC542B25; Sun, 28 Jul 2024 12:25:37 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jul 2024 12:25:16 +0200 Message-ID: <20240728102527.17991-11-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240728102527.17991-1-ffmpeg@haasn.xyz> References: <20240728102527.17991-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/22] avcodec/dovi_rpuenc: add configuration for compression 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: 9pofU3CYru17 From: Niklas Haas In particular, validate that the chosen compression level is compatible with the chosen profile. --- libavcodec/dovi_rpu.h | 1 + libavcodec/dovi_rpuenc.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libavcodec/dovi_rpu.h b/libavcodec/dovi_rpu.h index 1bbc6ef02c..24a8353bdc 100644 --- a/libavcodec/dovi_rpu.h +++ b/libavcodec/dovi_rpu.h @@ -138,6 +138,7 @@ int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame); */ int ff_dovi_configure_ext(DOVIContext *s, AVCodecParameters *codecpar, const AVDOVIMetadata *metadata, + enum AVDOVICompression compression, int strict_std_compliance); /** diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c index ad161809a9..25e520dd92 100644 --- a/libavcodec/dovi_rpuenc.c +++ b/libavcodec/dovi_rpuenc.c @@ -54,6 +54,7 @@ static struct { int ff_dovi_configure_ext(DOVIContext *s, AVCodecParameters *codecpar, const AVDOVIMetadata *metadata, + enum AVDOVICompression compression, int strict_std_compliance) { AVDOVIDecoderConfigurationRecord *cfg; @@ -71,6 +72,10 @@ int ff_dovi_configure_ext(DOVIContext *s, AVCodecParameters *codecpar, if (s->enable == FF_DOVI_AUTOMATIC && !hdr) goto skip; + if (compression == AV_DOVI_COMPRESSION_RESERVED || + compression > AV_DOVI_COMPRESSION_EXTENDED) + return AVERROR(EINVAL); + switch (codecpar->codec_id) { case AV_CODEC_ID_AV1: dv_profile = 10; break; case AV_CODEC_ID_H264: dv_profile = 9; break; @@ -138,6 +143,25 @@ int ff_dovi_configure_ext(DOVIContext *s, AVCodecParameters *codecpar, goto skip; } + if (compression != AV_DOVI_COMPRESSION_NONE) { + if (dv_profile < 8 && strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { + av_log(s->logctx, AV_LOG_ERROR, "Dolby Vision metadata compression " + "is not permitted for profiles 7 and earlier. (dv_profile: %d, " + "compression: %d)\n", dv_profile, compression); + return AVERROR(EINVAL); + } else if (compression == AV_DOVI_COMPRESSION_EXTENDED && + strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { + av_log(s->logctx, AV_LOG_ERROR, "Dolby Vision extended metadata " + "compression is experimental and not supported by " + "devices."); + return AVERROR(EINVAL); + } else if (dv_profile == 8) { + av_log(s->logctx, AV_LOG_WARNING, "Dolby Vision metadata compression " + "for profile 8 is known to be unsupported by many devices, " + "use with caution.\n"); + } + } + pps = codecpar->width * codecpar->height; if (codecpar->framerate.num) { pps = pps * codecpar->framerate.num / codecpar->framerate.den; @@ -191,6 +215,7 @@ int ff_dovi_configure_ext(DOVIContext *s, AVCodecParameters *codecpar, cfg->el_present_flag = 0; cfg->bl_present_flag = 1; cfg->dv_bl_signal_compatibility_id = bl_compat_id; + cfg->dv_md_compression = compression; s->cfg = *cfg; return 0; @@ -219,7 +244,9 @@ int ff_dovi_configure(DOVIContext *s, AVCodecContext *avctx) if (sd) metadata = (const AVDOVIMetadata *) sd->data; - ret = ff_dovi_configure_ext(s, codecpar, metadata, avctx->strict_std_compliance); + /* Current encoders cannot handle metadata compression during encoding */ + ret = ff_dovi_configure_ext(s, codecpar, metadata, AV_DOVI_COMPRESSION_NONE, + avctx->strict_std_compliance); if (ret < 0) goto fail;