diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-08-24 19:41:16 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-17 13:22:25 +0200 |
commit | 40bdd8cc05d9c98a18cf2b1c2a00c8a5a7b38113 (patch) | |
tree | 0fc408f78b9b6934ac351cd4499c07737f8f6a62 /libavformat/nutenc.c | |
parent | 9f05b3ba604a30eeb6f5ff877b8b5b5c93a268d7 (diff) |
avformat: Avoid allocation for AVStreamInternal
Do this by allocating AVStream together with the data that is
currently in AVStreamInternal; or rather: Put AVStream at the
beginning of a new structure called FFStream (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVStreamInternal altogether.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/nutenc.c')
-rw-r--r-- | libavformat/nutenc.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 6fb0a810e1..7977980935 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -1006,6 +1006,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) ff_nut_reset_ts(nut, *nus->time_base, pkt->dts); for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; + FFStream *const sti = ffstream(st); int64_t dts_tb = av_rescale_rnd(pkt->dts, nus->time_base->num * (int64_t)nut->stream[i].time_base->den, nus->time_base->den * (int64_t)nut->stream[i].time_base->num, @@ -1013,12 +1014,12 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) int index = av_index_search_timestamp(st, dts_tb, AVSEEK_FLAG_BACKWARD); if (index >= 0) { - sp_pos = FFMIN(sp_pos, st->internal->index_entries[index].pos); - if (!nut->write_index && 2*index > st->internal->nb_index_entries) { - memmove(st->internal->index_entries, - st->internal->index_entries + index, - sizeof(*st->internal->index_entries) * (st->internal->nb_index_entries - index)); - st->internal->nb_index_entries -= index; + sp_pos = FFMIN(sp_pos, sti->index_entries[index].pos); + if (!nut->write_index && 2*index > sti->nb_index_entries) { + memmove(sti->index_entries, + sti->index_entries + index, + sizeof(*sti->index_entries) * (sti->nb_index_entries - index)); + sti->nb_index_entries -= index; } } } |