[FFmpeg-cvslog] avformat/utils: simplify ff_alloc_extradata()
James Almer
git at videolan.org
Wed Mar 7 00:15:26 EET 2018
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Mar 6 01:37:21 2018 -0300| [2aa42fac77ac1d29d858327fc72c972672ff3729] | committer: James Almer
avformat/utils: simplify ff_alloc_extradata()
Cosmetic refactor
Reviewed-by: 74a2fa708af88d225ed708af758f236f869b1a57
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2aa42fac77ac1d29d858327fc72c972672ff3729
---
libavformat/utils.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 31340a484b..3ca1ca2441 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -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)
More information about the ffmpeg-cvslog
mailing list