--- mplayer.c Fri Oct 17 00:06:18 2003 +++ mplayer_kkar.c Mon Oct 20 15:23:56 2003 @@ -225,6 +225,16 @@ static int loop_times=-1; static int loop_seek=0; +// --> endpos: (by kkar) + +// (from mencoder) +enum end_at_type_t {END_AT_NONE, END_AT_TIME, END_AT_SIZE}; +static enum end_at_type_t end_at_type = END_AT_NONE; +static double end_at; +static int parse_end_at(m_option_t *conf, const char* param); + +// <-- endpos: (by kkar) + // A/V sync: int autosync=0; // 30 might be a good default value. @@ -709,6 +719,60 @@ #endif + +// --> kkar added this function from mencoder! +static int parse_end_at(m_option_t *conf, const char* param) +{ + + end_at_type = END_AT_NONE; + + /* End at size parsing */ + /*{ + char unit[4]; + + end_at_type = END_AT_SIZE; + + if(sscanf(param, "%lf%3s", &end_at, unit) == 2) { + if(!strcasecmp(unit, "b")) + ; + else if(!strcasecmp(unit, "kb")) + end_at *= 1024; + else if(!strcasecmp(unit, "mb")) + end_at *= 1024*1024; + else + end_at_type = END_AT_NONE; + } + else + end_at_type = END_AT_NONE; + } */ + + /* End at time parsing. This has to be last because of + * sscanf("%f", ...) below */ + if(end_at_type == END_AT_NONE) + { + int a,b; float d; + + end_at_type = END_AT_TIME; + + if (sscanf(param, "%d:%d:%f", &a, &b, &d) == 3) + end_at = 3600*a + 60*b + d; + else if (sscanf(param, "%d:%f", &a, &d) == 2) + end_at = 60*a + d; + else if (sscanf(param, "%f", &d) == 1) + end_at = d; + else + end_at_type = END_AT_NONE; + } + + if(end_at_type == END_AT_NONE) + return ERR_FUNC_ERR; + + return 1; +} +// <-- kkar added this function from mencoder! + + + int main(int argc,char* argv[]){ @@ -1959,9 +2023,16 @@ eof=PT_NEXT_ENTRY; goto goto_next_file; } + while(!eof){ float aq_sleep_time=0; +// --> kkar part added from mencoder + //if((end_at_type == END_AT_SIZE && end_at <= ftello(muxer_f)) || + if(end_at_type == END_AT_TIME && end_at < sh_video->timer) + eof = PT_NEXT_ENTRY; +// <-- kkar part added from mencoder + if(play_n_frames>=0){ --play_n_frames; if(play_n_frames<0) eof = PT_NEXT_ENTRY; @@ -2479,6 +2550,7 @@ osd_function = OSD_FFW; abs_seek_pos = 0; rel_seek_secs = next_edl_record->length_sec; + #ifdef DEBUG_EDL printf( "\nEDL_SKIP: start [%f], stop [%f], length [%f]\n", next_edl_record->start_sec, next_edl_record->stop_sec, next_edl_record->length_sec ); #endif @@ -3353,6 +3425,20 @@ seek_to_sec = NULL; } + + /*if (stop_to_sec) { + int a,b; float d; + + if (sscanf(stop_to_sec, "%d:%d:%f", &a,&b,&d)==3) + rel_stop_secs += 3600*a +60*b +d ; + else if (sscanf(stop_to_sec, "%d:%f", &a, &d)==2) + rel_stop_secs += 60*a +d; + else if (sscanf(stop_to_sec, "%f", &d)==1) + rel_stop_secs += d; + + stop_to_sec = NULL; + } */ + /* Looping. */ if(eof==1 && loop_times>=0) {