@@ -665,3 +665,24 @@ int ff_cbs_delete_unit(CodedBitstreamContext *ctx,
return 0;
}
+
+int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit,
+ void** content)
+{
+ if (unit->content && (!unit->content_ref ||
+ !av_buffer_is_writable(unit->content_ref))) {
+ int err;
+ if (!ctx->codec->make_writable)
+ return AVERROR_PATCHWELCOME;
+
+ err = ctx->codec->make_writable(ctx, unit);
+ if (err < 0)
+ return err;
+
+ if (content)
+ *content = unit->content;
+ }
+
+ return 0;
+}
@@ -352,5 +352,14 @@ int ff_cbs_delete_unit(CodedBitstreamContext *ctx,
CodedBitstreamFragment *frag,
int position);
+/**
+ * Make the content of a unit writable.
+ *
+ * If content is supplied, *content will point to the unit's content on success.
+ */
+int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit,
+ void **content);
+
#endif /* AVCODEC_CBS_H */
@@ -44,6 +44,10 @@ typedef struct CodedBitstreamType {
int (*read_unit)(CodedBitstreamContext *ctx,
CodedBitstreamUnit *unit);
+ // Make a unit's content writable.
+ int (*make_writable)(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit);
+
// Write the unit->data bitstream from unit->content.
int (*write_unit)(CodedBitstreamContext *ctx,
CodedBitstreamUnit *unit);
This will enable us to change e.g. the parameter sets of H.2645 in ways that would change the parsing process of future units. An example of this is the h264_redundant_pps bsf. The actual implementation of the underlying codec-dependent make_writable functions is not contained in this commit. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com> --- Here is an updated patchset. Sorry for the unnecessary noise. libavcodec/cbs.c | 21 +++++++++++++++++++++ libavcodec/cbs.h | 9 +++++++++ libavcodec/cbs_internal.h | 4 ++++ 3 files changed, 34 insertions(+)