mirror of
https://github.com/mpv-player/mpv
synced 2025-01-04 14:12:10 +00:00
video: remove user-controllable PTS sorting (--pts-association-mode)
Useless. Sometimes it might be useful to make some extremely broken files work, but on the other hand --no-correct-pts is sufficient for these cases. While we still need some of the code for AVI, the "auto" mode in particular inflated the size of the code.
This commit is contained in:
parent
0e245b3752
commit
8e654d3f78
@ -1171,9 +1171,6 @@ Property list
|
||||
is loaded, or when switching ordered chapter segments. This is because
|
||||
the same underlying code is used for seeking and resyncing.)
|
||||
|
||||
``pts-association-mode`` (RW)
|
||||
See ``--pts-association-mode``.
|
||||
|
||||
``hr-seek`` (RW)
|
||||
See ``--hr-seek``.
|
||||
|
||||
|
@ -3535,20 +3535,6 @@ Miscellaneous
|
||||
|
||||
.. warning:: Using realtime priority can cause system lockup.
|
||||
|
||||
``--pts-association-mode=<decode|sort|auto>``
|
||||
Select the method used to determine which container packet timestamp
|
||||
corresponds to a particular output frame from the video decoder. Normally
|
||||
you should not need to change this option.
|
||||
|
||||
:decoder: Use decoder reordering functionality. Unlike in classic MPlayer
|
||||
and mplayer2, this includes a DTS fallback. (Default.)
|
||||
:sort: Maintain a buffer of unused pts values and use the lowest value
|
||||
for the frame.
|
||||
:auto: Try to pick a working mode from the ones above automatically.
|
||||
|
||||
You can also try to use ``--no-correct-pts`` for files with completely
|
||||
broken timestamps.
|
||||
|
||||
``--force-media-title=<string>``
|
||||
Force the contents of the ``media-title`` property to this value. Useful
|
||||
for scripts which want to set a title, without overriding the user's
|
||||
|
@ -521,8 +521,6 @@ const m_option_t mp_opts[] = {
|
||||
|
||||
// a-v sync stuff:
|
||||
OPT_FLAG("correct-pts", correct_pts, 0),
|
||||
OPT_CHOICE("pts-association-mode", user_pts_assoc_mode, 0,
|
||||
({"auto", 0}, {"decoder", 1}, {"sort", 2})),
|
||||
OPT_FLAG("initial-audio-sync", initial_audio_sync, 0),
|
||||
OPT_CHOICE("video-sync", video_sync, 0,
|
||||
({"audio", VS_DEFAULT},
|
||||
@ -754,7 +752,6 @@ const struct MPOpts mp_default_opts = {
|
||||
.edition_id = -1,
|
||||
.default_max_pts_correction = -1,
|
||||
.correct_pts = 1,
|
||||
.user_pts_assoc_mode = 1,
|
||||
.initial_audio_sync = 1,
|
||||
.frame_dropping = 1,
|
||||
.term_osd = 2,
|
||||
|
@ -144,7 +144,6 @@ typedef struct MPOpts {
|
||||
int chapterrange[2];
|
||||
int edition_id;
|
||||
int correct_pts;
|
||||
int user_pts_assoc_mode;
|
||||
int initial_audio_sync;
|
||||
int video_sync;
|
||||
double sync_max_video_change;
|
||||
|
@ -3405,7 +3405,6 @@ static const struct m_property mp_properties[] = {
|
||||
{"demuxer-cache-idle", mp_property_demuxer_cache_idle},
|
||||
{"cache-buffering-state", mp_property_cache_buffering},
|
||||
{"paused-for-cache", mp_property_paused_for_cache},
|
||||
{"pts-association-mode", mp_property_generic_option},
|
||||
{"hr-seek", mp_property_generic_option},
|
||||
{"clock", mp_property_clock},
|
||||
{"seekable", mp_property_seekable},
|
||||
@ -3734,7 +3733,6 @@ static const struct property_osd_display {
|
||||
{ "chapter", .seek_msg = OSD_SEEK_INFO_CHAPTER_TEXT,
|
||||
.seek_bar = OSD_SEEK_INFO_BAR },
|
||||
{ "edition", .seek_msg = OSD_SEEK_INFO_EDITION },
|
||||
{ "pts-association-mode", "PTS association mode" },
|
||||
{ "hr-seek", "hr-seek" },
|
||||
{ "speed", "Speed" },
|
||||
{ "clock", "Clock" },
|
||||
|
@ -67,8 +67,6 @@ void video_reset_decoding(struct dec_video *d_video)
|
||||
d_video->decoded_pts = MP_NOPTS_VALUE;
|
||||
d_video->codec_pts = MP_NOPTS_VALUE;
|
||||
d_video->codec_dts = MP_NOPTS_VALUE;
|
||||
d_video->sorted_pts = MP_NOPTS_VALUE;
|
||||
d_video->unsorted_pts = MP_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
int video_vd_control(struct dec_video *d_video, int cmd, void *arg)
|
||||
@ -228,57 +226,14 @@ static void add_pts_to_sort(struct dec_video *d_video, double pts)
|
||||
}
|
||||
}
|
||||
|
||||
// Return true if pts1 comes before pts2. pts1 can be MP_NOPTS_VALUE, but pts2
|
||||
// always has to be valid. pts1 can't be equal or larger than pts2.
|
||||
#define PTS_IS_ORDERED(pts1, pts2) \
|
||||
((pts2) != MP_NOPTS_VALUE && ((pts1) == MP_NOPTS_VALUE || ((pts1) < (pts2))))
|
||||
|
||||
static double retrieve_sorted_pts(struct dec_video *d_video, double codec_pts)
|
||||
{
|
||||
struct MPOpts *opts = d_video->opts;
|
||||
|
||||
double sorted_pts;
|
||||
if (d_video->num_buffered_pts) {
|
||||
d_video->num_buffered_pts--;
|
||||
sorted_pts = d_video->buffered_pts[d_video->num_buffered_pts];
|
||||
} else {
|
||||
MP_ERR(d_video, "No pts value from demuxer to use for frame!\n");
|
||||
sorted_pts = MP_NOPTS_VALUE;
|
||||
return d_video->buffered_pts[d_video->num_buffered_pts];
|
||||
}
|
||||
|
||||
if (!PTS_IS_ORDERED(d_video->sorted_pts, sorted_pts))
|
||||
d_video->num_sorted_pts_problems++;
|
||||
d_video->sorted_pts = sorted_pts;
|
||||
|
||||
if (!PTS_IS_ORDERED(d_video->unsorted_pts, codec_pts))
|
||||
d_video->num_unsorted_pts_problems++;
|
||||
d_video->unsorted_pts = codec_pts;
|
||||
|
||||
if (d_video->header->video->avi_dts) {
|
||||
// Actually, they don't need to be sorted, we just reuse the buffering.
|
||||
d_video->pts_assoc_mode = 2;
|
||||
} else if (opts->user_pts_assoc_mode) {
|
||||
d_video->pts_assoc_mode = opts->user_pts_assoc_mode;
|
||||
} else if (d_video->pts_assoc_mode == 0) {
|
||||
if (codec_pts != MP_NOPTS_VALUE)
|
||||
d_video->pts_assoc_mode = 1;
|
||||
else
|
||||
d_video->pts_assoc_mode = 2;
|
||||
} else {
|
||||
int probcount1 = d_video->num_unsorted_pts_problems;
|
||||
int probcount2 = d_video->num_sorted_pts_problems;
|
||||
if (d_video->pts_assoc_mode == 2) {
|
||||
int tmp = probcount1;
|
||||
probcount1 = probcount2;
|
||||
probcount2 = tmp;
|
||||
}
|
||||
if (probcount1 >= probcount2 * 1.5 + 2) {
|
||||
d_video->pts_assoc_mode = 3 - d_video->pts_assoc_mode;
|
||||
MP_WARN(d_video, "Switching to pts association mode %d.\n",
|
||||
d_video->pts_assoc_mode);
|
||||
}
|
||||
}
|
||||
return d_video->pts_assoc_mode == 1 ? codec_pts : sorted_pts;
|
||||
MP_ERR(d_video, "No pts value from demuxer to use for frame!\n");
|
||||
return MP_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
struct mp_image *video_decode(struct dec_video *d_video,
|
||||
@ -286,9 +241,7 @@ struct mp_image *video_decode(struct dec_video *d_video,
|
||||
int drop_frame)
|
||||
{
|
||||
struct MPOpts *opts = d_video->opts;
|
||||
bool sort_pts =
|
||||
(opts->user_pts_assoc_mode != 1 || d_video->header->video->avi_dts)
|
||||
&& opts->correct_pts;
|
||||
bool sort_pts = d_video->header->video->avi_dts && opts->correct_pts;
|
||||
|
||||
struct demux_packet packet_copy;
|
||||
if (packet && packet->dts == MP_NOPTS_VALUE) {
|
||||
|
@ -55,14 +55,9 @@ struct dec_video {
|
||||
double codec_dts;
|
||||
int num_codec_dts_problems;
|
||||
|
||||
// PTS sorting (obscure, non-default)
|
||||
// PTS sorting (needed for AVI-style timestamps)
|
||||
double buffered_pts[32];
|
||||
int num_buffered_pts;
|
||||
double sorted_pts;
|
||||
int num_sorted_pts_problems;
|
||||
double unsorted_pts;
|
||||
int num_unsorted_pts_problems;
|
||||
int pts_assoc_mode;
|
||||
|
||||
// PTS or DTS of packet last read
|
||||
double last_packet_pdts;
|
||||
|
Loading…
Reference in New Issue
Block a user