mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
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>
This commit is contained in:
parent
9a44ec9410
commit
ce6a98e830
@ -1454,23 +1454,24 @@ static void find_index_range(AVFormatContext *s, const char *full_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int update_stream_extradata(AVFormatContext *s, OutputStream *os,
|
static int update_stream_extradata(AVFormatContext *s, OutputStream *os,
|
||||||
AVCodecParameters *par,
|
AVPacket *pkt, AVRational *frame_rate)
|
||||||
AVRational *frame_rate)
|
|
||||||
{
|
{
|
||||||
|
AVCodecParameters *par = os->ctx->streams[0]->codecpar;
|
||||||
uint8_t *extradata;
|
uint8_t *extradata;
|
||||||
|
int ret, extradata_size;
|
||||||
|
|
||||||
if (os->ctx->streams[0]->codecpar->extradata_size || !par->extradata_size)
|
if (par->extradata_size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
extradata = av_malloc(par->extradata_size);
|
extradata = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &extradata_size);
|
||||||
|
if (!extradata_size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!extradata)
|
ret = ff_alloc_extradata(par, extradata_size);
|
||||||
return AVERROR(ENOMEM);
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
memcpy(extradata, par->extradata, par->extradata_size);
|
memcpy(par->extradata, extradata, extradata_size);
|
||||||
|
|
||||||
os->ctx->streams[0]->codecpar->extradata = extradata;
|
|
||||||
os->ctx->streams[0]->codecpar->extradata_size = par->extradata_size;
|
|
||||||
|
|
||||||
set_codec_str(s, par, frame_rate, os->codec_str, sizeof(os->codec_str));
|
set_codec_str(s, par, frame_rate, os->codec_str, sizeof(os->codec_str));
|
||||||
|
|
||||||
@ -1687,7 +1688,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
int64_t seg_end_duration, elapsed_duration;
|
int64_t seg_end_duration, elapsed_duration;
|
||||||
int ret;
|
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)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user