summaryrefslogtreecommitdiffstats
path: root/libavcodec/h264_mp4toannexb_bsf.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-12-09 20:31:29 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-12-09 20:31:29 +0100
commit8c677a9f06c5d145da0301cdc3c6bff9ebacb5d7 (patch)
tree9c756ade47cc06771cb120f53b5f9c22724717f6 /libavcodec/h264_mp4toannexb_bsf.c
parent94a849b8b6c3e4a90361485b2e12a9a5c35833a3 (diff)
parent9b8d11a76ae7bca8bbb58abb822138f8b42c776c (diff)
downloadffmpeg-streaming-8c677a9f06c5d145da0301cdc3c6bff9ebacb5d7.zip
ffmpeg-streaming-8c677a9f06c5d145da0301cdc3c6bff9ebacb5d7.tar.gz
Merge commit '9b8d11a76ae7bca8bbb58abb822138f8b42c776c'
* commit '9b8d11a76ae7bca8bbb58abb822138f8b42c776c': avcodec: Use av_reallocp where suitable Conflicts: libavcodec/bitstream.c libavcodec/eatgv.c libavcodec/flashsv.c libavcodec/libtheoraenc.c libavcodec/libvpxenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/h264_mp4toannexb_bsf.c')
-rw-r--r--libavcodec/h264_mp4toannexb_bsf.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c
index 58568a7..8c0fbb3 100644
--- a/libavcodec/h264_mp4toannexb_bsf.c
+++ b/libavcodec/h264_mp4toannexb_bsf.c
@@ -37,13 +37,14 @@ static int alloc_and_copy(uint8_t **poutbuf, int *poutbuf_size,
{
uint32_t offset = *poutbuf_size;
uint8_t nal_header_size = offset ? 3 : 4;
- void *tmp;
+ int err;
*poutbuf_size += sps_pps_size + in_size + nal_header_size;
- tmp = av_realloc(*poutbuf, *poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!tmp)
- return AVERROR(ENOMEM);
- *poutbuf = tmp;
+ if ((err = av_reallocp(poutbuf,
+ *poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE)) < 0) {
+ *poutbuf_size = 0;
+ return err;
+ }
if (sps_pps)
memcpy(*poutbuf + offset, sps_pps, sps_pps_size);
memcpy(*poutbuf + sps_pps_size + nal_header_size + offset, in, in_size);
@@ -77,7 +78,7 @@ static int h264_extradata_to_annexb(AVCodecContext *avctx, const int padding)
}
while (unit_nb--) {
- void *tmp;
+ int err;
unit_size = AV_RB16(extradata);
total_size += unit_size + 4;
@@ -93,12 +94,8 @@ static int h264_extradata_to_annexb(AVCodecContext *avctx, const int padding)
av_free(out);
return AVERROR(EINVAL);
}
- tmp = av_realloc(out, total_size + padding);
- if (!tmp) {
- av_free(out);
- return AVERROR(ENOMEM);
- }
- out = tmp;
+ if ((err = av_reallocp(&out, total_size + padding)) < 0)
+ return err;
memcpy(out + total_size - unit_size - 4, nalu_header, 4);
memcpy(out + total_size - unit_size, extradata + 2, unit_size);
extradata += 2 + unit_size;
OpenPOWER on IntegriCloud