On 17/11/2019 07:34, Andreas Rheinhardt wrote: > 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.rheinha...@gmail.com> > --- > libavcodec/cbs.c | 64 ++++++++++++++++++++++++++++++++++--- > libavcodec/cbs.h | 7 ++++ > libavcodec/cbs_av1.c | 59 +++------------------------------- > libavcodec/cbs_av1.h | 4 --- > libavcodec/cbs_h2645.c | 67 ++------------------------------------- > libavcodec/cbs_h2645.h | 7 ---- > libavcodec/cbs_internal.h | 6 ++-- > libavcodec/cbs_jpeg.c | 64 +++---------------------------------- > libavcodec/cbs_jpeg.h | 7 ---- > libavcodec/cbs_mpeg2.c | 62 +++--------------------------------- > libavcodec/cbs_mpeg2.h | 4 --- > libavcodec/cbs_vp9.c | 61 ++++++----------------------------- > libavcodec/cbs_vp9.h | 4 ---> 13 files changed, 94 insertions(+), 322 > deletions(-)
Beautiful, applied :) Thanks! - Mark _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".