@@ -24,6 +24,7 @@
#include "libavutil/dict.h"
#include "libavutil/parseutils.h"
#include "libavutil/opt.h"
+#include "libavcodec/h264.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
#include "avformat.h"
@@ -161,7 +162,7 @@ static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
uint8_t *extradata = par->extradata;
int extradata_size = par->extradata_size;
uint8_t *tmpbuf = NULL;
- const uint8_t *sps = NULL, *sps_end;
+ const uint8_t *sps = NULL;
if (par->extradata_size > MAX_EXTRADATA_SIZE) {
av_log(s, AV_LOG_ERROR, "Too much extradata!\n");
@@ -199,10 +200,9 @@ static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
*p = ',';
p++;
}
- if (!sps) {
+ if (nal_type == H264_NAL_SPS && !sps && r1 - r >= 4)
sps = r;
- sps_end = r1;
- }
+
if (!av_base64_encode(p, MAX_PSET_SIZE - (p - psets), r, r1 - r)) {
av_log(s, AV_LOG_ERROR, "Cannot Base64-encode %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"!\n", MAX_PSET_SIZE - (p - psets), r1 - r);
av_free(psets);
@@ -213,7 +213,7 @@ static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
p += strlen(p);
r = r1;
}
- if (sps && sps_end - sps >= 4 && p - psets <= MAX_PSET_SIZE - strlen(profile_string) - 7) {
+ if (sps && p - psets <= MAX_PSET_SIZE - strlen(profile_string) - 7) {
memcpy(p, profile_string, strlen(profile_string));
p += strlen(p);
ff_data_to_hex(p, sps + 1, 3, 0);
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavformat/sdp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)