# HG changeset patch # User kostya # Date 1167629547 0 # Node ID cde17266ad08521c472ad0905d0919bb8c06de97 # Parent 9adbec516265342c72204f48b39f90a4a9e4c3fe Decode previous 32 frames to avoid seeking artifacts in MPC diff -r 9adbec516265 -r cde17266ad08 mpc.c --- a/mpc.c Mon Jan 01 05:29:53 2007 +0000 +++ b/mpc.c Mon Jan 01 05:32:27 2007 +0000 @@ -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 @@ 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 @@ 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 @@ /* 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;