summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-08-01 18:18:52 +0000
committerjstebbins <[email protected]>2011-08-01 18:18:52 +0000
commitdad8255c86fd6f00a3ff7ce6416ccb10156d7356 (patch)
tree25e7f6f52fc7d39d2ae9a49ec32633c7fc13e91d
parent76d480815a9c6773e0fa5bcffaded04646279b8a (diff)
libhb: fix mis-detection of mov files as mpeg PS
Tightens the mpeg PS detection further to prevent mis-detection of mov files as mpeg PS. Hopefully doesn't cause faulures to detect real mpeg PS files. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4150 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/stream.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libhb/stream.c b/libhb/stream.c
index d4f810c99..905cdd951 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -408,7 +408,6 @@ static int hb_stream_check_for_ps(hb_stream_t *stream)
uint8_t buf[2048*4];
uint8_t sc_buf[4];
int pos = 0;
- int hits = 0;
fseek(stream->file_handle, 0, SEEK_SET);
@@ -427,16 +426,19 @@ static int hb_stream_check_for_ps(hb_stream_t *stream)
{
int pes_offset, prev, data_len;
uint8_t sid;
-
- if ( ++hits == 3 )
- return 1;
- pes_offset = 14 + (buf[13] & 0x7);
- sid = buf[pes_offset+3];
- data_len = (buf[pes_offset+4] << 8) + buf[pes_offset+5];
+ uint8_t *b = buf+offset;
+
+ // Skip the pack header
+ pes_offset = 14 + (b[13] & 0x7);
+ b += pes_offset;
+ // Get the next stream id
+ sid = b[3];
+ data_len = (b[4] << 8) + b[5];
if ( data_len && sid > 0xba && sid < 0xf9 )
{
prev = ftell( stream->file_handle );
- pos = pes_offset + 6 + data_len + prev;
+ pos = prev - ( sizeof(buf) - offset );
+ pos += pes_offset + 6 + data_len;
fseek( stream->file_handle, pos, SEEK_SET );
if ( fread(sc_buf, 1, 4, stream->file_handle) != 4 )
return 0;