From patchwork Wed Jan 31 17:04:47 2007 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ville Rannikko X-Patchwork-Id: 12432 Received: from smtp-3.hut.fi ([130.233.228.93]) by www.linuxtv.org with esmtp (Exim 4.50) id 1HCIvb-0006Hc-8z for vdr@linuxtv.org; Wed, 31 Jan 2007 18:07:23 +0100 Received: from localhost (putosiko.hut.fi [130.233.228.114]) by smtp-3.hut.fi (8.13.6/8.12.10) with ESMTP id l0VH60Q2004647 for ; Wed, 31 Jan 2007 19:06:00 +0200 Received: from smtp-3.hut.fi ([130.233.228.93]) by localhost (putosiko.hut.fi [130.233.228.114]) (amavisd-new, port 10024) with LMTP id 23087-18-7 for ; Wed, 31 Jan 2007 19:05:59 +0200 (EET) Received: from vipunen.hut.fi (vipunen.hut.fi [130.233.228.9]) by smtp-3.hut.fi (8.13.6/8.12.10) with ESMTP id l0VH4lZ7004373 for ; Wed, 31 Jan 2007 19:04:47 +0200 Date: Wed, 31 Jan 2007 19:04:47 +0200 (EET) From: Ville Rannikko To: vdr@linuxtv.org Message-ID: MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on putosiko.hut.fi X-TKK-Virus-Scanned: by amavisd-new-2.1.2-hutcc at putosiko.hut.fi Subject: [vdr] FF card AV sync problems, possible fix to VDR X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jan 2007 17:07:23 -0000 Status: O X-Status: X-Keywords: X-UID: 11910 Hi! The newest firmware for FF cards did not completely fix the AV desync problems for me. According to information from Werner the problem happens when small video frames fill the decoder buffer with over 2 seconds of data. So I made this patch for dvbplayer.c to stop it from uploading more PES frames to decoder when STC/PTS difference is more than 2 seconds. This seems to fix the remaining problems for me, but I have not tested it much. The PTS/STC-code has been mostly taken from the dvb-subtitles plugin. Comments, please Ville --- dvbplayer.c.orig 2007-01-31 18:21:42.000000000 +0200 +++ dvbplayer.c 2007-01-31 18:35:36.000000000 +0200 @@ -495,6 +495,51 @@ } } if (p) { + if(playMode == pmPlay && pc > 13) + { + int64_t stc = -1; + int64_t pts = -1; + + if ( p[0] == 0x00 && p[1] == 0x00 && p[2] == 0x01) + { + if(p[7] & 0x80) + { + switch( p[3] ) + { + case 0xE0 ... 0xEF: // video + case 0xC0 ... 0xDF: // audio + pts = (int64_t) (p[ 9] & 0x0E) << 29 ; + pts |= (int64_t) p[ 10] << 22 ; + pts |= (int64_t) (p[ 11] & 0xFE) << 14 ; + pts |= (int64_t) p[ 12] << 7 ; + pts |= (int64_t) (p[ 13] & 0xFE) >> 1 ; + } + } + } + if(pts != -1) + { + cDevice *pd = cDevice::PrimaryDevice(); + if(pd) + { + stc = pd->GetSTC(); + if(stc != 0) + { + if(pts & (int64_t)1<<32) + { + stc |= (int64_t)1<<32; + } + int64_t timeDiff = (pts-stc); + if (pts 2000) + cCondWait::SleepMs(timeDiff - 2000); + } + } + } + } int w = PlayPes(p, pc, playMode != pmPlay); if (w > 0) { p += w;