diff --git a/libmpeg2/decode.c b/libmpeg2/decode.c index 37f7328456..e6ef6b77ba 100644 --- a/libmpeg2/decode.c +++ b/libmpeg2/decode.c @@ -52,7 +52,7 @@ mpeg2_config_t config; //static uint8_t chunk_buffer[224 * 1024 + 4]; //static uint32_t shift = 0; -static int drop_flag = 0; +//static int drop_flag = 0; static int drop_frame = 0; #ifdef MPEG12_POSTPROC @@ -151,7 +151,7 @@ static void copy_slice (vo_frame_t * frame, uint8_t ** src){ static int in_slice_flag=0; -static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer) +static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer, int framedrop) { int is_frame_done = 0; @@ -163,6 +163,7 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer) // if(picture->picture_structure != FRAME_PICTURE) printf("Field! %d \n",picture->second_field); + if(!framedrop) if (((picture->picture_structure == FRAME_PICTURE) || (picture->second_field)) ) { @@ -208,7 +209,8 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer) //exit (1); } - drop_frame = drop_flag && (picture->picture_coding_type == B_TYPE); + drop_frame = framedrop && (picture->picture_coding_type == B_TYPE); + drop_frame |= framedrop>=2; // hard drop //decode_reorder_frames (); break; @@ -259,7 +261,7 @@ static int parse_chunk (vo_functions_t * output, int code, uint8_t * buffer) #endif picture->current_frame->copy=copy_slice; #endif - + if(framedrop) picture->current_frame->copy=NULL; picture->current_frame->vo=output; picture->slice=0; @@ -285,7 +287,7 @@ static void mpeg2_sighandler(int sig){ longjmp(mpeg2_jmp_buf,1); } -int mpeg2_decode_data (vo_functions_t *output, uint8_t *current, uint8_t *end) +int mpeg2_decode_data (vo_functions_t *output, uint8_t *current, uint8_t *end,int framedrop) { //static uint8_t code = 0xff; //static uint8_t chunk_buffer[65536]; @@ -323,7 +325,7 @@ while(currentcodec->driver){ } t-=GetTimer(); - mpeg2_decode_data(video_out, videobuffer, videobuffer+videobuf_len); + mpeg2_decode_data(video_out, videobuffer, videobuffer+videobuf_len,drop_frame); t+=GetTimer(); video_time_usage+=t*0.000001; newfps=frameratecode2framerate[picture->frame_rate_code]*0.0001f;