aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-01-18 09:31:01 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-04-13 09:09:25 +0200
commit59e3a9aede5e2f9271c82583d8724c272ce33a0a (patch)
treee7ab2ca0a57881fab4c33c87c42bb7c1f04b68c9 /libavformat/matroskaenc.c
parent385964409a62158c7ad5226f1c1d4adc160ea830 (diff)
downloadffmpeg-59e3a9aede5e2f9271c82583d8724c272ce33a0a.tar.gz
avformat/matroskaenc: Change signature of mkv_write_track()
Up until now, mkv_write_track() received the index of the stream whose header data it is about to write as parameter; this index has until recently been explicitly used to generate both TrackNumber and TrackUID. But this is no longer so and as there is no reason why the function for writing a single TrackEntry should even know the index of the TrackEntry it is about to write, said index is replaced in the list of function parameters by the corresponding AVStream and mkv_track. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 5ba8fea59a..d0a02c0f5d 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1081,11 +1081,11 @@ static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
}
static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
- int i, AVIOContext *pb, int default_stream_exists)
+ AVStream *st, mkv_track *track, AVIOContext *pb,
+ int default_stream_exists)
{
- AVStream *st = s->streams[i];
AVCodecParameters *par = st->codecpar;
- ebml_master subinfo, track;
+ ebml_master subinfo, track_master;
int native_id = 0;
int qt_id = 0;
int bit_depth;
@@ -1108,9 +1108,9 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
return ret;
}
- track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0);
- put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER, mkv->tracks[i].track_num);
- put_ebml_uid (pb, MATROSKA_ID_TRACKUID, mkv->tracks[i].uid);
+ track_master = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0);
+ put_ebml_uint(pb, MATROSKA_ID_TRACKNUMBER, track->track_num);
+ put_ebml_uid (pb, MATROSKA_ID_TRACKUID, track->uid);
put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0); // no lacing (yet)
if ((tag = av_dict_get(st->metadata, "title", NULL, 0)))
@@ -1207,7 +1207,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
else if (!native_id) {
// if there is no mkv-specific codec ID, use VFW mode
put_ebml_string(pb, MATROSKA_ID_CODECID, "V_MS/VFW/FOURCC");
- mkv->tracks[i].write_dts = 1;
+ track->write_dts = 1;
s->internal->avoid_negative_ts_use_pts = 0;
}
@@ -1283,9 +1283,9 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n");
return AVERROR(EINVAL);
}
-// mkv->tracks[i].ts_offset = av_rescale_q(par->initial_padding,
-// (AVRational){ 1, par->sample_rate },
-// st->time_base);
+// track->ts_offset = av_rescale_q(par->initial_padding,
+// (AVRational){ 1, par->sample_rate },
+// st->time_base);
put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, codecdelay);
}
@@ -1301,7 +1301,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0);
put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , par->channels);
- mkv->tracks[i].sample_rate_offset = avio_tell(pb);
+ track->sample_rate_offset = avio_tell(pb);
put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate);
if (output_sample_rate)
put_ebml_float(pb, MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, output_sample_rate);
@@ -1337,13 +1337,13 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
}
if (mkv->mode != MODE_WEBM || par->codec_id != AV_CODEC_ID_WEBVTT) {
- mkv->tracks[i].codecpriv_offset = avio_tell(pb);
+ track->codecpriv_offset = avio_tell(pb);
ret = mkv_write_codecprivate(s, pb, par, native_id, qt_id);
if (ret < 0)
return ret;
}
- end_ebml_master(pb, track);
+ end_ebml_master(pb, track_master);
return 0;
}
@@ -1365,7 +1365,9 @@ static int mkv_write_tracks(AVFormatContext *s)
default_stream_exists |= st->disposition & AV_DISPOSITION_DEFAULT;
}
for (i = 0; i < s->nb_streams; i++) {
- ret = mkv_write_track(s, mkv, i, mkv->tracks_bc, default_stream_exists);
+ AVStream *st = s->streams[i];
+ ret = mkv_write_track(s, mkv, st, &mkv->tracks[i],
+ mkv->tracks_bc, default_stream_exists);
if (ret < 0)
return ret;
}