diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-10-13 10:19:09 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-10-13 20:13:38 +0000 |
commit | 3fd79833e266aec2d77cf07092e8b1406fd307d4 (patch) | |
tree | 9812ce213a4955aa463ebf61ae6409a24152da7f /libavformat/utils.c | |
parent | fe448cd28d674c3eff3072552eae366d0b659ce9 (diff) | |
download | ffmpeg-3fd79833e266aec2d77cf07092e8b1406fd307d4.tar.gz |
avformat: add ff_alloc_extradata() helper
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 61405d7c97..6a7f58027c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2678,6 +2678,26 @@ int av_find_stream_info(AVFormatContext *ic) } #endif +int ff_alloc_extradata(AVCodecContext *avctx, int size) +{ + int ret; + + if (size < 0 || size >= INT32_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { + avctx->extradata_size = 0; + return AVERROR(EINVAL); + } + avctx->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); + if (avctx->extradata) { + memset(avctx->extradata + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + avctx->extradata_size = size; + ret = 0; + } else { + avctx->extradata_size = 0; + ret = AVERROR(ENOMEM); + } + return ret; +} + int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) { int i, count, ret = 0, j; |