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

* [FFmpeg-devel] [PATCH v1 02/19] avcodec/vvc: support decoding prefix and suffix nal units
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 03/19] avcodec/vvc/sei: add decode_film_grain_characteristics toqsxw
                   ` (16 subsequent siblings)
  17 siblings, 0 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>
---
 configure               |  4 ++-
 libavcodec/Makefile     |  1 +
 libavcodec/vvc/Makefile |  1 +
 libavcodec/vvc/dec.c    | 32 ++++++++++++++++++++++++
 libavcodec/vvc/dec.h    |  2 ++
 libavcodec/vvc/sei.c    | 55 +++++++++++++++++++++++++++++++++++++++++
 libavcodec/vvc/sei.h    | 45 +++++++++++++++++++++++++++++++++
 7 files changed, 139 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vvc/sei.c
 create mode 100644 libavcodec/vvc/sei.h

diff --git a/configure b/configure
index 2fdbe8cbbe..516f18becb 100755
--- a/configure
+++ b/configure
@@ -2654,6 +2654,7 @@ CONFIG_EXTRA="
     vp56dsp
     vp8dsp
     vulkan_encode
+    vvc_sei
     wma_freqs
     wmv2dsp
 "
@@ -2902,6 +2903,7 @@ mpegvideoenc_select="aandcttables fdctdsp me_cmp mpegvideo pixblockdsp"
 msmpeg4dec_select="h263_decoder"
 msmpeg4enc_select="h263_encoder"
 vc1dsp_select="h264chroma qpeldsp startcode"
+vvc_sei_select="atsc_a53 golomb"
 wmv2dsp_select="qpeldsp"
 
 # decoders / encoders
@@ -3138,7 +3140,7 @@ vp6f_decoder_select="vp6_decoder"
 vp7_decoder_select="h264pred videodsp vp8dsp"
 vp8_decoder_select="h264pred videodsp vp8dsp"
 vp9_decoder_select="videodsp vp9_parser vp9_superframe_split_bsf"
-vvc_decoder_select="cabac cbs_h266 golomb videodsp"
+vvc_decoder_select="cabac cbs_h266 golomb videodsp vvc_sei"
 wcmv_decoder_select="inflate_wrapper"
 webp_decoder_select="vp8_decoder exif"
 wmalossless_decoder_select="llauddsp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 37b201ec4a..7467c883d3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -809,6 +809,7 @@ OBJS-$(CONFIG_VP9_V4L2M2M_DECODER)     += v4l2_m2m_dec.o
 OBJS-$(CONFIG_VQA_DECODER)             += vqavideo.o
 OBJS-$(CONFIG_VQC_DECODER)             += vqcdec.o
 OBJS-$(CONFIG_VVC_DECODER)             += executor.o h2645data.o
+OBJS-$(CONFIG_VVC_SEI)                 += h2645_sei.o aom_film_grain.o
 OBJS-$(CONFIG_WADY_DPCM_DECODER)       += dpcm.o
 OBJS-$(CONFIG_WAVARC_DECODER)          += wavarc.o
 OBJS-$(CONFIG_WAVPACK_DECODER)         += wavpack.o wavpackdata.o dsd.o
diff --git a/libavcodec/vvc/Makefile b/libavcodec/vvc/Makefile
index 6a28d32bc2..10125ffc2d 100644
--- a/libavcodec/vvc/Makefile
+++ b/libavcodec/vvc/Makefile
@@ -14,4 +14,5 @@ OBJS-$(CONFIG_VVC_DECODER)          +=  vvc/dec.o           \
                                         vvc/mvs.o           \
                                         vvc/ps.o            \
                                         vvc/refs.o          \
+                                        vvc/sei.o           \
                                         vvc/thread.o        \
diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 0b6443a112..206be3cc33 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -640,6 +640,7 @@ static av_cold void frame_context_free(VVCFrameContext *fc)
     pic_arrays_free(fc);
     av_frame_free(&fc->output_frame);
     ff_vvc_frame_ps_free(&fc->ps);
+    ff_vvc_sei_reset(&fc->sei);
 }
 
 static av_cold int frame_context_init(VVCFrameContext *fc, AVCodecContext *avctx)
@@ -682,6 +683,10 @@ static int frame_context_setup(VVCFrameContext *fc, VVCContext *s)
                     return ret;
             }
         }
+
+        ret = ff_vvc_sei_replace(&fc->sei, &prev->sei);
+        if (ret < 0)
+            return ret;
     }
 
     if (IS_IDR(s)) {
@@ -697,6 +702,22 @@ static int frame_context_setup(VVCFrameContext *fc, VVCContext *s)
     return 0;
 }
 
+/* SEI does not affect decoding, so we ignore the return value */
+static void decode_prefix_sei(VVCFrameContext *fc, VVCContext *s)
+{
+    CodedBitstreamFragment *frame = &s->current_frame;
+
+    for (int i = 0; i < frame->nb_units; i++) {
+        const CodedBitstreamUnit *unit = frame->units + i;
+
+        if (unit->type == VVC_PREFIX_SEI_NUT) {
+            int ret = ff_vvc_sei_decode(&fc->sei, unit->content_ref, fc);
+            if (ret < 0)
+                return;
+        }
+    }
+}
+
 static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
 {
     const VVCPH *ph                 = &fc->ps.ph;
@@ -710,6 +731,8 @@ static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
     if ((ret = ff_vvc_set_new_ref(s, fc, &fc->frame)) < 0)
         goto fail;
 
+    decode_prefix_sei(fc, s);
+
     if (!IS_IDR(s))
         ff_vvc_bump_frame(s, fc);
 
@@ -914,6 +937,15 @@ static int decode_nal_unit(VVCContext *s, VVCFrameContext *fc, AVBufferRef *buf_
         if (ret < 0)
             return ret;
         break;
+    case VVC_PREFIX_SEI_NUT:
+        /* handle by decode_prefix_sei() */
+        break;
+
+    case VVC_SUFFIX_SEI_NUT:
+        /* SEI does not affect decoding, so we ignore the return value*/
+        if (fc)
+            ff_vvc_sei_decode(&fc->sei, unit->content_ref, fc);
+        break;
     }
 
     return 0;
diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
index 6aa3121550..df81a83489 100644
--- a/libavcodec/vvc/dec.h
+++ b/libavcodec/vvc/dec.h
@@ -29,6 +29,7 @@
 
 #include "ps.h"
 #include "dsp.h"
+#include "sei.h"
 
 #define LUMA                    0
 #define CHROMA                  1
@@ -124,6 +125,7 @@ typedef struct VVCFrameContext {
     struct AVFrame *output_frame;
 
     VVCFrameParamSets ps;
+    VVCSEI sei;
 
     SliceContext  **slices;
     int nb_slices;
diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c
new file mode 100644
index 0000000000..2842862a36
--- /dev/null
+++ b/libavcodec/vvc/sei.c
@@ -0,0 +1,55 @@
+/*
+ * VVC Supplementary Enhancement Information messages
+ *
+ * copyright (c) 2024 Wu Jianhua <toqsxw@outlook.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "sei.h"
+#include "dec.h"
+#include "libavutil/refstruct.h"
+
+int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc)
+{
+    if (!sei)
+        return AVERROR_INVALIDDATA;
+
+    for (int i = 0; i < sei->message_list.nb_messages; i++) {
+        SEIRawMessage *message = &sei->message_list.messages[i];
+
+        switch (message->payload_type) {
+        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 ?
+                    "PREFIX" : "SUFFIX", message->payload_type);
+            return FF_H2645_SEI_MESSAGE_UNHANDLED;
+        }
+    }
+
+    return 0;
+}
+
+int ff_vvc_sei_replace(VVCSEI *dst, const VVCSEI *src)
+{
+    return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
+}
+
+void ff_vvc_sei_reset(VVCSEI *s)
+{
+    ff_h2645_sei_reset(&s->common);
+}
diff --git a/libavcodec/vvc/sei.h b/libavcodec/vvc/sei.h
new file mode 100644
index 0000000000..17e04cde63
--- /dev/null
+++ b/libavcodec/vvc/sei.h
@@ -0,0 +1,45 @@
+/*
+ * VVC Supplementary Enhancement Information messages
+ *
+ * copyright (c) 2024 Wu Jianhua <toqsxw@outlook.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_VVC_SEI_H
+#define AVCODEC_VVC_SEI_H
+
+#include <stdint.h>
+
+#include "libavcodec/get_bits.h"
+#include "libavcodec/cbs.h"
+#include "libavcodec/cbs_h266.h"
+#include "libavcodec/h2645_sei.h"
+#include "libavcodec/sei.h"
+#include "libavcodec/vvc.h"
+
+typedef struct VVCSEI {
+    H2645SEI common;
+} VVCSEI;
+
+struct VVCFrameContext;
+
+int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc);
+int ff_vvc_sei_replace(VVCSEI *dst, const VVCSEI *src);
+void ff_vvc_sei_reset(VVCSEI *s);
+
+#endif /* AVCODEC_VVC_SEI_H */
-- 
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

* [FFmpeg-devel] [PATCH v1 03/19] avcodec/vvc/sei: add decode_film_grain_characteristics
  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 ` 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
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 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".

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

* [FFmpeg-devel] [PATCH v1 04/19] avcodec/vvc/dec: export sei to the frame when the frame starts
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 05/19] avcodec/vvc/dec: support applying film grain by the decoder toqsxw
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/h2645_sei.c |  9 +++++----
 libavcodec/h2645_sei.h |  2 +-
 libavcodec/vvc/dec.c   | 12 ++++++++++++
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 2494daaf3c..78d9db20fd 100644
--- a/libavcodec/h2645_sei.c
+++ b/libavcodec/h2645_sei.c
@@ -44,8 +44,9 @@
 #include "h2645_sei.h"
 #include "itut35.h"
 
-#define IS_H264(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_H264 : CONFIG_H264_SEI)
-#define IS_HEVC(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_HEVC : CONFIG_HEVC_SEI)
+#define IS_H264(codec_id) (CONFIG_H264_SEI && (CONFIG_HEVC_SEI || CONFIG_VVC_SEI ) ? codec_id == AV_CODEC_ID_H264 : CONFIG_H264_SEI)
+#define IS_HEVC(codec_id) (CONFIG_HEVC_SEI && (CONFIG_H264_SEI || CONFIG_VVC_SEI ) ? codec_id == AV_CODEC_ID_HEVC : CONFIG_HEVC_SEI)
+#define IS_VVC(codec_id)  (CONFIG_VVC_SEI  && (CONFIG_H264_SEI || CONFIG_HEVC_SEI) ? codec_id == AV_CODEC_ID_VVC  : CONFIG_VVC_SEI )
 
 #if CONFIG_HEVC_SEI
 static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s,
@@ -427,7 +428,7 @@ static int decode_film_grain_characteristics(H2645SEIFilmGrainCharacteristics *h
                 }
             }
         }
-        if (IS_HEVC(codec_id))
+        if (!IS_H264(codec_id))
             h->persistence_flag = get_bits1(gb);
         else
             h->repetition_period = get_ue_golomb_long(gb);
@@ -854,7 +855,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
         fgp->subsampling_x = fgp->subsampling_y = 0;
 
         h274->model_id = fgc->model_id;
-        if (fgc->separate_colour_description_present_flag) {
+        if (IS_VVC(codec_id) || fgc->separate_colour_description_present_flag) {
             fgp->bit_depth_luma   = fgc->bit_depth_luma;
             fgp->bit_depth_chroma = fgc->bit_depth_chroma;
             fgp->color_range      = fgc->full_range + 1;
diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index abc49760d9..f2ad7147c6 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -108,7 +108,7 @@ typedef struct H2645SEIFilmGrainCharacteristics {
     uint8_t intensity_interval_upper_bound[3][256];
     int16_t comp_model_value[3][256][6];
     int repetition_period;       //< H.264 only
-    int persistence_flag;        //< HEVC  only
+    int persistence_flag;        //< HEVC/VVC
 } H2645SEIFilmGrainCharacteristics;
 
 typedef struct H2645SEIMasteringDisplay {
diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 206be3cc33..8b1c2c751b 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -718,6 +718,14 @@ static void decode_prefix_sei(VVCFrameContext *fc, VVCContext *s)
     }
 }
 
+static int set_side_data(VVCContext *s, VVCFrameContext *fc)
+{
+    AVFrame *out = fc->ref->frame;
+
+    return ff_h2645_sei_to_frame(out, &fc->sei.common, AV_CODEC_ID_VVC, s->avctx,
+        NULL, fc->ps.sps->bit_depth, fc->ps.sps->bit_depth, fc->ref->poc);
+}
+
 static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
 {
     const VVCPH *ph                 = &fc->ps.ph;
@@ -733,6 +741,10 @@ static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
 
     decode_prefix_sei(fc, s);
 
+    ret = set_side_data(s, fc);
+    if (ret < 0)
+        goto fail;
+
     if (!IS_IDR(s))
         ff_vvc_bump_frame(s, fc);
 
-- 
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

* [FFmpeg-devel] [PATCH v1 05/19] avcodec/vvc/dec: support applying film grain by the decoder
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (2 preceding siblings ...)
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 06/19] avcodec/vvc/dec: support removing film grain params from side data toqsxw
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/Makefile   |  2 +-
 libavcodec/vvc/dec.c  | 89 +++++++++++++++++++++++++++++++++++++++++--
 libavcodec/vvc/dec.h  |  8 +++-
 libavcodec/vvc/refs.c | 11 +++++-
 4 files changed, 104 insertions(+), 6 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 7467c883d3..e2d324202d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -809,7 +809,7 @@ OBJS-$(CONFIG_VP9_V4L2M2M_DECODER)     += v4l2_m2m_dec.o
 OBJS-$(CONFIG_VQA_DECODER)             += vqavideo.o
 OBJS-$(CONFIG_VQC_DECODER)             += vqcdec.o
 OBJS-$(CONFIG_VVC_DECODER)             += executor.o h2645data.o
-OBJS-$(CONFIG_VVC_SEI)                 += h2645_sei.o aom_film_grain.o
+OBJS-$(CONFIG_VVC_SEI)                 += h2645_sei.o aom_film_grain.o h274.o
 OBJS-$(CONFIG_WADY_DPCM_DECODER)       += dpcm.o
 OBJS-$(CONFIG_WAVARC_DECODER)          += wavarc.o
 OBJS-$(CONFIG_WAVPACK_DECODER)         += wavpack.o wavpackdata.o dsd.o
diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 8b1c2c751b..4c0d08440a 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -26,9 +26,12 @@
 #include "libavcodec/hwconfig.h"
 #include "libavcodec/profiles.h"
 #include "libavutil/refstruct.h"
+#include "libavcodec/aom_film_grain.h"
+#include "libavcodec/thread.h"
 #include "libavutil/cpu.h"
 #include "libavutil/mem.h"
 #include "libavutil/thread.h"
+#include "libavutil/film_grain_params.h"
 
 #include "dec.h"
 #include "ctu.h"
@@ -601,6 +604,14 @@ static int ref_frame(VVCFrame *dst, const VVCFrame *src)
     av_refstruct_replace(&dst->sps, src->sps);
     av_refstruct_replace(&dst->pps, src->pps);
 
+    if (src->needs_fg) {
+        ret = av_frame_ref(dst->frame_grain, src->frame_grain);
+        if (ret < 0)
+            return ret;
+
+        dst->needs_fg = src->needs_fg;
+    }
+
     av_refstruct_replace(&dst->progress, src->progress);
 
     av_refstruct_replace(&dst->tab_dmvr_mvf, src->tab_dmvr_mvf);
@@ -634,6 +645,7 @@ static av_cold void frame_context_free(VVCFrameContext *fc)
     for (int i = 0; i < FF_ARRAY_ELEMS(fc->DPB); i++) {
         ff_vvc_unref_frame(fc, &fc->DPB[i], ~0);
         av_frame_free(&fc->DPB[i].frame);
+        av_frame_free(&fc->DPB[i].frame_grain);
     }
 
     ff_vvc_frame_thread_free(fc);
@@ -656,6 +668,10 @@ static av_cold int frame_context_init(VVCFrameContext *fc, AVCodecContext *avctx
         fc->DPB[j].frame = av_frame_alloc();
         if (!fc->DPB[j].frame)
             return AVERROR(ENOMEM);
+
+        fc->DPB[j].frame_grain = av_frame_alloc();
+        if (!fc->DPB[j].frame_grain)
+            return AVERROR(ENOMEM);
     }
     fc->cu_pool = av_refstruct_pool_alloc(sizeof(CodingUnit), 0);
     if (!fc->cu_pool)
@@ -726,6 +742,41 @@ static int set_side_data(VVCContext *s, VVCFrameContext *fc)
         NULL, fc->ps.sps->bit_depth, fc->ps.sps->bit_depth, fc->ref->poc);
 }
 
+static int check_film_grain(VVCContext *s, VVCFrameContext *fc)
+{
+    int ret;
+
+    fc->ref->needs_fg = (fc->sei.common.film_grain_characteristics &&
+        fc->sei.common.film_grain_characteristics->present ||
+        fc->sei.common.aom_film_grain.enable) &&
+        !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
+        !s->avctx->hwaccel;
+
+    if (fc->ref->needs_fg &&
+        (fc->sei.common.film_grain_characteristics->present &&
+            !ff_h274_film_grain_params_supported(fc->sei.common.film_grain_characteristics->model_id,
+                fc->ref->frame->format) ||
+            !av_film_grain_params_select(fc->ref->frame))) {
+        av_log_once(s->avctx, AV_LOG_WARNING, AV_LOG_DEBUG, &s->film_grain_warning_shown,
+            "Unsupported film grain parameters. Ignoring film grain.\n");
+        fc->ref->needs_fg = 0;
+    }
+
+    if (fc->ref->needs_fg) {
+        fc->ref->frame_grain->format = fc->ref->frame->format;
+        fc->ref->frame_grain->width  = fc->ref->frame->width;
+        fc->ref->frame_grain->height = fc->ref->frame->height;
+
+        ret = ff_thread_get_buffer(s->avctx, fc->ref->frame_grain, 0);
+        if (ret < 0)
+            return ret;
+
+        return av_frame_copy_props(fc->ref->frame_grain, fc->ref->frame);
+    }
+
+    return 0;
+}
+
 static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
 {
     const VVCPH *ph                 = &fc->ps.ph;
@@ -745,6 +796,10 @@ static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
     if (ret < 0)
         goto fail;
 
+    ret = check_film_grain(s, fc);
+    if (ret < 0)
+        goto fail;
+
     if (!IS_IDR(s))
         ff_vvc_bump_frame(s, fc);
 
@@ -1002,14 +1057,42 @@ fail:
     return ret;
 }
 
+static int frame_end(VVCContext *s, VVCFrameContext *fc)
+{
+    const AVFilmGrainParams *fgp;
+    int ret = 0;
+
+    if (fc->ref->needs_fg) {
+        av_assert0(fc->ref->frame_grain->buf[0]);
+        fgp = av_film_grain_params_select(fc->ref->frame);
+        switch (fgp->type) {
+        case AV_FILM_GRAIN_PARAMS_NONE:
+            av_assert0(0);
+            return AVERROR_BUG;
+        case AV_FILM_GRAIN_PARAMS_H274:
+            ret = ff_h274_apply_film_grain(fc->ref->frame_grain, fc->ref->frame,
+                &s->h274db, fgp);
+            break;
+        case AV_FILM_GRAIN_PARAMS_AV1:
+            ret = ff_aom_apply_film_grain(fc->ref->frame_grain, fc->ref->frame, fgp);
+            break;
+        }
+    }
+
+    return ret;
+}
+
 static int wait_delayed_frame(VVCContext *s, AVFrame *output, int *got_output)
 {
     VVCFrameContext *delayed = get_frame_context(s, s->fcs, s->nb_frames - s->nb_delayed);
     int ret                  = ff_vvc_frame_wait(s, delayed);
 
-    if (!ret && delayed->output_frame->buf[0] && output) {
-        av_frame_move_ref(output, delayed->output_frame);
-        *got_output = 1;
+    if (!ret) {
+        ret = frame_end(s, delayed);
+        if (ret >= 0 && delayed->output_frame->buf[0] && output) {
+            av_frame_move_ref(output, delayed->output_frame);
+            *got_output = 1;
+        }
     }
     s->nb_delayed--;
 
diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
index df81a83489..b159863b31 100644
--- a/libavcodec/vvc/dec.h
+++ b/libavcodec/vvc/dec.h
@@ -26,6 +26,7 @@
 
 #include "libavcodec/videodsp.h"
 #include "libavcodec/vvc.h"
+#include "libavcodec/h274.h"
 
 #include "ps.h"
 #include "dsp.h"
@@ -71,12 +72,15 @@ typedef struct VVCWindow {
 
 typedef struct VVCFrame {
     struct AVFrame *frame;
-
+    struct AVFrame *frame_grain;
     const VVCSPS *sps;                          ///< RefStruct reference
     const VVCPPS *pps;                          ///< RefStruct reference
     struct MvField *tab_dmvr_mvf;               ///< RefStruct reference
     RefPicListTab **rpl_tab;                    ///< RefStruct reference
     RefPicListTab  *rpl;                        ///< RefStruct reference
+
+    int needs_fg;                               ///< 1 if grain needs to be applied by the decoder
+
     int nb_rpl_elems;
 
     int ctb_count;
@@ -218,6 +222,7 @@ typedef struct VVCContext {
     CodedBitstreamFragment current_frame;
 
     VVCParamSets ps;
+    H274FilmGrainDatabase h274db;
 
     int temporal_id;        ///< temporal_id_plus1 - 1
     int poc_tid0;
@@ -228,6 +233,7 @@ typedef struct VVCContext {
     enum VVCNALUnitType vcl_unit_type;
     int no_output_before_recovery_flag; ///< NoOutputBeforeRecoveryFlag
     int gdr_recovery_point_poc;         ///< recoveryPointPocVal
+    int film_grain_warning_shown;
 
     /**
      * Sequence counters for decoded and output frames, so that old
diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index 1cfca48204..4cf44bcf46 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -52,6 +52,12 @@ void ff_vvc_unref_frame(VVCFrameContext *fc, VVCFrame *frame, int flags)
         frame->flags = 0;
     if (!frame->flags) {
         av_frame_unref(frame->frame);
+
+        if (frame->needs_fg) {
+            av_frame_unref(frame->frame_grain);
+            frame->needs_fg = 0;
+        }
+
         av_refstruct_unref(&frame->sps);
         av_refstruct_unref(&frame->pps);
         av_refstruct_unref(&frame->progress);
@@ -285,7 +291,10 @@ int ff_vvc_output_frame(VVCContext *s, VVCFrameContext *fc, AVFrame *out, const
             if (frame->flags & VVC_FRAME_FLAG_CORRUPT)
                 frame->frame->flags |= AV_FRAME_FLAG_CORRUPT;
 
-            ret = av_frame_ref(out, frame->frame);
+            ret = av_frame_ref(out, frame->needs_fg ? frame->frame_grain : frame->frame);
+            if (ret < 0)
+                return ret;
+
             if (frame->flags & VVC_FRAME_FLAG_BUMPING)
                 ff_vvc_unref_frame(fc, frame, VVC_FRAME_FLAG_OUTPUT | VVC_FRAME_FLAG_BUMPING);
             else
-- 
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

* [FFmpeg-devel] [PATCH v1 06/19] avcodec/vvc/dec: support removing film grain params from side data
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (3 preceding siblings ...)
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 07/19] avcodec/h274: add H274SEIPictureHash struct toqsxw
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/refs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index 4cf44bcf46..cfbc2977c0 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -295,6 +295,9 @@ int ff_vvc_output_frame(VVCContext *s, VVCFrameContext *fc, AVFrame *out, const
             if (ret < 0)
                 return ret;
 
+            if (!(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN))
+                av_frame_remove_side_data(out, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
+
             if (frame->flags & VVC_FRAME_FLAG_BUMPING)
                 ff_vvc_unref_frame(fc, frame, VVC_FRAME_FLAG_OUTPUT | VVC_FRAME_FLAG_BUMPING);
             else
-- 
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

* [FFmpeg-devel] [PATCH v1 07/19] avcodec/h274: add H274SEIPictureHash struct
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (4 preceding siblings ...)
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 08/19] avcodec/vvc/sei: add decode_decoded_picture_hash toqsxw
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/h274.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/h274.h b/libavcodec/h274.h
index cebc8becb3..e1803edaf3 100644
--- a/libavcodec/h274.h
+++ b/libavcodec/h274.h
@@ -64,4 +64,14 @@ int ff_h274_apply_film_grain(AVFrame *out, const AVFrame *in,
                              H274FilmGrainDatabase *db,
                              const AVFilmGrainParams *params);
 
+typedef struct H274SEIPictureHash {
+    int present;
+    union {
+        uint8_t  md5[3][16];
+        uint16_t crc[3];
+        uint32_t checksum[3];
+    };
+    uint8_t hash_type;
+} H274SEIPictureHash;
+
 #endif /* AVCODEC_H274_H */
-- 
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

* [FFmpeg-devel] [PATCH v1 08/19] avcodec/vvc/sei: add decode_decoded_picture_hash
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (5 preceding siblings ...)
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 07/19] avcodec/h274: add H274SEIPictureHash struct toqsxw
@ 2025-04-01 17:16 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 09/19] avcodec/h274: add ff_h274_hash functions toqsxw
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/sei.c | 19 +++++++++++++++++++
 libavcodec/vvc/sei.h |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c
index 365f815950..2d81ae5908 100644
--- a/libavcodec/vvc/sei.c
+++ b/libavcodec/vvc/sei.c
@@ -80,6 +80,20 @@ static int decode_film_grain_characteristics(H2645SEIFilmGrainCharacteristics *h
     return 0;
 }
 
+static int decode_decoded_picture_hash(H274SEIPictureHash *h, const SEIRawDecodedPictureHash *s)
+{
+    h->present   = 1;
+    h->hash_type = s->dph_sei_hash_type;
+    if (h->hash_type == 0)
+        memcpy(h->md5, s->dph_sei_picture_md5, sizeof(h->md5));
+    else if (h->hash_type == 1)
+        memcpy(h->crc, s->dph_sei_picture_crc, sizeof(h->crc));
+    else if (h->hash_type == 2)
+        memcpy(h->checksum, s->dph_sei_picture_checksum, sizeof(h->checksum));
+
+    return 0;
+}
+
 int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc)
 {
     H2645SEI *c  = &s->common;
@@ -99,6 +113,9 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon
                 return AVERROR(ENOMEM);
             return decode_film_grain_characteristics(c->film_grain_characteristics, payload, fc);
 
+        case SEI_TYPE_DECODED_PICTURE_HASH:
+            return decode_decoded_picture_hash(&s->picture_hash, payload);
+
         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 ?
@@ -112,10 +129,12 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon
 
 int ff_vvc_sei_replace(VVCSEI *dst, const VVCSEI *src)
 {
+    dst->picture_hash.present = 0;        // drop hash
     return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
 }
 
 void ff_vvc_sei_reset(VVCSEI *s)
 {
     ff_h2645_sei_reset(&s->common);
+    s->picture_hash.present = 0;
 }
diff --git a/libavcodec/vvc/sei.h b/libavcodec/vvc/sei.h
index 17e04cde63..6e4855bf60 100644
--- a/libavcodec/vvc/sei.h
+++ b/libavcodec/vvc/sei.h
@@ -31,9 +31,11 @@
 #include "libavcodec/h2645_sei.h"
 #include "libavcodec/sei.h"
 #include "libavcodec/vvc.h"
+#include "libavcodec/h274.h"
 
 typedef struct VVCSEI {
     H2645SEI common;
+    H274SEIPictureHash picture_hash;
 } VVCSEI;
 
 struct VVCFrameContext;
-- 
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

* [FFmpeg-devel] [PATCH v1 09/19] avcodec/h274: add ff_h274_hash functions
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (6 preceding siblings ...)
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 10/19] avcodec/vvcdec: verify picture hash toqsxw
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/h274.c | 163 ++++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/h274.h |   7 ++
 2 files changed, 170 insertions(+)

diff --git a/libavcodec/h274.c b/libavcodec/h274.c
index 5709200322..9edc705042 100644
--- a/libavcodec/h274.c
+++ b/libavcodec/h274.c
@@ -26,7 +26,11 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/bswap.h"
+#include "libavutil/crc.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/md5.h"
+#include "libavutil/mem.h"
 
 #include "h274.h"
 
@@ -790,3 +794,162 @@ static const int8_t R64T[64][64] = {
          17, -16,  15, -14,  13, -12,  11, -10,   9,  -8,   7,  -6,   4,  -3,   2,  -1,
     }
 };
+
+static int verify_plane_md5(struct AVMD5 *ctx,
+    const uint8_t *src, const int w, const int h, const int stride,
+    const uint8_t *expected)
+{
+#define MD5_SIZE 16
+    uint8_t md5[MD5_SIZE];
+    av_md5_init(ctx);
+    for (int j = 0; j < h; j++) {
+        av_md5_update(ctx, src, w);
+        src += stride;
+    }
+    av_md5_final(ctx, md5);
+
+    if (memcmp(md5, expected, MD5_SIZE))
+        return AVERROR_INVALIDDATA;
+
+    return 0;
+}
+
+static int verify_plane_crc(const uint8_t *src, const int w, const int h, const int stride,
+    const uint8_t *expected)
+{
+    uint32_t crc = 0x0F1D;     // CRC-16-CCITT-AUG
+    const AVCRC *ctx = av_crc_get_table(AV_CRC_16_CCITT);
+
+    for (int j = 0; j < h; j++) {
+        crc = av_crc(ctx, crc, src, w);
+        src += stride;
+    }
+    crc = av_bswap16(crc);
+
+    if (memcmp(&crc, expected, sizeof(uint16_t)))
+        return AVERROR_INVALIDDATA;
+
+    return 0;
+}
+
+#define CAL_CHECKSUM(pixel) (checksum + ((pixel) ^ xor_mask))
+static int verify_plane_checksum(const uint8_t *src, const int w, const int h, const int stride, const int ps,
+    const uint8_t *expected)
+{
+    uint32_t checksum = 0;
+
+    for (int y = 0; y < h; y++) {
+        for (int x = 0; x < w; x++) {
+            const int xor_mask = (x & 0xFF) ^ (y & 0xFF) ^ (x >> 8) ^ (y >> 8);
+            checksum = CAL_CHECKSUM(src[x << ps]);
+            if (ps)
+                checksum = CAL_CHECKSUM(src[(x << ps) + 1]);
+        }
+        src += stride;
+    }
+
+    if (checksum != *(uint32_t*)expected)
+        return AVERROR_INVALIDDATA;
+
+    return 0;
+}
+
+static const uint8_t *get_plane_hash(const H274SEIPictureHash *h, const int plane)
+{
+    if (!h->hash_type)
+        return h->md5[plane];
+    if (h->hash_type == 1)
+        return (uint8_t*)&h->crc[plane];
+    return (uint8_t*)&h->checksum[plane];
+}
+
+enum {
+    HASH_MD5SUM,
+    HASH_CRC,
+    HASH_CHECKSUM,
+    HASH_LAST = HASH_CHECKSUM,
+};
+
+struct H274HashContext {
+    int type;
+    struct AVMD5 *ctx;
+};
+
+int ff_h274_hash_freep(H274HashContext **ctx)
+{
+    if (ctx && *ctx) {
+        H274HashContext *c = *ctx;
+        if (c->ctx)
+            av_free(c->ctx);
+        av_freep(ctx);
+    }
+    return 0;
+}
+
+int ff_h274_hash_init(H274HashContext **ctx, const int type)
+{
+    H274HashContext *c;
+
+    if (type > HASH_LAST || !ctx)
+        return AVERROR(EINVAL);
+
+    c = *ctx;
+    if (c) {
+        if (c->type != type) {
+            if (c->type == HASH_MD5SUM)
+                av_freep(&c->ctx);
+            c->type = type;
+        }
+    } else {
+        *ctx = c = av_mallocz(sizeof(H274HashContext));
+        if (!c)
+            return AVERROR(ENOMEM);
+        c->type = type;
+    }
+
+    if (type == HASH_MD5SUM && !c->ctx) {
+        c->ctx = av_md5_alloc();
+        if (!c->ctx)
+            return AVERROR(ENOMEM);
+    }
+
+    return 0;
+}
+
+int ff_h274_hash_verify(H274HashContext *c, const H274SEIPictureHash *hash,
+    const AVFrame *frame, const int coded_width, const int coded_height)
+{
+    const AVPixFmtDescriptor *desc;
+    int err = 0;
+
+    if (!c || !hash || !frame)
+        return AVERROR(EINVAL);
+
+    if (c->type != hash->hash_type)
+        return AVERROR(EINVAL);
+
+    desc = av_pix_fmt_desc_get(frame->format);
+    if (!desc)
+        return AVERROR(EINVAL);
+
+    for (int i = 0; i < desc->nb_components; i++) {
+        const int w             = i ? (coded_width  >> desc->log2_chroma_w) : coded_width;
+        const int h             = i ? (coded_height >> desc->log2_chroma_h) : coded_height;
+        const int ps            = desc->comp[i].step - 1;
+        const uint8_t *expected = get_plane_hash(hash, i);
+        const uint8_t *src      = frame->data[i];
+        const int stride        = frame->linesize[i];
+
+        if (c->type == HASH_MD5SUM)
+            err = verify_plane_md5(c->ctx, src, w << ps, h, stride, expected);
+        else if (c->type == HASH_CRC)
+            err = verify_plane_crc(src, w << ps, h, stride, expected);
+        else if (c->type == HASH_CHECKSUM)
+            err = verify_plane_checksum(src, w, h, stride, ps, expected);
+        if (err < 0)
+            goto fail;
+    }
+
+fail:
+    return err;
+}
diff --git a/libavcodec/h274.h b/libavcodec/h274.h
index e1803edaf3..e2bb1aec55 100644
--- a/libavcodec/h274.h
+++ b/libavcodec/h274.h
@@ -64,6 +64,8 @@ int ff_h274_apply_film_grain(AVFrame *out, const AVFrame *in,
                              H274FilmGrainDatabase *db,
                              const AVFilmGrainParams *params);
 
+typedef struct H274HashContext H274HashContext;
+
 typedef struct H274SEIPictureHash {
     int present;
     union {
@@ -74,4 +76,9 @@ typedef struct H274SEIPictureHash {
     uint8_t hash_type;
 } H274SEIPictureHash;
 
+int ff_h274_hash_init(H274HashContext **c, int type);
+int ff_h274_hash_verify(H274HashContext *c, const H274SEIPictureHash *hash,
+    const AVFrame *frame, int coded_width, int coded_height);
+int ff_h274_hash_freep(H274HashContext **c);
+
 #endif /* AVCODEC_H274_H */
-- 
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

* [FFmpeg-devel] [PATCH v1 10/19] avcodec/vvcdec: verify picture hash
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (7 preceding siblings ...)
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 09/19] avcodec/h274: add ff_h274_hash functions toqsxw
@ 2025-04-01 17:16 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 11/19] avcodec/cbs_sei_syntax_template: add sei message sei_display_orientation toqsxw
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/dec.c | 16 +++++++++++++++-
 libavcodec/vvc/sei.c | 10 ++++++++++
 libavcodec/vvc/sei.h |  3 +++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index 4c0d08440a..6c36eb553e 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -1079,7 +1079,21 @@ static int frame_end(VVCContext *s, VVCFrameContext *fc)
         }
     }
 
-    return ret;
+    if (!s->avctx->hwaccel && s->avctx->err_recognition & AV_EF_CRCCHECK) {
+        VVCSEI *sei = &fc->sei;
+        if (sei->picture_hash.present) {
+            ret = ff_vvc_sei_verify_hash(sei, fc->ref->frame, fc->ps.pps->width, fc->ps.pps->height);
+            if (ret < 0) {
+                av_log(s->avctx, AV_LOG_ERROR,
+                    "Verifying checksum for frame with decoder_order %d: failed\n",
+                    (int)fc->decode_order);
+                if (s->avctx->err_recognition & AV_EF_EXPLODE)
+                    return ret;
+            }
+        }
+    }
+
+    return 0;
 }
 
 static int wait_delayed_frame(VVCContext *s, AVFrame *output, int *got_output)
diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c
index 2d81ae5908..c955d9921f 100644
--- a/libavcodec/vvc/sei.c
+++ b/libavcodec/vvc/sei.c
@@ -136,5 +136,15 @@ int ff_vvc_sei_replace(VVCSEI *dst, const VVCSEI *src)
 void ff_vvc_sei_reset(VVCSEI *s)
 {
     ff_h2645_sei_reset(&s->common);
+    ff_h274_hash_freep(&s->hash_ctx);
     s->picture_hash.present = 0;
 }
+
+int ff_vvc_sei_verify_hash(VVCSEI *s, const AVFrame *frame, const int coded_width, const int coded_height)
+{
+    const int ret = ff_h274_hash_init(&s->hash_ctx, s->picture_hash.hash_type);
+    if (ret < 0)
+        return ret;
+
+    return ff_h274_hash_verify(s->hash_ctx, &s->picture_hash, frame, coded_width, coded_height);
+}
diff --git a/libavcodec/vvc/sei.h b/libavcodec/vvc/sei.h
index 6e4855bf60..a8aedc2837 100644
--- a/libavcodec/vvc/sei.h
+++ b/libavcodec/vvc/sei.h
@@ -36,6 +36,8 @@
 typedef struct VVCSEI {
     H2645SEI common;
     H274SEIPictureHash picture_hash;
+
+    H274HashContext *hash_ctx;
 } VVCSEI;
 
 struct VVCFrameContext;
@@ -43,5 +45,6 @@ struct VVCFrameContext;
 int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc);
 int ff_vvc_sei_replace(VVCSEI *dst, const VVCSEI *src);
 void ff_vvc_sei_reset(VVCSEI *s);
+int ff_vvc_sei_verify_hash(VVCSEI *s, const AVFrame *frame, int coded_width, int coded_height);
 
 #endif /* AVCODEC_VVC_SEI_H */
-- 
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

* [FFmpeg-devel] [PATCH v1 11/19] avcodec/cbs_sei_syntax_template: add sei message sei_display_orientation
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (8 preceding siblings ...)
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 10/19] avcodec/vvcdec: verify picture hash toqsxw
@ 2025-04-01 17:16 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 12/19] avcodec/vvc/sei: add decode_display_orientation toqsxw
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 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                 |  7 +++++++
 libavcodec/cbs_sei_syntax_template.c | 18 ++++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 768181874c..c868770209 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -2193,6 +2193,12 @@ static const SEIMessageTypeDescriptor cbs_sei_common_types[] = {
         sizeof(SEIRawFilmGrainCharacteristics),
         SEI_MESSAGE_RW(sei, film_grain_characteristics),
     },
+    {
+        SEI_TYPE_DISPLAY_ORIENTATION,
+        1, 0,
+        sizeof(SEIRawDisplayOrientation),
+        SEI_MESSAGE_RW(sei, display_orientation)
+    },
     SEI_MESSAGE_TYPE_END,
 };
 
diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
index a0fb004ecd..7be12e33e0 100644
--- a/libavcodec/cbs_sei.h
+++ b/libavcodec/cbs_sei.h
@@ -118,6 +118,13 @@ typedef struct SEIRawFilmGrainCharacteristics {
     uint8_t      fg_characteristics_persistence_flag;
 } SEIRawFilmGrainCharacteristics;
 
+typedef struct SEIRawDisplayOrientation {
+    uint8_t      display_orientation_cancel_flag;
+    uint8_t      display_orientation_persistence_flag;
+    uint8_t      display_orientation_transform_type;
+    uint8_t      display_orientation_reserved_zero_3bits;
+} SEIRawDisplayOrientation;
+
 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 b105299cd9..fb19f6ee42 100644
--- a/libavcodec/cbs_sei_syntax_template.c
+++ b/libavcodec/cbs_sei_syntax_template.c
@@ -277,6 +277,24 @@ SEI_FUNC(film_grain_characteristics,
     return 0;
 }
 
+SEI_FUNC(display_orientation, (CodedBitstreamContext *ctx, RWContext *rw,
+                               SEIRawDisplayOrientation *current,
+                               SEIMessageState *state))
+{
+    int err;
+
+    HEADER("Display Orientation");
+
+    flag(display_orientation_cancel_flag);
+    if (!current->display_orientation_cancel_flag) {
+        flag(display_orientation_persistence_flag);
+        u(3, display_orientation_transform_type, 0, 7);
+        ub(3, display_orientation_reserved_zero_3bits);
+    }
+
+    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

* [FFmpeg-devel] [PATCH v1 12/19] avcodec/vvc/sei: add decode_display_orientation
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (9 preceding siblings ...)
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 13/19] avcodec/vvc/sei: add decode_content_light_level_info toqsxw
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/sei.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c
index c955d9921f..6f918d114c 100644
--- a/libavcodec/vvc/sei.c
+++ b/libavcodec/vvc/sei.c
@@ -94,6 +94,30 @@ static int decode_decoded_picture_hash(H274SEIPictureHash *h, const SEIRawDecode
     return 0;
 }
 
+static int decode_display_orientation(H2645SEIDisplayOrientation *h, const SEIRawDisplayOrientation *s)
+{
+    int degrees[] = { 0, 0x8000, 0x4000, 0xC000 };
+
+    h->present = !s->display_orientation_cancel_flag;
+    if (h->present) {
+        if (s->display_orientation_transform_type > 7)
+            return AVERROR_INVALIDDATA;
+
+        h->vflip = 0;
+        if (s->display_orientation_transform_type == 1 ||
+            s->display_orientation_transform_type == 3 ||
+            s->display_orientation_transform_type == 4 ||
+            s->display_orientation_transform_type == 6) {
+            h->hflip = 1;
+        } else {
+            h->hflip = 0;
+        }
+        h->anticlockwise_rotation = degrees[s->display_orientation_transform_type >> 1];
+    }
+
+    return 0;
+}
+
 int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc)
 {
     H2645SEI *c  = &s->common;
@@ -116,6 +140,9 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon
         case SEI_TYPE_DECODED_PICTURE_HASH:
             return decode_decoded_picture_hash(&s->picture_hash, payload);
 
+        case SEI_TYPE_DISPLAY_ORIENTATION:
+            return decode_display_orientation(&s->common.display_orientation, payload);
+
         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".

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

* [FFmpeg-devel] [PATCH v1 13/19] avcodec/vvc/sei: add decode_content_light_level_info
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (10 preceding siblings ...)
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 12/19] avcodec/vvc/sei: add decode_display_orientation toqsxw
@ 2025-04-01 17:16 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 14/19] avcodec/cbs_sei_syntax_template: add sei message frame_field_information toqsxw
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/sei.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c
index 6f918d114c..85a07dad3f 100644
--- a/libavcodec/vvc/sei.c
+++ b/libavcodec/vvc/sei.c
@@ -118,6 +118,15 @@ static int decode_display_orientation(H2645SEIDisplayOrientation *h, const SEIRa
     return 0;
 }
 
+static int decode_content_light_level_info(H2645SEIContentLight *h, const SEIRawContentLightLevelInfo *s)
+{
+    h->present                     = 1;
+    h->max_content_light_level     = s->max_content_light_level;
+    h->max_pic_average_light_level = s->max_pic_average_light_level;
+
+    return 0;
+}
+
 int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc)
 {
     H2645SEI *c  = &s->common;
@@ -143,6 +152,9 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon
         case SEI_TYPE_DISPLAY_ORIENTATION:
             return decode_display_orientation(&s->common.display_orientation, payload);
 
+        case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
+            return decode_content_light_level_info(&s->common.content_light, payload);
+
         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".

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

* [FFmpeg-devel] [PATCH v1 14/19] avcodec/cbs_sei_syntax_template: add sei message frame_field_information
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (11 preceding siblings ...)
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 15/19] avcodec/h274: add H274SEIFrameFieldInfo struct toqsxw
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 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                 | 12 ++++++++++++
 libavcodec/cbs_sei_syntax_template.c | 26 ++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index c868770209..6677134d77 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -2199,6 +2199,12 @@ static const SEIMessageTypeDescriptor cbs_sei_common_types[] = {
         sizeof(SEIRawDisplayOrientation),
         SEI_MESSAGE_RW(sei, display_orientation)
     },
+    {
+        SEI_TYPE_FRAME_FIELD_INFO,
+        1, 0,
+        sizeof(SEIRawFrameFieldInformation),
+        SEI_MESSAGE_RW(sei, frame_field_information)
+    },
     SEI_MESSAGE_TYPE_END,
 };
 
diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
index 7be12e33e0..81867b79a7 100644
--- a/libavcodec/cbs_sei.h
+++ b/libavcodec/cbs_sei.h
@@ -125,6 +125,18 @@ typedef struct SEIRawDisplayOrientation {
     uint8_t      display_orientation_reserved_zero_3bits;
 } SEIRawDisplayOrientation;
 
+typedef struct SEIRawFrameFieldInformation {
+    uint8_t      ffi_field_pic_flag;
+    uint8_t      ffi_bottom_field_flag;
+    uint8_t      ffi_pairing_indicated_flag;
+    uint8_t      ffi_paired_with_next_field_flag;
+    uint8_t      ffi_display_fields_from_frame_flag;
+    uint8_t      ffi_top_field_first_flag;
+    uint8_t      ffi_display_elemental_periods_minus1;
+    uint8_t      ffi_source_scan_type;
+    uint8_t      ffi_duplicate_flag;
+} SEIRawFrameFieldInformation;
+
 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 fb19f6ee42..e6863a0fd7 100644
--- a/libavcodec/cbs_sei_syntax_template.c
+++ b/libavcodec/cbs_sei_syntax_template.c
@@ -295,6 +295,32 @@ SEI_FUNC(display_orientation, (CodedBitstreamContext *ctx, RWContext *rw,
     return 0;
 }
 
+SEI_FUNC(frame_field_information, (CodedBitstreamContext *ctx, RWContext *rw,
+                                       SEIRawFrameFieldInformation *current,
+                                       SEIMessageState *state))
+{
+    int err;
+
+    HEADER("Frame-field information");
+
+    flag(ffi_field_pic_flag);
+    if (current->ffi_field_pic_flag) {
+        flag(ffi_bottom_field_flag);
+        flag(ffi_pairing_indicated_flag);
+        if (current->ffi_pairing_indicated_flag)
+            flag(ffi_paired_with_next_field_flag);
+    } else {
+        flag(ffi_display_fields_from_frame_flag);
+        if (current->ffi_display_fields_from_frame_flag)
+            flag(ffi_top_field_first_flag);
+        u(8, ffi_display_elemental_periods_minus1, 0, 0xff);
+    }
+    u(2, ffi_source_scan_type, 0, 3);
+    flag(ffi_duplicate_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

* [FFmpeg-devel] [PATCH v1 15/19] avcodec/h274: add H274SEIFrameFieldInfo struct
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (12 preceding siblings ...)
  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 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 16/19] avcodec/vvc/sei: add decode_frame_field_info toqsxw
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/h274.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/h274.h b/libavcodec/h274.h
index e2bb1aec55..3629be2907 100644
--- a/libavcodec/h274.h
+++ b/libavcodec/h274.h
@@ -81,4 +81,12 @@ int ff_h274_hash_verify(H274HashContext *c, const H274SEIPictureHash *hash,
     const AVFrame *frame, int coded_width, int coded_height);
 int ff_h274_hash_freep(H274HashContext **c);
 
+typedef struct H274SEIFrameFieldInfo {
+    int present;
+    int picture_struct;
+    uint8_t display_elemental_periods;
+    uint8_t source_scan_type;
+    uint8_t duplicate_flag;
+} H274SEIFrameFieldInfo;
+
 #endif /* AVCODEC_H274_H */
-- 
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

* [FFmpeg-devel] [PATCH v1 16/19] avcodec/vvc/sei: add decode_frame_field_info
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (13 preceding siblings ...)
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 15/19] avcodec/h274: add H274SEIFrameFieldInfo struct toqsxw
@ 2025-04-01 17:16 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 17/19] avcodec/vvc: support fields toqsxw
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/sei.c | 26 ++++++++++++++++++++++++++
 libavcodec/vvc/sei.h |  1 +
 2 files changed, 27 insertions(+)

diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c
index 85a07dad3f..a029306abd 100644
--- a/libavcodec/vvc/sei.c
+++ b/libavcodec/vvc/sei.c
@@ -127,6 +127,27 @@ static int decode_content_light_level_info(H2645SEIContentLight *h, const SEIRaw
     return 0;
 }
 
+static int decode_frame_field_info(H274SEIFrameFieldInfo *h, const SEIRawFrameFieldInformation *s)
+{
+    if (s->ffi_source_scan_type > 3)
+        return AVERROR_INVALIDDATA;
+
+    h->present = 1;
+    if (s->ffi_field_pic_flag) {
+        if (s->ffi_bottom_field_flag)
+            h->picture_struct = AV_PICTURE_STRUCTURE_BOTTOM_FIELD;
+        else
+            h->picture_struct = AV_PICTURE_STRUCTURE_TOP_FIELD;
+    } else {
+        h->display_elemental_periods = s->ffi_display_elemental_periods_minus1 + 1;
+    }
+
+    h->source_scan_type = s->ffi_source_scan_type;
+    h->duplicate_flag   = s->ffi_duplicate_flag;
+
+    return 0;
+}
+
 int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc)
 {
     H2645SEI *c  = &s->common;
@@ -155,6 +176,9 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon
         case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
             return decode_content_light_level_info(&s->common.content_light, payload);
 
+        case SEI_TYPE_FRAME_FIELD_INFO:
+            return decode_frame_field_info(&s->frame_field_info, payload);
+
         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 ?
@@ -169,6 +193,7 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon
 int ff_vvc_sei_replace(VVCSEI *dst, const VVCSEI *src)
 {
     dst->picture_hash.present = 0;        // drop hash
+    dst->frame_field_info.present = 0;    // drop field info
     return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
 }
 
@@ -177,6 +202,7 @@ void ff_vvc_sei_reset(VVCSEI *s)
     ff_h2645_sei_reset(&s->common);
     ff_h274_hash_freep(&s->hash_ctx);
     s->picture_hash.present = 0;
+    s->frame_field_info.present = 0;
 }
 
 int ff_vvc_sei_verify_hash(VVCSEI *s, const AVFrame *frame, const int coded_width, const int coded_height)
diff --git a/libavcodec/vvc/sei.h b/libavcodec/vvc/sei.h
index a8aedc2837..8d19f22bb3 100644
--- a/libavcodec/vvc/sei.h
+++ b/libavcodec/vvc/sei.h
@@ -36,6 +36,7 @@
 typedef struct VVCSEI {
     H2645SEI common;
     H274SEIPictureHash picture_hash;
+    H274SEIFrameFieldInfo frame_field_info;
 
     H274HashContext *hash_ctx;
 } VVCSEI;
-- 
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

* [FFmpeg-devel] [PATCH v1 17/19] avcodec/vvc: support fields
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (14 preceding siblings ...)
  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 ` toqsxw
  2025-04-01 17:35   ` Andreas Rheinhardt
  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
  17 siblings, 1 reply; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

passed files:
    FIELD_A_Panasonic_4.bit
    FIELD_B_Panasonic_2.bit

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/refs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index cfbc2977c0..79967b77d3 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -160,6 +160,14 @@ static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
         frame->ref_width   = pps->r->pps_pic_width_in_luma_samples  - win->left_offset   - win->right_offset;
         frame->ref_height  = pps->r->pps_pic_height_in_luma_samples - win->bottom_offset - win->top_offset;
 
+        if (fc->sei.frame_field_info.present) {
+            if (fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD)
+                frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+            if (fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD ||
+                fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD)
+                frame->frame->flags |= AV_FRAME_FLAG_INTERLACED;
+        }
+
         frame->progress = alloc_progress();
         if (!frame->progress)
             goto fail;
-- 
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

* [FFmpeg-devel] [PATCH v1 18/19] avcodec/vvc/sei: add decode_ambient_viewing_environment
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (15 preceding siblings ...)
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 17/19] avcodec/vvc: support fields toqsxw
@ 2025-04-01 17:16 ` toqsxw
  2025-04-01 17:16 ` [FFmpeg-devel] [PATCH v1 19/19] avcodec/vvc/sei: add decode_mastering_display_colour_volume toqsxw
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/sei.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c
index a029306abd..7763dd401c 100644
--- a/libavcodec/vvc/sei.c
+++ b/libavcodec/vvc/sei.c
@@ -148,6 +148,16 @@ static int decode_frame_field_info(H274SEIFrameFieldInfo *h, const SEIRawFrameFi
     return 0;
 }
 
+static int decode_ambient_viewing_environment(H2645SEIAmbientViewingEnvironment *h, const SEIRawAmbientViewingEnvironment *s)
+{
+    h->present             = 1;
+    h->ambient_illuminance = s->ambient_illuminance;
+    h->ambient_light_x     = s->ambient_light_x;
+    h->ambient_light_y     = s->ambient_light_y;
+
+    return 0;
+}
+
 int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc)
 {
     H2645SEI *c  = &s->common;
@@ -179,6 +189,9 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon
         case SEI_TYPE_FRAME_FIELD_INFO:
             return decode_frame_field_info(&s->frame_field_info, payload);
 
+        case SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT:
+            return decode_ambient_viewing_environment(&s->common.ambient_viewing_environment, payload);
+
         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".

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

* [FFmpeg-devel] [PATCH v1 19/19] avcodec/vvc/sei: add decode_mastering_display_colour_volume
  2025-04-01 17:15 [FFmpeg-devel] [PATCH v1 01/19] avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics toqsxw
                   ` (16 preceding siblings ...)
  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 ` toqsxw
  17 siblings, 0 replies; 21+ messages in thread
From: toqsxw @ 2025-04-01 17:16 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu Jianhua

From: Wu Jianhua <toqsxw@outlook.com>

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
---
 libavcodec/vvc/sei.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/libavcodec/vvc/sei.c b/libavcodec/vvc/sei.c
index 7763dd401c..4c5c54f36c 100644
--- a/libavcodec/vvc/sei.c
+++ b/libavcodec/vvc/sei.c
@@ -158,6 +158,24 @@ static int decode_ambient_viewing_environment(H2645SEIAmbientViewingEnvironment
     return 0;
 }
 
+static int decode_mastering_display_colour_volume(H2645SEIMasteringDisplay *h, const SEIRawMasteringDisplayColourVolume *s)
+{
+    h->present = 1;
+
+    for (int c = 0; c < 3; c++) {
+        h->display_primaries[c][0] = s->display_primaries_x[c];
+        h->display_primaries[c][1] = s->display_primaries_y[c];
+    }
+
+    h->white_point[0] = s->white_point_x;
+    h->white_point[1] = s->white_point_y;
+
+    h->max_luminance  = s->max_display_mastering_luminance;
+    h->min_luminance  = s->min_display_mastering_luminance;
+
+    return 0;
+}
+
 int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameContext *fc)
 {
     H2645SEI *c  = &s->common;
@@ -192,6 +210,9 @@ int ff_vvc_sei_decode(VVCSEI *s, const H266RawSEI *sei, const struct VVCFrameCon
         case SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT:
             return decode_ambient_viewing_environment(&s->common.ambient_viewing_environment, payload);
 
+        case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
+            return decode_mastering_display_colour_volume(&s->common.mastering_display, payload);
+
         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".

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

* Re: [FFmpeg-devel] [PATCH v1 17/19] avcodec/vvc: support fields
  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
  0 siblings, 1 reply; 21+ messages in thread
From: Andreas Rheinhardt @ 2025-04-01 17:35 UTC (permalink / raw)
  To: ffmpeg-devel

toqsxw@gmail.com:
> From: Wu Jianhua <toqsxw@outlook.com>
> 
> passed files:
>     FIELD_A_Panasonic_4.bit
>     FIELD_B_Panasonic_2.bit
> 
> Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
> ---
>  libavcodec/vvc/refs.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
> index cfbc2977c0..79967b77d3 100644
> --- a/libavcodec/vvc/refs.c
> +++ b/libavcodec/vvc/refs.c
> @@ -160,6 +160,14 @@ static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
>          frame->ref_width   = pps->r->pps_pic_width_in_luma_samples  - win->left_offset   - win->right_offset;
>          frame->ref_height  = pps->r->pps_pic_height_in_luma_samples - win->bottom_offset - win->top_offset;
>  
> +        if (fc->sei.frame_field_info.present) {
> +            if (fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD)
> +                frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
> +            if (fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD ||
> +                fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD)
> +                frame->frame->flags |= AV_FRAME_FLAG_INTERLACED;
> +        }
> +
>          frame->progress = alloc_progress();
>          if (!frame->progress)
>              goto fail;

Does this output the fields separately? Normally, FFmpeg/libavcodec only
outputs actual frames and marks these with the AV_FRAME_FLAG_INTERLACED
flag if the content is interlaced. AV_FRAME_FLAG_INTERLACED does not
mean that it is a single field.

- Andreas

_______________________________________________
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

* [FFmpeg-devel] 回复:  [PATCH v1 17/19] avcodec/vvc: support fields
  2025-04-01 17:35   ` Andreas Rheinhardt
@ 2025-04-01 18:11     ` Wu Jianhua
  0 siblings, 0 replies; 21+ messages in thread
From: Wu Jianhua @ 2025-04-01 18:11 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt <andreas.rheinhardt@outlook.com>:
> toqsxw@gmail.com:
>> From: Wu Jianhua <toqsxw@outlook.com>
>>
>> passed files:
>>     FIELD_A_Panasonic_4.bit
>>     FIELD_B_Panasonic_2.bit
>>
>> Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
>> ---
>>  libavcodec/vvc/refs.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
>> index cfbc2977c0..79967b77d3 100644
>> --- a/libavcodec/vvc/refs.c
>> +++ b/libavcodec/vvc/refs.c
>> @@ -160,6 +160,14 @@ static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
>>          frame->ref_width   = pps->r->pps_pic_width_in_luma_samples  - win->left_offset   - win->right_offset;
>>          frame->ref_height  = pps->r->pps_pic_height_in_luma_samples - win->bottom_offset - win->top_offset;
>>
>> +        if (fc->sei.frame_field_info.present) {
>> +            if (fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD)
>> +                frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
>> +            if (fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD ||
>> +                fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD)
>> +                frame->frame->flags |= AV_FRAME_FLAG_INTERLACED;
>> +        }
>> +
>>          frame->progress = alloc_progress();
>>          if (!frame->progress)
>>              goto fail;
>
> Does this output the fields separately? Normally, FFmpeg/libavcodec only
> outputs actual frames and marks these with the AV_FRAME_FLAG_INTERLACED
> flag if the content is interlaced. AV_FRAME_FLAG_INTERLACED does not
> mean that it is a single field.
>
>- Andreas

The vvc decoder will output the each single fields and need to use the filter 'tinterlace' to output the actual frames,
so I don't need to mark it with AV_FRAME_FLAG_INTERLACED  flag, right?

Jianhua
_______________________________________________
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