avformat: add ff_get_extradata()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-12-25 16:34:46 +01:00
parent ac480cb58d
commit ee4e805093
2 changed files with 25 additions and 0 deletions

View File

@ -371,6 +371,15 @@ int ff_generate_avci_extradata(AVStream *st);
*/
int ff_alloc_extradata(AVCodecContext *avctx, int size);
/**
* Allocate extradata with additional FF_INPUT_BUFFER_PADDING_SIZE at end
* which is always set to 0 and fill it from pb.
*
* @param size size of extradata
* @return >= 0 if OK, AVERROR_xxx on error
*/
int ff_get_extradata(AVCodecContext *avctx, AVIOContext *pb, int size);
/**
* add frame for rfps calculation.
*

View File

@ -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;