From aac88b534c84a4bb7e0082b64f215762517f8e5b Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 1 Jan 2007 05:32:27 +0000 Subject: Decode previous 32 frames to avoid seeking artifacts in MPC Originally committed as revision 7393 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/mpc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libavformat/mpc.c') diff --git a/libavformat/mpc.c b/libavformat/mpc.c index f06cba7629..8b2358ea48 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -22,6 +22,7 @@ #include "bitstream.h" #define MPC_FRAMESIZE 1152 +#define DELAY_FRAMES 32 static const int mpc_rate[4] = { 44100, 48000, 37800, 32000 }; typedef struct { @@ -155,6 +156,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) pkt->data[1] = (c->curframe > c->fcount); pkt->stream_index = 0; + pkt->pts = cur; ret = get_buffer(&s->pb, pkt->data + 4, size); if(c->curbits) url_fseek(&s->pb, -4, SEEK_CUR); @@ -188,7 +190,7 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp MPCContext *c = s->priv_data; AVPacket pkt1, *pkt = &pkt1; int ret; - int index = av_index_search_timestamp(st, timestamp, flags); + int index = av_index_search_timestamp(st, timestamp - DELAY_FRAMES, flags); uint32_t lastframe; /* if found, seek there */ @@ -199,6 +201,7 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp /* if timestamp is out of bounds, return error */ if(timestamp < 0 || timestamp >= c->fcount) return -1; + timestamp -= DELAY_FRAMES; /* seek to the furthest known position and read packets until we reach desired position */ lastframe = c->curframe; -- cgit v1.2.3