From patchwork Tue Jun 18 19:35:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 50005 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp2780081vqg; Tue, 18 Jun 2024 12:42:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU5O6U2nP+5BNDPJSgIYlP1YYXk3w1e1zZ2bdeofZ76dImuqAJdRIdVkMqMT7gsxtoYTVIbCfB/xv+UO7ifuYGXIIQeASZ57OXZBA== X-Google-Smtp-Source: AGHT+IGaUQHdzyRYBkm2TkTj4ZwEghSlHCqZ3LxYCnQ7ho6Uc9eajh0mXVCqjpNGs1EdWs7lorFP X-Received: by 2002:a50:a6da:0:b0:57c:612e:6ded with SMTP id 4fb4d7f45d1cf-57d07c55b1dmr230883a12.0.1718739774758; Tue, 18 Jun 2024 12:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718739774; cv=none; d=google.com; s=arc-20160816; b=SAM9jFVJePL1KM6lF/SjXIdbX+EaT8oq9ytghiiDZeBncrzWDe+xN2RDEzrGqBCNny B0EkdlnqNy2DJPK9xunxAEryeCKarZHAeJig4BnZXpDCJ1emZa2C4gBolfBCYVON1D// i9B0H2C+VIA/lLY69DaGNRvSpsGk6SDI+Ky0SQJLHgyDZ6jzdXi6N5d9Cpi1SmFs+Ff6 81AnFBjNd8ThoyE539XGxQJaZ+G2avputNwX2jq6dg1+XLbvF/BjbzJq2jA8FRYuAiCn 0CDgPpbNfkwrx3O6YC/PA9LiPFcVFxFnTmSzT7etDdsgcXruk3QKmTtY+R4JHCF58k6b V45A== 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=286DPrEYJvLAglvjKFQcwo/SOqdij5vyWYw2pGeimpg=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=k6QWiJeSEpEAuby8zU1u6PH805KDHRi3eQASQyZgtHug6TGfqnR7K1s0FDY2eFYvdY E49xnQDIKt4CWVEpHPKMuphw5JekpY6GSbXyOATz8AO/i/gSaBEnVLo435tujEs5mO5h IetpodUmSW3iSf/OO3grcyVkx/7PK4j75+cbXynqxGfkBZIFWv8UydUSh0imB22cHBM0 2zupuf7Hx+95CfLoceORD2MKfTKNIHitJtrmykLlWcbCVgBqBpIObAVs5Y7crDj9aKuN y+5JaNH2anV5JISjLlMRmg9uMAnIlAH7jkTBUeWN65ImlJ9/ZOtkJ46ZAuYOUkyJtp5/ q/jg==; 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=vFOso6FU; 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-57cb7461e2asi5864272a12.613.2024.06.18.12.42.54; Tue, 18 Jun 2024 12:42:54 -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=vFOso6FU; 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 D46E068D768; Tue, 18 Jun 2024 22:42:34 +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 0785668D5B5 for ; Tue, 18 Jun 2024 22:42:24 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1718739743; bh=kbE+IycUhgSjPjB4uqlciLk4w/rfi3r/RlpphK/GmTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vFOso6FUHW7a8BymbG2LZZ4S63SWM9rg8ixl2h8ug3cTcU3wZV+Owv2uJeX/NJglU U1tBMtEgqXVGIVwof2diuj/f9UQKMyp+SKxvl1UNm/IET82LMqzPAFak2ccVZ/ihuv Cw1lXOuBuXmZqqm40S7P+zXO+sDSQ3QeemqySrzs= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id C6F7641C1E; Tue, 18 Jun 2024 21:42:23 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Jun 2024 21:35:32 +0200 Message-ID: <20240618194221.26073-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240618194221.26073-1-ffmpeg@haasn.xyz> References: <20240618194221.26073-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/8] avcodec/dovi_rpuenc: also copy ext blocks to dovi ctx 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: ajl1n0qjnTF+ From: Niklas Haas As the comment implies, DOVIContext.ext_blocks should also reflect the current state after ff_dovi_rpu_generate(). Fluff for now, but will be needed once we start implementing metadata compression for extension blocks as well. --- libavcodec/dovi_rpuenc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c index a6262844d4..45fcd9a86c 100644 --- a/libavcodec/dovi_rpuenc.c +++ b/libavcodec/dovi_rpuenc.c @@ -506,6 +506,12 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, } } + if (metadata->num_ext_blocks && !s->ext_blocks) { + s->ext_blocks = ff_refstruct_allocz(sizeof(AVDOVIDmData) * AV_DOVI_MAX_EXT_BLOCKS); + if (!s->ext_blocks) + return AVERROR(ENOMEM); + } + vdr_dm_metadata_present = memcmp(color, &ff_dovi_color_default, sizeof(*color)); use_prev_vdr_rpu = !memcmp(s->vdr[vdr_rpu_id], mapping, sizeof(*mapping)); if (num_ext_blocks_v1 || num_ext_blocks_v2) @@ -635,6 +641,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, } if (vdr_dm_metadata_present) { + size_t ext_sz; const int denom = profile == 4 ? (1 << 30) : (1 << 28); set_ue_golomb(pb, color->dm_metadata_id); /* affected_dm_id */ set_ue_golomb(pb, color->dm_metadata_id); /* current_dm_id */ @@ -672,6 +679,11 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, for (int i = 0; i < metadata->num_ext_blocks; i++) generate_ext_v2(pb, av_dovi_get_ext(metadata, i)); } + + ext_sz = FFMIN(sizeof(AVDOVIDmData), metadata->ext_block_size); + for (int i = 0; i < metadata->num_ext_blocks; i++) + memcpy(&s->ext_blocks[i], av_dovi_get_ext(metadata, i), ext_sz); + s->num_ext_blocks = metadata->num_ext_blocks; } else { s->color = &ff_dovi_color_default; s->num_ext_blocks = 0;