[FFmpeg-cvslog] Merge commit 'eccc03c8fbc603a0a3257df66f0705f74fe2581a'

Mark Thompson git at videolan.org
Thu Feb 22 00:53:50 EET 2018


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Wed Feb 21 22:43:13 2018 +0000| [fbeac5356c692b6f681a21749dee3a3e414f1230] | committer: Mark Thompson

Merge commit 'eccc03c8fbc603a0a3257df66f0705f74fe2581a'

* commit 'eccc03c8fbc603a0a3257df66f0705f74fe2581a':
  cbs_h264: Add support for filler NAL units

Some bitstream -> get_bits.

Merged-by: Mark Thompson <sw at jkqxz.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fbeac5356c692b6f681a21749dee3a3e414f1230
---

 libavcodec/cbs_h264.h                 |  6 ++++++
 libavcodec/cbs_h2645.c                | 21 +++++++++++++++++++++
 libavcodec/cbs_h264_syntax_template.c | 29 +++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
index 11dce87103..2219d9da8d 100644
--- a/libavcodec/cbs_h264.h
+++ b/libavcodec/cbs_h264.h
@@ -408,6 +408,12 @@ typedef struct H264RawSlice {
     AVBufferRef *data_ref;
 } H264RawSlice;
 
+typedef struct H264RawFiller {
+    H264RawNALUnitHeader nal_unit_header;
+
+    uint32_t filler_size;
+} H264RawFiller;
+
 
 typedef struct CodedBitstreamH264Context {
     // Reader/writer context in common with the H.265 implementation.
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index b717937e4a..5ad0f2b500 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -815,6 +815,19 @@ static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx,
         }
         break;
 
+    case H264_NAL_FILLER_DATA:
+        {
+            err = ff_cbs_alloc_unit_content(ctx, unit,
+                                            sizeof(H264RawFiller), NULL);
+            if (err < 0)
+                return err;
+
+            err = cbs_h264_read_filler(ctx, &gbc, unit->content);
+            if (err < 0)
+                return err;
+        }
+        break;
+
     default:
         return AVERROR(ENOSYS);
     }
@@ -1070,6 +1083,14 @@ static int cbs_h264_write_nal_unit(CodedBitstreamContext *ctx,
         }
         break;
 
+    case H264_NAL_FILLER_DATA:
+        {
+            err = cbs_h264_write_filler(ctx, pbc, unit->content);
+            if (err < 0)
+                return err;
+        }
+        break;
+
     default:
         av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for "
                "NAL unit type %"PRIu32".\n", unit->type);
diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c
index 05370b81fa..f58dee8a25 100644
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@ -1247,3 +1247,32 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw,
 
     return 0;
 }
+
+static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw,
+                        H264RawFiller *current)
+{
+    av_unused int ff_byte = 0xff;
+    int err;
+
+    HEADER("Filler Data");
+
+    CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
+                                1 << H264_NAL_FILLER_DATA));
+
+#ifdef READ
+    while (show_bits(rw, 8) == 0xff) {
+        xu(8, ff_byte, ff_byte, 0xff, 0xff);
+        ++current->filler_size;
+    }
+#else
+    {
+        uint32_t i;
+        for (i = 0; i < current->filler_size; i++)
+            xu(8, ff_byte, ff_byte, 0xff, 0xff);
+    }
+#endif
+
+    CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
+
+    return 0;
+}


======================================================================

diff --cc libavcodec/cbs_h2645.c
index b717937e4a,d6131a13e5..5ad0f2b500
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@@ -815,6 -815,19 +815,19 @@@ static int cbs_h264_read_nal_unit(Coded
          }
          break;
  
+     case H264_NAL_FILLER_DATA:
+         {
+             err = ff_cbs_alloc_unit_content(ctx, unit,
+                                             sizeof(H264RawFiller), NULL);
+             if (err < 0)
+                 return err;
+ 
 -            err = cbs_h264_read_filler(ctx, &bc, unit->content);
++            err = cbs_h264_read_filler(ctx, &gbc, unit->content);
+             if (err < 0)
+                 return err;
+         }
+         break;
+ 
      default:
          return AVERROR(ENOSYS);
      }
diff --cc libavcodec/cbs_h264_syntax_template.c
index 05370b81fa,1aa7888584..f58dee8a25
--- a/libavcodec/cbs_h264_syntax_template.c
+++ b/libavcodec/cbs_h264_syntax_template.c
@@@ -1247,3 -1247,32 +1247,32 @@@ static int FUNC(slice_header)(CodedBits
  
      return 0;
  }
+ 
+ static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw,
+                         H264RawFiller *current)
+ {
+     av_unused int ff_byte = 0xff;
+     int err;
+ 
+     HEADER("Filler Data");
+ 
+     CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
+                                 1 << H264_NAL_FILLER_DATA));
+ 
+ #ifdef READ
 -    while (bitstream_peek(rw, 8) == 0xff) {
++    while (show_bits(rw, 8) == 0xff) {
+         xu(8, ff_byte, ff_byte, 0xff, 0xff);
+         ++current->filler_size;
+     }
+ #else
+     {
+         uint32_t i;
+         for (i = 0; i < current->filler_size; i++)
+             xu(8, ff_byte, ff_byte, 0xff, 0xff);
+     }
+ #endif
+ 
+     CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
+ 
+     return 0;
+ }



More information about the ffmpeg-cvslog mailing list