aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-07-30 15:08:36 -0300
committerJames Almer <jamrial@gmail.com>2019-08-05 15:02:50 -0300
commitd1c81070bce261329b641b648efe42062b699cd3 (patch)
tree99c628eb89362dbcc2f5f51f34e00292f166d797
parent5152602ba8f49ceb58aa89fcad8e6aaa9a6a27ff (diff)
downloadffmpeg-d1c81070bce261329b641b648efe42062b699cd3.tar.gz
avformat/dashenc: update stream extradata from packet side data
codecpar->extradata is not going to change between packets. New extradata is instead propagated using packet side data. Use ff_alloc_extradata() as well. Signed-off-by: James Almer <jamrial@gmail.com> (cherry picked from commit ce6a98e8306105b07bd7653f4f10c23fd75914ee)
-rw-r--r--libavformat/dashenc.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index b25afb40aa..a1b7b7242f 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1435,23 +1435,24 @@ static void find_index_range(AVFormatContext *s, const char *full_path,
}
static int update_stream_extradata(AVFormatContext *s, OutputStream *os,
- AVCodecParameters *par,
- AVRational *frame_rate)
+ AVPacket *pkt, AVRational *frame_rate)
{
+ AVCodecParameters *par = os->ctx->streams[0]->codecpar;
uint8_t *extradata;
+ int ret, extradata_size;
- if (os->ctx->streams[0]->codecpar->extradata_size || !par->extradata_size)
+ if (par->extradata_size)
return 0;
- extradata = av_malloc(par->extradata_size);
-
- if (!extradata)
- return AVERROR(ENOMEM);
+ extradata = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &extradata_size);
+ if (!extradata_size)
+ return 0;
- memcpy(extradata, par->extradata, par->extradata_size);
+ ret = ff_alloc_extradata(par, extradata_size);
+ if (ret < 0)
+ return ret;
- os->ctx->streams[0]->codecpar->extradata = extradata;
- os->ctx->streams[0]->codecpar->extradata_size = par->extradata_size;
+ memcpy(par->extradata, extradata, extradata_size);
set_codec_str(s, par, frame_rate, os->codec_str, sizeof(os->codec_str));
@@ -1668,7 +1669,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
int64_t seg_end_duration, elapsed_duration;
int ret;
- ret = update_stream_extradata(s, os, st->codecpar, &st->avg_frame_rate);
+ ret = update_stream_extradata(s, os, pkt, &st->avg_frame_rate);
if (ret < 0)
return ret;