diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-12-25 16:34:46 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-12-25 17:14:32 +0100 |
commit | ee4e8050931250f609a37f300a1d1831a44ecb1b (patch) | |
tree | fcd75c93561ef0d5f0d5af5468d57a59267de17f /libavformat/utils.c | |
parent | ac480cb58dbe7859c96a08e9e5cd3dd3b0fb0ae7 (diff) | |
download | ffmpeg-ee4e8050931250f609a37f300a1d1831a44ecb1b.tar.gz |
avformat: add ff_get_extradata()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 7f19abc5f1..40d886f58a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2701,6 +2701,22 @@ int ff_alloc_extradata(AVCodecContext *avctx, int size) return ret; } +int ff_get_extradata(AVCodecContext *avctx, AVIOContext *pb, int size) +{ + int ret = ff_alloc_extradata(avctx, size); + if (ret < 0) + return ret; + ret = avio_read(pb, avctx->extradata, size); + if (ret != size) { + av_freep(&avctx->extradata); + avctx->extradata_size = 0; + av_log(avctx, AV_LOG_ERROR, "Failed to read extradata of size %d\n", size); + return ret < 0 ? ret : AVERROR_INVALIDDATA; + } + + return ret; +} + int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t ts) { int i, j; |