diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-02-20 23:30:01 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-20 23:30:14 +0300 |
commit | 5346b57ee719f95e2ccd07359a30e55e2a8d41ac (patch) | |
tree | bc6f42e147a7647418b06490da9ea241208c6508 | |
parent | 2130ed3312d468fd3f6e299d35c013fe568b83ab (diff) | |
parent | 7650caf013f45ebebf128855735a0c6350836ea4 (diff) |
Merge commit '7650caf013f45ebebf128855735a0c6350836ea4'
* commit '7650caf013f45ebebf128855735a0c6350836ea4':
rtpdec_h264: Use av_realloc instead of av_malloc+mempcy
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/rtpdec_h264.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c index abee9528d3..5e618a8f9d 100644 --- a/libavformat/rtpdec_h264.c +++ b/libavformat/rtpdec_h264.c @@ -115,18 +115,16 @@ static int parse_sprop_parameter_sets(AVFormatContext *s, packet_size = av_base64_decode(decoded_packet, base64packet, sizeof(decoded_packet)); if (packet_size > 0) { - uint8_t *dest = av_malloc(packet_size + sizeof(start_sequence) + - codec->extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + uint8_t *dest = av_realloc(codec->extradata, + packet_size + sizeof(start_sequence) + + codec->extradata_size + + FF_INPUT_BUFFER_PADDING_SIZE); if (!dest) { av_log(s, AV_LOG_ERROR, "Unable to allocate memory for extradata!\n"); return AVERROR(ENOMEM); } - if (codec->extradata_size) { - memcpy(dest, codec->extradata, codec->extradata_size); - av_free(codec->extradata); - } + codec->extradata = dest; memcpy(dest + codec->extradata_size, start_sequence, sizeof(start_sequence)); @@ -135,7 +133,6 @@ static int parse_sprop_parameter_sets(AVFormatContext *s, memset(dest + codec->extradata_size + sizeof(start_sequence) + packet_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); - codec->extradata = dest; codec->extradata_size += sizeof(start_sequence) + packet_size; } } |