From fcf87ef2bf1967512e9e44f46f6a20eb542b6cc4 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 28 Feb 2017 09:26:25 +0100 Subject: [PATCH] mpegtsdemux: Fix wrong usage of '<<' operator Detected by GCC 7. Add comments for clarity https://bugzilla.gnome.org/show_bug.cgi?id=779333 --- gst/mpegtsdemux/pesparse.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gst/mpegtsdemux/pesparse.c b/gst/mpegtsdemux/pesparse.c index 1d7a3b607d..e0f11f2a08 100644 --- a/gst/mpegtsdemux/pesparse.c +++ b/gst/mpegtsdemux/pesparse.c @@ -314,14 +314,23 @@ mpegts_parse_pes_header (const guint8 * data, gsize length, PESHeader * res) } if (flags & 0x10) { - /* P-STD */ + /* P-STD + * '01' : 2 bits + * P-STD_buffer_scale : 1 bit + * P-STD_buffer_size : 13 bits + * */ if (G_UNLIKELY (length < 2)) goto need_more_data; val8 = *data; if (G_UNLIKELY ((val8 & 0xc0) != 0x40)) goto bad_P_STD_marker; + /* If P-STD_buffer_scale is 0 + * multiply by 128 (i.e. << 7), + * else + * multiply by 1024 (i.e. << 10) + */ res->P_STD_buffer_size = - (GST_READ_UINT16_BE (data) & 0x1fff) << (val8 & 0x20) ? 10 : 7; + (GST_READ_UINT16_BE (data) & 0x1fff) << ((val8 & 0x20) ? 10 : 7); GST_LOG ("P_STD_buffer_size : %d", res->P_STD_buffer_size); data += 2; length -= 2;