diff mbox series

[FFmpeg-devel,1/3] cbs_h265: add raw filler encoding

Message ID 20240912082334.925402-1-dev@lynne.ee
State New
Headers show
Series [FFmpeg-devel,1/3] cbs_h265: add raw filler encoding | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Lynne Sept. 12, 2024, 8:23 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

---
 libavcodec/cbs_h2645.c                | 17 ++++++++++++++++
 libavcodec/cbs_h265.h                 |  6 ++++++
 libavcodec/cbs_h265_syntax_template.c | 29 +++++++++++++++++++++++++++
 3 files changed, 52 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 4abd9e0c2e..1969ad8116 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1055,6 +1055,14 @@  static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx,
         }
         break;
 
+    case HEVC_NAL_FD_NUT:
+        {
+            err = cbs_h265_read_filler(ctx, &gbc, unit->content);
+            if (err < 0)
+                return err;
+        }
+        break;
+
     case HEVC_NAL_SEI_PREFIX:
     case HEVC_NAL_SEI_SUFFIX:
         {
@@ -1497,6 +1505,14 @@  static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx,
         }
         break;
 
+    case HEVC_NAL_FD_NUT:
+        {
+            err = cbs_h265_write_filler(ctx, pbc, unit->content);
+            if (err < 0)
+                return err;
+        }
+        break;
+
     case HEVC_NAL_SEI_PREFIX:
     case HEVC_NAL_SEI_SUFFIX:
         {
@@ -2006,6 +2022,7 @@  static const CodedBitstreamUnitTypeDescriptor cbs_h265_unit_types[] = {
     CBS_UNIT_TYPE_INTERNAL_REF(HEVC_NAL_PPS, H265RawPPS, extension_data.data),
 
     CBS_UNIT_TYPE_POD(HEVC_NAL_AUD, H265RawAUD),
+    CBS_UNIT_TYPE_POD(HEVC_NAL_FD_NUT,  H265RawFiller),
 
     // Slices of non-IRAP pictures.
     CBS_UNIT_RANGE_INTERNAL_REF(HEVC_NAL_TRAIL_N, HEVC_NAL_RASL_R,
diff --git a/libavcodec/cbs_h265.h b/libavcodec/cbs_h265.h
index 892a35bd22..26a5a34fe9 100644
--- a/libavcodec/cbs_h265.h
+++ b/libavcodec/cbs_h265.h
@@ -741,6 +741,12 @@  typedef struct H265RawSEI {
     SEIRawMessageList    message_list;
 } H265RawSEI;
 
+typedef struct H265RawFiller {
+    H265RawNALUnitHeader nal_unit_header;
+
+    uint32_t filler_size;
+} H265RawFiller;
+
 typedef struct CodedBitstreamH265Context {
     // Reader/writer context in common with the H.264 implementation.
     CodedBitstreamH2645Context common;
diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c
index 9f0281b8e8..1c11514435 100644
--- a/libavcodec/cbs_h265_syntax_template.c
+++ b/libavcodec/cbs_h265_syntax_template.c
@@ -2364,3 +2364,32 @@  static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw,
 
     return 0;
 }
+
+
+static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw,
+                        H265RawFiller *current)
+{
+    int err;
+
+    HEADER("Filler Data");
+
+    CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
+                                HEVC_NAL_FD_NUT));
+
+#ifdef READ
+    while (show_bits(rw, 8) == 0xff) {
+        fixed(8, ff_byte, 0xff);
+        ++current->filler_size;
+    }
+#else
+    {
+        uint32_t i;
+        for (i = 0; i < current->filler_size; i++)
+            fixed(8, ff_byte, 0xff);
+    }
+#endif
+
+    CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
+
+    return 0;
+}