[FFmpeg-devel,RFC] lavf: add CoreMedia AVCodecTag mappings

Submitted by Josh de Kock on Nov. 19, 2016, 4:37 p.m.

Details

Message ID 20161119163700.58344-1-josh@itanimul.li
State New
Headers show

Commit Message

Josh de Kock Nov. 19, 2016, 4:37 p.m.
I've mapped a fair amount of the CoreMedia FourCCs to their respective
AVCodecIDs. The ones I didn't know or thought didn't exist in FFmpeg
have been mapped to AV_CODEC_ID_NONE.

Signed-off-by: Josh de Kock <josh@itanimul.li>
---
 libavformat/Makefile    |   1 +
 libavformat/avformat.h  |  32 ++++++++++
 libavformat/coremedia.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++++
 libavformat/coremedia.h |  36 +++++++++++
 4 files changed, 234 insertions(+)
 create mode 100644 libavformat/coremedia.c
 create mode 100644 libavformat/coremedia.h

Comments

Carl Eugen Hoyos Nov. 20, 2016, 10:49 p.m.
2016-11-19 17:37 GMT+01:00 Josh de Kock <josh@itanimul.li>:
> I've mapped a fair amount of the CoreMedia FourCCs to their
> respective AVCodecIDs. The ones I didn't know or thought didn't
> exist in FFmpeg have been mapped to AV_CODEC_ID_NONE.

Could you explain the use-case for these mappings?

Carl Eugen
Josh de Kock Nov. 21, 2016, 9:35 a.m.
On 20/11/2016 22:49, Carl Eugen Hoyos wrote:
> 2016-11-19 17:37 GMT+01:00 Josh de Kock <josh@itanimul.li>:
>> I've mapped a fair amount of the CoreMedia FourCCs to their
>> respective AVCodecIDs. The ones I didn't know or thought didn't
>> exist in FFmpeg have been mapped to AV_CODEC_ID_NONE.
>
> Could you explain the use-case for these mappings?
>
> Carl Eugen

This was discussed in IRC, there was a bit of confusion about how FFmpeg 
supported certain types of data, so the muxed, metadata, and timecode 
mappings are no longer relevant.

As for usecase, it would make working with CoreMedia and FFmpeg tons 
easier because you can easily identify what the different types of 
stream are coming out of CoreMedia with minimal custom code (i.e. 
checking the mapping first, and then probe it with FFmpeg if one is not 
found). It also helps with getting an AVCodecID from a CMDescriptionRef 
with the least amount of pain.
Carl Eugen Hoyos Nov. 21, 2016, 9:51 a.m.
2016-11-21 10:35 GMT+01:00 Josh de Kock <josh@itanimul.li>:
> On 20/11/2016 22:49, Carl Eugen Hoyos wrote:
>>
>> 2016-11-19 17:37 GMT+01:00 Josh de Kock <josh@itanimul.li>:
>>>
>>> I've mapped a fair amount of the CoreMedia FourCCs to their
>>> respective AVCodecIDs. The ones I didn't know or thought didn't
>>> exist in FFmpeg have been mapped to AV_CODEC_ID_NONE.
>>
>> Could you explain the use-case for these mappings?
>>
> This was discussed in IRC, there was a bit of confusion about how FFmpeg
> supported certain types of data, so the muxed, metadata, and timecode
> mappings are no longer relevant.
>
> As for usecase, it would make working with CoreMedia and FFmpeg tons easier
> because you can easily identify what the different types of stream are
> coming out of CoreMedia with minimal custom code (i.e. checking the mapping
> first, and then probe it with FFmpeg if one is not found). It also helps
> with getting an AVCodecID from a CMDescriptionRef with the least amount of
> pain.

Could it be that you are saying FFmpeg needs a CoreMedia demuxer?

Carl Eugen
Josh de Kock Nov. 21, 2016, 9:55 a.m.
On 21/11/2016 09:51, Carl Eugen Hoyos wrote:
> 2016-11-21 10:35 GMT+01:00 Josh de Kock <josh@itanimul.li>:
>> On 20/11/2016 22:49, Carl Eugen Hoyos wrote:
>>>
>>> 2016-11-19 17:37 GMT+01:00 Josh de Kock <josh@itanimul.li>:
>>>>
>>>> I've mapped a fair amount of the CoreMedia FourCCs to their
>>>> respective AVCodecIDs. The ones I didn't know or thought didn't
>>>> exist in FFmpeg have been mapped to AV_CODEC_ID_NONE.
>>>
>>> Could you explain the use-case for these mappings?
>>>
>> This was discussed in IRC, there was a bit of confusion about how FFmpeg
>> supported certain types of data, so the muxed, metadata, and timecode
>> mappings are no longer relevant.
>>
>> As for usecase, it would make working with CoreMedia and FFmpeg tons easier
>> because you can easily identify what the different types of stream are
>> coming out of CoreMedia with minimal custom code (i.e. checking the mapping
>> first, and then probe it with FFmpeg if one is not found). It also helps
>> with getting an AVCodecID from a CMDescriptionRef with the least amount of
>> pain.
>
> Could it be that you are saying FFmpeg needs a CoreMedia demuxer?
>

Pretty much (it's also something I'm already working on).

Patch hide | download patch | download mbox

diff --git a/libavformat/Makefile b/libavformat/Makefile
index f93658d..89ba8c7 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -10,6 +10,7 @@  OBJS = allformats.o         \
        avio.o               \
        aviobuf.o            \
        cutils.o             \
+       coremedia.o          \
        dump.o               \
        format.o             \
        id3v1.o              \
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f9f4d72..a29e892 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2865,6 +2865,38 @@  const struct AVCodecTag *avformat_get_mov_video_tags(void);
  * @return the table mapping MOV FourCCs for audio to AVCodecID.
  */
 const struct AVCodecTag *avformat_get_mov_audio_tags(void);
+/**
+ * @return the table mapping Apple's CoreMedia FourCCs for video to AVCodecID.
+ */
+const struct AVCodecTag *avformat_get_coremedia_video_tags(void);
+/**
+ * @return the table mapping Apple's CoreMedia FourCCs for audio to AVCodecID.
+ */
+const struct AVCodecTag *avformat_get_coremedia_audio_tags(void);
+/**
+ * @return the table mapping Apple's CoreMedia FourCCs for muxed data to AVCodecID.
+ */
+const struct AVCodecTag *avformat_get_coremedia_muxed_tags(void);
+/**
+ * @return the table mapping Apple's CoreMedia FourCCs for subtitle to AVCodecID.
+ */
+const struct AVCodecTag *avformat_get_coremedia_subtitle_tags(void);
+/**
+ * @return the table mapping Apple's CoreMedia FourCCs for closed captions to AVCodecID.
+ */
+const struct AVCodecTag *avformat_get_coremedia_closedcaption_tags(void);
+/**
+ * @return the table mapping Apple's CoreMedia FourCCs for metadata to AVCodecID.
+ */
+const struct AVCodecTag *avformat_get_coremedia_metadata_tags(void);
+/**
+ * @return the table mapping Apple's CoreMedia FourCCs for text to AVCodecID.
+ */
+const struct AVCodecTag *avformat_get_coremedia_text_tags(void);
+/**
+ * @return the table mapping Apple's CoreMedia FourCCs for timecode to AVCodecID.
+ */
+const struct AVCodecTag *avformat_get_coremedia_timecode_tags(void);
 
 /**
  * @}
diff --git a/libavformat/coremedia.c b/libavformat/coremedia.c
new file mode 100644
index 0000000..16eb2bd
--- /dev/null
+++ b/libavformat/coremedia.c
@@ -0,0 +1,165 @@ 
+/*
+ * CoreMedia routines
+ * Copyright (c) 2016 Josh de Kock <josh@itanimul.li>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/avcodec.h"
+#include "avformat.h"
+#include "libavformat/coremedia.h"
+
+const AVCodecTag ff_coremedia_muxed_tags[] = {
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v',' ',' ') },
+    /**< MPEG-1 System stream */
+    { AV_CODEC_ID_NONE, MKBETAG('m','p','1','s') },
+    /**< MPEG-2 Transport stream */
+    { AV_CODEC_ID_MPEG2TS, MKBETAG('m','p','2','t') },
+    /**< MPEG-2 Program stream */
+    { AV_CODEC_ID_NONE, MKBETAG('m','p','2','p') },
+    /**< DV stream */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v',' ',' ') },
+    { 0 }
+};
+
+const AVCodecTag ff_coremedia_video_tags[] = {
+    /**< Component Y'CbCr 8-bit 4:2:2 ordered Cb Y'0 Cr Y'1 */
+    { AV_CODEC_ID_NONE, MKBETAG('2','v','u','y') },
+    /**< Apple Animation format */
+    { AV_CODEC_ID_QTRLE, MKBETAG('r','l','e',' ') },
+    /**< Cinepak format */
+    { AV_CODEC_ID_CINEPAK, MKBETAG('c','v','i','d') },
+    /**< Joint Photographic Experts Group (JPEG) format */
+    { AV_CODEC_ID_MJPEG, MKBETAG('j','p','e','g') },
+    /**< JPEG format with Open-DML extensions */
+    { AV_CODEC_ID_NONE, MKBETAG('d','m','b','1') },
+    /**< Sorenson video format */
+    { AV_CODEC_ID_SVQ1, MKBETAG('S','V','Q','1') },
+    /**< Sorenson 3 video format */
+    { AV_CODEC_ID_SVQ3, MKBETAG('S','V','Q','3') },
+    /**< ITU-T H.263 format */
+    { AV_CODEC_ID_H263, MKBETAG('h','2','6','3') },
+    /**< ITU-T H.264 format (AKA ISO/IEC 14496-10 - MPEG-4 Part 10, Advanced Video Coding format) */
+    { AV_CODEC_ID_H264, MKBETAG('a','v','c','1') },
+    /**< ITU-T HEVC format */
+    { AV_CODEC_ID_HEVC, MKBETAG('h','v','c','1') },
+    /**< ISO/IEC Moving Picture Experts Group (MPEG) MPEG-4 Part 2 video format */
+    { AV_CODEC_ID_MPEG4, MKBETAG('m','p','4','v') },
+    /**< MPEG-2 video format */
+    { AV_CODEC_ID_MPEG2VIDEO, MKBETAG('m','p','2','v') },
+    /**< MPEG-1 video format */
+    { AV_CODEC_ID_MPEG1VIDEO, MKBETAG('m','p','1','v') },
+    /**< DV NTSC format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','c',' ') },
+    /**< DV PAL format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','c','p') },
+    /**< Panasonic DVCPro PAL format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','p','p') },
+    /**< Panasonic DVCPro-50 NTSC format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','5','n') },
+    /**< Panasonic DVCPro-50 PAL format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','5','p') },
+    /**< Panasonic DVCPro-HD 720p60 format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','h','p') },
+    /**< Panasonic DVCPro-HD 720p50 format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','h','q') },
+    /**< Panasonic DVCPro-HD 1080i60 format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','h','6') },
+    /**< Panasonic DVCPro-HD 1080i50 format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','h','5') },
+    /**< Panasonic DVCPro-HD 1080p30 format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','h','3') },
+    /**< Panasonic DVCPro-HD 1080p25 format */
+    { AV_CODEC_ID_DVVIDEO, MKBETAG('d','v','h','2') },
+    /**< Apple ProRes 4444 format */
+    { AV_CODEC_ID_PRORES, MKBETAG('a','p','4','h') },
+    /**< Apple ProRes 422 HQ format */
+    { AV_CODEC_ID_PRORES, MKBETAG('a','p','c','h') },
+    /**< Apple ProRes 422 format */
+    { AV_CODEC_ID_PRORES, MKBETAG('a','p','c','n') },
+    /**< Apple ProRes 422 LT format */
+    { AV_CODEC_ID_PRORES, MKBETAG('a','p','c','s') },
+    /**< Apple ProRes 422 Proxy format */
+    { AV_CODEC_ID_PRORES, MKBETAG('a','p','c','o') },
+    { 0 }
+};
+const AVCodecTag ff_coremedia_audio_tags[] = {
+    /**< iTMS protected low-complexity AAC */
+    { AV_CODEC_ID_NONE, MKBETAG('p','a','a','c') },
+    /**< Audible's protected AAC */
+    { AV_CODEC_ID_NONE, MKBETAG('a','a','a','c') },
+    { 0 }
+};
+const AVCodecTag ff_coremedia_metadata_tags[] = {
+    /**< SHOUTCast format */
+    { AV_CODEC_ID_NONE, MKBETAG('i','c','y',' ') },
+    /**< ID3 format */
+    { AV_CODEC_ID_TIMED_ID3, MKBETAG('i','d','3',' ') },
+    /**< Boxed format */
+    { AV_CODEC_ID_NONE, MKBETAG('m','e','b','x') },
+};
+const AVCodecTag ff_coremedia_timecode_tags[] = {
+    /**< 32-bit timeCode sample */
+    { AV_CODEC_ID_NONE, MKBETAG('t','m','c','d') },
+    /**< 64-bit timeCode sample */
+    { AV_CODEC_ID_NONE, MKBETAG('t','c','6','4') },
+    /**< 32-bit counter-mode sample */
+    { AV_CODEC_ID_NONE, MKBETAG('c','n','3','2') },
+    /**< 64-bit counter-mode sample */
+    { AV_CODEC_ID_NONE, MKBETAG('c','n','6','4') },
+    { 0 }
+};
+const AVCodecTag ff_coremedia_subtitle_tags[] = {
+    /**< 3GPP Text media/MPEG-4 Part 17 */
+    { AV_CODEC_ID_MOV_TEXT, MKBETAG('t','x','3','g') },
+    /**< WebVTT (Web Video Text Tracks) */
+    { AV_CODEC_ID_WEBVTT, MKBETAG('w','v','t','t') },
+    { 0 }
+};
+const AVCodecTag ff_coremedia_closedcaption_tags[] = {
+    /**< CEA 608-compliant samples */
+    { AV_CODEC_ID_EIA_608, MKBETAG('c','6','0','8') },
+    /**< CEA 708-compliant samples */
+    { AV_CODEC_ID_NONE, MKBETAG('c','7','0','8') },
+    /**< ATSC/52 part-4 compliant samples */
+    { AV_CODEC_ID_NONE, MKBETAG('a','t','c','c') },
+    { 0 }
+};
+const AVCodecTag ff_coremedia_text_tags[] = {
+    /**< QuickTime Text media */
+    { AV_CODEC_ID_NONE, MKBETAG('t','e','x','t') },
+    /**< 3GPP Text media/MPEG-4 Part 17 */
+    { AV_CODEC_ID_MOV_TEXT, MKBETAG('t','x','3','g') },
+    { 0 }
+};
+
+
+#define avformat_get_coremedia_tags(type)                                     \
+    const struct AVCodecTag *avformat_get_coremedia_ ## type ## _tags(void) { \
+        return ff_coremedia_ ## type ## _tags;                                \
+    }
+
+avformat_get_coremedia_tags(muxed);
+avformat_get_coremedia_tags(video);
+avformat_get_coremedia_tags(audio);
+avformat_get_coremedia_tags(subtitle);
+avformat_get_coremedia_tags(timecode);
+avformat_get_coremedia_tags(text);
+avformat_get_coremedia_tags(metadata);
+avformat_get_coremedia_tags(closedcaption);
+
+#undef avformat_get_coremedia_tags
diff --git a/libavformat/coremedia.h b/libavformat/coremedia.h
new file mode 100644
index 0000000..20e99c5
--- /dev/null
+++ b/libavformat/coremedia.h
@@ -0,0 +1,36 @@ 
+/*
+ * CoreMedia routines
+ * Copyright (c) 2016 Josh de Kock <josh@itanimul.li>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFORMAT_COREMEDIA_H
+#define AVFORMAT_COREMEDIA_H
+
+#include "internal.h"
+
+extern const struct AVCodecTag ff_coremedia_muxed_tags[];
+extern const struct AVCodecTag ff_coremedia_video_tags[];
+extern const struct AVCodecTag ff_coremedia_audio_tags[];
+extern const struct AVCodecTag ff_coremedia_subtitle_tags[];
+extern const struct AVCodecTag ff_coremedia_closedcaption_tags[];
+extern const struct AVCodecTag ff_coremedia_text_tags[];
+extern const struct AVCodecTag ff_coremedia_subtitle_tags[];
+extern const struct AVCodecTag ff_coremedia_metadata_tags[];
+
+#endif /* AVFORMAT_COREMEDIA_H */