1
mirror of https://github.com/mpv-player/mpv synced 2025-01-20 21:07:29 +01:00

demux_mf: map to codecs directly

Instead of going through FourCCs and codec_tags.c.
This commit is contained in:
wm4 2013-02-24 16:31:43 +01:00
parent bab429870e
commit 10ed11eefa
2 changed files with 35 additions and 39 deletions

View File

@ -290,9 +290,6 @@ static const struct mp_codec_tag mp_video_codec_tags[] = {
{MKTAG('M', 'V', 'I', '1'), "motionpixels"}, {MKTAG('M', 'V', 'I', '1'), "motionpixels"},
{MKTAG('M', 'D', 'E', 'C'), "mdec"}, {MKTAG('M', 'D', 'E', 'C'), "mdec"},
{MKTAG('N', 'U', 'V', '1'), "nuv"}, {MKTAG('N', 'U', 'V', '1'), "nuv"},
{MKTAG('p', 't', 'x', ' '), "ptx"},
{MKTAG('S', 'G', 'I', '1'), "sgi"},
{MKTAG('s', 'u', 'n', ' '), "sunrast"},
{MKTAG('F', 'L', 'I', 'C'), "flic"}, {MKTAG('F', 'L', 'I', 'C'), "flic"},
{MKTAG('R', 'o', 'Q', 'V'), "roq"}, {MKTAG('R', 'o', 'Q', 'V'), "roq"},
{MKTAG('A', 'M', 'V', 'V'), "amv"}, {MKTAG('A', 'M', 'V', 'V'), "amv"},

View File

@ -98,42 +98,42 @@ static int demux_mf_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds){
static const struct { static const struct {
const char *type; const char *type;
uint32_t format; const char *codec;
} type2format[] = { } type2format[] = {
{ "bmp", mmioFOURCC('b', 'm', 'p', ' ') }, { "bmp", "bmp" },
{ "dpx", mmioFOURCC('d', 'p', 'x', ' ') }, { "dpx", "dpx" },
{ "j2c", mmioFOURCC('M', 'J', '2', 'C') }, { "j2c", "jpeg2000" },
{ "j2k", mmioFOURCC('M', 'J', '2', 'C') }, { "j2k", "jpeg2000" },
{ "jp2", mmioFOURCC('M', 'J', '2', 'C') }, { "jp2", "jpeg2000" },
{ "jpc", mmioFOURCC('M', 'J', '2', 'C') }, { "jpc", "jpeg2000" },
{ "jpeg", mmioFOURCC('I', 'J', 'P', 'G') }, { "jpeg", "mjpeg" },
{ "jpg", mmioFOURCC('I', 'J', 'P', 'G') }, { "jpg", "mjpeg" },
{ "jps", mmioFOURCC('I', 'J', 'P', 'G') }, { "jps", "mjpeg" },
{ "jls", mmioFOURCC('I', 'J', 'P', 'G') }, { "jls", "ljpeg" },
{ "thm", mmioFOURCC('I', 'J', 'P', 'G') }, { "thm", "mjpeg" },
{ "db", mmioFOURCC('I', 'J', 'P', 'G') }, { "db", "mjpeg" },
{ "pcx", mmioFOURCC('p', 'c', 'x', ' ') }, { "pcx", "pcx" },
{ "png", mmioFOURCC('M', 'P', 'N', 'G') }, { "png", "png" },
{ "pns", mmioFOURCC('M', 'P', 'N', 'G') }, { "pns", "png" },
{ "ptx", mmioFOURCC('p', 't', 'x', ' ') }, { "ptx", "ptx" },
{ "tga", mmioFOURCC('M', 'T', 'G', 'A') }, { "tga", "targa" },
{ "tif", mmioFOURCC('t', 'i', 'f', 'f') }, { "tif", "tiff" },
{ "tiff", mmioFOURCC('t', 'i', 'f', 'f') }, { "tiff", "tiff" },
{ "sgi", mmioFOURCC('S', 'G', 'I', '1') }, { "sgi", "sgi" },
{ "sun", mmioFOURCC('s', 'u', 'n', ' ') }, { "sun", "sunrast" },
{ "ras", mmioFOURCC('s', 'u', 'n', ' ') }, { "ras", "sunrast" },
{ "ra", mmioFOURCC('s', 'u', 'n', ' ') }, { "ra", "sunrast" },
{ "im1", mmioFOURCC('s', 'u', 'n', ' ') }, { "im1", "sunrast" },
{ "im8", mmioFOURCC('s', 'u', 'n', ' ') }, { "im8", "sunrast" },
{ "im24", mmioFOURCC('s', 'u', 'n', ' ') }, { "im24", "sunrast" },
{ "sunras", mmioFOURCC('s', 'u', 'n', ' ') }, { "sunras", "sunrast" },
{ NULL, 0 } {0}
}; };
static uint32_t probe_format(mf_t *mf) static const char *probe_format(mf_t *mf)
{ {
if (mf->nr_of_files < 1) if (mf->nr_of_files < 1)
return 0; return NULL;
char *type = mf_type; char *type = mf_type;
if (!type || !type[0]) { if (!type || !type[0]) {
char *p = strrchr(mf->names[0], '.'); char *p = strrchr(mf->names[0], '.');
@ -141,13 +141,13 @@ static uint32_t probe_format(mf_t *mf)
type = p + 1; type = p + 1;
} }
if (!type || !type[0]) if (!type || !type[0])
return 0; return NULL;
int i; int i;
for (i = 0; type2format[i].type; i++) { for (i = 0; type2format[i].type; i++) {
if (strcasecmp(type, type2format[i].type) == 0) if (strcasecmp(type, type2format[i].type) == 0)
break; break;
} }
return type2format[i].format; return type2format[i].codec;
} }
static mf_t *open_mf(demuxer_t *demuxer) static mf_t *open_mf(demuxer_t *demuxer)
@ -193,12 +193,11 @@ static demuxer_t* demux_open_mf(demuxer_t* demuxer){
// (even though new_sh_video() ought to take care of it) // (even though new_sh_video() ought to take care of it)
demuxer->video->sh = sh_video; demuxer->video->sh = sh_video;
sh_video->format = probe_format(mf); sh_video->gsh->codec = probe_format(mf);
if (!sh_video->format) { if (!sh_video->gsh->codec) {
mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] file type was not set! (try -mf type=ext)\n" ); mp_msg(MSGT_DEMUX, MSGL_INFO, "[demux_mf] file type was not set! (try -mf type=ext)\n" );
goto error; goto error;
} }
mp_set_video_codec_from_tag(sh_video);
// make sure that the video demuxer stream header knows about its // make sure that the video demuxer stream header knows about its
// parent video demuxer stream (this is getting wacky), or else // parent video demuxer stream (this is getting wacky), or else