diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-10-26 14:10:55 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-10-28 13:53:23 +0100 |
commit | 04385218885935df99ec9f98ab73bb461775d28b (patch) | |
tree | 9c2a8aa91adcc977843d829c634dda63b9afd520 /libavcodec/dvdsubenc.c | |
parent | dc1099442e2d772b440b0c37d465538a7fe5a684 (diff) |
lavc: un-avpriv avpriv_bprint_to_extradata()
It has not been used outside of lavc since 6f69f7a8bf6.
Also, move it to the only place where it is used.
Diffstat (limited to 'libavcodec/dvdsubenc.c')
-rw-r--r-- | libavcodec/dvdsubenc.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c index e54b5f0d7b..9fa9d5b6d7 100644 --- a/libavcodec/dvdsubenc.c +++ b/libavcodec/dvdsubenc.c @@ -424,6 +424,29 @@ fail: return ret; } +static int bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf) +{ + int ret; + char *str; + + ret = av_bprint_finalize(buf, &str); + if (ret < 0) + return ret; + if (!av_bprint_is_complete(buf)) { + av_free(str); + return AVERROR(ENOMEM); + } + + avctx->extradata = str; + /* Note: the string is NUL terminated (so extradata can be read as a + * string), but the ending character is not accounted in the size (in + * binary formats you are likely not supposed to mux that character). When + * extradata is copied, it is also padded with AV_INPUT_BUFFER_PADDING_SIZE + * zeros. */ + avctx->extradata_size = buf->len; + return 0; +} + static int dvdsub_init(AVCodecContext *avctx) { DVDSubtitleContext *dvdc = avctx->priv_data; @@ -451,7 +474,7 @@ static int dvdsub_init(AVCodecContext *avctx) av_bprintf(&extradata, " %06"PRIx32"%c", dvdc->global_palette[i] & 0xFFFFFF, i < 15 ? ',' : '\n'); - ret = avpriv_bprint_to_extradata(avctx, &extradata); + ret = bprint_to_extradata(avctx, &extradata); if (ret < 0) return ret; |