From 4db8f76d2c9b6356fbd60e2e23dab6602920f1c9 Mon Sep 17 00:00:00 2001 From: Mark Calderbank Date: Sat, 25 Nov 2006 01:43:39 +0000 Subject: [PATCH] Demuxer::scanForVideo() --- demuxer.cc | 15 +++++++++++++++ demuxer.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/demuxer.cc b/demuxer.cc index 293536f..dbdf009 100644 --- a/demuxer.cc +++ b/demuxer.cc @@ -353,6 +353,21 @@ UINT Demuxer::stripAudio(UCHAR* buf, UINT len) return write_pos; } +bool Demuxer::scanForVideo(UCHAR* buf, UINT len) +{ + UINT pos = 3; + UINT pattern; + if (len < 4) return false; + pattern = (buf[0] << 16) | (buf[1] << 8) | (buf[2]); + while (pos < len) + { + pattern = ((pattern & 0xFFFFFF) << 8) | buf[pos++]; + if (pattern >= (0x100|PESTYPE_VID0) && pattern <= (0x100|PESTYPE_VIDMAX)) + return true; + } + return false; +} + bool* Demuxer::getmpAudioChannels() { return avail_mpaudchan; diff --git a/demuxer.h b/demuxer.h index 7471624..5cd0819 100644 --- a/demuxer.h +++ b/demuxer.h @@ -110,6 +110,11 @@ protected: // *static function* static UINT stripAudio(UCHAR* buf, UINT len); + // Scan a buffer to see if video packets are present. + // Returns true if video exists; false if not. + // *static function* + static bool scanForVideo(UCHAR* buf, UINT len); + protected: // General demuxer objects and status indicators static Demuxer* instance; -- 2.39.5