mirror of https://github.com/mpv-player/mpv
video: eliminate frametime variable
This commit is contained in:
parent
6f6632b8dd
commit
a6706c41d8
|
@ -1793,6 +1793,8 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time)
|
|||
{
|
||||
float delay = opts->playback_speed * ao_get_delay(mpctx->ao);
|
||||
float d = delay - mpctx->delay;
|
||||
if (frame_time < 0)
|
||||
frame_time = mpctx->sh_video->fps > 0 ? 1.0 / mpctx->sh_video->fps : 0;
|
||||
// we should avoid dropping too many frames in sequence unless we
|
||||
// are too late. and we allow 100ms A-V delay here:
|
||||
if (d < -mpctx->dropped_frames * frame_time - 0.100 && !mpctx->paused
|
||||
|
@ -2305,14 +2307,12 @@ int reinit_video_chain(struct MPContext *mpctx)
|
|||
}
|
||||
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_V, "[V] filefmt:%d fourcc:0x%X "
|
||||
"size:%dx%d fps:%5.3f ftime:=%6.4f\n",
|
||||
"size:%dx%d fps:%5.3f\n",
|
||||
mpctx->master_demuxer->file_format, mpctx->sh_video->format,
|
||||
mpctx->sh_video->disp_w, mpctx->sh_video->disp_h,
|
||||
mpctx->sh_video->fps, mpctx->sh_video->frametime);
|
||||
if (opts->force_fps) {
|
||||
mpctx->sh_video->fps);
|
||||
if (opts->force_fps)
|
||||
mpctx->sh_video->fps = opts->force_fps;
|
||||
mpctx->sh_video->frametime = 1.0f / mpctx->sh_video->fps;
|
||||
}
|
||||
update_fps(mpctx);
|
||||
|
||||
if (!mpctx->sh_video->fps && !opts->force_fps && !opts->correct_pts) {
|
||||
|
@ -2449,7 +2449,7 @@ static struct demux_packet *video_read_frame(struct MPContext *mpctx)
|
|||
if (pkt->pts != MP_NOPTS_VALUE)
|
||||
sh_video->last_pts = pkt->pts;
|
||||
|
||||
float frame_time = sh_video->frametime;
|
||||
float frame_time = sh_video->fps > 0 ? 1.0f / sh_video->fps : 0;
|
||||
|
||||
// override frame_time for variable/unknown FPS formats:
|
||||
if (!mpctx->opts.force_fps) {
|
||||
|
@ -2458,10 +2458,8 @@ static struct demux_packet *video_read_frame(struct MPContext *mpctx)
|
|||
: next_pts - sh_video->last_pts;
|
||||
if (d >= 0) {
|
||||
if (demuxer->file_format == DEMUXER_TYPE_TV) {
|
||||
if (d > 0) {
|
||||
sh_video->frametime = d;
|
||||
if (d > 0)
|
||||
sh_video->fps = 1.0f / d;
|
||||
}
|
||||
frame_time = d;
|
||||
} else {
|
||||
if ((int)sh_video->fps <= 1)
|
||||
|
@ -2574,7 +2572,7 @@ static double update_video(struct MPContext *mpctx, double endpts)
|
|||
if (pts >= mpctx->hrseek_pts - .005)
|
||||
mpctx->hrseek_framedrop = false;
|
||||
int framedrop_type = mpctx->hrseek_active && mpctx->hrseek_framedrop ?
|
||||
1 : check_framedrop(mpctx, sh_video->frametime);
|
||||
1 : check_framedrop(mpctx, -1);
|
||||
struct mp_image *decoded_frame =
|
||||
decode_video(sh_video, pkt, framedrop_type, pts);
|
||||
talloc_free(pkt);
|
||||
|
@ -4281,10 +4279,8 @@ goto_reopen_demuxer: ;
|
|||
|
||||
if (opts->force_fps && mpctx->sh_video) {
|
||||
mpctx->sh_video->fps = opts->force_fps;
|
||||
mpctx->sh_video->frametime = 1.0f / mpctx->sh_video->fps;
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_INFO,
|
||||
"FPS forced to be %5.3f (ftime: %5.3f).\n",
|
||||
mpctx->sh_video->fps, mpctx->sh_video->frametime);
|
||||
"FPS forced to be %5.3f.\n", mpctx->sh_video->fps);
|
||||
}
|
||||
|
||||
//==================== START PLAYING =======================
|
||||
|
|
|
@ -402,7 +402,6 @@ static void handle_stream(demuxer_t *demuxer, int i)
|
|||
av_q2d(st->codec->time_base) *
|
||||
st->codec->ticks_per_frame);
|
||||
sh_video->fps = fps;
|
||||
sh_video->frametime = 1 / fps;
|
||||
if (st->sample_aspect_ratio.num)
|
||||
sh_video->aspect = codec->width * st->sample_aspect_ratio.num
|
||||
/ (float)(codec->height * st->sample_aspect_ratio.den);
|
||||
|
|
|
@ -219,7 +219,6 @@ static demuxer_t* demux_open_mf(demuxer_t* demuxer){
|
|||
sh_video->disp_w = 0;
|
||||
sh_video->disp_h = 0;
|
||||
sh_video->fps = mf_fps;
|
||||
sh_video->frametime = 1 / sh_video->fps;
|
||||
|
||||
mf->sh = sh_video;
|
||||
demuxer->priv=(void*)mf;
|
||||
|
|
|
@ -1283,7 +1283,6 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
|
|||
if (track->v_frate == 0.0)
|
||||
track->v_frate = 25.0;
|
||||
sh_v->fps = track->v_frate;
|
||||
sh_v->frametime = 1 / track->v_frate;
|
||||
sh_v->aspect = 0;
|
||||
if (!track->realmedia) {
|
||||
sh_v->disp_w = track->v_width;
|
||||
|
|
|
@ -421,7 +421,6 @@ static demuxer_t * demux_mng_open(demuxer_t * demuxer)
|
|||
|
||||
// set framerate to some value (MNG does not have a fixed framerate)
|
||||
sh_video->fps = 5.0f;
|
||||
sh_video->frametime = 1.0f / sh_video->fps;
|
||||
|
||||
// set video frame parameters
|
||||
sh_video->bih = calloc(1, sizeof(*sh_video->bih));
|
||||
|
|
|
@ -119,7 +119,6 @@ static demuxer_t* demux_rawvideo_open(demuxer_t* demuxer) {
|
|||
sh_video->gsh->codec=decoder;
|
||||
sh_video->format=imgfmt;
|
||||
sh_video->fps=fps;
|
||||
sh_video->frametime=1.0/fps;
|
||||
sh_video->disp_w=width;
|
||||
sh_video->disp_h=height;
|
||||
sh_video->i_bps=fps*imgsize;
|
||||
|
|
|
@ -124,7 +124,6 @@ typedef struct sh_video {
|
|||
int pts_assoc_mode;
|
||||
// output format: (set by demuxer)
|
||||
float fps; // frames per second (set only if constant fps)
|
||||
float frametime; // 1/fps
|
||||
float aspect; // aspect ratio stored in the file (for prescaling)
|
||||
float stream_aspect; // aspect ratio in media headers (DVD IFO files)
|
||||
int i_bps; // == bitrate (compressed bytes/sec)
|
||||
|
|
|
@ -743,8 +743,6 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
|
|||
if (tvh->tv_param->fps != -1.0f)
|
||||
sh_video->fps = tvh->tv_param->fps;
|
||||
|
||||
sh_video->frametime = 1.0f/sh_video->fps;
|
||||
|
||||
/* If playback only mode, go to immediate mode, fail silently */
|
||||
if(tvh->tv_param->immediate == 1)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue