From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id F028F4C083 for <ffmpegdev@gitmailbox.com>; Tue, 1 Apr 2025 17:16:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 773DB687CB9; Tue, 1 Apr 2025 20:16:38 +0300 (EEST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 453C0687C48 for <ffmpeg-devel@ffmpeg.org>; Tue, 1 Apr 2025 20:16:32 +0300 (EEST) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-226185948ffso113430945ad.0 for <ffmpeg-devel@ffmpeg.org>; Tue, 01 Apr 2025 10:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743527790; x=1744132590; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pQ6IDUoknZe1R9CR2fpbGcoprveyRFLIWeIIgL2u6P4=; b=K4Y23kkjM9+WYi7m52jQV+bIMwxfznSTdz1eyW9+Vvev8CzoAkD/O27jIt5MgLujGp TvLT0CCk5jAKix2VgjTBBIK8obyuk3ChhKxt1TquFt5xTvC0xmKNCr7QUoyFlq6kkA4E ByZLIclAlvJA1pnJes6WRgVDi+mdLU23CHSthzGQJRglenPZypI5AcCE2zBw2XiZiTx3 83VQ3N4XVhTBcrxRdI8B34Z+1Yd2xKSwYJOWYcS3X2gmdBzjslhPpyP18eGwjfb78vwi 544Zh1ZcVDrW8qR4bCUkQZr+v7YsMjoIrU3fDVLQB0GsQarX0yzTMKJJoLFbWOhPCY2X rj8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743527790; x=1744132590; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pQ6IDUoknZe1R9CR2fpbGcoprveyRFLIWeIIgL2u6P4=; b=kMxwSAyL4Mk9WlZQQBpkLz4TSEZi35ffaXoVVPwqiXCwExgkjqsiqf2cYAMUxqWYEo 6xtxJHAvkY/BTEHg22fE+h7wQO1Ksg0hiuXfV4suM5Jt0/W++WAD2S9uAwBhKXEun+VT Pn4okYf2jUg7VHorSg9KMHutQJXUWxEnd2WJVKZZSOP/lYB5QmZrB287osXWwL76EUTo irPCH1WSEswOi3p6vfeE+Ft/Lrj111R2aS1Ly27LBCXAW6NohH9sK5d9wyBq/FLCoDcS 54la2Chzf7hMI6L4xZhTYTq0XIHAVj+BHHmeNYCaCAzqcjjDCdqSyk6fU+yGogn2QmTB LMGA== X-Gm-Message-State: AOJu0YzUEsL31KWX1BEfcp2AHpOL4XzizzK/Lk4wNHulWPt3wbRoxVO8 Km4CTUnyLpahxYoVCnpSGUhJDlpoGY035AL3p+i106xfzacni5eFhCNk8loDIfo= X-Gm-Gg: ASbGncu9P2fCCJEHhkjQBq3/6gI25bOPHiZFvhWSQo810NBXAZv8UAIZl0S1Lah+06g iySlL/J3d/rOtQNGAZQLqw334T6KSxVTdf890HkTbhvlyRoCfJcIkQoh2g/BL/lUXJIDnTTezga ygfnRxIl+m+nHUpOUAcKVyDuDnNRSOP3r/3mXVIuMSUzjw3AG9XgHshbmYrSOjeb2pl7bI3J/gD 3cjt9uR6qsQxUtLHOT3JiaOtFVNVUhXnvm9zLHCTAUBb+qEC2q0laxLBruuGWYO2FBkUaHkRPbv /qv8IwnglYxpisqneMhZWOTNUWGisI1FqnTk2tTUCmoSTju2445R9ujeKm36vorK7A== X-Google-Smtp-Source: AGHT+IEafnA9TBPXjjjfvSXYT8gmMRiHOtkrl8XLTgkxHTx5f3hSh9Oy1mCoCiMkKIm0rfLheY7x/g== X-Received: by 2002:a17:903:124d:b0:220:c813:dfd1 with SMTP id d9443c01a7336-2292f9e636cmr200735005ad.36.1743527790374; Tue, 01 Apr 2025 10:16:30 -0700 (PDT) Received: from localhost.localdomain ([124.79.129.75]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291eee0bafsm90902495ad.90.2025.04.01.10.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 10:16:29 -0700 (PDT) From: toqsxw@gmail.com X-Google-Original-From: toqsxw@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Apr 2025 01:15:58 +0800 Message-ID: <20250401171616.1378-1-toqsxw@outlook.com> X-Mailer: git-send-email 2.44.0.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: Wu Jianhua <toqsxw@outlook.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250401171616.1378-1-toqsxw@outlook.com/> List-Archive: <https://master.gitmailbox.com/ffmpegdev/> List-Post: <mailto:ffmpegdev@gitmailbox.com> From: Wu Jianhua <toqsxw@outlook.com> Signed-off-by: Wu Jianhua <toqsxw@outlook.com> --- libavcodec/cbs_h2645.c | 6 ++++ libavcodec/cbs_sei.h | 21 +++++++++++ libavcodec/cbs_sei_syntax_template.c | 53 ++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 369e3ac876..768181874c 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -2187,6 +2187,12 @@ static const SEIMessageTypeDescriptor cbs_sei_common_types[] = { sizeof(SEIRawAmbientViewingEnvironment), SEI_MESSAGE_RW(sei, ambient_viewing_environment), }, + { + SEI_TYPE_FILM_GRAIN_CHARACTERISTICS, + 1, 0, + sizeof(SEIRawFilmGrainCharacteristics), + SEI_MESSAGE_RW(sei, film_grain_characteristics), + }, SEI_MESSAGE_TYPE_END, }; diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h index 15ef3415ab..a0fb004ecd 100644 --- a/libavcodec/cbs_sei.h +++ b/libavcodec/cbs_sei.h @@ -97,6 +97,27 @@ typedef struct SEIRawAmbientViewingEnvironment { uint16_t ambient_light_y; } SEIRawAmbientViewingEnvironment; +typedef struct SEIRawFilmGrainCharacteristics { + uint8_t fg_characteristics_cancel_flag; + uint8_t fg_model_id; + uint8_t fg_separate_colour_description_present_flag; + uint8_t fg_bit_depth_luma_minus8; + uint8_t fg_bit_depth_chroma_minus8; + uint8_t fg_full_range_flag; + uint8_t fg_colour_primaries; + uint8_t fg_transfer_characteristics; + uint8_t fg_matrix_coeffs; + uint8_t fg_blending_mode_id; + uint8_t fg_log2_scale_factor; + uint8_t fg_comp_model_present_flag[3]; + uint8_t fg_num_intensity_intervals_minus1[3]; + uint8_t fg_num_model_values_minus1[3]; + uint8_t fg_intensity_interval_lower_bound[3][256]; + uint8_t fg_intensity_interval_upper_bound[3][256]; + int16_t fg_comp_model_value[3][256][6]; + uint8_t fg_characteristics_persistence_flag; +} SEIRawFilmGrainCharacteristics; + typedef struct SEIRawMessage { uint32_t payload_type; uint32_t payload_size; diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c index 0205bb47aa..b105299cd9 100644 --- a/libavcodec/cbs_sei_syntax_template.c +++ b/libavcodec/cbs_sei_syntax_template.c @@ -224,6 +224,59 @@ SEI_FUNC(ambient_viewing_environment, return 0; } +SEI_FUNC(film_grain_characteristics, + (CodedBitstreamContext *ctx, RWContext *rw, + SEIRawFilmGrainCharacteristics *current, + SEIMessageState *state)) +{ + int err, c, i, j; + + HEADER("Film Grain Characteristics"); + + flag(fg_characteristics_cancel_flag); + if (!current->fg_characteristics_cancel_flag) { + int filmGrainBitDepth[3]; + + u(2, fg_model_id, 0, 1); + flag(fg_separate_colour_description_present_flag); + if (current->fg_separate_colour_description_present_flag) { + ub(3, fg_bit_depth_luma_minus8); + ub(3, fg_bit_depth_chroma_minus8); + flag(fg_full_range_flag); + ub(8, fg_colour_primaries); + ub(8, fg_transfer_characteristics); + ub(8, fg_matrix_coeffs); + } + + filmGrainBitDepth[0] = current->fg_bit_depth_luma_minus8 + 8; + filmGrainBitDepth[1] = + filmGrainBitDepth[2] = current->fg_bit_depth_chroma_minus8 + 8; + + u(2, fg_blending_mode_id, 0, 1); + ub(4, fg_log2_scale_factor); + for (c = 0; c < 3; c++) + flags(fg_comp_model_present_flag[c], 1, c); + + for (c = 0; c < 3; c++) { + if (current->fg_comp_model_present_flag[c]) { + ubs(8, fg_num_intensity_intervals_minus1[c], 1, c); + us(3, fg_num_model_values_minus1[c], 0, 5, 1, c); + for (i = 0; i <= current->fg_num_intensity_intervals_minus1[c]; i++) { + ubs(8, fg_intensity_interval_lower_bound[c][i], 2, c, i); + ubs(8, fg_intensity_interval_upper_bound[c][i], 2, c, i); + for (j = 0; j <= current->fg_num_model_values_minus1[c]; j++) + ses(fg_comp_model_value[c][i][j], 0 - current->fg_model_id * (1 << (filmGrainBitDepth[c] - 1)), + ((1 << filmGrainBitDepth[c]) - 1) - current->fg_model_id * (1 << (filmGrainBitDepth[c] - 1)), + 3, c, i, j); + } + } + } + flag(fg_characteristics_persistence_flag); + } + + return 0; +} + static int FUNC(message)(CodedBitstreamContext *ctx, RWContext *rw, SEIRawMessage *current) { -- 2.44.0.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".