diff options
author | James Courtier-Dutton <jcdutton@users.sourceforge.net> | 2002-01-10 23:28:58 +0000 |
---|---|---|
committer | James Courtier-Dutton <jcdutton@users.sourceforge.net> | 2002-01-10 23:28:58 +0000 |
commit | dca29e272c725922b3b14f067887d30e9a1ddef4 (patch) | |
tree | 80740087e05d896957672d0c624a67f39344068c | |
parent | 8ad96f32c2c1602b1f9799025ce811fddb0067d1 (diff) | |
download | xine-lib-dca29e272c725922b3b14f067887d30e9a1ddef4.tar.gz xine-lib-dca29e272c725922b3b14f067887d30e9a1ddef4.tar.bz2 |
Decode group_of_pictures chunks.
This gives us time codes from the stream.
Not yet passed on to vo_frame.
CVS patchset: 1389
CVS date: 2002/01/10 23:28:58
-rw-r--r-- | src/libmpeg2/decode.c | 18 | ||||
-rw-r--r-- | src/libmpeg2/header.c | 50 | ||||
-rw-r--r-- | src/libmpeg2/mpeg2_internal.h | 8 |
3 files changed, 61 insertions, 15 deletions
diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c index 462bea407..c74bc7339 100644 --- a/src/libmpeg2/decode.c +++ b/src/libmpeg2/decode.c @@ -128,12 +128,11 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code, { picture_t * picture; int is_frame_done; -// printf("libmpeg2:code=0x%02x\n",code); - - /* - printf ("libmpeg2: parse_chunk 0x%02x\n", code); - */ - +/* + if (code >= 0xb0) { + printf ("libmpeg2: parse_chunk 0x%02x\n", code); + } +*/ /* wait for sequence_header_code */ if (mpeg2dec->is_sequence_needed) { if (code != 0xb3) { @@ -286,9 +285,10 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code, printf ("libmpeg2:SEQUENCE END CODE NOT HANDLED!\n"); #endif case 0xb8: /* group of pictures start code */ -#ifdef LOG_PAN_SCAN - printf ("libmpeg2:GROUP of PICTURES NOT HANDLED!\n"); -#endif + if (header_process_group_of_pictures (picture, buffer)) { + fprintf (stderr, "bad group of pictures\n"); + exit (1); + } default: if (code >= 0xb9) fprintf (stderr, "stream not demultiplexed ?\n"); diff --git a/src/libmpeg2/header.c b/src/libmpeg2/header.c index 2e7b634d5..e075f51e1 100644 --- a/src/libmpeg2/header.c +++ b/src/libmpeg2/header.c @@ -89,9 +89,9 @@ static uint32_t get_bits(uint8_t *buffer, uint32_t count, uint32_t *bit_position bit_mask ^= ((1 << (bit_offset-count)) - 1); bit_bite = count; } -#ifdef LOG_PAN_SCAN + /* printf("Byte=0x%02x Bitmask=0x%04x byte_offset=%u bit_offset=%u bit_byte=%u count=%u\n",buffer[byte_offset], bit_mask, byte_offset, bit_offset, bit_bite,count); -#endif + */ result = (result << bit_bite) | ((buffer[byte_offset] & bit_mask) >> (bit_offset-bit_bite)); *bit_position+=bit_bite; count-=bit_bite; @@ -213,10 +213,10 @@ static int header_process_sequence_extension (picture_t * picture, picture->coded_picture_height = (picture->coded_picture_height + 31) & ~31; - /* +/* printf ("libmpeg2: sequence extension+5 : %08x (%d)\n", buffer[5], buffer[5] % 0x80); - */ + */ /* MPEG1 - for testing only */ picture->mpeg1 = 0; @@ -228,6 +228,9 @@ static int header_process_quant_matrix_extension (picture_t * picture, uint8_t * buffer) { int i; +#ifdef LOG_PAN_SCAN + printf ("libmpeg2: quant_matrix extension\n"); +#endif if (buffer[0] & 8) { for (i = 0; i < 64; i++) @@ -247,6 +250,9 @@ static int header_process_quant_matrix_extension (picture_t * picture, static int header_process_picture_coding_extension (picture_t * picture, uint8_t * buffer) { +/* + printf ("libmpeg2: picture_coding_extension\n"); + */ /* pre subtract 1 for use later in compute_motion_vector */ picture->f_motion.f_code[0] = (buffer[0] & 15) - 1; picture->f_motion.f_code[1] = (buffer[1] >> 4) - 1; @@ -302,14 +308,15 @@ static int header_process_sequence_display_extension (picture_t * picture, uint8 printf(" display_vertical_size %u\n", picture->display_vertical_size); #endif - return 0; } static int header_process_picture_display_extension (picture_t * picture, uint8_t * buffer) { - /* FIXME: implement. */ uint32_t bit_position; uint32_t padding; +#ifdef LOG_PAN_SCAN + printf ("libmpeg2: picture_display_extension\n"); +#endif bit_position = 0; padding = get_bits(buffer, 4, &bit_position); picture->frame_centre_horizontal_offset = get_bits(buffer, 16, &bit_position); @@ -322,6 +329,9 @@ static int header_process_picture_display_extension (picture_t * picture, uint8_ picture->frame_centre_horizontal_offset, picture->frame_centre_vertical_offset); #endif +// printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); +// close(stdout); +// _exit(0); return 0; } @@ -381,6 +391,34 @@ int header_process_extension (picture_t * picture, uint8_t * buffer) return 0; } +int header_process_group_of_pictures (picture_t * picture, uint8_t * buffer) { + uint32_t bit_position; + uint32_t padding; + bit_position = 0; + picture->drop_frame_flag = get_bits(buffer, 1, &bit_position); + picture->time_code_hours = get_bits(buffer, 5, &bit_position); + picture->time_code_minutes = get_bits(buffer, 6, &bit_position); + padding = get_bits(buffer, 1, &bit_position); + picture->time_code_seconds = get_bits(buffer, 6, &bit_position); + picture->time_code_pictures = get_bits(buffer, 6, &bit_position); + picture->closed_gop = get_bits(buffer, 1, &bit_position); + picture->broken_link = get_bits(buffer, 1, &bit_position); + +#ifdef LOG_PAN_SCAN + printf("Group of pictures\n"); + printf(" drop_frame_flag: %u\n", picture->drop_frame_flag); + printf(" time_code: HH:MM:SS:Pictures %02u:%02u:%02u:%02u\n", + picture->time_code_hours, + picture->time_code_minutes, + picture->time_code_seconds, + picture->time_code_pictures); + printf(" closed_gop: %u\n", picture->closed_gop); + printf(" bloken_link: %u\n", picture->broken_link); +#endif + + return 0; +} + int header_process_picture_header (picture_t *picture, uint8_t * buffer) { picture->picture_coding_type = (buffer [1] >> 3) & 7; diff --git a/src/libmpeg2/mpeg2_internal.h b/src/libmpeg2/mpeg2_internal.h index 262eaf5dc..fcb70368b 100644 --- a/src/libmpeg2/mpeg2_internal.h +++ b/src/libmpeg2/mpeg2_internal.h @@ -146,6 +146,13 @@ typedef struct picture_s { uint32_t matrix_coefficients; uint32_t display_horizontal_size; uint32_t display_vertical_size; + uint32_t drop_frame_flag; + uint32_t time_code_hours; + uint32_t time_code_minutes; + uint32_t time_code_seconds; + uint32_t time_code_pictures; + uint32_t closed_gop; + uint32_t broken_link; } picture_t; @@ -165,6 +172,7 @@ void header_state_init (picture_t * picture); int header_process_picture_header (picture_t * picture, uint8_t * buffer); int header_process_sequence_header (picture_t * picture, uint8_t * buffer); int header_process_extension (picture_t * picture, uint8_t * buffer); +int header_process_group_of_pictures (picture_t * picture, uint8_t * buffer); /* idct.c */ void idct_init (void); |