diff options
author | wm4 <wm4@nowhere> | 2014-01-11 01:25:49 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-01-11 01:25:49 +0100 |
commit | 4b4926bbb3102836fc0c2edafe791cca6209f45e (patch) | |
tree | 3ed7d5f45e2e61ab956e18db96106cf27d99323a /common/av_common.c | |
parent | 27e4360b0bc521ec6bb6ecd7c374a51c8114d090 (diff) | |
download | mpv-4b4926bbb3102836fc0c2edafe791cca6209f45e.tar.bz2 mpv-4b4926bbb3102836fc0c2edafe791cca6209f45e.tar.xz |
Factor out setting AVCodecContext extradata
Diffstat (limited to 'common/av_common.c')
-rw-r--r-- | common/av_common.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/common/av_common.c b/common/av_common.c index 9c41c03251..1a162b7d95 100644 --- a/common/av_common.c +++ b/common/av_common.c @@ -29,6 +29,19 @@ #include "osdep/numcores.h" +int mp_lavc_set_extradata(AVCodecContext *avctx, void *ptr, int size) +{ + if (size) { + av_free(avctx->extradata); + avctx->extradata_size = 0; + avctx->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return -1; + avctx->extradata_size = size; + memcpy(avctx->extradata, ptr, size); + } + return 0; +} // Copy the codec-related fields from st into avctx. This does not set the // codec itself, only codec related header data provided by libavformat. @@ -38,16 +51,7 @@ // This is strictly for decoding only. void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st) { - if (st->extradata_size) { - av_free(avctx->extradata); - avctx->extradata_size = 0; - avctx->extradata = - av_mallocz(st->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - if (avctx->extradata) { - avctx->extradata_size = st->extradata_size; - memcpy(avctx->extradata, st->extradata, st->extradata_size); - } - } + mp_lavc_set_extradata(avctx, st->extradata, st->extradata_size); avctx->codec_tag = st->codec_tag; avctx->stream_codec_tag = st->stream_codec_tag; avctx->bit_rate = st->bit_rate; |