From dc2a4863af9b0e587ac4ec3e2096639098e99a8f Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 17 May 2012 03:31:11 +0300 Subject: options: support parsing values into substructs Add an alternate mode for option parser objects (struct m_config) which is not inherently tied to any particular instance of an option value struct. Instead, this type or parsers can be used to initialize defaults in or parse values into a struct given as a parameter. They do not have the save slot functionality used for main player configuration. The new functionality will be used to replace the separate subopt_helper.c parsing code that is currently used to parse per-object suboptions in VOs etc. Previously, option default values were handled by initializing them in external code before creating a parser. This initialization was done with constants even for dynamically-allocated types like strings. Because trying to free a pointer to a constant would cause a crash when trying to replace the default with another value, parser initialization code then replaced all the original defaults with dynamically-allocated copies. This replace-with-copy behavior is no longer supported for new-style options; instead the option definition itself may contain a default value (new OPTDEF macros), and the new function m_config_initialize() is used to set all options to their default values. Convert the existing initialized dynamically allocated options in main config (the string options --dumpfile, --term-osd-esc, --input=conf) to use this. Other non-dynamic ones could be later converted to use this style of initialization too. There's currently no public call to free all dynamically allocated options in a given option struct because I intend to use talloc functionality for that (make them children of the struct and free with it). --- mplayer.c | 1 + 1 file changed, 1 insertion(+) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 5aa6f4cde0..5a2e7be1b3 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3942,6 +3942,7 @@ int main(int argc, char *argv[]) m_config_register_options(mpctx->mconfig, mplayer_opts); m_config_register_options(mpctx->mconfig, common_opts); mp_input_register_options(mpctx->mconfig); + m_config_initialize(mpctx->mconfig, opts); // Preparse the command line m_config_preparse_command_line(mpctx->mconfig, argc, argv, &verbose); -- cgit v1.2.3 From 65b24e46a1c2f26688458cf16a11733e96da0f22 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 17 Jul 2012 23:18:06 +0300 Subject: core: fix attempt to get audio pts without audio written_audio_pts() can be called even if no audio track is active (at least through get_current_time() when there's no known video PTS). This triggered a crash due to NULL dereference. Add a check to return MP_NOPTS_VALUE if no audio track exists. Also remove a questionable update_osd_msg() call from per-file initialization code. The call was at a point where an audio track might be selected but not properly initialized, possibly also causing a crash if update_osd_msg() queries current position. I don't see any reason why the call would have been needed; it should get called anyway before OSD contents are actually used for the new file. --- mplayer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 5a2e7be1b3..2a87de2c2c 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1846,6 +1846,8 @@ init_error: static double written_audio_pts(struct MPContext *mpctx) { sh_audio_t *sh_audio = mpctx->sh_audio; + if (!sh_audio) + return MP_NOPTS_VALUE; demux_stream_t *d_audio = mpctx->d_audio; // first calculate the end pts of audio that has been output by decoder double a_pts = sh_audio->pts; @@ -4817,10 +4819,8 @@ goto_enable_cache: if (verbose) opts->term_osd = 0; - // Make sure old OSD does not stay around, - // e.g. with -fixed-vo and same-resolution files + // Make sure old OSD does not stay around clear_osd_msgs(); - update_osd_msg(mpctx); //================ SETUP AUDIO ========================== -- cgit v1.2.3 From 5f3c3f8c32d20405a2caf7de66aa1ea7f513d4d2 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 24 Jul 2012 09:01:47 +0300 Subject: video, audio: use lavc decoders without codecs.conf entries Add support for using libavcodec decoders that do not have entries in codecs.conf. This is currently only used with demux_lavf, and the codec selection is based on codec_id returned by libavformat. Also modify codec-related terminal output somewhat to make it use information from libavcodec and avoid excessively long default output. The new any-lavc-codec support is implemented with codecs.conf entries that invoke vd_ffmpeg/ad_ffmpeg without directly specifying any libavcodec codec name. In this mode, the decoders now instead select the libavcodec codec based on codec_id previously set by demux_lavf (if any). These new "generic" codecs.conf entries specify "status buggy", so that they're tried after any specific entries with higher-priority status. Add new directive "anyinput" to codecs.conf syntax. This means the entry will always match regardless of fourcc. This is used for the above new codecs.conf entries (so the driver always gets to decide whether to accept the input, and will fail init() if it can't find a suitable codec in libavcodec). Remove parsing support for the obsolete codecs.conf directive "cpuflags". This directive has not had any effect and has not been used in default codecs.conf since many years ago. Shorten codec-related terminal output. When using libavcodec decoders, show the libavcodec long_name field rather than codecs.conf "info" field as the name of the codec. Stop showing the codecs.conf entry name and "vfm/afm" name by default, as these are rarely needed; they're now in verbose output only. Show "VIDEO:" line at VO initialization rather than at demuxer open. This didn't really belong in demuxer code; the new location may show more accurate values (known after decoder has been opened) and works right if video track is changed after initial demuxer open. The vd.c changes (primarily done for terminal output changes) remove round-to-even behavior from code setting dimensions based on aspect ratio. I hope nothing depended on this; at least the even values were not consistently guaranteed anyway, as the rounding code did not run if the video file did not specify a nonzero aspect value. --- mplayer.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 2a87de2c2c..934ba3a819 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1770,14 +1770,11 @@ void reinit_audio_chain(struct MPContext *mpctx) } if (!(mpctx->initialized_flags & INITIALIZED_ACODEC)) { current_module = "init_audio_codec"; - mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n"); if (!init_best_audio_codec(mpctx->sh_audio, audio_codec_list, audio_fm_list)) goto init_error; mpctx->initialized_flags |= INITIALIZED_ACODEC; - mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n"); } - current_module = "af_preinit"; if (!(mpctx->initialized_flags & INITIALIZED_AO)) { mpctx->initialized_flags |= INITIALIZED_AO; @@ -2696,9 +2693,7 @@ int reinit_video_chain(struct MPContext *mpctx) current_module = "init_video_codec"; - mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n"); init_best_video_codec(sh_video, video_codec_list, video_fm_list); - mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n"); if (!sh_video->initialized) { if (!opts->fixed_vo) -- cgit v1.2.3 From 8079f4ff821aa811de449f08dfdba777e8dd0397 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 25 Jul 2012 00:23:27 +0300 Subject: demux, vd_ffmpeg: fix demux keyframe flag, set AV_PKT_FLAG_KEY There was some confusion about the "flags" field in demuxer packets. Demuxers set it to either 1 or 0x10 to indicate a keyframe (and the field was not used to indicate anything else). This didn't cause visible problems because nothing read the value. Replace the "flags" field with a boolean "keyframe" field. Set AV_PKT_FLAG_KEY based on this field in packets fed to libavcodec video decoders (looks like PNG and ZeroCodec are the only ones which depend on values from demuxer; previously this was hardcoded to true for PNG). Make demux_mf set the keyframe field in every packet. This matters for PNG files now that the demuxer flag is forwarded to libavcodec. Fix logic setting the field in demux_mkv. It had probably not been updated when adding SimpleBlock support. This probably makes no difference for any current practical use. --- mplayer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 934ba3a819..fe2e509fb4 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2785,8 +2785,8 @@ static double update_video_nocorrect_pts(struct MPContext *mpctx) decoded_frame = mp_dvdnav_restore_smpi(mpctx, &in_size, &packet, NULL); if (in_size >= 0 && !decoded_frame) #endif - decoded_frame = decode_video(sh_video, NULL, packet, in_size, - framedrop_type, sh_video->pts); + decoded_frame = decode_video(sh_video, sh_video->ds->current, packet, + in_size, framedrop_type, sh_video->pts); #ifdef CONFIG_DVDNAV // Save last still frame for future display mp_dvdnav_save_smpi(mpctx, in_size, packet, decoded_frame); -- cgit v1.2.3