[FFmpeg-cvslog] avformat/dashenc: make AdaptationSet id an integer value

James Almer git at videolan.org
Sun Feb 16 19:05:46 EET 2020


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Jan  8 13:47:08 2020 -0300| [4d27def59c922eafc7092af7096eb048db8e0db3] | committer: James Almer

avformat/dashenc: make AdaptationSet id an integer value

Unlike Representation id, it's defined as an integer in the spec, and not as a
string.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4d27def59c922eafc7092af7096eb048db8e0db3
---

 libavformat/dashenc.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9a8dde98e9..59ce3cb6a9 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -80,7 +80,7 @@ typedef struct Segment {
 } Segment;
 
 typedef struct AdaptationSet {
-    char id[10];
+    int id;
     char *descriptor;
     int64_t seg_duration;
     int64_t frag_duration;
@@ -802,7 +802,7 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind
     AVDictionaryEntry *lang, *role;
     int i;
 
-    avio_printf(out, "\t\t<AdaptationSet id=\"%s\" contentType=\"%s\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"",
+    avio_printf(out, "\t\t<AdaptationSet id=\"%d\" contentType=\"%s\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"",
                 as->id, as->media_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");
     if (as->media_type == AVMEDIA_TYPE_VIDEO && as->max_frame_rate.num && !as->ambiguous_frame_rate && av_cmp_q(as->min_frame_rate, as->max_frame_rate) < 0)
         avio_printf(out, " maxFrameRate=\"%d/%d\"", as->max_frame_rate.num, as->max_frame_rate.den);
@@ -929,7 +929,7 @@ static int parse_adaptation_sets(AVFormatContext *s)
         for (i = 0; i < s->nb_streams; i++) {
             if ((ret = add_adaptation_set(s, &as, s->streams[i]->codecpar->codec_type)) < 0)
                 return ret;
-            snprintf(as->id, sizeof(as->id), "%d", i);
+            as->id = i;
 
             c->streams[i].as_idx = c->nb_as;
             ++as->nb_streams;
@@ -950,12 +950,20 @@ static int parse_adaptation_sets(AVFormatContext *s)
             p++;
             continue;
         } else if (state == new_set && av_strstart(p, "id=", &p)) {
+            char id_str[10], *end_str;
+
+            n = strcspn(p, ",");
+            snprintf(id_str, sizeof(id_str), "%.*s", n, p);
+
+            i = strtol(id_str, &end_str, 10);
+            if (id_str == end_str || i < 0 || i > c->nb_as) {
+                av_log(s, AV_LOG_ERROR, "\"%s\" is not a valid value for an AdaptationSet id\n", id_str);
+                return AVERROR(EINVAL);
+            }
 
             if ((ret = add_adaptation_set(s, &as, AVMEDIA_TYPE_UNKNOWN)) < 0)
                 return ret;
-
-            n = strcspn(p, ",");
-            snprintf(as->id, sizeof(as->id), "%.*s", n, p);
+            as->id = i;
 
             p += n;
             if (*p)



More information about the ffmpeg-cvslog mailing list