diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-01-05 00:44:49 +0100 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-01-05 00:44:49 +0100 |
commit | c81c9deccc79646bd7ac3f1759a4a3e4fb8a88af (patch) | |
tree | b39027bf19757a904f9d306085d8744046f24a1f /src/video_dec/libmpeg2/header.c | |
parent | 119076c9300e2e2a816dc1a6ca32ba77f338b20c (diff) | |
parent | a2a95425350da93551388acdca8a00818a34c317 (diff) | |
download | xine-lib-c81c9deccc79646bd7ac3f1759a4a3e4fb8a88af.tar.gz xine-lib-c81c9deccc79646bd7ac3f1759a4a3e4fb8a88af.tar.bz2 |
Merge from 1.2.
Diffstat (limited to 'src/video_dec/libmpeg2/header.c')
-rw-r--r-- | src/video_dec/libmpeg2/header.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/video_dec/libmpeg2/header.c b/src/video_dec/libmpeg2/header.c index 12ba0ff8a..0c2b76891 100644 --- a/src/video_dec/libmpeg2/header.c +++ b/src/video_dec/libmpeg2/header.c @@ -101,6 +101,14 @@ static uint32_t get_bits(uint8_t *buffer, uint32_t count, uint32_t *bit_position return result; } +static int32_t get_bits_signed(uint8_t *buffer, uint32_t count, uint32_t *bit_position) { + uint32_t value = get_bits(buffer, count, bit_position); + uint32_t sign_mask = (uint32_t)(-1 << (count - 1)); + if (value & sign_mask) + value |= sign_mask; /* sign-extend value */ + return (int32_t)value; +} + void mpeg2_header_state_init (picture_t * picture) { picture->scan = mpeg2_scan_norm; @@ -291,13 +299,13 @@ static int picture_display_extension (picture_t * picture, uint8_t * buffer) { bit_position = 0; padding = get_bits(buffer, 4, &bit_position); - picture->frame_centre_horizontal_offset = get_bits(buffer, 16, &bit_position); + picture->frame_centre_horizontal_offset = get_bits_signed(buffer, 16, &bit_position); padding = get_bits(buffer, 1, &bit_position); - picture->frame_centre_vertical_offset = get_bits(buffer, 16, &bit_position); + picture->frame_centre_vertical_offset = get_bits_signed(buffer, 16, &bit_position); padding = get_bits(buffer, 1, &bit_position); #ifdef LOG_PAN_SCAN - printf("Pan & Scan centre (x,y) = (%u, %u)\n", + printf("Pan & Scan centre (x,y) = (%d, %d)\n", picture->frame_centre_horizontal_offset, picture->frame_centre_vertical_offset); #endif |