From patchwork Thu May 23 03:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Stejerean X-Patchwork-Id: 49161 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:542:0:b0:460:55fa:d5ed with SMTP id 63csp777436vqf; Wed, 22 May 2024 20:45:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUVS01IPBX2KgPktQU1Y/1ZZU5L/FF9azNOkVLEhG0qfbbC8aluLZCOZLweUQ8Y0jDaFeb7Fqagn7LVgWCTEkuoeRKnyiriNE6Nhw== X-Google-Smtp-Source: AGHT+IGs/mTMoJLPhHUeJLgFzTnigSxrbSQqU6HkdmQqnoFfxwzAFaCPV337KWyfNxpi1d4iVy7Y X-Received: by 2002:a05:6402:50c8:b0:572:6698:9247 with SMTP id 4fb4d7f45d1cf-57832a0fd91mr2388599a12.1.1716435956329; Wed, 22 May 2024 20:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716435956; cv=none; d=google.com; s=arc-20160816; b=eo8zibRG1RTIbExBE8F7mVuCr6WBDselCRwoTsfEfgn99n8gdOeNe0RkfEQ3FLnT70 abCYDooSWN6wwY5AqxT7w/tQBog0xgOknRZOww9FcQLfWSaA3Z8Q2kbCrUwNkYJazJ8y BnCv5fnrf5Uc/j60n1Q2j3GigcyJKwPvGVQpapTYDM3llAbkjcI6dQfgRlppHXTvJ2kn ydXnNL70829PW1RrKntc3Aoob2X83q4be5LNs1Q4aL1UrI7yPhs3830EEeiPNus6prY3 gCRVtPS84ytGgmiHoQGkCVeOMvj4a5R1bURPzbryNdrdaZCC7N6VVoPfmB7jyVtxqcKl TLiw== 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:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:message-id:thread-topic :thread-index:references:mime-version:date:to:delivered-to; bh=jnMK+/myS1iWclFEs95WJXuJFBh8OANQfGqkkEZZ00g=; fh=CBS/D0cB4KwqFBY8d8UQ4TY1w6HZ9TulitLE+VqI2+k=; b=Mk3p/cdlJ6rEFF9oi3NAy0DoVVTsn3jaAQbrfDngA2UEWV3Et9XXqRl7/+i7LjFVlK MXiRV0tLzsfcaPgpnk5SCv5QmblZ01WiEpGaqxfYlhoHJ2SWsdm0UcD2FXn4hflucoOP XH5+2VcZ/LncKOkg5EBPBj6BnIdoly8aHEfwpe9hFvD3p0tjJ4Ei0grscDoGK1nzpahz 7q5+e9VpiZOcR6FvfSP9HpCHDU/QSjnd1So0h8ZCCesO/yzXc+oqaPaHXo939jM8xeqp JfxTvdhQTNPV2pDqu8A99BH2HDZf7lMQTysSpBFZXguHbQr3HWmtEqJqWMJZ6+E5eUvT kpfg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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-5733c3412f4si16300547a12.476.2024.05.22.20.45.55; Wed, 22 May 2024 20:45: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; 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 DB23F68D4A6; Thu, 23 May 2024 06:45:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a27-107.smtp-out.us-west-2.amazonses.com (a27-107.smtp-out.us-west-2.amazonses.com [54.240.27.107]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C3BBF68D14E for ; Thu, 23 May 2024 06:45:46 +0300 (EEST) To: =?utf-8?q?ffmpeg-devel=40ffmpeg=2Eorg?= Date: Thu, 23 May 2024 03:45:44 +0000 Mime-Version: 1.0 References: <20240523034540.39960-1-cosmin@cosmin.at> X-Mailer: Amazon WorkMail Thread-Index: AQHarMOvJ2h/aTBfRJOj5+Uim2jVRA== Thread-Topic: [PATCH v2] avcodec/dovi - disable metadata compression by default X-Original-Mailer: git-send-email 2.42.1 X-Wm-Sent-Timestamp: 1716435943 Message-ID: <0101018fa38e031b-b9f59614-db2b-42f8-9d91-7892329ea5fa-000000@us-west-2.amazonses.com> Feedback-ID: ::1.us-west-2.An468LAV0jCjQDrDLvlZjeAthld7qrhZr+vow8irkvU=:AmazonSES X-SES-Outgoing: 2024.05.23-54.240.27.107 Subject: [FFmpeg-devel] [PATCH v2] avcodec/dovi - disable metadata compression by default 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: , X-Patchwork-Original-From: Cosmin Stejerean via ffmpeg-devel From: Cosmin Stejerean Reply-To: FFmpeg development discussions and patches Cc: =?utf-8?q?Cosmin_Stejerean?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CnXfP6D+2tKD From: Cosmin Stejerean not all clients support metadata compression, output when vdr_dm_metadata_changed fails the DV verifier. --- libavcodec/dovi_rpu.h | 10 ++++++++++ libavcodec/dovi_rpuenc.c | 8 ++++++-- libavcodec/libaomenc.c | 3 +-- libavcodec/libsvtav1.c | 3 +-- libavcodec/libx265.c | 3 +-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/libavcodec/dovi_rpu.h b/libavcodec/dovi_rpu.h index 8ce0c88e9d..dee34165c9 100644 --- a/libavcodec/dovi_rpu.h +++ b/libavcodec/dovi_rpu.h @@ -28,6 +28,11 @@ #include "libavutil/frame.h" #include "avcodec.h" +#define DOVI_ENCODING_OPTS \ + { "dolbyvision", "Enable Dolby Vision RPU coding", OFFSET(dovi.enable), AV_OPT_TYPE_BOOL, {.i64 = FF_DOVI_AUTOMATIC }, -1, 1, VE, .unit = "dovi" }, \ + { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DOVI_AUTOMATIC}, .flags = VE, .unit = "dovi" }, \ + { "dv_enable_compression", "Enable Dolby Vision metadata compression", OFFSET(dovi.enable_compression), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, VE }, + #define DOVI_MAX_DM_ID 15 typedef struct DOVIContext { void *logctx; @@ -71,6 +76,11 @@ typedef struct DOVIContext { AVDOVIDmData *ext_blocks; int num_ext_blocks; + /** + * Enable metadata compression in the output. Currently this is experimental. + */ + int enable_compression; + /** * Private fields internal to dovi_rpu.c */ diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c index 3c3e0f84c0..26ed25733a 100644 --- a/libavcodec/dovi_rpuenc.c +++ b/libavcodec/dovi_rpuenc.c @@ -512,8 +512,12 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, } } - vdr_dm_metadata_changed = !s->color || memcmp(s->color, color, sizeof(*color)); - use_prev_vdr_rpu = !memcmp(&s->vdr[vdr_rpu_id]->mapping, mapping, sizeof(*mapping)); + // the output when vdr_dm_metadata_changed is 0 fails the DV verifier + // force it to 1 until we can get some samples or documentation on correct syntax + vdr_dm_metadata_changed = 1; // !s->color || memcmp(s->color, color, sizeof(*color)); + + // not all clients support metadata compression + use_prev_vdr_rpu = s->enable_compression && !memcmp(&s->vdr[vdr_rpu_id]->mapping, mapping, sizeof(*mapping)); buffer_size = 12 /* vdr seq info */ + 5 /* CRC32 + terminator */; buffer_size += num_ext_blocks_v1 * 13; diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index dec74ebecd..3837eaaec2 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -1487,8 +1487,7 @@ static const AVOption options[] = { { "ssim", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AOM_TUNE_SSIM}, 0, 0, VE, .unit = "tune"}, FF_AV1_PROFILE_OPTS { "still-picture", "Encode in single frame mode (typically used for still AVIF images).", OFFSET(still_picture), AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, VE }, - { "dolbyvision", "Enable Dolby Vision RPU coding", OFFSET(dovi.enable), AV_OPT_TYPE_BOOL, {.i64 = FF_DOVI_AUTOMATIC }, -1, 1, VE, .unit = "dovi" }, - { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DOVI_AUTOMATIC}, .flags = VE, .unit = "dovi" }, + DOVI_ENCODING_OPTS { "enable-rect-partitions", "Enable rectangular partitions", OFFSET(enable_rect_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, { "enable-1to4-partitions", "Enable 1:4/4:1 partitions", OFFSET(enable_1to4_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, { "enable-ab-partitions", "Enable ab shape partitions", OFFSET(enable_ab_partitions), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 2fef8c8971..d747c31824 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -731,8 +731,7 @@ static const AVOption options[] = { AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE }, { "svtav1-params", "Set the SVT-AV1 configuration using a :-separated list of key=value parameters", OFFSET(svtav1_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE }, - { "dolbyvision", "Enable Dolby Vision RPU coding", OFFSET(dovi.enable), AV_OPT_TYPE_BOOL, {.i64 = FF_DOVI_AUTOMATIC }, -1, 1, VE, .unit = "dovi" }, - { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DOVI_AUTOMATIC}, .flags = VE, .unit = "dovi" }, + DOVI_ENCODING_OPTS {NULL}, }; diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index ac1dbc4f97..30a0b3d205 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -951,8 +951,7 @@ static const AVOption options[] = { { "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE }, { "x265-params", "set the x265 configuration using a :-separated list of key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, VE }, #if X265_BUILD >= 167 - { "dolbyvision", "Enable Dolby Vision RPU coding", OFFSET(dovi.enable), AV_OPT_TYPE_BOOL, {.i64 = FF_DOVI_AUTOMATIC }, -1, 1, VE, .unit = "dovi" }, - { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DOVI_AUTOMATIC}, .flags = VE, .unit = "dovi" }, + DOVI_ENCODING_OPTS #endif { NULL } };