From fd88fb70aff630d4d6a861c02c63aeeca5e8f3ca Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 13 Jun 2015 21:59:04 +0200 Subject: demux_mkv: remove FourCCs from video codec handling Inherited from MPlayer times, we used FourCCs to identify video codecs. This was later changed to libavcodec codec names (which made life a whole lot simpler). But demux_mkv still uses FourCCs a lot. Change this for video. It's pretty simple, because some preparation was done in the past. We just have to replace some "internal" FourCCs with different handling. One potentially complicated issue is that there is no natural way to set the sh->format (AVCodecContext.codec_tag) field anymore. Most decoders do not need it, though mjpeg is an exception. Note that the AVI compatibility code still requires codec mappings, but these are provided by FFmpeg. Also, the audio code is not changed. For the MKV_V_MPEG2 -> mpeg1video thing see next commit. --- demux/codec_tags.c | 13 ------------- demux/demux_mkv.c | 53 +++++++++++++++++++++++++++-------------------------- 2 files changed, 27 insertions(+), 39 deletions(-) (limited to 'demux') diff --git a/demux/codec_tags.c b/demux/codec_tags.c index fd67933fbc..2d444dbc7c 100644 --- a/demux/codec_tags.c +++ b/demux/codec_tags.c @@ -30,13 +30,6 @@ struct mp_codec_tag { static const struct mp_codec_tag mp_codec_tags[] = { // Made-up tags used by demux_mkv.c to map codecs. // (This is a leftover from MPlayer's codecs.conf mechanism.) - {MKTAG('p', 'r', '0', '0'), "prores"}, - {MKTAG('H', 'E', 'V', 'C'), "hevc"}, - {MKTAG('R', 'V', '2', '0'), "rv20"}, - {MKTAG('R', 'V', '3', '0'), "rv30"}, - {MKTAG('R', 'V', '4', '0'), "rv40"}, - {MKTAG('R', 'V', '1', '0'), "rv10"}, - {MKTAG('R', 'V', '1', '3'), "rv10"}, {MKTAG('E', 'A', 'C', '3'), "eac3"}, {MKTAG('M', 'P', '4', 'A'), "aac"}, // also the QT tag {MKTAG('v', 'r', 'b', 's'), "vorbis"}, @@ -51,12 +44,6 @@ static const struct mp_codec_tag mp_codec_tags[] = { {MKTAG('d', 'n', 'e', 't'), "ac3"}, {MKTAG('s', 'i', 'p', 'r'), "sipr"}, {MKTAG('T', 'T', 'A', '1'), "tta"}, - // Fringe codecs, occur in the wild, but not mapped in FFmpeg. - {MKTAG('B', 'I', 'K', 'b'), "binkvideo"}, - {MKTAG('B', 'I', 'K', 'f'), "binkvideo"}, - {MKTAG('B', 'I', 'K', 'g'), "binkvideo"}, - {MKTAG('B', 'I', 'K', 'h'), "binkvideo"}, - {MKTAG('B', 'I', 'K', 'i'), "binkvideo"}, {0} }; diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 7169f2c32a..41dc534f0d 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1194,24 +1194,24 @@ static void display_create_tracks(demuxer_t *demuxer) typedef struct { char *id; - int fourcc; + const char *codec; int extradata; } videocodec_info_t; static const videocodec_info_t vinfo[] = { - {MKV_V_MJPEG, MP_FOURCC('m', 'j', 'p', 'g'), 1}, - {MKV_V_MPEG1, MP_FOURCC('m', 'p', 'g', '1'), 0}, - {MKV_V_MPEG2, MP_FOURCC('m', 'p', 'g', '2'), 0}, - {MKV_V_MPEG4_SP, MP_FOURCC('m', 'p', '4', 'v'), 1}, - {MKV_V_MPEG4_ASP, MP_FOURCC('m', 'p', '4', 'v'), 1}, - {MKV_V_MPEG4_AP, MP_FOURCC('m', 'p', '4', 'v'), 1}, - {MKV_V_MPEG4_AVC, MP_FOURCC('a', 'v', 'c', '1'), 1}, - {MKV_V_THEORA, MP_FOURCC('t', 'h', 'e', 'o'), 1}, - {MKV_V_VP8, MP_FOURCC('V', 'P', '8', '0'), 0}, - {MKV_V_VP9, MP_FOURCC('V', 'P', '9', '0'), 0}, - {MKV_V_DIRAC, MP_FOURCC('d', 'r', 'a', 'c'), 0}, - {MKV_V_PRORES, MP_FOURCC('p', 'r', '0', '0'), 0}, - {MKV_V_HEVC, MP_FOURCC('H', 'E', 'V', 'C'), 1}, + {MKV_V_MJPEG, "mjpeg", 1}, + {MKV_V_MPEG1, "mpeg1video", 0}, + {MKV_V_MPEG2, "mpeg1video", 0}, + {MKV_V_MPEG4_SP, "mpeg4", 1}, + {MKV_V_MPEG4_ASP, "mpeg4", 1}, + {MKV_V_MPEG4_AP, "mpeg4", 1}, + {MKV_V_MPEG4_AVC, "h264", 1}, + {MKV_V_THEORA, "theora", 1}, + {MKV_V_VP8, "vp8", 0}, + {MKV_V_VP9, "vp9", 0}, + {MKV_V_DIRAC, "dirac", 0}, + {MKV_V_PRORES, "prores", 0}, + {MKV_V_HEVC, "hevc", 1}, {0} }; @@ -1253,23 +1253,23 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track) || !strcmp(track->codec_id, MKV_V_REALV40))) { unsigned char *src; - uint32_t type2; unsigned int cnt; src = (uint8_t *) track->private_data + RVPROPERTIES_SIZE; cnt = track->private_size - RVPROPERTIES_SIZE; - type2 = AV_RB32(src - 4); - if (type2 == 0x10003000 || type2 == 0x10003001) - sh->format = MP_FOURCC('R', 'V', '1', '3'); - else - sh->format = MP_FOURCC('R', 'V', track->codec_id[9], '0'); + uint32_t t2 = AV_RB32(src - 4); + switch (t2 == 0x10003000 || t2 == 0x10003001 ? '1' : track->codec_id[9]) { + case '1': sh->codec = "rv10"; break; + case '2': sh->codec = "rv20"; break; + case '3': sh->codec = "rv30"; break; + case '4': sh->codec = "rv40"; break; + } // copy type1 and type2 info from rv properties extradata_size = cnt + 8; extradata = src - 8; track->parse = true; track->parse_timebase = 1e3; - mp_set_codec_from_tag(sh); } else if (strcmp(track->codec_id, MKV_V_UNCOMPRESSED) == 0) { // raw video, "like AVI" - this is a FourCC sh->format = track->colorspace; @@ -1291,10 +1291,8 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track) const videocodec_info_t *vi = vinfo; while (vi->id && strcmp(vi->id, track->codec_id)) vi++; - if (vi->id) { - sh->format = vi->fourcc; - mp_set_codec_from_tag(sh); - } + if (vi->codec) + sh->codec = vi->codec; if (vi->extradata && track->private_data && track->private_size > 0) { extradata = track->private_data; @@ -1302,9 +1300,12 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track) } } - if (sh->format == MP_FOURCC('V', 'P', '9', '0')) { + const char *codec = sh->codec ? sh->codec : ""; + if (!strcmp(codec, "vp9")) { track->parse = true; track->parse_timebase = 1e9; + } else if (!strcmp(codec, "mjpeg")) { + sh->format = MP_FOURCC('m', 'j', 'p', 'g'); } if (extradata_size > 0x1000000) { -- cgit v1.2.3