From aac2acec23ebb178cfd6ef09fdde7106002d3bc4 Mon Sep 17 00:00:00 2001 From: Mark Calderbank Date: Wed, 3 May 2006 21:38:03 +0000 Subject: [PATCH] Remove endian dependency in demuxer --- demuxer.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/demuxer.cc b/demuxer.cc index b529e41..a829986 100644 --- a/demuxer.cc +++ b/demuxer.cc @@ -19,6 +19,7 @@ */ #include "demuxer.h" +#include const int Demuxer::FrameRates[9] = { 0, 23, 24, 25, 29, 30, 50, 59, 60 }; @@ -559,14 +560,18 @@ void Demuxer::parse_video_details(UCHAR* buf, int len) int Demuxer::findVideoPTS(UCHAR* buf, int len, ULLONG* dest) { - UINT LoPattern = 0x100 | FRAMETYPE_VID0, - HiPattern = 0x100 | FRAMETYPE_VIDMAX; - while (len >= 14) { UINT pattern = *(UINT*)buf; buf++; len--; - if (pattern < LoPattern || pattern > HiPattern) continue; +#if __BYTE_ORDER == __BIG_ENDIAN + if (pattern < (0x100 | FRAMETYPE_VID0) || + pattern > (0x100 | FRAMETYPE_VIDMAX)) continue; +#else + if ((pattern & 0xFFFFFF) != 0x010000 || + pattern < ((UINT)FRAMETYPE_VID0 << 24) || + pattern > ((UINT)FRAMETYPE_VIDMAX << 24)) continue; +#endif if ((buf[5] & 0xC0) != 0x80) continue; UINT framelength = ((UINT)buf[3] << 8) | buf[4]; -- 2.39.5