[FFmpeg-devel] [PATCH] added synchronous KLV codec ID and mpegts PAT and PMT descriptors as specified in stanag4609 annex C
paolovergori
webinostestbed at gmail.com
Fri Aug 29 14:24:21 CEST 2014
---
libavcodec/avcodec.h | 17 +++++++++--------
libavcodec/codec_desc.c | 6 ++++++
libavformat/mpegts.c | 2 ++
libavformat/mpegts.h | 1 +
libavformat/mpegtsenc.c | 27 +++++++++++++++++++++++++++
5 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fb1c9ca..99eba82 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -526,14 +526,15 @@ enum AVCodecID {
/* other specific kind of codecs (generally used for attachments) */
AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
AV_CODEC_ID_TTF = 0x18000,
- AV_CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
- AV_CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
- AV_CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
- AV_CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
- AV_CODEC_ID_SMPTE_KLV = MKBETAG('K','L','V','A'),
- AV_CODEC_ID_DVD_NAV = MKBETAG('D','N','A','V'),
- AV_CODEC_ID_TIMED_ID3 = MKBETAG('T','I','D','3'),
- AV_CODEC_ID_BIN_DATA = MKBETAG('D','A','T','A'),
+ AV_CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
+ AV_CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
+ AV_CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
+ AV_CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
+ AV_CODEC_ID_SMPTE_KLV = MKBETAG('K','L','V','A'),
+ AV_CODEC_ID_SMPTE_KLV_SYNC = MKBETAG('K','L','V','S'),
+ AV_CODEC_ID_DVD_NAV = MKBETAG('D','N','A','V'),
+ AV_CODEC_ID_TIMED_ID3 = MKBETAG('T','I','D','3'),
+ AV_CODEC_ID_BIN_DATA = MKBETAG('D','A','T','A'),
AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9e9728b..5cad936 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2706,6 +2706,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("SMPTE 336M Key-Length-Value (KLV) metadata"),
},
{
+ .id = AV_CODEC_ID_SMPTE_KLV_SYNC,
+ .type = AVMEDIA_TYPE_DATA,
+ .name = "klvSync",
+ .long_name = NULL_IF_CONFIG_SMALL("SMPTE 336M Key-Length-Value (KLV) synchronous metadata"),
+ },
+ {
.id = AV_CODEC_ID_DVD_NAV,
.type = AVMEDIA_TYPE_DATA,
.name = "dvd_nav_packet",
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index a118689..6633801 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -694,12 +694,14 @@ static const StreamType REGD_types[] = {
{ MKTAG('D', 'T', 'S', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS },
{ MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC },
{ MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA, AV_CODEC_ID_SMPTE_KLV },
+ { MKTAG('K', 'L', 'V', 'S'), AVMEDIA_TYPE_DATA, AV_CODEC_ID_SMPTE_KLV_SYNC },
{ MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1 },
{ 0 },
};
static const StreamType METADATA_types[] = {
{ MKTAG('K','L','V','A'), AVMEDIA_TYPE_DATA, AV_CODEC_ID_SMPTE_KLV },
+ { MKTAG('K', 'L', 'V', 'S'), AVMEDIA_TYPE_DATA, AV_CODEC_ID_SMPTE_KLV_SYNC },
{ MKTAG('I','D','3',' '), AVMEDIA_TYPE_DATA, AV_CODEC_ID_TIMED_ID3 },
{ 0 },
};
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 84f3098..5efb1cd 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -51,6 +51,7 @@
#define STREAM_TYPE_AUDIO_AAC 0x0f
#define STREAM_TYPE_AUDIO_AAC_LATM 0x11
#define STREAM_TYPE_VIDEO_MPEG4 0x10
+#define STREAM_TYPE_DATA_KLV_SYNC 0x15
#define STREAM_TYPE_VIDEO_H264 0x1b
#define STREAM_TYPE_VIDEO_HEVC 0x24
#define STREAM_TYPE_VIDEO_CAVS 0x42
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 0184d87..e2b9540 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -297,6 +297,9 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
case AV_CODEC_ID_TRUEHD:
stream_type = STREAM_TYPE_AUDIO_TRUEHD;
break;
+ case AV_CODEC_ID_SMPTE_KLV_SYNC:
+ stream_type = STREAM_TYPE_DATA_KLV_SYNC;
+ break;
default:
stream_type = STREAM_TYPE_PRIVATE_DATA;
break;
@@ -462,6 +465,30 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
*q++ = 'V';
*q++ = 'A';
}
+ if (st->codec->codec_id == AV_CODEC_ID_SMPTE_KLV_SYNC) {
+ *q++ = 0x26;
+ *q++ = 0x09;
+ *q++ = 0x01;
+ *q++ = 0x00;
+ *q++ = 0xFF;
+ *q++ = 'K';
+ *q++ = 'L';
+ *q++ = 'V';
+ *q++ = 'A';
+ *q++ = 0x00;
+ *q++ = 0x0f;
+ *q++ = 0x27;
+ *q++ = 0x09;
+ *q++ = 0xC0;
+ *q++ = 0x00;
+ *q++ = 0x00;//0x04;
+ *q++ = 0xC0;
+ *q++ = 0x00;
+ *q++ = 0x00;//0x01;
+ *q++ = 0xC0;
+ *q++ = 0x00;
+ *q++ = 0x00;
+ }
break;
}
--
1.9.1
More information about the ffmpeg-devel
mailing list