]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/nutdec.c
cosmetics
[ffmpeg] / libavformat / nutdec.c
index e584ac521d1504313c635e036ebd6ea189697f6a..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);
@@ -315,20 +315,14 @@ static int decode_stream_header(NUTContext *nut){
         case 0:
             st->codec->codec_type = CODEC_TYPE_VIDEO;
             st->codec->codec_id = codec_get_id(codec_bmp_tags, tmp);
-            if (st->codec->codec_id == CODEC_ID_NONE)
-                av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
             break;
         case 1:
             st->codec->codec_type = CODEC_TYPE_AUDIO;
             st->codec->codec_id = codec_get_id(codec_wav_tags, tmp);
-            if (st->codec->codec_id == CODEC_ID_NONE)
-                av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
             break;
         case 2:
             st->codec->codec_type = CODEC_TYPE_SUBTITLE;
-//            st->codec->codec_id = codec_get_id(codec_wav_tags, tmp); FIXME
-            if (st->codec->codec_id == CODEC_ID_NONE)
-                av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
+            st->codec->codec_id = codec_get_id(ff_nut_subtitle_tags, tmp);
             break;
         case 3:
             st->codec->codec_type = CODEC_TYPE_DATA;
@@ -337,6 +331,9 @@ static int decode_stream_header(NUTContext *nut){
             av_log(s, AV_LOG_ERROR, "unknown stream class (%d)\n", class);
             return -1;
     }
+    if(class<3 && st->codec->codec_id == CODEC_ID_NONE)
+        av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
+
     GET_V(stc->time_base_id    , tmp < nut->time_base_count);
     GET_V(stc->msb_pts_shift   , tmp < 16);
     stc->max_pts_distance= ff_get_v(bc);
@@ -374,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;
@@ -415,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));
@@ -424,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);
         }
     }
 
@@ -837,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);