Skip to content
Snippets Groups Projects
Commit 0ebd4083 authored by Martin Storsjö's avatar Martin Storsjö
Browse files

sdp: Restore the original mp4 format h264 extradata if converted


If the sdp is generated before the rtp muxer is initialized
(e.g. as when called from the rtsp muxer), this has to be done,
otherwise the rtp muxer doesn't know that the input really is
in mp4 format.

Signed-off-by: default avatarMartin Storsjö <martin@martin.st>
parent e0a3c287
No related branches found
No related tags found
No related merge requests found
...@@ -156,6 +156,8 @@ static char *extradata2psets(AVCodecContext *c) ...@@ -156,6 +156,8 @@ static char *extradata2psets(AVCodecContext *c)
char *psets, *p; char *psets, *p;
const uint8_t *r; const uint8_t *r;
const char *pset_string = "; sprop-parameter-sets="; const char *pset_string = "; sprop-parameter-sets=";
uint8_t *orig_extradata = NULL;
int orig_extradata_size = 0;
if (c->extradata_size > MAX_EXTRADATA_SIZE) { if (c->extradata_size > MAX_EXTRADATA_SIZE) {
av_log(c, AV_LOG_ERROR, "Too much extradata!\n"); av_log(c, AV_LOG_ERROR, "Too much extradata!\n");
...@@ -172,6 +174,15 @@ static char *extradata2psets(AVCodecContext *c) ...@@ -172,6 +174,15 @@ static char *extradata2psets(AVCodecContext *c)
return NULL; return NULL;
} }
orig_extradata_size = c->extradata_size;
orig_extradata = av_mallocz(orig_extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!orig_extradata) {
av_bitstream_filter_close(bsfc);
return NULL;
}
memcpy(orig_extradata, c->extradata, orig_extradata_size);
av_bitstream_filter_filter(bsfc, c, NULL, &dummy_p, &dummy_int, NULL, 0, 0); av_bitstream_filter_filter(bsfc, c, NULL, &dummy_p, &dummy_int, NULL, 0, 0);
av_bitstream_filter_close(bsfc); av_bitstream_filter_close(bsfc);
} }
...@@ -179,6 +190,7 @@ static char *extradata2psets(AVCodecContext *c) ...@@ -179,6 +190,7 @@ static char *extradata2psets(AVCodecContext *c)
psets = av_mallocz(MAX_PSET_SIZE); psets = av_mallocz(MAX_PSET_SIZE);
if (psets == NULL) { if (psets == NULL) {
av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the parameter sets.\n"); av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the parameter sets.\n");
av_free(orig_extradata);
return NULL; return NULL;
} }
memcpy(psets, pset_string, strlen(pset_string)); memcpy(psets, pset_string, strlen(pset_string));
...@@ -208,6 +220,11 @@ static char *extradata2psets(AVCodecContext *c) ...@@ -208,6 +220,11 @@ static char *extradata2psets(AVCodecContext *c)
p += strlen(p); p += strlen(p);
r = r1; r = r1;
} }
if (orig_extradata) {
av_free(c->extradata);
c->extradata = orig_extradata;
c->extradata_size = orig_extradata_size;
}
return psets; return psets;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment