X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fcafdec.c;h=7fd9c6b8d13aa038079d2adb710afbfd34fbb855;hb=2d9d4440519f22c092ac37ccd1a1a914564d00b5;hp=f1668047954baa42d27ca451469af0a0b7cb3092;hpb=e79c3858b35fcc77c68c33b627958e736686957e;p=ffmpeg diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index f1668047954..7fd9c6b8d13 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -343,12 +343,14 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) int64_t left = CAF_MAX_PKT_SIZE; if (url_feof(pb)) - return AVERROR(EIO); + return AVERROR_EOF; /* don't read past end of data chunk */ if (caf->data_size > 0) { left = (caf->data_start + caf->data_size) - avio_tell(pb); - if (left <= 0) + if (!left) + return AVERROR_EOF; + if (left < 0) return AVERROR(EIO); } @@ -399,7 +401,7 @@ static int read_seek(AVFormatContext *s, int stream_index, if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) { /* calculate new byte position based on target frame position */ - pos = caf->bytes_per_packet * timestamp / caf->frames_per_packet; + pos = caf->bytes_per_packet * (timestamp / caf->frames_per_packet); if (caf->data_size > 0) pos = FFMIN(pos, caf->data_size); packet_cnt = pos / caf->bytes_per_packet;