diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-01-16 13:31:40 +0300 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-01-19 14:12:15 +0300 |
commit | 6a9830f50370568234e23c28abff8cc4b738ac4b (patch) | |
tree | 44d4f8aa397ba9cb1c77956e5cefdaed2a5e9e56 /libavformat | |
parent | 03d31ef39c18990a6fbdfad99c69084b60af7758 (diff) |
avformat/matroskaenc: Pass more parameters explicitly to mkv_write_block
This e.g. stops recalculating ts again.
Also pass the AVFormatContext as pointer to void as it is only used
for logging.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroskaenc.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 2ae033bce1..09d2fb2be5 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2417,27 +2417,23 @@ static int mkv_reformat_av1(MatroskaMuxContext *mkv, AVIOContext *pb, return 0; } -static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, - const AVPacket *pkt, int keyframe, uint64_t duration) +static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv, + AVIOContext *pb, const AVCodecParameters *par, + mkv_track *track, const AVPacket *pkt, + int keyframe, int64_t ts, uint64_t duration) { - MatroskaMuxContext *mkv = s->priv_data; - AVCodecParameters *par = s->streams[pkt->stream_index]->codecpar; - mkv_track *track = &mkv->tracks[pkt->stream_index]; uint8_t *data = NULL, *side_data = NULL; size_t side_data_size; int err = 0, offset = 0, size = pkt->size; - int64_t ts = track->write_dts ? pkt->dts : pkt->pts; uint64_t additional_id; uint32_t blockid = MATROSKA_ID_SIMPLEBLOCK; int64_t discard_padding = 0; unsigned track_number = track->track_num; ebml_master block_group, block_additions, block_more; - ts += track->ts_offset; - /* The following string is identical to the one in mkv_write_vtt_blocks * so that only one copy needs to exist in binaries. */ - av_log(s, AV_LOG_DEBUG, + av_log(logctx, AV_LOG_DEBUG, "Writing block of size %d with pts %" PRId64 ", dts %" PRId64 ", " "duration %" PRId64 " at relative offset %" PRId64 " in cluster " "at offset %" PRId64 ". TrackNumber %u, keyframe %d\n", @@ -2450,7 +2446,7 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb, data = pkt->data; if (err < 0) { - av_log(s, AV_LOG_ERROR, "Error when reformatting data of " + av_log(logctx, AV_LOG_ERROR, "Error when reformatting data of " "a packet from stream %d.\n", pkt->stream_index); return err; } @@ -2741,7 +2737,8 @@ static int mkv_write_packet_internal(AVFormatContext *s, const AVPacket *pkt) relative_packet_pos = avio_tell(pb); if (par->codec_id != AV_CODEC_ID_WEBVTT) { - ret = mkv_write_block(s, pb, pkt, keyframe, write_duration); + ret = mkv_write_block(s, mkv, pb, par, track, pkt, + keyframe, ts, write_duration); if (ret < 0) return ret; if (keyframe && IS_SEEKABLE(s->pb, mkv) && |