@@ -107,9 +107,9 @@ typedef struct mkv_track {
#define MODE_MATROSKAv2 0x01
#define MODE_WEBM 0x02
-/** Maximum number of tracks allowed in a Matroska file (with track numbers in
- * range 1 to 126 (inclusive) */
-#define MAX_TRACKS 126
+/** Maximum number of tracks supported by this muxer (with track numbers
+ * in the range 1 to 127 (inclusive)) */
+#define MAX_TRACKS 127
typedef struct MatroskaMuxContext {
const AVClass *class;
@@ -2034,7 +2034,7 @@ static int mkv_write_block(AVFormatContext *s, AVIOContext *pb,
put_ebml_id(pb, blockid);
put_ebml_num(pb, size + 4, 0);
- // this assumes stream_index is less than 126
+ // this assumes track_number is <= 127
avio_w8(pb, 0x80 | track_number);
avio_wb16(pb, ts - mkv->cluster_pts);
avio_w8(pb, (blockid == MATROSKA_ID_SIMPLEBLOCK && keyframe) ? (1 << 7) : 0);
@@ -2102,7 +2102,7 @@ static int mkv_write_vtt_blocks(AVFormatContext *s, AVIOContext *pb, AVPacket *p
put_ebml_id(pb, MATROSKA_ID_BLOCK);
put_ebml_num(pb, size + 4, 0);
- avio_w8(pb, 0x80 | track->track_num); // this assumes track_num is less than 126
+ avio_w8(pb, 0x80 | track->track_num); // this assumes track_num <= 127
avio_wb16(pb, ts - mkv->cluster_pts);
avio_w8(pb, flags);
avio_printf(pb, "%.*s\n%.*s\n%.*s", id_size, id, settings_size, settings, pkt->size, pkt->data);
Our code can actually write tracks with a TrackNumber in the range of 1..127 without problems. Variable length integers that only have '1' bits after the marker bit are not reserved when being used to encode the TrackNumber in a Block (there is no equivalent of unknown length elements here). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- Don't know yet if this or a version that completely removes said limit will get in. libavformat/matroskaenc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)