Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics
@ 2025-04-01 17:15 toqsxw
  2025-04-01 17:15 ` [FFmpeg-devel] [PATCH v1 02/19] avcodec/vvc: support decoding prefix and suffix nal units toqsxw
                   ` (17 more replies)
  0 siblings, 18 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

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".

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2025-04-01 18:11 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
2025-04-01 17:15 ` [FFmpeg-devel] [PATCH v1 02/19] avcodec/vvc: support decoding prefix and suffix nal units toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 03/19] avcodec/vvc/sei: add decode_film_grain_characteristics toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 04/19] avcodec/vvc/dec: export sei to the frame when the frame starts toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 05/19] avcodec/vvc/dec: support applying film grain by the decoder toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 06/19] avcodec/vvc/dec: support removing film grain params from side data toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 07/19] avcodec/h274: add H274SEIPictureHash struct toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 08/19] avcodec/vvc/sei: add decode_decoded_picture_hash toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 09/19] avcodec/h274: add ff_h274_hash functions toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 10/19] avcodec/vvcdec: verify picture hash toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 11/19] avcodec/cbs_sei_syntax_template: add sei message sei_display_orientation toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 12/19] avcodec/vvc/sei: add decode_display_orientation toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 13/19] avcodec/vvc/sei: add decode_content_light_level_info toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 14/19] avcodec/cbs_sei_syntax_template: add sei message frame_field_information toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 15/19] avcodec/h274: add H274SEIFrameFieldInfo struct toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 16/19] avcodec/vvc/sei: add decode_frame_field_info toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 17/19] avcodec/vvc: support fields toqsxw
2025-04-01 17:35   ` Andreas Rheinhardt
2025-04-01 18:11     ` [FFmpeg-devel] 回复: " Wu Jianhua
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 18/19] avcodec/vvc/sei: add decode_ambient_viewing_environment toqsxw
2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 19/19] avcodec/vvc/sei: add decode_mastering_display_colour_volume toqsxw

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git