]> git.sesse.net Git - ffmpeg/commit
avcodec/cbs: Factor out common code for writing units
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 17 Nov 2019 07:34:35 +0000 (08:34 +0100)
committerMark Thompson <sw@jkqxz.net>
Sun, 17 Nov 2019 23:31:44 +0000 (23:31 +0000)
commit7c92eaace2b338e0b3acc18e1543b365610578fd
tree51f9343c4cf5bfbb156c3a303f0839df57bcb31e
parent5d8d9e032cafa88e99046478090dd5a629e3d51c
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>
13 files changed:
libavcodec/cbs.c
libavcodec/cbs.h
libavcodec/cbs_av1.c
libavcodec/cbs_av1.h
libavcodec/cbs_h2645.c
libavcodec/cbs_h2645.h
libavcodec/cbs_internal.h
libavcodec/cbs_jpeg.c
libavcodec/cbs_jpeg.h
libavcodec/cbs_mpeg2.c
libavcodec/cbs_mpeg2.h
libavcodec/cbs_vp9.c
libavcodec/cbs_vp9.h