forked from FFmpeg/FFmpeg
lavf/matroska: add support for ARIB captions
This commit is contained in:
parent
7dc0944ce2
commit
f758d4fcb9
3 changed files with 54 additions and 0 deletions
|
@ -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},
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue