Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavformat / ape.c
index d6c8ec2..92e9ac7 100644 (file)
@@ -146,7 +146,7 @@ static int ape_read_header(AVFormatContext * s)
     AVStream *st;
     uint32_t tag;
     int i, ret;
-    int total_blocks;
+    int64_t total_blocks;
     int64_t final_size = 0;
     int64_t pts, file_size;
 
@@ -329,7 +329,7 @@ static int ape_read_header(AVFormatContext * s)
     if (!st)
         return AVERROR(ENOMEM);
 
-    total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
+    total_blocks = (ape->totalframes == 0) ? 0 : ((int64_t)(ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
 
     st->codecpar->codec_type      = AVMEDIA_TYPE_AUDIO;
     st->codecpar->codec_id        = AV_CODEC_ID_APE;
@@ -413,6 +413,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
     /* note: we need to modify the packet size here to handle the last
        packet */
     pkt->size = ret + extra_size;
+    pkt->duration = nblocks;
 
     ape->currentframe++;