summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filters/f_decoder_wrapper.c109
-rw-r--r--options/options.c28
-rw-r--r--options/options.h18
-rw-r--r--player/command.c4
-rw-r--r--player/main.c16
-rw-r--r--player/playloop.c3
6 files changed, 96 insertions, 82 deletions
diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c
index 73d3076294..7a53c72c06 100644
--- a/filters/f_decoder_wrapper.c
+++ b/filters/f_decoder_wrapper.c
@@ -69,7 +69,7 @@ static const struct m_option dec_queue_opts_list[] = {
{0}
};
-const struct m_sub_options vdec_queue_conf = {
+static const struct m_sub_options vdec_queue_conf = {
.opts = dec_queue_opts_list,
.size = sizeof(struct dec_queue_opts),
.defaults = &(const struct dec_queue_opts){
@@ -80,7 +80,7 @@ const struct m_sub_options vdec_queue_conf = {
},
};
-const struct m_sub_options adec_queue_conf = {
+static const struct m_sub_options adec_queue_conf = {
.opts = dec_queue_opts_list,
.size = sizeof(struct dec_queue_opts),
.defaults = &(const struct dec_queue_opts){
@@ -91,6 +91,56 @@ const struct m_sub_options adec_queue_conf = {
},
};
+#undef OPT_BASE_STRUCT
+#define OPT_BASE_STRUCT struct dec_wrapper_opts
+
+struct dec_wrapper_opts {
+ float movie_aspect;
+ int aspect_method;
+ double force_fps;
+ int correct_pts;
+ int video_rotate;
+ char *audio_decoders;
+ char *video_decoders;
+ char *audio_spdif;
+ struct dec_queue_opts *vdec_queue_opts;
+ struct dec_queue_opts *adec_queue_opts;
+ int64_t video_reverse_size;
+ int64_t audio_reverse_size;
+};
+
+static int decoder_list_opt(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param);
+
+const struct m_sub_options dec_wrapper_conf = {
+ .opts = (const struct m_option[]){
+ OPT_FLAG("correct-pts", correct_pts, 0),
+ OPT_DOUBLE("fps", force_fps, CONF_MIN, .min = 0),
+ OPT_STRING_VALIDATE("ad", audio_decoders, 0, decoder_list_opt),
+ OPT_STRING_VALIDATE("vd", video_decoders, 0, decoder_list_opt),
+ OPT_STRING_VALIDATE("audio-spdif", audio_spdif, 0, decoder_list_opt),
+ OPT_CHOICE_OR_INT("video-rotate", video_rotate, UPDATE_IMGPAR, 0, 359,
+ ({"no", -1})),
+ OPT_ASPECT("video-aspect-override", movie_aspect,
+ UPDATE_IMGPAR | M_OPT_RANGE, .min = -1, .max = 10),
+ OPT_CHOICE("video-aspect-method", aspect_method, UPDATE_IMGPAR,
+ ({"bitstream", 1}, {"container", 2})),
+ OPT_SUBSTRUCT("vd-queue", vdec_queue_opts, vdec_queue_conf, 0),
+ OPT_SUBSTRUCT("ad-queue", adec_queue_opts, adec_queue_conf, 0),
+ OPT_BYTE_SIZE("video-reversal-buffer", video_reverse_size, 0, 0, (size_t)-1),
+ OPT_BYTE_SIZE("audio-reversal-buffer", audio_reverse_size, 0, 0, (size_t)-1),
+ {0}
+ },
+ .size = sizeof(struct dec_wrapper_opts),
+ .defaults = &(const struct dec_wrapper_opts){
+ .correct_pts = 1,
+ .movie_aspect = -1.,
+ .aspect_method = 2,
+ .video_reverse_size = 1 * 1024 * 1024 * 1024,
+ .audio_reverse_size = 64 * 1024 * 1024,
+ },
+};
+
struct priv {
struct mp_log *log;
struct sh_stream *header;
@@ -103,6 +153,7 @@ struct priv {
struct mp_filter *dec_root_filter; // thread root filter; no thread => NULL
struct mp_filter *decf; // wrapper filter which drives the decoder
struct m_config_cache *opt_cache;
+ struct dec_wrapper_opts *opts;
struct mp_codec_params *codec;
struct mp_decoder *decoder;
@@ -174,6 +225,30 @@ struct priv {
int dropped_frames; // total frames _probably_ dropped
};
+static int decoder_list_opt(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param)
+{
+ if (!bstr_equals0(param, "help"))
+ return 1;
+ if (strcmp(opt->name, "ad") == 0) {
+ struct mp_decoder_list *list = audio_decoder_list();
+ mp_print_decoders(log, MSGL_INFO, "Audio decoders:", list);
+ talloc_free(list);
+ return M_OPT_EXIT;
+ }
+ if (strcmp(opt->name, "vd") == 0) {
+ struct mp_decoder_list *list = video_decoder_list();
+ mp_print_decoders(log, MSGL_INFO, "Video decoders:", list);
+ talloc_free(list);
+ return M_OPT_EXIT;
+ }
+ if (strcmp(opt->name, "audio-spdif") == 0) {
+ mp_info(log, "Choices: ac3,dts-hd,dts (and possibly more)\n");
+ return M_OPT_EXIT;
+ }
+ return 1;
+}
+
// Update cached values for main thread which require access to the decoder
// thread state. Must run on/locked with decoder thread.
static void update_cached_values(struct priv *p)
@@ -310,8 +385,6 @@ struct mp_decoder_list *audio_decoder_list(void)
static bool reinit_decoder(struct priv *p)
{
- struct MPOpts *opts = p->opt_cache->opts;
-
if (p->decoder)
talloc_free(p->decoder->f);
p->decoder = NULL;
@@ -329,11 +402,11 @@ static bool reinit_decoder(struct priv *p)
if (p->codec->type == STREAM_VIDEO) {
driver = &vd_lavc;
- user_list = opts->video_decoders;
+ user_list = p->opts->video_decoders;
fallback = "h264";
} else if (p->codec->type == STREAM_AUDIO) {
driver = &ad_lavc;
- user_list = opts->audio_decoders;
+ user_list = p->opts->audio_decoders;
fallback = "aac";
pthread_mutex_lock(&p->cache_lock);
@@ -342,7 +415,7 @@ static bool reinit_decoder(struct priv *p)
if (try_spdif && p->codec->codec) {
struct mp_decoder_list *spdif =
- select_spdif_codec(p->codec->codec, opts->audio_spdif);
+ select_spdif_codec(p->codec->codec, p->opts->audio_spdif);
if (spdif->num_entries) {
driver = &ad_spdif;
list = spdif;
@@ -472,7 +545,7 @@ static void fix_image_params(struct priv *p,
{
struct mp_image_params m = *params;
struct mp_codec_params *c = p->codec;
- struct MPOpts *opts = p->opt_cache->opts;
+ struct dec_wrapper_opts *opts = p->opts;
MP_VERBOSE(p, "Decoder format: %s\n", mp_image_params_to_str(params));
p->dec_format = *params;
@@ -642,14 +715,12 @@ done:
static void correct_video_pts(struct priv *p, struct mp_image *mpi)
{
- struct MPOpts *opts = p->opt_cache->opts;
-
mpi->pts *= p->play_dir;
- if (!opts->correct_pts || mpi->pts == MP_NOPTS_VALUE) {
+ if (!p->opts->correct_pts || mpi->pts == MP_NOPTS_VALUE) {
double fps = p->fps > 0 ? p->fps : 25;
- if (opts->correct_pts) {
+ if (p->opts->correct_pts) {
if (p->has_broken_decoded_pts <= 1) {
MP_WARN(p, "No video PTS! Making something up. Using "
"%f FPS.\n", fps);
@@ -841,7 +912,7 @@ static void enqueue_backward_frame(struct priv *p, struct mp_frame frame)
bool eof = frame.type == MP_FRAME_EOF;
if (!eof) {
- struct MPOpts *opts = p->opt_cache->opts;
+ struct dec_wrapper_opts *opts = p->opts;
uint64_t queue_size = 0;
switch (p->header->type) {
@@ -1064,8 +1135,8 @@ struct mp_decoder_wrapper *mp_decoder_wrapper_create(struct mp_filter *parent,
p->public.f = public_f;
pthread_mutex_init(&p->cache_lock, NULL);
- p->opt_cache = m_config_cache_alloc(p, public_f->global, &mp_opt_root);
- struct MPOpts *opts = p->opt_cache->opts;
+ p->opt_cache = m_config_cache_alloc(p, public_f->global, &dec_wrapper_conf);
+ p->opts = p->opt_cache->opts;
p->header = src;
p->codec = p->header->codec;
p->play_dir = 1;
@@ -1080,16 +1151,16 @@ struct mp_decoder_wrapper *mp_decoder_wrapper_create(struct mp_filter *parent,
MP_VERBOSE(p, "Container reported FPS: %f\n", p->fps);
- if (opts->force_fps) {
- p->fps = opts->force_fps;
+ if (p->opts->force_fps) {
+ p->fps = p->opts->force_fps;
MP_INFO(p, "FPS forced to %5.3f.\n", p->fps);
MP_INFO(p, "Use --no-correct-pts to force FPS based timing.\n");
}
- queue_opts = opts->vdec_queue_opts;
+ queue_opts = p->opts->vdec_queue_opts;
} else if (p->header->type == STREAM_AUDIO) {
p->log = mp_log_new(p, public_f->log, "!ad");
- queue_opts = opts->adec_queue_opts;
+ queue_opts = p->opts->adec_queue_opts;
} else {
goto error;
}
diff --git a/options/options.c b/options/options.c
index 8eab3598be..3eebc2e0df 100644
--- a/options/options.c
+++ b/options/options.c
@@ -437,8 +437,6 @@ static const m_option_t mp_opts[] = {
OPT_CHOICE("play-dir", play_dir, 0,
({"forward", 1}, {"+", 1}, {"backward", -1}, {"-", -1})),
- OPT_BYTE_SIZE("video-reversal-buffer", video_reverse_size, 0, 0, (size_t)-1),
- OPT_BYTE_SIZE("audio-reversal-buffer", audio_reverse_size, 0, 0, (size_t)-1),
OPT_FLAG("rebase-start-time", rebase_start_time, 0),
@@ -515,8 +513,6 @@ static const m_option_t mp_opts[] = {
// set A-V sync correction speed (0=disables it):
OPT_FLOATRANGE("mc", default_max_pts_correction, 0, 0, 100),
- // force video/audio rate:
- OPT_DOUBLE("fps", force_fps, CONF_MIN, .min = 0),
OPT_INTRANGE("audio-samplerate", force_srate, UPDATE_AUDIO, 0, 16*48000),
OPT_CHANNELS("audio-channels", audio_output_channels, UPDATE_AUDIO),
OPT_AUDIOFORMAT("audio-format", audio_output_format, UPDATE_AUDIO),
@@ -538,22 +534,10 @@ static const m_option_t mp_opts[] = {
OPT_SUBSTRUCT("", filter_opts, filter_conf, 0),
- OPT_STRING("ad", audio_decoders, 0),
- OPT_STRING("vd", video_decoders, 0),
-
- OPT_STRING("audio-spdif", audio_spdif, 0),
-
- OPT_ASPECT("video-aspect-override", movie_aspect, UPDATE_IMGPAR | M_OPT_RANGE,
- .min = -1, .max = 10),
- OPT_CHOICE("video-aspect-method", aspect_method, UPDATE_IMGPAR,
- ({"bitstream", 1}, {"container", 2})),
-
+ OPT_SUBSTRUCT("", dec_wrapper, dec_wrapper_conf, 0),
OPT_SUBSTRUCT("", vd_lavc_params, vd_lavc_conf, 0),
OPT_SUBSTRUCT("ad-lavc", ad_lavc_params, ad_lavc_conf, 0),
- OPT_SUBSTRUCT("vd-queue", vdec_queue_opts, vdec_queue_conf, 0),
- OPT_SUBSTRUCT("ad-queue", adec_queue_opts, adec_queue_conf, 0),
-
OPT_SUBSTRUCT("", demux_lavf, demux_lavf_conf, 0),
OPT_SUBSTRUCT("demuxer-rawaudio", demux_rawaudio, demux_rawaudio_conf, 0),
OPT_SUBSTRUCT("demuxer-rawvideo", demux_rawvideo, demux_rawvideo_conf, 0),
@@ -610,8 +594,6 @@ static const m_option_t mp_opts[] = {
OPT_STRING("title", wintitle, 0),
OPT_STRING("force-media-title", media_title, 0),
- OPT_CHOICE_OR_INT("video-rotate", video_rotate, UPDATE_IMGPAR, 0, 359,
- ({"no", -1})),
OPT_CHOICE_OR_INT("cursor-autohide", cursor_autohide_delay, 0,
0, 30000, ({"no", -1}, {"always", -2})),
@@ -674,7 +656,6 @@ static const m_option_t mp_opts[] = {
OPT_FLAG("merge-files", merge_files, 0),
// a-v sync stuff:
- OPT_FLAG("correct-pts", correct_pts, 0),
OPT_FLAG("initial-audio-sync", initial_audio_sync, 0),
OPT_CHOICE("video-sync", video_sync, 0,
({"audio", VS_DEFAULT},
@@ -925,8 +906,6 @@ static const m_option_t mp_opts[] = {
static const struct MPOpts mp_default_opts = {
.use_terminal = 1,
.msg_color = 1,
- .audio_decoders = NULL,
- .video_decoders = NULL,
.softvol_max = 130,
.softvol_volume = 100,
.softvol_mute = 0,
@@ -968,7 +947,6 @@ static const struct MPOpts mp_default_opts = {
.ab_loop_count = -1,
.edition_id = -1,
.default_max_pts_correction = -1,
- .correct_pts = 1,
.initial_audio_sync = 1,
.frame_dropping = 1,
.term_osd = 2,
@@ -991,15 +969,11 @@ static const struct MPOpts mp_default_opts = {
.audio_output_format = 0, // AF_FORMAT_UNKNOWN
.playback_speed = 1.,
.pitch_correction = 1,
- .movie_aspect = -1.,
- .aspect_method = 2,
.sub_auto = 0,
.audiofile_auto = -1,
.osd_bar_visible = 1,
.screenshot_template = "mpv-shot%n",
.play_dir = 1,
- .video_reverse_size = 1 * 1024 * 1024 * 1024,
- .audio_reverse_size = 64 * 1024 * 1024,
.audio_output_channels = {
.set = 1,
diff --git a/options/options.h b/options/options.h
index cf4025a20e..3a0663b6f8 100644
--- a/options/options.h
+++ b/options/options.h
@@ -172,12 +172,6 @@ typedef struct MPOpts {
int cursor_autohide_delay;
int cursor_autohide_fs;
- int video_rotate;
-
- char *audio_decoders;
- char *video_decoders;
- char *audio_spdif;
-
struct mp_subtitle_opts *subs_rend;
struct mp_sub_filter_opts *subs_filt;
struct mp_osd_render_opts *osd_rend;
@@ -207,7 +201,6 @@ typedef struct MPOpts {
int use_filedir_conf;
int hls_bitrate;
int edition_id;
- int correct_pts;
int initial_audio_sync;
int video_sync;
double sync_max_video_change;
@@ -266,8 +259,6 @@ typedef struct MPOpts {
int prefetch_open;
char *audio_demuxer_name;
char *sub_demuxer_name;
- int64_t video_reverse_size;
- int64_t audio_reverse_size;
int cache_pause;
int cache_pause_initial;
@@ -277,7 +268,6 @@ typedef struct MPOpts {
char *screenshot_template;
char *screenshot_directory;
- double force_fps;
int index_mode;
struct m_channels audio_output_channels;
@@ -288,10 +278,7 @@ typedef struct MPOpts {
struct m_obj_settings *vf_settings, *vf_defs;
struct m_obj_settings *af_settings, *af_defs;
struct filter_opts *filter_opts;
- float movie_aspect;
- int aspect_method;
- struct dec_queue_opts *vdec_queue_opts;
- struct dec_queue_opts *adec_queue_opts;
+ struct dec_wrapper_opts *dec_wrapper;
char **sub_name;
char **sub_paths;
char **audiofile_paths;
@@ -375,8 +362,7 @@ extern const struct m_sub_options mp_osd_render_sub_opts;
extern const struct m_sub_options filter_conf;
extern const struct m_sub_options resample_conf;
extern const struct m_sub_options stream_conf;
-extern const struct m_sub_options vdec_queue_conf;
-extern const struct m_sub_options adec_queue_conf;
+extern const struct m_sub_options dec_wrapper_conf;
extern const struct m_sub_options mp_opt_root;
#endif
diff --git a/player/command.c b/player/command.c
index fb28b285e1..2ac6add009 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2565,7 +2565,7 @@ static int mp_property_aspect(void *ctx, struct m_property *prop,
skip_warn: ;
- float aspect = mpctx->opts->movie_aspect;
+ float aspect = *(float *)opt->data;
if (mpctx->vo_chain && aspect <= 0) {
struct mp_image_params *params = &mpctx->vo_chain->filter->input_params;
if (params && params->p_w > 0 && params->p_h > 0) {
@@ -2586,7 +2586,7 @@ skip_warn: ;
*(struct m_option *)arg = *(opt->opt);
return M_PROPERTY_OK;
case M_PROPERTY_PRINT: {
- if (mpctx->opts->movie_aspect < 0) {
+ if (aspect < 0) {
*(char **)arg = talloc_asprintf(NULL, "%.3f (original)", aspect);
return M_PROPERTY_OK;
}
diff --git a/player/main.c b/player/main.c
index 6cb56ef601..9dbd160a70 100644
--- a/player/main.c
+++ b/player/main.c
@@ -201,22 +201,6 @@ static bool handle_help_options(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
struct mp_log *log = mpctx->log;
- if (opts->audio_decoders && strcmp(opts->audio_decoders, "help") == 0) {
- struct mp_decoder_list *list = audio_decoder_list();
- mp_print_decoders(log, MSGL_INFO, "Audio decoders:", list);
- talloc_free(list);
- return true;
- }
- if (opts->audio_spdif && strcmp(opts->audio_spdif, "help") == 0) {
- MP_INFO(mpctx, "Choices: ac3,dts-hd,dts (and possibly more)\n");
- return true;
- }
- if (opts->video_decoders && strcmp(opts->video_decoders, "help") == 0) {
- struct mp_decoder_list *list = video_decoder_list();
- mp_print_decoders(log, MSGL_INFO, "Video decoders:", list);
- talloc_free(list);
- return true;
- }
if ((opts->demuxer_name && strcmp(opts->demuxer_name, "help") == 0) ||
(opts->audio_demuxer_name && strcmp(opts->audio_demuxer_name, "help") == 0) ||
(opts->sub_demuxer_name && strcmp(opts->sub_demuxer_name, "help") == 0)) {
diff --git a/player/playloop.c b/player/playloop.c
index 113feea770..6fcd986ebd 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -289,8 +289,7 @@ static void mp_seek(MPContext *mpctx, struct seek_params seek)
double demux_pts = seek_pts;
- bool hr_seek = (opts->correct_pts && seek.exact != MPSEEK_KEYFRAME &&
- seek_pts != MP_NOPTS_VALUE) &&
+ bool hr_seek = seek.exact != MPSEEK_KEYFRAME && seek_pts != MP_NOPTS_VALUE &&
(seek.exact >= MPSEEK_EXACT || opts->hr_seek == 1 ||
(opts->hr_seek >= 0 && seek.type == MPSEEK_ABSOLUTE) ||
(opts->hr_seek == 2 && (!mpctx->vo_chain || mpctx->vo_chain->is_sparse)));