Index: stream/stream_dvdnav.c =================================================================== --- stream/stream_dvdnav.c (revision 34396) +++ stream/stream_dvdnav.c (working copy) @@ -302,7 +302,7 @@ fail: mp_msg(MSGT_STREAM,MSGL_INFO,"dvdnav_stream, seeking to %"PRIu64" failed: %s\n", newpos, dvdnav_err_to_string(priv->dvdnav)); - return 1; + return 0; } static void stream_dvdnav_close(stream_t *s) { @@ -465,7 +465,8 @@ case STREAM_CTRL_SEEK_TO_TIME: { uint64_t tm = *(double *)arg * 90000; - if(dvdnav_time_search(priv->dvdnav, tm) == DVDNAV_STATUS_OK) + printf("\njumping to %d", tm); + if(dvdnav_jump_to_sector_by_time(priv->dvdnav, tm) == DVDNAV_STATUS_OK) return 1; break; } Index: mplayer.c =================================================================== --- mplayer.c (revision 34396) +++ mplayer.c (working copy) @@ -144,6 +144,7 @@ int enable_mouse_movements; float start_volume = -1; double start_pts = MP_NOPTS_VALUE; +float osd_add_this_much = 0.0; char *heartbeat_cmd; static int max_framesize; @@ -1227,7 +1228,7 @@ // Video time if (sh_video) - saddf(line, &pos, width, "V:%6.1f ", sh_video->pts); + saddf(line, &pos, width, "V:%6.2f ", sh_video->pts); // A-V sync if (mpctx->sh_audio && sh_video) @@ -1577,15 +1578,47 @@ return; } + char osd_accuracy_level[128] = ""; + if (mpctx->sh_video) { // fallback on the timer if (osd_level >= 2) { - int len = demuxer_get_time_length(mpctx->demuxer); + double double_len = demuxer_get_time_length(mpctx->demuxer); + int len = (int) double_len; int percentage = -1; char percentage_text[10]; char fractions_text[4]; - int pts = demuxer_get_current_time(mpctx->demuxer); - + double pts = demuxer_get_current_time(mpctx->demuxer); + + if(osd_verbose) + printf("adding %f to %f \n", osd_add_this_much, pts); // cannot figure it out + pts += osd_add_this_much; + if(osd_verbose) + printf("final: %f\n", pts); + if((pts - 1.0) < mpctx->sh_video->pts) { + // kind of already infer this from the OSD title now :) + //printf("using mpeg ts appears larger, which if true is definitely better %f > %f - 1.0\n", mpctx->sh_video->pts, pts); + if(osd_add_this_much > 0) { + snprintf(osd_accuracy_level, 100, "EDL-high-DVD-accurate"); + } else { + if(mpctx->sh_video->pts == pts) { + snprintf(osd_accuracy_level, 100, "EDL-high-File-accurate"); + } else { + snprintf(osd_accuracy_level, 100, "EDL-high-DVD-accurate"); + } + } + pts = mpctx->sh_video->pts; + } else { + // typically only DVD gets here... + // hmm... + if(osd_add_this_much > 0) { + snprintf(osd_accuracy_level, 100,"EDL-medium-DVD-accurate"); + } else { + snprintf(osd_accuracy_level, 100,"EDL-low-DVD-accurate"); + } + } + int seconds = (int) pts; + if (mpctx->osd_show_percentage) percentage = demuxer_get_percent_pos(mpctx->demuxer); @@ -1607,24 +1640,25 @@ // whose first frame is not exactly at timestamp 0. Therefore, // we add 0.2 and cut off at the decimal point, which proved // as good heuristic - snprintf(fractions_text, sizeof(fractions_text), ".%02d", - (int)((mpctx->sh_video->pts - pts) * - mpctx->sh_video->fps + 0.2)); + //snprintf(fractions_text, sizeof(fractions_text), ".%02d", + // (int)((mpctx->sh_video->pts - pts) * + // mpctx->sh_video->fps + 0.2)); } else { // do not print fractions fractions_text[0] = 0; } - if (osd_level == 3) + if (osd_level == 3) snprintf(osd_text_timer, 63, - "%c %02d:%02d:%02d%s / %02d:%02d:%02d%s", - mpctx->osd_function, pts / 3600, (pts / 60) % 60, pts % 60, + "%s:%c %02d:%02d:%02d%s / %02d:%02d:%02d%s", + osd_accuracy_level, mpctx->osd_function, (int)pts / 3600, (int)(pts / 60) % 60, (int)pts % 60, fractions_text, len / 3600, (len / 60) % 60, len % 60, - percentage_text); - else - snprintf(osd_text_timer, 63, "%c %02d:%02d:%02d%s%s", - mpctx->osd_function, pts / 3600, (pts / 60) % 60, - pts % 60, fractions_text, percentage_text); + percentage_text); + else { + snprintf(osd_text_timer, 63, "%s:%c %02d:%02d:%02d%s%s", osd_accuracy_level, + mpctx->osd_function, (int)pts / 3600, ((int)pts / 60) % 60, + (int)pts % 60, fractions_text, percentage_text); + } } else osd_text_timer[0] = 0; @@ -1642,7 +1676,6 @@ // Clear the term osd line if (term_osd && osd_text[0]) { osd_text[0] = 0; - printf("%s\n", term_osd_esc); } } @@ -2590,6 +2623,7 @@ } // Execute EDL command for the current position if one exists +// this is where the "muting" or "skipping" actually occurs static void edl_update(MPContext *mpctx) { if (!edl_records) @@ -2602,7 +2636,7 @@ edl_records = NULL; return; } - + double pts = demuxer_get_current_time(mpctx->demuxer); // This indicates that we need to reset next EDL record according // to new PTS due to seek or other condition if (edl_needs_reset) { @@ -2613,22 +2647,22 @@ // Find next record, also skip immediately if we are already // inside any record while (next_edl_record) { - if (next_edl_record->start_sec > mpctx->sh_video->pts) + if (next_edl_record->start_sec > pts) break; - if (next_edl_record->stop_sec >= mpctx->sh_video->pts) { + if (next_edl_record->stop_sec >= pts) { if (edl_backward) { + // this is just for "after some seek, check if we're in an EDL" mpctx->osd_function = OSD_REW; edl_decision = 1; abs_seek_pos = 0; - rel_seek_secs = -(mpctx->sh_video->pts - + rel_seek_secs = -(pts - next_edl_record->start_sec + edl_backward_delay); - mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_SKIP: pts [%f], " - "offset [%f], start [%f], stop [%f], length [%f]\n", - mpctx->sh_video->pts, rel_seek_secs, + printf( "\nEDL_SKIP special: pts [%f], offset [%f], start [%f], stop [%f], length [%f]\n", + pts, rel_seek_secs, next_edl_record->start_sec, next_edl_record->stop_sec, next_edl_record->length_sec); - return; + return; // early return } break; } @@ -2643,15 +2677,16 @@ } if (next_edl_record && - mpctx->sh_video->pts >= next_edl_record->start_sec) { + pts >= next_edl_record->start_sec) { if (next_edl_record->action == EDL_SKIP) { mpctx->osd_function = OSD_FFW; edl_decision = 1; abs_seek_pos = 0; - rel_seek_secs = next_edl_record->stop_sec - mpctx->sh_video->pts; + rel_seek_secs = next_edl_record->stop_sec - pts; + printf("\n\nEDL rel seek secs %f %f [%f,%f] \n", rel_seek_secs, pts, next_edl_record->start_sec, next_edl_record->stop_sec); mp_msg(MSGT_CPLAYER, MSGL_DBG4, "EDL_SKIP: pts [%f], offset [%f], " "start [%f], stop [%f], length [%f]\n", - mpctx->sh_video->pts, rel_seek_secs, + pts, rel_seek_secs, next_edl_record->start_sec, next_edl_record->stop_sec, next_edl_record->length_sec); } else if (next_edl_record->action == EDL_MUTE) { @@ -3868,6 +3903,7 @@ edl_update(mpctx); + //================= Keyboard events, SEEKing ==================== current_module = "key_events"; @@ -3951,7 +3987,7 @@ guiInfo.Chapter = dvd_chapter_from_cell(dvdp, guiInfo.Track - 1, dvdp->cur_cell) + 1; } #endif - } + } // if use_gui #endif /* CONFIG_GUI */ } // while(!mpctx->eof) Index: cfg-mplayer.h =================================================================== --- cfg-mplayer.h (revision 34396) +++ cfg-mplayer.h (working copy) @@ -86,6 +86,7 @@ {"softvol", &soft_vol, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"nosoftvol", &soft_vol, CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"softvol-max", &soft_vol_max, CONF_TYPE_FLOAT, CONF_RANGE, 10, 10000, NULL}, +// {"add-osd", &add_this_much, CONF_TYPE_FLOAT, CONF_RANGE, 0, 10000, NULL}, {"volstep", &volstep, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL}, {"volume", &start_volume, CONF_TYPE_FLOAT, CONF_RANGE, -1, 10000, NULL}, {"master", "Option -master has been removed, use -af volume instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, @@ -233,7 +234,11 @@ {"crash-debug", &crash_debug, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, {"nocrash-debug", &crash_debug, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL}, #endif +// {"osd-add-this-much", &osd_add_this_much, CONF_TYPE_FLOAT, CONF_RANGE, 0, 10000, NULL}, {"osdlevel", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL}, + {"osd-add", &osd_add_this_much, CONF_TYPE_FLOAT, CONF_RANGE, -100.0, 100.0, NULL}, + {"osd-verbose", &osd_verbose, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, + {"osd-duration", &osd_duration, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL}, {"osd-fractions", &osd_fractions, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL}, #ifdef CONFIG_MENU Index: mplayer.h =================================================================== --- mplayer.h (revision 34396) +++ mplayer.h (working copy) @@ -27,6 +27,8 @@ extern char **audio_driver_list; extern int osd_level; +extern float osd_add_this_much; +extern int osd_verbose; extern unsigned int osd_visible; extern int autosync; extern int frame_dropping; Index: libmpdemux/demuxer.c =================================================================== --- libmpdemux/demuxer.c (revision 34396) +++ libmpdemux/demuxer.c (working copy) @@ -493,7 +493,6 @@ //codec_id = CODEC_ID_DNET; break; case MKTAG('E', 'A', 'C', '3'): - case MKTAG('e', 'c', '-', '3'): codec_id = CODEC_ID_EAC3; break; case 0x2001: @@ -1473,6 +1472,9 @@ return get_time_ans; } +int osd_verbose = 0; +double last_dvd_update_pos = 0; +double last_stream_pos_at_that_dvd_time = 0; /** * \brief demuxer_get_current_time() returns the time of the current play in three possible ways: * either when the stream reader satisfies STREAM_CTRL_GET_CURRENT_TIME (e.g. dvd) @@ -1480,15 +1482,50 @@ * 0 otherwise * \return the current play time */ -int demuxer_get_current_time(demuxer_t *demuxer) +double demuxer_get_current_time(demuxer_t *demuxer) { double get_time_ans = 0; sh_video_t *sh_video = demuxer->video->sh; - if (demuxer->stream_pts != MP_NOPTS_VALUE) - get_time_ans = demuxer->stream_pts; - else if (sh_video) + if (demuxer->stream_pts != MP_NOPTS_VALUE) { + get_time_ans = demuxer->stream_pts; + if (osd_verbose) + printf("\nlast NAV packet was %f, mpeg at %f ", get_time_ans, sh_video->pts); + +// 30/1.001 ... hmm. ... + get_time_ans *= 1.001; // convert to 29.97 fps, mplayer's golden standard :P // could do this within libdvdnav uh guess...possibly all of it... + if (osd_verbose) + printf("after -> 29.97 %f\n", get_time_ans); + + double total_length = demuxer_get_time_length(demuxer); + + if(get_time_ans != last_dvd_update_pos) { + last_dvd_update_pos = get_time_ans; + last_stream_pos_at_that_dvd_time = sh_video->pts; + if (osd_verbose) + printf("new NAV packet! %f [adjusted] at %f ", get_time_ans, sh_video->pts); + } else { + double difference = (sh_video->pts - last_stream_pos_at_that_dvd_time); + + if(difference > 0 && difference < 1.5) { // should never be very high, typically < 0.6 as it's just "between NAV packets" + if (osd_verbose) + printf("adding difference %f ", difference); + get_time_ans += difference; // add the latest difference, already in 29.97 so not morphing needed. weird-z-o + } else { + printf("not adding odd diff1? %f", difference); + last_stream_pos_at_that_dvd_time = sh_video->pts; + } + if(get_time_ans < 0) + get_time_ans = 0; + } + + } + else if (sh_video) { + printf("weird fella suddenly we're not a DVD? mpeg at %f ", sh_video->pts); + // we get here at the mpeg "splits" cross overs splits... get_time_ans = sh_video->pts; - return (int) get_time_ans; + + } + return get_time_ans; } int demuxer_get_percent_pos(demuxer_t *demuxer) Index: libmpdemux/demuxer.h =================================================================== --- libmpdemux/demuxer.h (revision 34396) +++ libmpdemux/demuxer.h (working copy) @@ -437,8 +437,8 @@ int demux_info_print(demuxer_t *demuxer); int demux_control(demuxer_t *demuxer, int cmd, void *arg); -int demuxer_get_current_time(demuxer_t *demuxer); -double demuxer_get_time_length(demuxer_t *demuxer); +double demuxer_get_current_time(demuxer_t *demuxer); +double demuxer_get_time_length(demuxer_t *demuxer); int demuxer_get_percent_pos(demuxer_t *demuxer); int demuxer_switch_audio(demuxer_t *demuxer, int index); int demuxer_switch_video(demuxer_t *demuxer, int index);