diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-09-26 01:18:19 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-09-26 01:18:19 +0000 |
commit | 105564c9ce5bea7587776e8cf39b2a3681b6d573 (patch) | |
tree | 7e0ea0f478d4022b3304441a68d800709f666ebe /src/libmpeg2 | |
parent | f1f49a64af45856152c4ee9697f45d907647b406 (diff) | |
download | xine-lib-105564c9ce5bea7587776e8cf39b2a3681b6d573.tar.gz xine-lib-105564c9ce5bea7587776e8cf39b2a3681b6d573.tar.bz2 |
libmpeg2 cleanups, more tweaks for still image display, implemented BUF_CONTROL_SPU_CHANNEL, trying to wipe out last windows style variable names (bFrameBad for example)
CVS patchset: 697
CVS date: 2001/09/26 01:18:19
Diffstat (limited to 'src/libmpeg2')
-rw-r--r-- | src/libmpeg2/decode.c | 127 | ||||
-rw-r--r-- | src/libmpeg2/header.c | 5 | ||||
-rw-r--r-- | src/libmpeg2/slice.c | 48 |
3 files changed, 71 insertions, 109 deletions
diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c index 48f5bf42c..96e7a86e2 100644 --- a/src/libmpeg2/decode.c +++ b/src/libmpeg2/decode.c @@ -76,17 +76,19 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code, picture_t * picture; int is_frame_done; - /* printf ("libmpeg2: parse_chunk 0x%02x\n", code); */ + /* + printf ("libmpeg2: parse_chunk 0x%02x\n", code); + */ /* wait for sequence_header_code */ if (mpeg2dec->is_sequence_needed) { if (code != 0xb3) { - /* printf ("libmpeg2: waiting for sequence header\n"); */ + /* printf ("libmpeg2: waiting for sequence header\n"); */ mpeg2dec->pts = 0; return 0; } } else if (mpeg2dec->is_frame_needed && (code != 0x00)) { - /* printf ("libmpeg2: waiting for frame start\n"); */ + /* printf ("libmpeg2: waiting for frame start\n"); */ mpeg2dec->pts = 0; return 0; } @@ -102,14 +104,14 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code, if ( picture->current_frame && ((picture->picture_structure == FRAME_PICTURE) || (picture->second_field)) ) { - picture->current_frame->bFrameBad |= mpeg2dec->drop_frame; + picture->current_frame->bad_frame |= mpeg2dec->drop_frame; -#if 0 -fprintf (stderr, "type %s: %s\n", - picture->picture_coding_type == I_TYPE ? "I" : - picture->picture_coding_type == P_TYPE ? "P" : "B", - picture->current_frame->bFrameBad ? "BAD" : "good"); -#endif +#if 0 + printf ("type %s: %s\n", + picture->picture_coding_type == I_TYPE ? "I" : + picture->picture_coding_type == P_TYPE ? "P" : "B", + picture->current_frame->bad_frame ? "BAD" : "good"); +#endif if (picture->picture_coding_type == B_TYPE) { if (picture->mpeg1) picture->current_frame->PTS = 0; @@ -117,7 +119,7 @@ fprintf (stderr, "type %s: %s\n", picture->current_frame->free (picture->current_frame); picture->current_frame = NULL; picture->throwaway_frame = NULL; - } else { + } else if (picture->forward_reference_frame) { mpeg2dec->frames_to_drop = picture->forward_reference_frame->draw (picture->forward_reference_frame); } @@ -148,8 +150,8 @@ fprintf (stderr, "type %s: %s\n", if (mpeg2dec->frames_to_drop>1) { mpeg2dec->drop_frame = 1; - } else if (picture->forward_reference_frame->bFrameBad - || picture->backward_reference_frame->bFrameBad) { + } else if (!picture->forward_reference_frame || picture->forward_reference_frame->bad_frame + || !picture->backward_reference_frame || picture->backward_reference_frame->bad_frame) { mpeg2dec->drop_frame = 1; } break; @@ -158,16 +160,17 @@ fprintf (stderr, "type %s: %s\n", if (mpeg2dec->frames_to_drop>2) { mpeg2dec->drop_frame = 1; - } else if (picture->backward_reference_frame->bFrameBad) { + } else if (!picture->backward_reference_frame || picture->backward_reference_frame->bad_frame) { mpeg2dec->drop_frame = 1; } break; case I_TYPE: - + /* if (mpeg2dec->frames_to_drop>4) { mpeg2dec->drop_frame = 1; } + */ break; } } @@ -176,7 +179,7 @@ fprintf (stderr, "type %s: %s\n", case 0xb3: /* sequence_header_code */ if (header_process_sequence_header (picture, buffer)) { - fprintf (stderr, "bad sequence header\n"); + printf ("libmpeg2: bad sequence header\n"); /* exit (1); */ } else if (mpeg2dec->is_sequence_needed || (picture->frame_width != picture->coded_picture_width) @@ -185,7 +188,6 @@ fprintf (stderr, "type %s: %s\n", printf ("mpeg2dec: frame size has changed to from %d x %d to %d x %d\n", picture->frame_width, picture->frame_height, picture->coded_picture_width, picture->coded_picture_height); - fflush(stdout); if (picture->forward_reference_frame) picture->forward_reference_frame->free (picture->forward_reference_frame); @@ -193,29 +195,11 @@ fprintf (stderr, "type %s: %s\n", if (picture->backward_reference_frame) picture->backward_reference_frame->free (picture->backward_reference_frame); - printf ("mpeg2dec: old frames freed.\n"); fflush (stdout); + printf ("mpeg2dec: old frames freed.\n"); mpeg2dec->is_sequence_needed = 0; - picture->forward_reference_frame = - mpeg2dec->output->get_frame (mpeg2dec->output, - picture->coded_picture_width, - picture->coded_picture_height, - picture->aspect_ratio_information, - IMGFMT_YV12, - picture->frame_duration, - VO_PREDICTION_FLAG | VO_BOTH_FIELDS); - picture->forward_reference_frame->PTS = 0; - picture->forward_reference_frame->bFrameBad = 1; - picture->backward_reference_frame = - mpeg2dec->output->get_frame (mpeg2dec->output, - picture->coded_picture_width, - picture->coded_picture_height, - picture->aspect_ratio_information, - IMGFMT_YV12, - picture->frame_duration, - VO_PREDICTION_FLAG | VO_BOTH_FIELDS); - picture->backward_reference_frame->PTS = 0; - picture->backward_reference_frame->bFrameBad = 1; + picture->forward_reference_frame = NULL; + picture->backward_reference_frame = NULL; picture->frame_width = picture->coded_picture_width; picture->frame_height = picture->coded_picture_height; @@ -264,13 +248,14 @@ fprintf (stderr, "type %s: %s\n", IMGFMT_YV12, picture->frame_duration, (VO_PREDICTION_FLAG | picture->picture_structure)); - picture->forward_reference_frame->free (picture->forward_reference_frame); + if (picture->forward_reference_frame) + picture->forward_reference_frame->free (picture->forward_reference_frame); picture->forward_reference_frame = picture->backward_reference_frame; picture->backward_reference_frame = picture->current_frame; } - picture->current_frame->bFrameBad = 0; + picture->current_frame->bad_frame = 0; picture->current_frame->PTS = mpeg2dec->pts; mpeg2dec->pts = 0; } @@ -377,37 +362,27 @@ void mpeg2_close (mpeg2dec_t * mpeg2dec) } */ - /* Ensure that the last decoded frame is drawn */ - if(!picture->current_frame) - return; - picture->current_frame->bFrameBad |= mpeg2dec->drop_frame; - - if (picture->picture_coding_type == B_TYPE) { - if (picture->mpeg1) - picture->current_frame->PTS = 0; - mpeg2dec->frames_to_drop = picture->current_frame->draw (picture->current_frame); - picture->current_frame->free (picture->current_frame); - picture->current_frame = NULL; - picture->throwaway_frame = NULL; - } else { - mpeg2dec->frames_to_drop = picture->current_frame->draw (picture->current_frame); + if (picture->forward_reference_frame) { + printf ("libmpeg2: blasting out forward reference frame on close\n"); + picture->forward_reference_frame->PTS = 0; + picture->forward_reference_frame->bad_frame = 0; + picture->forward_reference_frame->draw (picture->forward_reference_frame); + picture->forward_reference_frame->free (picture->forward_reference_frame); } - if (picture->throwaway_frame) - { - picture->throwaway_frame->displayed (picture->throwaway_frame); + if (picture->throwaway_frame) { + printf ("libmpeg2: blasting out throwaway frame on close\n"); + picture->throwaway_frame->PTS = 0; + picture->throwaway_frame->bad_frame = 0; + picture->throwaway_frame->draw (picture->throwaway_frame); picture->throwaway_frame->free (picture->throwaway_frame); } - if (picture->forward_reference_frame) - { - picture->forward_reference_frame->displayed (picture->forward_reference_frame); - picture->forward_reference_frame->free (picture->forward_reference_frame); - } - - if (picture->backward_reference_frame) - { - picture->backward_reference_frame->displayed (picture->backward_reference_frame); + if (picture->backward_reference_frame) { + printf ("libmpeg2: blasting out backward reference frame on close\n"); + picture->backward_reference_frame->PTS = 0; + picture->backward_reference_frame->bad_frame = 0; + picture->backward_reference_frame->draw (picture->backward_reference_frame); picture->backward_reference_frame->free (picture->backward_reference_frame); } @@ -445,26 +420,6 @@ void mpeg2_find_sequence_header (mpeg2dec_t * mpeg2dec, if (mpeg2dec->is_sequence_needed) { mpeg2dec->is_sequence_needed = 0; - picture->forward_reference_frame = - mpeg2dec->output->get_frame (mpeg2dec->output, - picture->coded_picture_width, - picture->coded_picture_height, - picture->aspect_ratio_information, - IMGFMT_YV12, - picture->frame_duration, - VO_PREDICTION_FLAG | VO_BOTH_FIELDS); - picture->forward_reference_frame->PTS = 0; - picture->forward_reference_frame->bFrameBad = 1; - picture->backward_reference_frame = - mpeg2dec->output->get_frame (mpeg2dec->output, - picture->coded_picture_width, - picture->coded_picture_height, - picture->aspect_ratio_information, - IMGFMT_YV12, - picture->frame_duration, - VO_PREDICTION_FLAG | VO_BOTH_FIELDS); - picture->backward_reference_frame->PTS = 0; - picture->backward_reference_frame->bFrameBad = 1; picture->frame_width = picture->coded_picture_width; picture->frame_height = picture->coded_picture_height; diff --git a/src/libmpeg2/header.c b/src/libmpeg2/header.c index cc2bf4022..9c4ac36f0 100644 --- a/src/libmpeg2/header.c +++ b/src/libmpeg2/header.c @@ -179,6 +179,11 @@ 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; diff --git a/src/libmpeg2/slice.c b/src/libmpeg2/slice.c index 0207425df..4abdf8a4a 100644 --- a/src/libmpeg2/slice.c +++ b/src/libmpeg2/slice.c @@ -1520,42 +1520,44 @@ void slice_process (picture_t * picture, uint8_t code, uint8_t * buffer) offset = (code - 1) * stride * 4; picture->v_offset = (code - 1) * 16; - forward_ref[0] = picture->forward_reference_frame->base; - if (picture->picture_structure != FRAME_PICTURE) { + if (picture->forward_reference_frame) { + forward_ref[0] = picture->forward_reference_frame->base; + if (picture->picture_structure != FRAME_PICTURE) { forward_ref[1] = picture->forward_reference_frame->base; offset <<= 1; picture->current_field = (picture->picture_structure == BOTTOM_FIELD); if ((picture->second_field) && (picture->picture_coding_type != B_TYPE)) - forward_ref[picture->picture_structure == TOP_FIELD] = - picture->current_frame->base; - + forward_ref[picture->picture_structure == TOP_FIELD] = + picture->current_frame->base; + picture->f_motion.ref[1][0] = forward_ref[1][0] + stride; picture->f_motion.ref[1][1] = forward_ref[1][1] + (stride >> 1); picture->f_motion.ref[1][2] = forward_ref[1][2] + (stride >> 1); - + picture->b_motion.ref[1][0] = - picture->backward_reference_frame->base[0] + stride; + picture->backward_reference_frame->base[0] + stride; picture->b_motion.ref[1][1] = - picture->backward_reference_frame->base[1] + (stride >> 1); + picture->backward_reference_frame->base[1] + (stride >> 1); picture->b_motion.ref[1][2] = - picture->backward_reference_frame->base[2] + (stride >> 1); + picture->backward_reference_frame->base[2] + (stride >> 1); + } + + picture->f_motion.ref[0][0] = forward_ref[0][0]; + picture->f_motion.ref[0][1] = forward_ref[0][1]; + picture->f_motion.ref[0][2] = forward_ref[0][2]; + + picture->f_motion.pmv[0][0] = picture->f_motion.pmv[0][1] = 0; + picture->f_motion.pmv[1][0] = picture->f_motion.pmv[1][1] = 0; + + picture->b_motion.ref[0][0] = picture->backward_reference_frame->base[0]; + picture->b_motion.ref[0][1] = picture->backward_reference_frame->base[1]; + picture->b_motion.ref[0][2] = picture->backward_reference_frame->base[2]; + + picture->b_motion.pmv[0][0] = picture->b_motion.pmv[0][1] = 0; + picture->b_motion.pmv[1][0] = picture->b_motion.pmv[1][1] = 0; } - picture->f_motion.ref[0][0] = forward_ref[0][0]; - picture->f_motion.ref[0][1] = forward_ref[0][1]; - picture->f_motion.ref[0][2] = forward_ref[0][2]; - - picture->f_motion.pmv[0][0] = picture->f_motion.pmv[0][1] = 0; - picture->f_motion.pmv[1][0] = picture->f_motion.pmv[1][1] = 0; - - picture->b_motion.ref[0][0] = picture->backward_reference_frame->base[0]; - picture->b_motion.ref[0][1] = picture->backward_reference_frame->base[1]; - picture->b_motion.ref[0][2] = picture->backward_reference_frame->base[2]; - - picture->b_motion.pmv[0][0] = picture->b_motion.pmv[0][1] = 0; - picture->b_motion.pmv[1][0] = picture->b_motion.pmv[1][1] = 0; - if ((picture->current_frame->copy) && (picture->picture_coding_type == B_TYPE)) offset = 0; |