From: rcombs <rcombs@rcombs.me> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] lavf/matroska: add support for ARIB captions Date: Fri, 13 Jan 2023 11:26:40 -0600 Message-ID: <20230113172640.52901-1-rcombs@rcombs.me> (raw) Not yet ready for merge, pending finalization of the standard proposal for this mapping: https://github.com/ietf-wg-cellar/matroska-specification/pull/724 --- libavformat/matroska.c | 1 + libavformat/matroskadec.c | 30 ++++++++++++++++++++++++++++++ libavformat/matroskaenc.c | 23 +++++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 90d94b65bf..79b2d09984 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -76,6 +76,7 @@ const CodecTags ff_mkv_codec_tags[]={ {"S_DVBSUB" , AV_CODEC_ID_DVB_SUBTITLE}, {"S_HDMV/PGS" , AV_CODEC_ID_HDMV_PGS_SUBTITLE}, {"S_HDMV/TEXTST" , AV_CODEC_ID_HDMV_TEXT_SUBTITLE}, + {"S_ARIBSUB" , AV_CODEC_ID_ARIB_CAPTION}, {"V_AV1" , AV_CODEC_ID_AV1}, {"V_AVS2" , AV_CODEC_ID_AVS2}, diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index d582f566a2..3a888e3ada 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -50,6 +50,7 @@ #include "libavutil/time_internal.h" #include "libavutil/spherical.h" +#include "libavcodec/avcodec.h" #include "libavcodec/bytestream.h" #include "libavcodec/flac.h" #include "libavcodec/mpeg4audio.h" @@ -2813,6 +2814,35 @@ static int matroska_parse_tracks(AVFormatContext *s) /* we don't need any value stored in CodecPrivate. make sure that it's not exported as extradata. */ track->codec_priv.size = 0; + } else if (codec_id == AV_CODEC_ID_ARIB_CAPTION && track->codec_priv.size == 3) { + int component_tag = track->codec_priv.data[0]; + int data_component_id = AV_RB16(track->codec_priv.data + 1); + + switch (data_component_id) { + case 0x0008: + // [0x30..0x37] are component tags utilized for + // non-mobile captioning service ("profile A"). + if (component_tag >= 0x30 && component_tag <= 0x37) { + st->codecpar->profile = FF_PROFILE_ARIB_PROFILE_A; + } + break; + case 0x0012: + // component tag 0x87 signifies a mobile/partial reception + // (1seg) captioning service ("profile C"). + if (component_tag == 0x87) { + st->codecpar->profile = FF_PROFILE_ARIB_PROFILE_C; + } + break; + default: + break; + } + + if (st->codecpar->profile == FF_PROFILE_UNKNOWN) + av_log(matroska->ctx, AV_LOG_WARNING, + "Unknown ARIB caption profile utilized: %02x / %04x\n", + component_tag, data_component_id); + + track->codec_priv.size = 0; } track->codec_priv.size -= extradata_offset; diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 2deb4284e8..67cfec761a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -58,6 +58,7 @@ #include "libavutil/stereo3d.h" #include "libavcodec/av1.h" +#include "libavcodec/avcodec.h" #include "libavcodec/codec_desc.h" #include "libavcodec/xiph.h" #include "libavcodec/mpeg4audio.h" @@ -1142,6 +1143,27 @@ static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn else *size_to_reserve = MAX_PCE_SIZE; break; + case AV_CODEC_ID_ARIB_CAPTION: { + unsigned stream_identifier, data_component_id; + switch (par->profile) { + case FF_PROFILE_ARIB_PROFILE_A: + stream_identifier = 0x30; + data_component_id = 0x0008; + break; + case FF_PROFILE_ARIB_PROFILE_C: + stream_identifier = 0x87; + data_component_id = 0x0012; + break; + default: + av_log(s, AV_LOG_ERROR, + "Unset/unknown ARIB caption profile %d utilized!\n", + par->profile); + return AVERROR_INVALIDDATA; + } + avio_w8(dyn_cp, stream_identifier); + avio_wb16(dyn_cp, data_component_id); + break; + } #endif default: if (CONFIG_MATROSKA_MUXER && par->codec_id == AV_CODEC_ID_PRORES && @@ -3274,6 +3296,7 @@ static const AVCodecTag additional_subtitle_tags[] = { { AV_CODEC_ID_DVB_SUBTITLE, 0xFFFFFFFF }, { AV_CODEC_ID_DVD_SUBTITLE, 0xFFFFFFFF }, { AV_CODEC_ID_HDMV_PGS_SUBTITLE, 0xFFFFFFFF }, + { AV_CODEC_ID_ARIB_CAPTION, 0xFFFFFFFF }, { AV_CODEC_ID_NONE, 0xFFFFFFFF } }; -- 2.38.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-01-13 17:27 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-13 17:26 rcombs [this message] 2023-01-13 19:06 ` Pierre-Anthony Lemieux 2023-01-29 23:06 ` Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230113172640.52901-1-rcombs@rcombs.me \ --to=rcombs@rcombs.me \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git