From patchwork Wed May 22 15:50:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Stejerean X-Patchwork-Id: 49149 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:542:0:b0:460:55fa:d5ed with SMTP id 63csp465779vqf; Wed, 22 May 2024 08:51:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+wHOsrwN+5MR0nR0kK+rWIf3DihxV7EueyyG2odN4ee1DS+a3R8E5C1bYVXCvk9zpynefiWguWt4JHgl4grSP4F2Wd4gz2wYnaA== X-Google-Smtp-Source: AGHT+IGJcKAHGUT/PJ31uKH5kwot4MgZsDukSlCytCwIeYzcmCJFhoVbU3Q9R36wr8c14YpshiUE X-Received: by 2002:a19:5512:0:b0:520:676a:7322 with SMTP id 2adb3069b0e04-526c0b5db7bmr2028070e87.46.1716393070269; Wed, 22 May 2024 08:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716393070; cv=none; d=google.com; s=arc-20160816; b=Adu3J9Uxaf6dpgSA6Y62tgHHmhW4rLJasf7Qgoh+PLhjhvJEgN9DuwrCForZIFcCXT pUb95hfbZP6BM25hNbSewdiCN2yuGAnCCzZ81XdK2aWQPmopvAoM6wgBfCwMorjZiN+n 4zFk1wvU47ebDSw0ezRXsw71SftiFCUOnhy7E02CMeRz4kPtc3JAn8w4V4PnOtQ70JMS XMNUxFva5i+MD3aodar2U0KY+sMydZbX79Maxde8nHFxcbT3ScPpbh8nfMEp1RcpZOCg 4vWErxPDvNG+Gq7WcEUxPerzNW8dy7zkVfWsVtW3uSycI9tKFN9s0KEJvr6FX82jpnnK 5e0g== 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:in-reply-to:mime-version:date:to :delivered-to; bh=rEU5RdSsDJbyhicNg4VIHm4eonQmOIw6MjCU3SUs4+Y=; fh=CBS/D0cB4KwqFBY8d8UQ4TY1w6HZ9TulitLE+VqI2+k=; b=xe/bH6+lL3KXH8Ueoa6HOYqn0S88zNLxfEv1KmaWqPzzNwRYHw55okF6+iXNDLu2C7 YHXoeSojDhGe+z3i0sdL1T0CbrOSo58rlakm7/EsvTFsveAJtwZTy7Dr8WYvqhWaQDvb o5ORCeJyoifbqmG25ay8IyJ9gBbBbiJ6uOIRM4vCkC7/4DOnJ2vMVPyXK6BsQccZFzPU vOF7jMFJjUCvpT3U47Z08gep/rDFFxeD9tWVhG8LigenaGi+JdOv6+XA2mbc3jiKZiYY 5rn4g+Tze+VM6/kQS9lHULFFl2s422cb83nadmqSx+XUp4HcDXvhaghjetRKyEMWRUUD G2/Q==; 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 a640c23a62f3a-a5ce94bc2d2si826531666b.31.2024.05.22.08.51.09; Wed, 22 May 2024 08:51:10 -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 586BE68D3EC; Wed, 22 May 2024 18:50:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a27-230.smtp-out.us-west-2.amazonses.com (a27-230.smtp-out.us-west-2.amazonses.com [54.240.27.230]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A8F8B68D3D7 for ; Wed, 22 May 2024 18:50:47 +0300 (EEST) To: =?utf-8?q?ffmpeg-devel=40ffmpeg=2Eorg?= Date: Wed, 22 May 2024 15:50:45 +0000 Mime-Version: 1.0 In-Reply-To: <20240522155031.33491-1-cosmin@cosmin.at> References: <20240522155031.33491-1-cosmin@cosmin.at> <20240522155031.33491-3-cosmin@cosmin.at> X-Mailer: Amazon WorkMail Thread-Index: AQHarF/HF65EW+ofRf6MqZNSpEw9twAAAF6J Thread-Topic: [PATCH v3 2/2] avcodec/dovi - correctly read el_bit_depth_minus8 and ext_mapping_idc X-Original-Mailer: git-send-email 2.42.1 X-Wm-Sent-Timestamp: 1716393044 Message-ID: <0101018fa0ff6c48-f1f4e7e8-6933-4a4b-ac8e-12d0c7811a4e-000000@us-west-2.amazonses.com> Feedback-ID: ::1.us-west-2.An468LAV0jCjQDrDLvlZjeAthld7qrhZr+vow8irkvU=:AmazonSES X-SES-Outgoing: 2024.05.22-54.240.27.230 Subject: [FFmpeg-devel] [PATCH v3 2/2] avcodec/dovi - correctly read el_bit_depth_minus8 and ext_mapping_idc 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: UphZcj8gablw From: Cosmin Stejerean These two fields are coded together into a single 16 bit integer with upper 8 bits for ext_mapping_idc and lower 8 bits for el_bit_depth_minus8. Furthermore ext_mapping_idc has two components, upper 3 bits and lower 5 bits. --- libavcodec/dovi_rpudec.c | 7 ++++++- libavcodec/dovi_rpuenc.c | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/dovi_rpudec.c b/libavcodec/dovi_rpudec.c index 7c7eda9d09..af41ab5827 100644 --- a/libavcodec/dovi_rpudec.c +++ b/libavcodec/dovi_rpudec.c @@ -411,13 +411,18 @@ int ff_dovi_rpu_parse(DOVIContext *s, const uint8_t *rpu, size_t rpu_size, if ((hdr->rpu_format & 0x700) == 0) { int bl_bit_depth_minus8 = get_ue_golomb_31(gb); - int el_bit_depth_minus8 = get_ue_golomb_31(gb); + int el_bit_depth_minus8_and_ext_mapping_idc = get_ue_golomb_long(gb); + int el_bit_depth_minus8 = el_bit_depth_minus8_and_ext_mapping_idc & 0xFF; // lowest 8 bits + int ext_mapping_idc = (el_bit_depth_minus8_and_ext_mapping_idc & 0xFF00) >> 8; // upper 8 bits + int vdr_bit_depth_minus8 = get_ue_golomb_31(gb); VALIDATE(bl_bit_depth_minus8, 0, 8); VALIDATE(el_bit_depth_minus8, 0, 8); VALIDATE(vdr_bit_depth_minus8, 0, 8); hdr->bl_bit_depth = bl_bit_depth_minus8 + 8; hdr->el_bit_depth = el_bit_depth_minus8 + 8; + hdr->ext_mapping_idc_0_4 = ext_mapping_idc & 0x1F; // lowest 5 bits of ext_mapping_idc + hdr->ext_mapping_idc_5_7 = (ext_mapping_idc & 0xE0) >> 5; // upper 3 bits of ext_mapping_idc hdr->vdr_bit_depth = vdr_bit_depth_minus8 + 8; hdr->spatial_resampling_filter_flag = get_bits1(gb); skip_bits(gb, 3); /* reserved_zero_3bits */ diff --git a/libavcodec/dovi_rpuenc.c b/libavcodec/dovi_rpuenc.c index 3c3e0f84c0..91c0a85050 100644 --- a/libavcodec/dovi_rpuenc.c +++ b/libavcodec/dovi_rpuenc.c @@ -444,6 +444,7 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, int vdr_dm_metadata_changed, vdr_rpu_id, use_prev_vdr_rpu, profile, buffer_size, rpu_size, pad, zero_run; int num_ext_blocks_v1, num_ext_blocks_v2; + uint8_t ext_mapping_idc; uint32_t crc; uint8_t *dst; if (!metadata) { @@ -551,7 +552,8 @@ int ff_dovi_rpu_generate(DOVIContext *s, const AVDOVIMetadata *metadata, put_bits(pb, 1, hdr->bl_video_full_range_flag); if ((hdr->rpu_format & 0x700) == 0) { set_ue_golomb(pb, hdr->bl_bit_depth - 8); - set_ue_golomb(pb, hdr->el_bit_depth - 8); + ext_mapping_idc = (hdr->ext_mapping_idc_5_7 << 5) | hdr->ext_mapping_idc_0_4; + set_ue_golomb(pb, (ext_mapping_idc << 8) | hdr->el_bit_depth - 8); set_ue_golomb(pb, hdr->vdr_bit_depth - 8); put_bits(pb, 1, hdr->spatial_resampling_filter_flag); put_bits(pb, 3, 0); /* reserved_zero_3bits */