From 752ee356fa599ba9ede80385ab08ac7c75b127eb Mon Sep 17 00:00:00 2001 From: Johns Date: Sun, 13 May 2012 18:33:24 +0200 Subject: [PATCH] Poll input buffers, if display buffers are full. --- softhddev.c | 31 +++++++++++++++++++++++++++++-- video.c | 10 +++++++--- video.h | 4 ++-- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/softhddev.c b/softhddev.c index b8752b4..d5426f9 100644 --- a/softhddev.c +++ b/softhddev.c @@ -397,7 +397,7 @@ static inline int FastAdtsCheck(const uint8_t * p) /// o B*1 MPEG Version: 0 for MPEG-4, 1 for MPEG-2 /// o C*2 layer: always 0 /// o .. -/// o F*4 sampling frequency index (15 is invalid) +/// o F*4 sampling frequency index (15 is invalid) /// o .. /// o M*13 frame length /// @@ -655,6 +655,12 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size, //pesdx->State = PES_MPEG_DECODE; break; } + if (AudioCodecID != CODEC_ID_NONE) { + // shouldn't happen after we have a vaild codec + // detected + Debug(4, "pesdemux: skip @%d %02x\n", pesdx->Skip, + q[0]); + } // try next byte ++pesdx->Skip; ++q; @@ -1093,6 +1099,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id) // 4 bytes 0xFFExxxxx Mpeg audio // 3 bytes 0x56Exxx AAC LATM audio // 5 bytes 0x0B77xxxxxx AC3 audio + // 7/9 bytes 0xFFFxxxxxxxxxxx ADTS audio // PCM audio can't be found r = 0; codec_id = CODEC_ID_NONE; // keep compiler happy @@ -1427,6 +1434,26 @@ void FixPacketForFFMpeg(VideoDecoder * MyVideoDecoder, AVPacket * avpkt) CodecVideoDecode(MyVideoDecoder, tmp); } +/** +** Poll PES packet ringbuffer. +** +** Called if video frame buffers are full. +*/ +int VideoPollInput(void) +{ + if (VideoClearBuffers) { + atomic_set(&VideoPacketsFilled, 0); + VideoPacketRead = VideoPacketWrite; + if (MyVideoDecoder) { + CodecVideoFlushBuffers(MyVideoDecoder); + VideoResetStart(MyHwDecoder); + } + VideoClearBuffers = 0; + return 1; + } + return 0; +} + /** ** Decode from PES packet ringbuffer. ** @@ -1434,7 +1461,7 @@ void FixPacketForFFMpeg(VideoDecoder * MyVideoDecoder, AVPacket * avpkt) ** @retval 1 stream paused ** @retval -1 empty stream */ -int VideoDecode(void) +int VideoDecodeInput(void) { int filled; AVPacket *avpkt; diff --git a/video.c b/video.c index f7666c7..8be3aa8 100644 --- a/video.c +++ b/video.c @@ -4677,8 +4677,10 @@ static void VaapiDisplayHandlerThread(void) // FIXME: hot polling pthread_mutex_lock(&VideoLockMutex); // fetch+decode or reopen - err = VideoDecode(); + err = VideoDecodeInput(); pthread_mutex_unlock(&VideoLockMutex); + } else { + err = VideoPollInput(); } if (err) { // FIXME: sleep on wakeup @@ -8085,8 +8087,10 @@ static void VdpauDisplayHandlerThread(void) // FIXME: hot polling pthread_mutex_lock(&VideoLockMutex); // fetch+decode or reopen - err = VideoDecode(); + err = VideoDecodeInput(); pthread_mutex_unlock(&VideoLockMutex); + } else { + err = VideoPollInput(); } if (err) { // FIXME: sleep on wakeup @@ -10296,7 +10300,7 @@ void FeedKeyPress( __attribute__ ((unused)) { } -int VideoDecode(void) +int VideoDecodeInput(void) { return -1; } diff --git a/video.h b/video.h index 1793e29..f027c9f 100644 --- a/video.h +++ b/video.h @@ -177,8 +177,8 @@ extern void VideoOsdExit(void); ///< Cleanup osd. extern void VideoInit(const char *); ///< Setup video module. extern void VideoExit(void); ///< Cleanup and exit video module. -extern void VideoFlushInput(void); ///< Flush video input buffers. -extern int VideoDecode(void); ///< Decode video input buffers. +extern int VideoPollInput(void); ///< Poll video input buffers. +extern int VideoDecodeInput(void); ///< Decode video input buffers. extern int VideoGetBuffers(void); ///< Get number of input buffers. /// @}