From 037f582badb9c1b9defc83a737bd1e5ed458473c Mon Sep 17 00:00:00 2001 From: Johns Date: Tue, 24 Jan 2012 16:37:11 +0100 Subject: [PATCH] Fix still picture handling. --- ChangeLog | 1 + softhddev.c | 34 ++++++++++++++++++++++++++++++---- softhddevice.cpp | 4 ++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a171ec..3b2bf1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ User johns Date: + Fix still picture handling. Fix for dead-lock in VdpauExit. Workaround for dead-lock in VdpauExit. VDPAU: Add very primitive software scaler for grab image. diff --git a/softhddev.c b/softhddev.c index 758ef0d..b998b7d 100644 --- a/softhddev.c +++ b/softhddev.c @@ -902,10 +902,12 @@ void Freeze(void) void StillPicture(const uint8_t * data, int size) { int i; + static uint8_t seq_end_mpeg[] = { 0x00, 0x00, 0x01, 0xB7 }; + static uint8_t seq_end_h264[] = { 0x00, 0x00, 0x00, 0x01, 0x10 }; // must be a PES start code if (size < 9 || !data || data[0] || data[1] || data[2] != 0x01) { - Error(_("[softhddev] invalid PES video packet\n")); + Error(_("[softhddev] invalid still video packet\n")); return; } if (VideoCodecID == CODEC_ID_NONE) { @@ -913,13 +915,37 @@ void StillPicture(const uint8_t * data, int size) Error(_("[softhddev] no codec known for still picture\n")); return; } + //Clear(); // flush video buffers - Clear(); // flush video buffers // +1 future for deinterlace for (i = -1; i < (VideoCodecID == CODEC_ID_MPEG2VIDEO ? 3 : 17); ++i) { - PlayVideo(data, size); // reference frames + //if ( 1 ) { + const uint8_t *split; + int n; + + // split the I-frame into single pes packets + split = data; + n = size; + do { + int len; + + len = (split[4] << 8) + split[5]; + if (len > n) { + break; + } + PlayVideo(split, len + 6); // feed it + split += 6 + len; + n -= 6 + len; + } while (n > 6); + VideoNextPacket(VideoCodecID); // terminate last packet + + if (VideoCodecID == CODEC_ID_H264) { + VideoEnqueue(AV_NOPTS_VALUE, seq_end_h264, sizeof(seq_end_h264)); + } else { + VideoEnqueue(AV_NOPTS_VALUE, seq_end_mpeg, sizeof(seq_end_mpeg)); + } + VideoNextPacket(VideoCodecID); // terminate last packet } - VideoNextPacket(VideoCodecID); // terminate last packet } /** diff --git a/softhddevice.cpp b/softhddevice.cpp index 4bdb6a3..a841316 100644 --- a/softhddevice.cpp +++ b/softhddevice.cpp @@ -795,8 +795,8 @@ void cSoftHdDevice::SetVolumeDevice(int volume) */ void cSoftHdDevice::StillPicture(const uchar * data, int length) { - dsyslog("[softhddev]%s: %s\n", __FUNCTION__, - data[0] == 0x47 ? "ts" : "pes"); + dsyslog("[softhddev]%s: %s %p %d\n", __FUNCTION__, + data[0] == 0x47 ? "ts" : "pes", data, length); if (data[0] == 0x47) { // ts sync cDevice::StillPicture(data, length);