# HG changeset patch # User reimar # Date 1254411629 0 # Node ID 8c0b5c6d0f17c9feb6ecd1b77fb03ac50c0f6adc # Parent 13dd683f3ff20623ba0ce9d20a833eb7236dbd63 put_bits can only reliably write up to 31 bit bits, above it relies on undefined shift behaviour. Document this, fix the assert and add a put_bits32 to handle writing 32 bits and use that where necessary. diff -r 13dd683f3ff2 -r 8c0b5c6d0f17 mpegenc.c --- a/mpegenc.c Thu Oct 01 10:24:02 2009 +0000 +++ b/mpegenc.c Thu Oct 01 15:40:29 2009 +0000 @@ -89,7 +89,7 @@ init_put_bits(&pb, buf, 128); - put_bits(&pb, 32, PACK_START_CODE); + put_bits32(&pb, PACK_START_CODE); if (s->is_mpeg2) { put_bits(&pb, 2, 0x1); } else { @@ -125,7 +125,7 @@ init_put_bits(&pb, buf, 128); - put_bits(&pb, 32, SYSTEM_HEADER_START_CODE); + put_bits32(&pb, SYSTEM_HEADER_START_CODE); put_bits(&pb, 16, 0); put_bits(&pb, 1, 1);