avformat/mpegts: add support for preserving SMPTE 2038 when transcoding MPEG-TS streams

Add the appropriate descriptors to the MPEG-TS demux and mux to
ensure that SMPTE 2038 VANC streams are properly preserved
when using codec copy (including adding the appropriate PMT
descriptors).

The focus of this patch is TS input to TS output.  A separate
patch adds support for output of 2038 VANC over decklink SDI.

Thanks to Marton Balint for feedback to preserve ABI compatibility.

Signed-off-by: Devin Heitmueller <dheitmueller@ltnglobal.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Devin Heitmueller 2023-03-17 11:03:49 -04:00 committed by Marton Balint
parent 0d3a2f9370
commit 19798229df
3 changed files with 10 additions and 2 deletions

View File

@ -866,6 +866,7 @@ static const StreamType REGD_types[] = {
{ MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3 },
{ 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('V', 'A', 'N', 'C'), AVMEDIA_TYPE_DATA, AV_CODEC_ID_SMPTE_2038 },
{ MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA, AV_CODEC_ID_TIMED_ID3 },
{ MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1 },
{ MKTAG('O', 'p', 'u', 's'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_OPUS },

View File

@ -422,6 +422,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream *st)
case AV_CODEC_ID_TIMED_ID3:
stream_type = STREAM_TYPE_METADATA;
break;
case AV_CODEC_ID_SMPTE_2038:
stream_type = STREAM_TYPE_PRIVATE_DATA;
break;
case AV_CODEC_ID_DVB_SUBTITLE:
case AV_CODEC_ID_DVB_TELETEXT:
case AV_CODEC_ID_ARIB_CAPTION:
@ -804,6 +807,8 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
case AVMEDIA_TYPE_DATA:
if (codec_id == AV_CODEC_ID_SMPTE_KLV) {
put_registration_descriptor(&q, MKTAG('K', 'L', 'V', 'A'));
} else if (codec_id == AV_CODEC_ID_SMPTE_2038) {
put_registration_descriptor(&q, MKTAG('V', 'A', 'N', 'C'));
} else if (codec_id == AV_CODEC_ID_TIMED_ID3) {
const char *tag = "ID3 ";
*q++ = METADATA_DESCRIPTOR;

View File

@ -304,7 +304,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
par->codec_tag = av_codec_get_tag(of->p.codec_tag, par->codec_id);
}
if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT)
if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
par->codec_id != AV_CODEC_ID_SMPTE_2038)
si->nb_interleaved_streams++;
}
si->interleave_packet = of->interleave_packet;
@ -942,7 +943,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
++stream_count;
} else if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
par->codec_id != AV_CODEC_ID_VP8 &&
par->codec_id != AV_CODEC_ID_VP9) {
par->codec_id != AV_CODEC_ID_VP9 &&
par->codec_id != AV_CODEC_ID_SMPTE_2038) {
++noninterleaved_count;
}
}