mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
Move correct_pts to options struct
This commit is contained in:
parent
0d59f81e54
commit
9b06b5ed85
@ -326,8 +326,8 @@ const m_option_t mplayer_opts[]={
|
||||
{"playlist", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
|
||||
// a-v sync stuff:
|
||||
{"correct-pts", &user_correct_pts, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
{"no-correct-pts", &user_correct_pts, CONF_TYPE_FLAG, 0, 1, 0, NULL},
|
||||
FLAG_ON("correct-pts", user_correct_pts, 0),
|
||||
FLAG_OFF("no-correct-pts", user_correct_pts, 0),
|
||||
{"noautosync", &autosync, CONF_TYPE_FLAG, 0, 0, -1, NULL},
|
||||
{"autosync", &autosync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL},
|
||||
// {"dapsync", &dapsync, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
|
@ -8,5 +8,12 @@ void set_default_mplayer_options(struct MPOpts *opts)
|
||||
.audio_driver_list = NULL,
|
||||
.video_driver_list = NULL,
|
||||
.fixed_vo = 0,
|
||||
.user_correct_pts = -1,
|
||||
};
|
||||
}
|
||||
|
||||
void set_default_mencoder_options(struct MPOpts *opts)
|
||||
{
|
||||
set_default_mplayer_options(opts);
|
||||
opts->user_correct_pts = 0;
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
struct MPOpts;
|
||||
void set_default_mplayer_options(struct MPOpts *opts);
|
||||
void set_default_mencoder_options(struct MPOpts *opts);
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "options.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
@ -335,8 +336,9 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
|
||||
unsigned int t = GetTimer();
|
||||
unsigned int t2;
|
||||
double tt;
|
||||
struct MPOpts *opts = sh_video->opts;
|
||||
|
||||
if (correct_pts && pts != MP_NOPTS_VALUE) {
|
||||
if (opts->correct_pts && pts != MP_NOPTS_VALUE) {
|
||||
int delay = get_current_video_decoder_lag(sh_video);
|
||||
if (delay >= 0) {
|
||||
if (delay > sh_video->num_buffered_pts)
|
||||
@ -393,7 +395,7 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
|
||||
else if (field_dominance == 1)
|
||||
mpi->fields &= ~MP_IMGFIELD_TOP_FIRST;
|
||||
|
||||
if (correct_pts) {
|
||||
if (opts->correct_pts) {
|
||||
if (sh_video->num_buffered_pts) {
|
||||
sh_video->num_buffered_pts--;
|
||||
sh_video->pts = sh_video->buffered_pts[sh_video->num_buffered_pts];
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "options.h"
|
||||
#include "mp_msg.h"
|
||||
#include "cpudetect.h"
|
||||
|
||||
@ -300,7 +301,6 @@ static void (*qpel_li)(unsigned char *d, unsigned char *s, int w, int h, int ds,
|
||||
static void (*qpel_4tap)(unsigned char *d, unsigned char *s, int w, int h, int ds, int ss, int up);
|
||||
|
||||
static int continue_buffered_image(struct vf_instance_s *);
|
||||
extern int correct_pts;
|
||||
|
||||
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
|
||||
{
|
||||
@ -312,6 +312,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
|
||||
|
||||
static int continue_buffered_image(struct vf_instance_s *vf)
|
||||
{
|
||||
struct MPOpts *opts = vf->opts;
|
||||
int i=vf->priv->buffered_i;
|
||||
double pts = vf->priv->buffered_pts;
|
||||
mp_image_t *mpi = vf->priv->buffered_mpi;
|
||||
@ -362,7 +363,7 @@ static int continue_buffered_image(struct vf_instance_s *vf)
|
||||
dmpi->stride[2] = 2*mpi->stride[2];
|
||||
}
|
||||
ret |= vf_next_put_image(vf, dmpi, pts);
|
||||
if (correct_pts)
|
||||
if (opts->correct_pts)
|
||||
break;
|
||||
else
|
||||
if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
|
||||
@ -392,7 +393,7 @@ static int continue_buffered_image(struct vf_instance_s *vf)
|
||||
mpi->chroma_width, mpi->chroma_height, (i^!tff));
|
||||
}
|
||||
ret |= vf_next_put_image(vf, dmpi, pts);
|
||||
if (correct_pts)
|
||||
if (opts->correct_pts)
|
||||
break;
|
||||
else
|
||||
if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
|
||||
@ -418,7 +419,7 @@ static int continue_buffered_image(struct vf_instance_s *vf)
|
||||
dmpi->stride[2], mpi->stride[2]*2, (i^!tff));
|
||||
}
|
||||
ret |= vf_next_put_image(vf, dmpi, pts);
|
||||
if (correct_pts)
|
||||
if (opts->correct_pts)
|
||||
break;
|
||||
else
|
||||
if (!i) vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "cpudetect.h"
|
||||
#include "options.h"
|
||||
|
||||
#include "mp_msg.h"
|
||||
|
||||
@ -391,7 +392,6 @@ static int config(struct vf_instance_s* vf,
|
||||
}
|
||||
|
||||
static int continue_buffered_image(struct vf_instance_s *vf);
|
||||
extern int correct_pts;
|
||||
|
||||
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
|
||||
int tff;
|
||||
@ -422,6 +422,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
|
||||
|
||||
static int continue_buffered_image(struct vf_instance_s *vf)
|
||||
{
|
||||
struct MPOpts *opts = vf->opts;
|
||||
mp_image_t *mpi = vf->priv->buffered_mpi;
|
||||
int tff = vf->priv->buffered_tff;
|
||||
double pts = vf->priv->buffered_pts;
|
||||
@ -438,10 +439,10 @@ static int continue_buffered_image(struct vf_instance_s *vf)
|
||||
mpi->width,mpi->height);
|
||||
vf_clone_mpi_attributes(dmpi, mpi);
|
||||
filter(vf->priv, dmpi->planes, dmpi->stride, mpi->w, mpi->h, i ^ tff ^ 1, tff);
|
||||
if (correct_pts && i < (vf->priv->mode & 1))
|
||||
if (opts->correct_pts && i < (vf->priv->mode & 1))
|
||||
vf_queue_frame(vf, continue_buffered_image);
|
||||
ret |= vf_next_put_image(vf, dmpi, pts /*FIXME*/);
|
||||
if (correct_pts)
|
||||
if (opts->correct_pts)
|
||||
break;
|
||||
if(i<(vf->priv->mode&1))
|
||||
vf_next_control(vf, VFCTRL_FLIP_PAGE, NULL);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "options.h"
|
||||
#include "mp_msg.h"
|
||||
#include "help_mp.h"
|
||||
|
||||
@ -405,6 +406,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
|
||||
}
|
||||
|
||||
static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
|
||||
struct MPOpts *opts = demuxer->opts;
|
||||
AVFormatContext *avfc;
|
||||
AVFormatParameters ap;
|
||||
const AVOption *opt;
|
||||
@ -420,7 +422,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
|
||||
|
||||
if (opt_cryptokey)
|
||||
parse_cryptokey(avfc, opt_cryptokey);
|
||||
if (user_correct_pts != 0)
|
||||
if (opts->user_correct_pts != 0)
|
||||
avfc->flags |= AVFMT_FLAG_GENPTS;
|
||||
if (index_mode == 0)
|
||||
avfc->flags |= AVFMT_FLAG_IGNIDX;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "options.h"
|
||||
#include "stream/stream.h"
|
||||
#include "demuxer.h"
|
||||
#include "stheader.h"
|
||||
@ -1687,6 +1688,7 @@ static const videocodec_info_t vinfo[] = {
|
||||
static int
|
||||
demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid)
|
||||
{
|
||||
struct MPOpts *opts = demuxer->opts;
|
||||
BITMAPINFOHEADER *bih;
|
||||
void *ImageDesc = NULL;
|
||||
sh_video_t *sh_v;
|
||||
@ -1797,7 +1799,7 @@ demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid)
|
||||
bih = realloc (bih, bih->biSize);
|
||||
memcpy (bih + 1, track->private_data, track->private_size);
|
||||
}
|
||||
track->reorder_timecodes = user_correct_pts == 0;
|
||||
track->reorder_timecodes = opts->user_correct_pts == 0;
|
||||
if (!vi->id) {
|
||||
mp_msg (MSGT_DEMUX,MSGL_WARN, MSGTR_MPDEMUX_MKV_UnknownCodecID,
|
||||
track->codec_id, track->tnum);
|
||||
|
@ -738,9 +738,6 @@ int get_demuxer_type_from_name(char *demuxer_name, int *force)
|
||||
|
||||
int extension_parsing = 1; // 0=off 1=mixed (used only for unstable formats)
|
||||
|
||||
int correct_pts = 0;
|
||||
int user_correct_pts = -1;
|
||||
|
||||
/*
|
||||
NOTE : Several demuxers may be opened at the same time so
|
||||
demuxers should NEVER rely on an external var to enable them
|
||||
@ -1045,9 +1042,9 @@ demuxer_t *demux_open(struct MPOpts *opts, stream_t *vs, int file_format,
|
||||
else
|
||||
res = vd;
|
||||
|
||||
correct_pts = user_correct_pts;
|
||||
if (correct_pts < 0)
|
||||
correct_pts =
|
||||
opts->correct_pts = opts->user_correct_pts;
|
||||
if (opts->correct_pts < 0)
|
||||
opts->correct_pts =
|
||||
demux_control(res, DEMUXER_CTRL_CORRECT_PTS,
|
||||
NULL) == DEMUXER_CTRL_OK;
|
||||
return res;
|
||||
|
@ -150,9 +150,6 @@ typedef struct demuxer_info_st {
|
||||
|
||||
struct demuxer_st;
|
||||
|
||||
extern int correct_pts;
|
||||
extern int user_correct_pts;
|
||||
|
||||
/**
|
||||
* Demuxer description structure
|
||||
*/
|
||||
|
@ -91,6 +91,7 @@
|
||||
|
||||
#include "libmpcodecs/ae.h"
|
||||
#include "options.h"
|
||||
#include "defaultopts.h"
|
||||
|
||||
MPOpts opts;
|
||||
|
||||
@ -419,11 +420,10 @@ ao_data_t ao_data = {0,0,0,0,OUTBURST,-1,0};
|
||||
audio_encoding_params_t aparams;
|
||||
audio_encoder_t *aencoder = NULL;
|
||||
|
||||
user_correct_pts = 0;
|
||||
|
||||
mp_msg_init();
|
||||
|
||||
// Create the config context and register the options
|
||||
set_default_mencoder_options(&opts);
|
||||
mconfig = m_config_new(&opts);
|
||||
m_config_register_options(mconfig,mencoder_opts);
|
||||
|
||||
|
@ -2242,11 +2242,12 @@ err_out:
|
||||
|
||||
static double update_video(int *blit_frame)
|
||||
{
|
||||
struct MPOpts *opts = &mpctx->opts;
|
||||
sh_video_t * const sh_video = mpctx->sh_video;
|
||||
//-------------------- Decode a frame: -----------------------
|
||||
double frame_time;
|
||||
*blit_frame = 0; // Don't blit if we hit EOF
|
||||
if (!correct_pts) {
|
||||
if (!opts->correct_pts) {
|
||||
unsigned char* start=NULL;
|
||||
void *decoded_frame = NULL;
|
||||
int drop_frame=0;
|
||||
|
Loading…
Reference in New Issue
Block a user