summaryrefslogtreecommitdiffstats
path: root/core/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-02-09 15:15:19 +0100
committerwm4 <wm4@nowhere>2013-02-10 17:25:56 +0100
commit4d016a92c876e98797c362d05468bf27d5a85414 (patch)
tree8959f0e63885dee7c5d25e4c7f8b0ac4cea7fd69 /core/command.c
parentbb8da972052beef22b2dff2ba1003eff5cc1a797 (diff)
downloadmpv-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/command.c')
-rw-r--r--core/command.c62
1 files changed, 10 insertions, 52 deletions
diff --git a/core/command.c b/core/command.c
index 90a5dc66f5..7b9f374e0d 100644
--- a/core/command.c
+++ b/core/command.c
@@ -30,7 +30,6 @@
#include "stream/stream.h"
#include "demux/demux.h"
#include "demux/stheader.h"
-#include "codec-cfg.h"
#include "mplayer.h"
#include "playlist.h"
#include "playlist_parser.h"
@@ -603,22 +602,16 @@ static int mp_property_audio_delay(m_option_t *prop, int action,
static int mp_property_audio_format(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- if (!mpctx->sh_audio)
- return M_PROPERTY_UNAVAILABLE;
- return m_property_int_ro(prop, action, arg, mpctx->sh_audio->format);
+ const char *c = mpctx->sh_audio ? mpctx->sh_audio->gsh->codec : NULL;
+ return m_property_strdup_ro(prop, action, arg, c);
}
/// Audio codec name (RO)
static int mp_property_audio_codec(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- if (!mpctx->sh_audio || !mpctx->sh_audio->codec)
- return M_PROPERTY_UNAVAILABLE;
- if (action == M_PROPERTY_GET) {
- *(char **)arg = talloc_strdup(NULL, mpctx->sh_audio->codec->name);
- return M_PROPERTY_OK;
- }
- return M_PROPERTY_NOT_IMPLEMENTED;
+ const char *c = mpctx->sh_audio ? mpctx->sh_audio->gsh->decoder_desc : NULL;
+ return m_property_strdup_ro(prop, action, arg, c);
}
/// Audio bitrate (RO)
@@ -1103,51 +1096,16 @@ static int mp_property_vsync(m_option_t *prop, int action, void *arg,
static int mp_property_video_format(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- char *meta;
- if (!mpctx->sh_video)
- return M_PROPERTY_UNAVAILABLE;
- switch (action) {
- case M_PROPERTY_PRINT:
- switch (mpctx->sh_video->format) {
- case 0x10000001:
- meta = talloc_strdup(NULL, "mpeg1");
- break;
- case 0x10000002:
- meta = talloc_strdup(NULL, "mpeg2");
- break;
- case 0x10000004:
- meta = talloc_strdup(NULL, "mpeg4");
- break;
- case 0x10000005:
- meta = talloc_strdup(NULL, "h264");
- break;
- default:
- if (mpctx->sh_video->format >= 0x20202020) {
- meta = talloc_asprintf(NULL, "%.4s",
- (char *) &mpctx->sh_video->format);
- } else
- meta = talloc_asprintf(NULL, "0x%08X", mpctx->sh_video->format);
- }
- *(char **)arg = meta;
- return M_PROPERTY_OK;
- case M_PROPERTY_GET:
- *(int *)arg = mpctx->sh_video->format;
- return M_PROPERTY_OK;
- }
- return M_PROPERTY_NOT_IMPLEMENTED;
+ const char *c = mpctx->sh_video ? mpctx->sh_video->gsh->codec : NULL;
+ return m_property_strdup_ro(prop, action, arg, c);
}
/// Video codec name (RO)
static int mp_property_video_codec(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- if (!mpctx->sh_video || !mpctx->sh_video->codec)
- return M_PROPERTY_UNAVAILABLE;
- if (action == M_PROPERTY_GET) {
- *(char **)arg = talloc_strdup(NULL, mpctx->sh_video->codec->name);
- return M_PROPERTY_OK;
- }
- return M_PROPERTY_NOT_IMPLEMENTED;
+ const char *c = mpctx->sh_video ? mpctx->sh_video->gsh->decoder_desc : NULL;
+ return m_property_strdup_ro(prop, action, arg, c);
}
@@ -1395,7 +1353,7 @@ static const m_option_t mp_properties[] = {
{ "mute", mp_property_mute, CONF_TYPE_FLAG,
M_OPT_RANGE, 0, 1, NULL },
M_OPTION_PROPERTY_CUSTOM("audio-delay", mp_property_audio_delay),
- { "audio-format", mp_property_audio_format, CONF_TYPE_INT,
+ { "audio-format", mp_property_audio_format, CONF_TYPE_STRING,
0, 0, 0, NULL },
{ "audio-codec", mp_property_audio_codec, CONF_TYPE_STRING,
0, 0, 0, NULL },
@@ -1435,7 +1393,7 @@ static const m_option_t mp_properties[] = {
.offset = offsetof(struct MPOpts, vo_gamma_hue)),
M_OPTION_PROPERTY_CUSTOM("panscan", mp_property_panscan),
M_OPTION_PROPERTY_CUSTOM_("vsync", mp_property_vsync),
- { "video-format", mp_property_video_format, CONF_TYPE_INT,
+ { "video-format", mp_property_video_format, CONF_TYPE_STRING,
0, 0, 0, NULL },
{ "video-codec", mp_property_video_codec, CONF_TYPE_STRING,
0, 0, 0, NULL },