diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2019-11-17 08:34:35 +0100 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2019-11-17 23:31:44 +0000 |
commit | 7c92eaace2b338e0b3acc18e1543b365610578fd (patch) | |
tree | 51f9343c4cf5bfbb156c3a303f0839df57bcb31e /libavcodec/cbs_internal.h | |
parent | 5d8d9e032cafa88e99046478090dd5a629e3d51c (diff) | |
download | ffmpeg-7c92eaace2b338e0b3acc18e1543b365610578fd.tar.gz |
avcodec/cbs: Factor out common code for writing units
All cbs-functions to write units share a common pattern:
1. They check whether they have a write buffer (that is used to store
the unit's data until the needed size becomes known after writing the
unit when a dedicated buffer will be allocated).
2. They use this buffer for a PutBitContext.
3. The (codec-specific) writing takes place through the PutBitContext.
4. The return value is checked. AVERROR(ENOSPC) here always indicates
that the buffer was too small and leads to a reallocation of said
buffer.
5. The final buffer will be allocated and the data copied.
This commit factors this common code out in a single function in cbs.c.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/cbs_internal.h')
-rw-r--r-- | libavcodec/cbs_internal.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index dd4babf092..4c5a535ca6 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -44,9 +44,11 @@ typedef struct CodedBitstreamType { int (*read_unit)(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit); - // Write the unit->data bitstream from unit->content. + // Write the data bitstream from unit->content into pbc. + // Return value AVERROR(ENOSPC) indicates that pbc was too small. int (*write_unit)(CodedBitstreamContext *ctx, - CodedBitstreamUnit *unit); + CodedBitstreamUnit *unit, + PutBitContext *pbc); // Read the data from all of frag->units and assemble it into // a bitstream for the whole fragment. |