core: simplify some no-correct-pts code

Remove the special handling for mng/mkv. These don't profit at all from
no-correct-pts mode, and even removing the mkv specific code makes mkv
work better (wow!).

Don't check for (int)fps == 1000. I don't know where this value comes
from. Maybe it was once a special value which triggered certain
behavior, but the code for that must have gone away. The only way to
trigger this value would be by coincidence if two frames are 1 ms apart.

Otherwise, the behavior should be exactly the same, except for some
removed messages.
This commit is contained in:
wm4 2013-07-10 02:07:47 +02:00
parent 186f6021b1
commit 5ec611e7ba
1 changed files with 13 additions and 33 deletions

View File

@ -2484,12 +2484,11 @@ static void filter_video(struct MPContext *mpctx, struct mp_image *frame)
}
static int video_read_frame(sh_video_t *sh_video, float *frame_time_ptr,
static int video_read_frame(sh_video_t *sh_video,
unsigned char **start, int force_fps)
{
demux_stream_t *d_video = sh_video->ds;
demuxer_t *demuxer = d_video->demuxer;
float frame_time = 1;
float pts1 = d_video->pts;
int in_size = 0;
@ -2500,49 +2499,30 @@ static int video_read_frame(sh_video_t *sh_video, float *frame_time_ptr,
if (in_size < 0)
return -1; // EOF
frame_time *= sh_video->frametime;
float frame_time = sh_video->frametime;
// override frame_time for variable/unknown FPS formats:
if (!force_fps) {
switch (demuxer->file_format) {
case DEMUXER_TYPE_MATROSKA:
case DEMUXER_TYPE_MNG:
if (d_video->pts > 0 && pts1 > 0 && d_video->pts>pts1)
frame_time = d_video->pts-pts1;
break;
case DEMUXER_TYPE_TV: {
double next_pts = ds_get_next_pts(d_video);
double d= (next_pts != MP_NOPTS_VALUE) ? next_pts - d_video->pts : d_video->pts-pts1;
if (d >= 0) {
if(d > 0){
if ((int)sh_video->fps == 1000)
mp_msg(MSGT_CPLAYER,MSGL_V,"\navg. framerate: %d fps \n",(int)(1.0f/d));
sh_video->frametime = d; // 1ms
sh_video->fps = 1.0f/d;
double next_pts = ds_get_next_pts(d_video);
double d = next_pts == MP_NOPTS_VALUE ? d_video->pts - pts1
: next_pts - d_video->pts;
if (d >= 0) {
if (demuxer->file_format == DEMUXER_TYPE_TV) {
if (d > 0) {
sh_video->frametime = d;
sh_video->fps = 1.0f / d;
}
frame_time = d;
} else {
mp_msg(MSGT_CPLAYER,MSGL_WARN,"\nInvalid frame duration value (%5.3f/%5.3f => %5.3f). Defaulting to %5.3f sec.\n",d_video->pts,next_pts,d,frame_time);
// frame_time = 1/25.0;
}
break;
}
case DEMUXER_TYPE_LAVF:
if ((int)sh_video->fps == 1000 || (int)sh_video->fps <= 1) {
double next_pts = ds_get_next_pts(d_video);
double d = (next_pts != MP_NOPTS_VALUE) ? next_pts - d_video->pts : d_video->pts - pts1;
if(d>=0){
if ((int)sh_video->fps <= 1)
frame_time = d;
}
}
break;
}
}
sh_video->pts = d_video->pts;
if (frame_time_ptr)
*frame_time_ptr=frame_time;
sh_video->next_frame_time = frame_time;
return in_size;
}
@ -2563,7 +2543,7 @@ static double update_video_nocorrect_pts(struct MPContext *mpctx)
frame_time = 0;
int in_size = 0;
while (!in_size)
in_size = video_read_frame(sh_video, &sh_video->next_frame_time,
in_size = video_read_frame(sh_video,
&packet, mpctx->opts.force_fps);
if (in_size < 0)
return -1;