]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/ffmdec.c
lavf: increase retries to guess duration from pts by 1
[ffmpeg] / libavformat / ffmdec.c
index 7cbcf2bf2aa9c66fe1dbbf10e25b519582f2f497..028f1ee7974fd4ad20f4a24c3da7294e0883c26e 100644 (file)
@@ -111,8 +111,8 @@ static int ffm_read_data(AVFormatContext *s,
             if (ffm->first_packet || (frame_offset & 0x8000)) {
                 if (!frame_offset) {
                     /* This packet has no frame headers in it */
-                    if (avio_tell(pb) >= ffm->packet_size * 3) {
-                        avio_seek(pb, -ffm->packet_size * 2, SEEK_CUR);
+                    if (avio_tell(pb) >= ffm->packet_size * 3LL) {
+                        avio_seek(pb, -ffm->packet_size * 2LL, SEEK_CUR);
                         goto retry_read;
                     }
                     /* This is bad, we cannot find a valid frame header */
@@ -386,7 +386,9 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
 
         duration = AV_RB24(ffm->header + 5);
 
-        av_new_packet(pkt, size);
+        if (av_new_packet(pkt, size) < 0) {
+            return AVERROR(ENOMEM);
+        }
         pkt->stream_index = ffm->header[0];
         if ((unsigned)pkt->stream_index >= s->nb_streams) {
             av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index);
@@ -443,7 +445,7 @@ static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, in
     while (pos_min <= pos_max) {
         pts_min = get_dts(s, pos_min);
         pts_max = get_dts(s, pos_max);
-        if (pts_min > wanted_pts || pts_max < wanted_pts) {
+        if (pts_min > wanted_pts || pts_max <= wanted_pts) {
             pos = pts_min > wanted_pts ? pos_min : pos_max;
             goto found;
         }