Browse code

WavPack demuxer: set packet duration

Signed-off-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>

Paul B Mahol authored on 2012/02/09 07:17:54
Showing 1 changed files
... ...
@@ -251,6 +251,7 @@ static int wv_read_packet(AVFormatContext *s,
251 251
     int ret;
252 252
     int size, ver, off;
253 253
     int64_t pos;
254
+    uint32_t block_samples;
254 255
 
255 256
     if (s->pb->eof_reached)
256 257
         return AVERROR(EIO);
... ...
@@ -316,6 +317,12 @@ static int wv_read_packet(AVFormatContext *s,
316 316
     pkt->stream_index = 0;
317 317
     wc->block_parsed = 1;
318 318
     pkt->pts = wc->soff;
319
+    block_samples = AV_RN32(wc->extra);
320
+    if (block_samples > INT32_MAX)
321
+        av_log(s, AV_LOG_WARNING, "Too many samples in block: %"PRIu32"\n", block_samples);
322
+    else
323
+        pkt->duration = block_samples;
324
+
319 325
     av_add_index_entry(s->streams[0], pos, pkt->pts, 0, 0, AVINDEX_KEYFRAME);
320 326
     return 0;
321 327
 }