diff options
| author | Mark Thompson <[email protected]> | 2018-02-21 22:22:54 +0000 | 
|---|---|---|
| committer | Mark Thompson <[email protected]> | 2018-02-21 22:22:54 +0000 | 
| commit | 0cc8e34a94c84132cf5b0f6472c5f61c8a66cee1 (patch) | |
| tree | 36c8a457e098ff96367b96c67ea2ce036fc31f30 /libavcodec/cbs.h | |
| parent | b656fa710a34ec7c3b192c38344a2c470ff2eaf5 (diff) | |
| parent | ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2 (diff) | |
Merge commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2'
* commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2':
  cbs: Refcount all the things!
Some changes for bitstream API.
Merged-by: Mark Thompson <[email protected]>
Diffstat (limited to 'libavcodec/cbs.h')
| -rw-r--r-- | libavcodec/cbs.h | 51 | 
1 files changed, 42 insertions, 9 deletions
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index ff97880610..396ff0faec 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -22,6 +22,8 @@  #include <stddef.h>  #include <stdint.h> +#include "libavutil/buffer.h" +  #include "avcodec.h" @@ -81,6 +83,11 @@ typedef struct CodedBitstreamUnit {       * This supports non-byte-aligned bitstreams.       */      size_t   data_bit_padding; +    /** +     * If data is reference counted, a reference to the buffer containing +     * data.  Null if data is not reference counted. +     */ +    AVBufferRef *data_ref;      /**       * Pointer to the decomposed form of this unit. @@ -91,11 +98,10 @@ typedef struct CodedBitstreamUnit {       */      void *content;      /** -     * Whether the content was supplied externally. -     * -     * If so, it should not be freed when freeing the unit. +     * If content is reference counted, a reference to the buffer containing +     * content.  Null if content is not reference counted.       */ -    int   content_external; +    AVBufferRef *content_ref;  } CodedBitstreamUnit;  /** @@ -123,6 +129,11 @@ typedef struct CodedBitstreamFragment {       * The number of bits which should be ignored in the final byte.       */      size_t data_bit_padding; +    /** +     * If data is reference counted, a reference to the buffer containing +     * data.  Null if data is not reference counted. +     */ +    AVBufferRef *data_ref;      /**       * Number of units in this fragment. @@ -279,27 +290,49 @@ void ff_cbs_fragment_uninit(CodedBitstreamContext *ctx,  /** + * 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, +                              size_t size, +                              void (*free)(void *unit, uint8_t *content)); + +/** + * 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, +                           size_t size); + +/**   * Insert a new unit into a fragment with the given content.   * - * The content structure continues to be owned by the caller, and - * will not be freed when the unit is. + * 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 position,                                 CodedBitstreamUnitType type, -                               void *content); +                               void *content, +                               AVBufferRef *content_buf);  /**   * Insert a new unit into a fragment with the given data bitstream.   * - * The data buffer will be owned by the unit after this operation. + * 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.   */  int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx,                              CodedBitstreamFragment *frag,                              int position,                              CodedBitstreamUnitType type, -                            uint8_t *data, size_t data_size); +                            uint8_t *data, size_t data_size, +                            AVBufferRef *data_buf);  /**   * Delete a unit from a fragment and free all memory it uses.  | 
