summaryrefslogtreecommitdiff
path: root/libavcodec/cbs.h
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2020-07-27 17:32:21 +0100
committerMark Thompson <sw@jkqxz.net>2020-09-02 00:00:57 +0100
commit42daac1c74169ec4373b5199932c5f3176a2e897 (patch)
tree648c634f72e60fb0d6fff3da6ea9a1ac577de23b /libavcodec/cbs.h
parent2cb152d52f28081acf3c2306557944105af8374f (diff)
cbs: Add support functions for handling unit content references
Use the unit type table to determine what we need to do to clone the internals of the unit content when making copies for refcounting or writeability. (This will still fail for units with complex content if they do not have a defined clone function.) Setup and naming from a patch by Andreas Rheinhardt <andreas.rheinhardt@gmail.com>, but with the implementation changed to use the unit type information if possible rather than requiring a codec-specific function.
Diffstat (limited to 'libavcodec/cbs.h')
-rw-r--r--libavcodec/cbs.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index ea8d942894..3a054aa8f3 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -400,4 +400,33 @@ void ff_cbs_delete_unit(CodedBitstreamFragment *frag,
int position);
+/**
+ * Make the content of a unit refcounted.
+ *
+ * If the unit is not refcounted, this will do a deep copy of the unit
+ * content to new refcounted buffers.
+ *
+ * It is not valid to call this function on a unit which does not have
+ * decomposed content.
+ */
+int ff_cbs_make_unit_refcounted(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit);
+
+/**
+ * Make the content of a unit writable so that internal fields can be
+ * modified.
+ *
+ * If it is known that there are no other references to the content of
+ * the unit, does nothing and returns success. Otherwise (including the
+ * case where the unit content is not refcounted), it does a full clone
+ * of the content (including any internal buffers) to make a new copy,
+ * and replaces the existing references inside the unit with that.
+ *
+ * It is not valid to call this function on a unit which does not have
+ * decomposed content.
+ */
+int ff_cbs_make_unit_writable(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit);
+
+
#endif /* AVCODEC_CBS_H */