diff mbox series

[FFmpeg-devel,09/20] avformat/matroskaenc: Increase max supported tracks

Message ID 20200405155928.9323-10-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series Matroska muxer patches
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt April 5, 2020, 3:59 p.m. UTC
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(-)
diff mbox series

Patch

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index ab1c28ae02..f313b93e2a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -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);