diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-02-21 12:25:04 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-21 12:25:09 +0100 |
commit | 621450e786c66b84626f0c7bafcfff6bed330e5d (patch) | |
tree | 3d7f9940c63287e5ce014097697f0319d9062335 /libavformat/rtpdec_h264.c | |
parent | 9b41bf5c3dcefb95c8329e699f4bdb71ad267e6f (diff) | |
parent | 48183b3ad45c95e386a4cb02e1a68b53e6835ac5 (diff) | |
download | ffmpeg-621450e786c66b84626f0c7bafcfff6bed330e5d.tar.gz |
Merge commit '48183b3ad45c95e386a4cb02e1a68b53e6835ac5'
* commit '48183b3ad45c95e386a4cb02e1a68b53e6835ac5':
rtpdec_h264: Generalize parse_sprop_parameter_sets
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtpdec_h264.c')
-rw-r--r-- | libavformat/rtpdec_h264.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c index d3439b9fc0..39e2b9c2b5 100644 --- a/libavformat/rtpdec_h264.c +++ b/libavformat/rtpdec_h264.c @@ -93,7 +93,7 @@ static void parse_profile_level_id(AVFormatContext *s, } static int parse_sprop_parameter_sets(AVFormatContext *s, - AVCodecContext *codec, + uint8_t **data_ptr, int *size_ptr, const char *value) { char base64packet[1024]; @@ -115,31 +115,28 @@ 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_realloc(codec->extradata, + uint8_t *dest = av_realloc(*data_ptr, packet_size + sizeof(start_sequence) + - codec->extradata_size + + *size_ptr + FF_INPUT_BUFFER_PADDING_SIZE); if (!dest) { av_log(s, AV_LOG_ERROR, "Unable to allocate memory for extradata!\n"); return AVERROR(ENOMEM); } - codec->extradata = dest; + *data_ptr = dest; - memcpy(dest + codec->extradata_size, start_sequence, + memcpy(dest + *size_ptr, start_sequence, sizeof(start_sequence)); - memcpy(dest + codec->extradata_size + sizeof(start_sequence), + memcpy(dest + *size_ptr + sizeof(start_sequence), decoded_packet, packet_size); - memset(dest + codec->extradata_size + sizeof(start_sequence) + + memset(dest + *size_ptr + sizeof(start_sequence) + packet_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); - codec->extradata_size += sizeof(start_sequence) + packet_size; + *size_ptr += sizeof(start_sequence) + packet_size; } } - av_log(s, AV_LOG_DEBUG, "Extradata set to %p (size: %d)\n", - codec->extradata, codec->extradata_size); - return 0; } @@ -167,9 +164,14 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s, if (strlen(value) == 6) parse_profile_level_id(s, h264_data, value); } else if (!strcmp(attr, "sprop-parameter-sets")) { + int ret; codec->extradata_size = 0; av_freep(&codec->extradata); - return parse_sprop_parameter_sets(s, codec, value); + ret = parse_sprop_parameter_sets(s, &codec->extradata, + &codec->extradata_size, value); + av_log(s, AV_LOG_DEBUG, "Extradata set to %p (size: %d)\n", + codec->extradata, codec->extradata_size); + return ret; } return 0; } |