Commit 2aa42fac authored by James Almer's avatar James Almer

avformat/utils: simplify ff_alloc_extradata()

Cosmetic refactor

Reviewed-by: 74a2fa708af88d225ed708af758f236f869b1a57
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 0ca33b1d
......@@ -3243,24 +3243,20 @@ static int tb_unreliable(AVCodecContext *c)
int ff_alloc_extradata(AVCodecParameters *par, int size)
{
int ret;
av_freep(&par->extradata);
if (size < 0 || size >= INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
par->extradata = NULL;
par->extradata_size = 0;
par->extradata_size = 0;
if (size < 0 || size >= INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
return AVERROR(EINVAL);
}
par->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (par->extradata) {
memset(par->extradata + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
par->extradata_size = size;
ret = 0;
} else {
par->extradata_size = 0;
ret = AVERROR(ENOMEM);
}
return ret;
if (!par->extradata)
return AVERROR(ENOMEM);
memset(par->extradata + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
par->extradata_size = size;
return 0;
}
int ff_get_extradata(AVFormatContext *s, AVCodecParameters *par, AVIOContext *pb, int size)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment