/**
* The codec-specific type of a bitstream unit.
*
+ * AV1: obu_type
* H.264 / AVC: nal_unit_type
* H.265 / HEVC: nal_unit_type
+ * JPEG: marker value (without 0xff prefix)
* MPEG-2: start code value (without prefix)
* VP9: unused, set to zero (every unit is a frame)
*/
* Free the units contained in a fragment as well as the fragment's
* own data buffer, but not the units array itself.
*/
-void ff_cbs_fragment_reset(CodedBitstreamContext *ctx,
- CodedBitstreamFragment *frag);
+void ff_cbs_fragment_reset(CodedBitstreamFragment *frag);
/**
* Free the units array of a fragment in addition to what
* ff_cbs_fragment_reset does.
*/
-void ff_cbs_fragment_free(CodedBitstreamContext *ctx,
- CodedBitstreamFragment *frag);
+void ff_cbs_fragment_free(CodedBitstreamFragment *frag);
/**
* Allocate a new internal content buffer of the given size in the unit.
*
* The content will be zeroed.
*/
-int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx,
- CodedBitstreamUnit *unit,
+int ff_cbs_alloc_unit_content(CodedBitstreamUnit *unit,
size_t size,
void (*free)(void *opaque, uint8_t *content));
+/**
+ * Allocate a new internal content buffer matching the type of the unit.
+ *
+ * The content will be zeroed.
+ */
+int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx,
+ CodedBitstreamUnit *unit);
+
+
/**
* Allocate a new internal data buffer of the given size in the unit.
*
* The data buffer will have input padding.
*/
-int ff_cbs_alloc_unit_data(CodedBitstreamContext *ctx,
- CodedBitstreamUnit *unit,
+int ff_cbs_alloc_unit_data(CodedBitstreamUnit *unit,
size_t size);
/**
* The content structure continues to be owned by the caller if
* content_buf is not supplied.
*/
-int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx,
- CodedBitstreamFragment *frag,
+int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag,
int position,
CodedBitstreamUnitType type,
void *content,
* Insert a new unit into a fragment with the given data bitstream.
*
* If data_buf is not supplied then data must have been allocated with
- * av_malloc() and will become owned by the unit after this call.
+ * av_malloc() and will on success become owned by the unit after this
+ * call or freed on error.
*/
-int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx,
- CodedBitstreamFragment *frag,
+int ff_cbs_insert_unit_data(CodedBitstreamFragment *frag,
int position,
CodedBitstreamUnitType type,
uint8_t *data, size_t data_size,
*
* Requires position to be >= 0 and < frag->nb_units.
*/
-void ff_cbs_delete_unit(CodedBitstreamContext *ctx,
- CodedBitstreamFragment *frag,
+void ff_cbs_delete_unit(CodedBitstreamFragment *frag,
int position);