diff options
author | wm4 <wm4@nowhere> | 2013-02-09 15:15:19 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-02-10 17:25:56 +0100 |
commit | 4d016a92c876e98797c362d05468bf27d5a85414 (patch) | |
tree | 8959f0e63885dee7c5d25e4c7f8b0ac4cea7fd69 /core/mplayer.c | |
parent | bb8da972052beef22b2dff2ba1003eff5cc1a797 (diff) | |
download | mpv-4d016a92c876e98797c362d05468bf27d5a85414.tar.bz2 mpv-4d016a92c876e98797c362d05468bf27d5a85414.tar.xz |
core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)
The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)
demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.
Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.
Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
Diffstat (limited to 'core/mplayer.c')
-rw-r--r-- | core/mplayer.c | 95 |
1 files changed, 18 insertions, 77 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index 5dc719d97f..baee6482b1 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -86,7 +86,7 @@ #include "audio/out/ao.h" -#include "core/codec-cfg.h" +#include "core/codecs.h" #include "sub/spudec.h" @@ -203,12 +203,6 @@ static int drop_frame_cnt; // total number of dropped frames static int64_t seek_to_byte; static double step_sec; -// codecs: -char **audio_codec_list; // override audio codec -char **video_codec_list; // override video codec -char **audio_fm_list; // override audio codec family -char **video_fm_list; // override video codec family - // this dvdsub_id was selected via slang // use this to allow dvdnav to follow -slang across stream resets, // in particular the subtitle ID for a language changes @@ -314,37 +308,12 @@ static void print_stream(struct MPContext *mpctx, struct track *t, int id) mp_msg(MSGT_CPLAYER, MSGL_INFO, " [P]"); if (t->title) mp_msg(MSGT_CPLAYER, MSGL_INFO, " '%s'", t->title); - mp_msg(MSGT_CPLAYER, MSGL_INFO, " ("); - if (s && s->common_header->format) { - int format = s->common_header->format; - // not sure about endian crap - char name[sizeof(format) + 1] = {0}; - memcpy(name, &format, sizeof(format)); - bool ok = true; - for (int n = 0; name[n]; n++) { - if ((name[n] < 32 || name[n] >= 128) && name[n] != 0) - ok = false; - } - if (ok && strlen(name) > 0) { - mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", name); - } else { - mp_msg(MSGT_CPLAYER, MSGL_INFO, "%#x", format); - } - } else if (s && t->type == STREAM_SUB) { - char t = s->sub->type; - const char *name = NULL; - switch (t) { - case 't': name = "SRT"; break; - case 'a': name = "ASS"; break; - case 'v': name = "VobSub"; break; - } - if (!name) - name = (char[2]){t, '\0'}; - mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", name); - } - if (s && s->common_header->demuxer_codecname) - mp_msg(MSGT_CPLAYER, MSGL_INFO, "/%s", s->common_header->demuxer_codecname); - mp_msg(MSGT_CPLAYER, MSGL_INFO, ")"); + const char *codec = s ? s->codec : NULL; + if (s && t->type == STREAM_SUB) + codec = sh_sub_type2str(s->sub->type); + if (t->sh_sub) // external subs hack + codec = sh_sub_type2str(t->sh_sub->type); + mp_msg(MSGT_CPLAYER, MSGL_INFO, " (%s)", codec ? codec : "<unknown>"); if (t->is_external) mp_msg(MSGT_CPLAYER, MSGL_INFO, " (external)"); mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); @@ -1590,7 +1559,7 @@ void reinit_audio_chain(struct MPContext *mpctx) goto no_audio; } if (!(mpctx->initialized_flags & INITIALIZED_ACODEC)) { - if (!init_best_audio_codec(mpctx->sh_audio, audio_codec_list, audio_fm_list)) + if (!init_best_audio_codec(mpctx->sh_audio, opts->audio_decoders)) goto init_error; mpctx->initialized_flags |= INITIALIZED_ACODEC; } @@ -2414,17 +2383,13 @@ int reinit_video_chain(struct MPContext *mpctx) mpctx->osd->render_subs_in_filter = vf->control(vf, VFCTRL_INIT_OSD, NULL) == VO_TRUE; - init_best_video_codec(sh_video, video_codec_list, video_fm_list); + init_best_video_codec(sh_video, opts->video_decoders); if (!sh_video->initialized) goto err_out; mpctx->initialized_flags |= INITIALIZED_VCODEC; - if (sh_video->codec) - mp_msg(MSGT_IDENTIFY, MSGL_INFO, - "ID_VIDEO_CODEC=%s\n", sh_video->codec->name); - sh_video->last_pts = MP_NOPTS_VALUE; sh_video->num_buffered_pts = 0; sh_video->next_frame_time = 0; @@ -4261,33 +4226,21 @@ static bool handle_help_options(struct MPContext *mpctx) list_audio_out(); opt_exit = 1; } - if (audio_codec_list && strcmp(audio_codec_list[0], "help") == 0) { - mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available audio codecs:\n"); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_CODECS\n"); - list_codecs(1); - mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); + if (opts->audio_decoders && strcmp(opts->audio_decoders, "help") == 0) { + struct mp_decoder_list *list = mp_audio_decoder_list(); + mp_print_decoders(MSGT_CPLAYER, MSGL_INFO, "Audio decoders:", list); + talloc_free(list); opt_exit = 1; } - if (video_codec_list && strcmp(video_codec_list[0], "help") == 0) { - mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available video codecs:\n"); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_CODECS\n"); - list_codecs(0); - mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); - opt_exit = 1; - } - if (video_fm_list && strcmp(video_fm_list[0], "help") == 0) { - vfm_help(); - mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); - opt_exit = 1; - } - if (audio_fm_list && strcmp(audio_fm_list[0], "help") == 0) { - afm_help(); - mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); + if (opts->video_decoders && strcmp(opts->video_decoders, "help") == 0) { + struct mp_decoder_list *list = mp_video_decoder_list(); + mp_print_decoders(MSGT_CPLAYER, MSGL_INFO, "Video decoders:", list); + talloc_free(list); opt_exit = 1; } if (af_cfg.list && strcmp(af_cfg.list[0], "help") == 0) { af_help(); - printf("\n"); + mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); opt_exit = 1; } #ifdef CONFIG_X11 @@ -4315,15 +4268,6 @@ static bool handle_help_options(struct MPContext *mpctx) return opt_exit; } -static bool load_codecs_conf(struct MPContext *mpctx) -{ - /* Check codecs.conf. */ - if (mpctx->opts.codecs_file && parse_codec_cfg(mpctx->opts.codecs_file)) - return true; - mp_tmsg(MSGT_CPLAYER, MSGL_V, "Using built-in default codecs.conf.\n"); - return parse_codec_cfg(NULL); -} - #ifdef PTW32_STATIC_LIB static void detach_ptw32(void) { @@ -4415,9 +4359,6 @@ int main(int argc, char *argv[]) exit_player(mpctx, EXIT_ERROR, 1); } - if (!load_codecs_conf(mpctx)) - exit_player(mpctx, EXIT_ERROR, 1); - if (handle_help_options(mpctx)) exit_player(mpctx, EXIT_NONE, 1); |