]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/au.c
au: set stream start time and packet durations
[ffmpeg] / libavformat / au.c
index f055a6fdf21c5a157cc811176227a57e0d7808a8..670ec79e5928108affddf22476fc83cda65f4109 100644 (file)
@@ -89,7 +89,7 @@ static int au_read_header(AVFormatContext *s)
     codec = ff_codec_get_id(codec_au_tags, id);
 
     if (codec == AV_CODEC_ID_NONE) {
-        av_log_ask_for_sample(s, "unknown or unsupported codec tag: %d\n", id);
+        av_log_ask_for_sample(s, "unknown or unsupported codec tag: %u\n", id);
         return AVERROR_PATCHWELCOME;
     }
 
@@ -100,7 +100,12 @@ static int au_read_header(AVFormatContext *s)
     }
 
     if (channels == 0 || channels >= INT_MAX / (BLOCK_SIZE * bps >> 3)) {
-        av_log(s, AV_LOG_ERROR, "Invalid number of channels %d\n", channels);
+        av_log(s, AV_LOG_ERROR, "Invalid number of channels %u\n", channels);
+        return AVERROR_INVALIDDATA;
+    }
+
+    if (rate == 0 || rate > INT_MAX) {
+        av_log(s, AV_LOG_ERROR, "Invalid sample rate: %u\n", rate);
         return AVERROR_INVALIDDATA;
     }
 
@@ -115,6 +120,8 @@ static int au_read_header(AVFormatContext *s)
     st->codec->sample_rate = rate;
     st->codec->bit_rate    = channels * rate * bps;
     st->codec->block_align = channels * bps >> 3;
+
+    st->start_time = 0;
     avpriv_set_pts_info(st, 64, 1, rate);
     return 0;
 }
@@ -129,6 +136,7 @@ static int au_read_packet(AVFormatContext *s,
     if (ret < 0)
         return ret;
     pkt->stream_index = 0;
+    pkt->duration     = ret / s->streams[0]->codec->block_align;
 
     return 0;
 }