]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/nutdec.c
cosmetics
[ffmpeg] / libavformat / nutdec.c
index 409cd7c5885fab6b728cf421f907f25d0e966b7a..186e308a72c7caadb16a60127737e452497ce829 100644 (file)
@@ -111,7 +111,7 @@ static uint64_t find_any_startcode(ByteIOContext *bc, int64_t pos){
     uint64_t state=0;
 
     if(pos >= 0)
-        url_fseek(bc, pos, SEEK_SET); //note, this may fail if the stream is not seekable, but that should not matter, as in this case we simply start where we are currently
+        url_fseek(bc, pos, SEEK_SET); //note, this may fail if the stream is not seekable, but that should not matter, as in this case we simply start where we currently are
 
     while(!url_feof(bc)){
         state= (state<<8) | get_byte(bc);
@@ -371,6 +371,19 @@ static int decode_stream_header(NUTContext *nut){
     return 0;
 }
 
+static void set_disposition_bits(AVFormatContext* avf, char* value, int stream_id){
+    int flag = 0, i;
+    for (i=0; ff_nut_dispositions[i].flag; ++i) {
+        if (!strcmp(ff_nut_dispositions[i].str, value))
+            flag = ff_nut_dispositions[i].flag;
+    }
+    if (!flag)
+        av_log(avf, AV_LOG_INFO, "unknown disposition type '%s'\n", value);
+    for (i = 0; i < avf->nb_streams; ++i)
+        if (stream_id == i || stream_id == -1)
+            avf->streams[i]->disposition |= flag;
+}
+
 static int decode_info_header(NUTContext *nut){
     AVFormatContext *s= nut->avf;
     ByteIOContext *bc = s->pb;
@@ -412,6 +425,11 @@ static int decode_info_header(NUTContext *nut){
             type= "v";
         }
 
+        if (stream_id_plus1 < 0 || stream_id_plus1 > s->nb_streams) {
+            av_log(s, AV_LOG_ERROR, "invalid stream id for info packet\n");
+            continue;
+        }
+
         if(chapter_id==0 && !strcmp(type, "UTF-8")){
             if     (!strcmp(name, "Author"))
                 av_strlcpy(s->author   , str_value, sizeof(s->author));
@@ -421,6 +439,8 @@ static int decode_info_header(NUTContext *nut){
                 av_strlcpy(s->copyright, str_value, sizeof(s->copyright));
             else if(!strcmp(name, "Description"))
                 av_strlcpy(s->comment  , str_value, sizeof(s->comment));
+            else if(!strcmp(name, "Disposition"))
+                set_disposition_bits(s, str_value, stream_id_plus1 - 1);
         }
     }
 
@@ -834,7 +854,7 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flag
                                                 next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp);
             if(pos2>=0)
                 pos= pos2;
-            //FIXME dir but i think it does not matter
+            //FIXME dir but I think it does not matter
         }
         dummy.pos= pos;
         sp= av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pos_cmp, NULL);