From 880ec0ab10d7d1da6434113a725f1bb925c87ecf Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Wed, 10 Sep 2003 00:01:59 +0000 Subject: Force the RHS to int64_t. My compiler seems to think that the RHS is a int32_t which then needs expanding to int64_t. The expansion takes the high bit of the int32_t, which is the sign bit, and sets all the higher bits to the same sign. This in effect turns the result into a negative number, when it should just be a large positive int64_t number. This fix should probably be duplicated in all other demuxers, but I don't have time for that. CVS patchset: 5350 CVS date: 2003/09/10 00:01:59 --- src/demuxers/demux_mpeg_pes.c | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index 944e5deec..f5df98f1d 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpeg_pes.c,v 1.8 2003/09/05 00:12:04 jcdutton Exp $ + * $Id: demux_mpeg_pes.c,v 1.9 2003/09/10 00:01:59 jcdutton Exp $ * * demultiplexer for mpeg 2 PES (Packetized Elementary Streams) * reads streams of variable blocksizes @@ -629,27 +629,27 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element this->dts = 0; if ((p[0] & 0xf0) == 0x20) { - this->pts = (p[ 0] & 0x0E) << 29 ; - this->pts |= p[ 1] << 22 ; - this->pts |= (p[ 2] & 0xFE) << 14 ; - this->pts |= p[ 3] << 7 ; - this->pts |= (p[ 4] & 0xFE) >> 1 ; + this->pts = (int64_t) (p[ 0] & 0x0E) << 29 ; + this->pts |= (int64_t) p[ 1] << 22 ; + this->pts |= (int64_t) (p[ 2] & 0xFE) << 14 ; + this->pts |= (int64_t) p[ 3] << 7 ; + this->pts |= (int64_t) (p[ 4] & 0xFE) >> 1 ; p += 5; header_len+= 5; this->packet_len -=5; return header_len; } else if ((p[0] & 0xf0) == 0x30) { - this->pts = (p[ 0] & 0x0E) << 29 ; - this->pts |= p[ 1] << 22 ; - this->pts |= (p[ 2] & 0xFE) << 14 ; - this->pts |= p[ 3] << 7 ; - this->pts |= (p[ 4] & 0xFE) >> 1 ; + this->pts = (int64_t) (p[ 0] & 0x0E) << 29 ; + this->pts |= (int64_t) p[ 1] << 22 ; + this->pts |= (int64_t) (p[ 2] & 0xFE) << 14 ; + this->pts |= (int64_t) p[ 3] << 7 ; + this->pts |= (int64_t) (p[ 4] & 0xFE) >> 1 ; - this->dts = (p[ 5] & 0x0E) << 29 ; - this->dts |= p[ 6] << 22 ; - this->dts |= (p[ 7] & 0xFE) << 14 ; - this->dts |= p[ 8] << 7 ; - this->dts |= (p[ 9] & 0xFE) >> 1 ; + this->dts = (int64_t) (p[ 5] & 0x0E) << 29 ; + this->dts |= (int64_t) p[ 6] << 22 ; + this->dts |= (int64_t) (p[ 7] & 0xFE) << 14 ; + this->dts |= (int64_t) p[ 8] << 7 ; + this->dts |= (int64_t) (p[ 9] & 0xFE) >> 1 ; p += 10; header_len += 10; @@ -690,11 +690,11 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element if (p[7] & 0x80) { /* pts avail */ - this->pts = (p[ 9] & 0x0E) << 29 ; - this->pts |= p[10] << 22 ; - this->pts |= (p[11] & 0xFE) << 14 ; - this->pts |= p[12] << 7 ; - this->pts |= (p[13] & 0xFE) >> 1 ; + this->pts = (int64_t) (p[ 9] & 0x0E) << 29 ; + this->pts |= (int64_t) p[10] << 22 ; + this->pts |= (int64_t) (p[11] & 0xFE) << 14 ; + this->pts |= (int64_t) p[12] << 7 ; + this->pts |= (int64_t) (p[13] & 0xFE) >> 1 ; #ifdef LOG printf ("demux_mpeg_pes: pts = %lld\n", this->pts); @@ -705,11 +705,11 @@ static int32_t parse_pes_for_pts(demux_mpeg_pes_t *this, uint8_t *p, buf_element if (p[7] & 0x40) { /* dts avail */ - this->dts = (p[14] & 0x0E) << 29 ; - this->dts |= p[15] << 22 ; - this->dts |= (p[16] & 0xFE) << 14 ; - this->dts |= p[17] << 7 ; - this->dts |= (p[18] & 0xFE) >> 1 ; + this->dts = (int64_t) (p[14] & 0x0E) << 29 ; + this->dts |= (int64_t) p[15] << 22 ; + this->dts |= (int64_t) (p[16] & 0xFE) << 14 ; + this->dts |= (int64_t) p[17] << 7 ; + this->dts |= (int64_t) (p[18] & 0xFE) >> 1 ; } else this->dts = 0; -- cgit v1.2.3