From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id AE7A94E01B for ; Sun, 27 Apr 2025 11:46:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4E27E68B4B4; Sun, 27 Apr 2025 14:45:51 +0300 (EEST) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 57971687D95 for ; Sun, 27 Apr 2025 14:45:20 +0300 (EEST) Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-736a7e126c7so3557292b3a.3 for ; Sun, 27 Apr 2025 04:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745754318; x=1746359118; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IBn1ycADfZKARLgCtvEbHWggfD2ej3erXBmDd82DZKg=; b=L0jrFYJE2IKRwdFLdv+CVywbdBvxvpA5WKLOCEj9Jf/4aFN2Nb6hj56nwyO0cqb42z DnqjgIZWm3USPiju812zuea9FtnRXWwwnhR+yNyE/RQu9+eOdsYaXfyPdEyVow2vDtCF BXYz+zVWqRf2E7pRnOXK01Jz57rwZ7pC85YGwA2b/lX0MzGYCFEsXQpJ3AMM4i6Cs2HY 41BvUv/xESzIt6JzkH9Qb2KTXl0O7QQeSL6UpUTo9J6P5j3/vQ9GFrfW2mVh1yUpLxdp Y8TOLuizyv0TR37X0EM70mH1UPhijtcBhD4M32qmSPztXc9iJSaFr0fRqMeS86w1SZ7V D6Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745754318; x=1746359118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IBn1ycADfZKARLgCtvEbHWggfD2ej3erXBmDd82DZKg=; b=wPPMGvoXqLZIfIqqiCNTMp4cSt9Qe1HIdxPP5sWbV0EqJB8MKi5eioPD7XXJ/TpFKC QVIfA6tuaHCYALiTkSHAk4q9iyfwftqI9JBvulE4ErQDqhpPF/IMgEs1aMf4rNM+HNua Dht3ejm678nAr+GDg2UR4dp7BZKWnqJsHvwxG+m6uTQg3ZyZVNYZYceCZHd5fWC1p47g 5UDeSqQwhaJMriIhTqcoF1xIzWI4GacCj5y17rCMQF6vdaPrvt/xfmDyijCstBPJxtiq 6ZQCQ0vfLh5MrSf4Her1TkmKmthhPKrYmfPo1tbqWvndppi0pCgd1Q9EhoP8V2PU2w+K uwvw== X-Gm-Message-State: AOJu0YzsCTN7dA/yaH3L9jY2+1EORRYq7npc7DAXYUK4MWUy+l+bGO8t knOzw2IPrnNaTORryppvhcGK7gCk2DrNcDAD9uxF/e16U70/d7c67venJyRG X-Gm-Gg: ASbGnctzpybONPzxLQ+sLbf+0GBOn35UXkU55QJI2sh3DbWGnXkmqkeG/6Zsfejm+1h iBCNQVS1AYkW8aSNrGEhf/JYMAPm5xVyVj8XfBykwJJGM/jMOn11rxX7CCHVf3cJpX/faLVsO3R RXRsQm+K17WQKJfzs92CWNwCFhnsJoWrQQOHdlpzLAXRvbMdhZTYrNnUT/9aaRPKNh7zjXDzXvp ulV0Jf1v/Wfh0I4wY/FYSnMQi+TtmN+x7riIjhP6PQ3iqmWqRb4mmjvptx/CQQdQ+aOnfT6JfA+ U77TeibKHE1Gq7kG7GA0hzWMR9FftsfG7tF+WeAUQ4FFLhoSXP/gVScp5/1glQ== X-Google-Smtp-Source: AGHT+IGsvtOAbVaMlLfRIRXHcxq1NGwSVPglszNtCzjafv0jQLcQj0knrVUWCKGiFFWwWfpUyLTdbQ== X-Received: by 2002:a05:6a00:130d:b0:736:4fe0:2661 with SMTP id d2e1a72fcca58-73ff72af24emr6877093b3a.11.1745754318422; Sun, 27 Apr 2025 04:45:18 -0700 (PDT) Received: from localhost.localdomain ([124.79.129.75]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73e259134ebsm6064452b3a.27.2025.04.27.04.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Apr 2025 04:45:18 -0700 (PDT) From: toqsxw@gmail.com X-Google-Original-From: toqsxw@outlook.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Apr 2025 19:44:34 +0800 Message-ID: <20250427114451.1236-4-toqsxw@outlook.com> X-Mailer: git-send-email 2.44.0.windows.1 In-Reply-To: <20250427114451.1236-1-toqsxw@outlook.com> References: <20250427114451.1236-1-toqsxw@outlook.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 04/20] avcodec/vvc/sei: add decode_film_grain_characteristics 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: nuomi2021@gmail.com, Wu Jianhua Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Wu Jianhua Signed-off-by: Wu Jianhua --- libavcodec/vvc/sei.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c index 2842862a36..365f815950 100644 --- a/libavcodec/vvc/sei.c +++ b/libavcodec/vvc/sei.c @@ -24,15 +24,81 @@ #include "dec.h" #include "libavutil/refstruct.h" +static int decode_film_grain_characteristics(H2645SEIFilmGrainCharacteristics *h, const SEIRawFilmGrainCharacteristics *s, const VVCFrameContext *fc) +{ + const VVCSPS *sps = fc->ps.sps; + + h->present = !s->fg_characteristics_cancel_flag; + if (h->present) { + h->model_id = s->fg_model_id; + h->separate_colour_description_present_flag = s->fg_separate_colour_description_present_flag; + if (h->separate_colour_description_present_flag) { + h->bit_depth_luma = s->fg_bit_depth_luma_minus8 + 8; + h->bit_depth_chroma = s->fg_bit_depth_chroma_minus8 + 8; + h->full_range = s->fg_full_range_flag; + h->color_primaries = s->fg_colour_primaries; + h->transfer_characteristics = s->fg_transfer_characteristics; + h->matrix_coeffs = s->fg_matrix_coeffs; + } else { + if (!sps) { + av_log(fc->log_ctx, AV_LOG_ERROR, + "No active SPS for film_grain_characteristics.\n"); + return AVERROR_INVALIDDATA; + } + h->bit_depth_luma = sps->bit_depth; + h->bit_depth_chroma = sps->bit_depth; + h->full_range = sps->r->vui.vui_full_range_flag; + h->color_primaries = sps->r->vui.vui_colour_primaries; + h->transfer_characteristics = sps->r->vui.vui_transfer_characteristics; + h->matrix_coeffs = sps->r->vui.vui_matrix_coeffs ; + } + + h->blending_mode_id = s->fg_blending_mode_id; + h->log2_scale_factor = s->fg_log2_scale_factor; + + for (int c = 0; c < 3; c++) { + h->comp_model_present_flag[c] = s->fg_comp_model_present_flag[c]; + if (h->comp_model_present_flag[c]) { + h->num_intensity_intervals[c] = s->fg_num_intensity_intervals_minus1[c] + 1; + h->num_model_values[c] = s->fg_num_model_values_minus1[c] + 1; + + if (h->num_model_values[c] > 6) + return AVERROR_INVALIDDATA; + + for (int i = 0; i < h->num_intensity_intervals[c]; i++) { + h->intensity_interval_lower_bound[c][i] = s->fg_intensity_interval_lower_bound[c][i]; + h->intensity_interval_upper_bound[c][i] = s->fg_intensity_interval_upper_bound[c][i]; + for (int j = 0; j < h->num_model_values[c]; j++) + h->comp_model_value[c][i][j] = s->fg_comp_model_value[c][i][j]; + } + } + } + + h->persistence_flag = s->fg_characteristics_persistence_flag; + } + + return 0; +} + int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc) { + H2645SEI *c = &s->common; + if (!sei) return AVERROR_INVALIDDATA; for (int i = 0; i < sei->message_list.nb_messages; i++) { SEIRawMessage *message = &sei->message_list.messages[i]; + void *payload = message->payload; switch (message->payload_type) { + case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS: + av_refstruct_unref(&c->film_grain_characteristics); + c->film_grain_characteristics = av_refstruct_allocz(sizeof(*c->film_grain_characteristics)); + if (!c->film_grain_characteristics) + return AVERROR(ENOMEM); + return decode_film_grain_characteristics(c->film_grain_characteristics, payload, fc); + default: av_log(fc->log_ctx, AV_LOG_DEBUG, "Skipped %s SEI %d\n", sei->nal_unit_header.nal_unit_type == VVC_PREFIX_SEI_NUT ? -- 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".