Commit 1c36cd78 authored by François Cartegnie's avatar François Cartegnie 🤞

fourcc/es: unify EIA/CEA fourcc with channel in fmt

parent ee7a7d10
......@@ -536,6 +536,7 @@ struct subs_format_t
} teletext;
struct
{
uint8_t i_channel;
uint8_t i_reorder_depth; /* Reorder depth or transport video */
} cc;
......
......@@ -539,11 +539,8 @@
#define VLC_CODEC_EBU_STL VLC_FOURCC('S','T','L',' ')
#define VLC_CODEC_SCTE_18 VLC_FOURCC('S','C','1','8')
#define VLC_CODEC_SCTE_27 VLC_FOURCC('S','C','2','7')
/* EIA-608 */
#define VLC_CODEC_EIA608_1 VLC_FOURCC('c','c','1',' ')
#define VLC_CODEC_EIA608_2 VLC_FOURCC('c','c','2',' ')
#define VLC_CODEC_EIA608_3 VLC_FOURCC('c','c','3',' ')
#define VLC_CODEC_EIA608_4 VLC_FOURCC('c','c','4',' ')
/* EIA/CEA-608 */
#define VLC_CODEC_CEA608 VLC_FOURCC('c','6','0','8')
#define VLC_CODEC_TTML VLC_FOURCC('T','T','M','L')
/* XYZ colorspace 12 bits packed in 16 bits, organisation |XXX0|YYY0|ZZZ0| */
......
......@@ -313,7 +313,7 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
if (!sys->cc_es) {
es_format_t fmt;
es_format_Init( &fmt, SPU_ES, VLC_CODEC_EIA608_1 );
es_format_Init( &fmt, SPU_ES, VLC_CODEC_CEA608 );
fmt.psz_description = strdup(N_("Closed captions 1"));
if (fmt.psz_description) {
sys->cc_es = es_out_Add(demux_->out, &fmt);
......
......@@ -236,27 +236,18 @@ static int Open( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
int i_field;
int i_channel;
switch( p_dec->fmt_in.i_codec )
{
case VLC_CODEC_EIA608_1:
i_field = 0; i_channel = 1;
break;
case VLC_CODEC_EIA608_2:
i_field = 0; i_channel = 2;
break;
case VLC_CODEC_EIA608_3:
i_field = 1; i_channel = 1;
break;
case VLC_CODEC_EIA608_4:
i_field = 1; i_channel = 2;
break;
if( p_dec->fmt_in.i_codec != VLC_CODEC_CEA608 ||
p_dec->fmt_in.subs.cc.i_channel > 3 )
return VLC_EGENERIC;
default:
return VLC_EGENERIC;
}
/* 0 -> i_field = 0; i_channel = 1;
1 -> i_field = 0; i_channel = 2;
2 -> i_field = 1; i_channel = 1;
3 -> i_field = 1; i_channel = 2; */
const int i_field = p_dec->fmt_in.subs.cc.i_channel >> 1;
const int i_channel = 1 + (p_dec->fmt_in.subs.cc.i_channel & 1);
p_dec->pf_decode = Decode;
p_dec->pf_flush = Flush;
......
......@@ -1247,7 +1247,7 @@ int SetupSpuES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
break;
case ATOM_c608: /* EIA608 closed captions */
//case ATOM_c708: /* EIA708 closed captions */
p_track->fmt.i_codec = VLC_CODEC_EIA608_1;
p_track->fmt.i_codec = VLC_CODEC_CEA608;
break;
case( VLC_FOURCC( 't', 'e', 'x', 't' ) ):
......
......@@ -586,7 +586,7 @@ static block_t * MP4_Block_Convert( demux_t *p_demux, const mp4_track_t *p_track
case VLC_CODEC_SPU:
/* accept as-is */
break;
case VLC_CODEC_EIA608_1:
case VLC_CODEC_CEA608:
p_block = MP4_EIA608_Convert( p_block );
break;
case VLC_CODEC_SUBT:
......
......@@ -720,7 +720,7 @@ static int Open ( vlc_object_t *p_this )
}
else if( p_sys->props.i_type == SUB_TYPE_SCC )
{
es_format_Init( &fmt, SPU_ES, VLC_CODEC_EIA608_1 );
es_format_Init( &fmt, SPU_ES, VLC_CODEC_CEA608 );
}
else
es_format_Init( &fmt, SPU_ES, VLC_CODEC_SUBT );
......
......@@ -761,12 +761,6 @@ static int DemuxRecVideo( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_bl
/* Register the CC decoders when needed */
for( i = 0; i < 4; i++ )
{
static const vlc_fourcc_t fcc[4] = {
VLC_CODEC_EIA608_1,
VLC_CODEC_EIA608_2,
VLC_CODEC_EIA608_3,
VLC_CODEC_EIA608_4,
};
static const char *ppsz_description[4] = {
N_("Closed captions 1"),
N_("Closed captions 2"),
......@@ -779,7 +773,8 @@ static int DemuxRecVideo( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_bl
if( !p_sys->cc.pb_present[i] || p_sys->p_cc[i] )
continue;
es_format_Init( &fmt, SPU_ES, fcc[i] );
es_format_Init( &fmt, SPU_ES, VLC_CODEC_CEA608 );
fmt.subs.cc.i_channel = i;
fmt.psz_description = strdup( vlc_gettext(ppsz_description[i]) );
fmt.i_group = TY_ES_GROUP;
p_sys->p_cc[i] = es_out_Add( p_demux->out, &fmt );
......
......@@ -2142,16 +2142,11 @@ int input_DecoderSetCcState( decoder_t *p_dec, bool b_decode, int i_channel )
if( b_decode )
{
static const vlc_fourcc_t fcc[4] = {
VLC_CODEC_EIA608_1,
VLC_CODEC_EIA608_2,
VLC_CODEC_EIA608_3,
VLC_CODEC_EIA608_4,
};
decoder_t *p_cc;
es_format_t fmt;
es_format_Init( &fmt, SPU_ES, fcc[i_channel] );
es_format_Init( &fmt, SPU_ES, VLC_CODEC_CEA608 );
fmt.subs.cc.i_channel = i_channel;
fmt.subs.cc.i_reorder_depth = p_owner->cc.i_reorder_depth;
p_cc = input_DecoderNew( p_owner->p_input, &fmt,
p_dec->p_owner->p_clock, p_owner->p_sout );
......
......@@ -204,21 +204,14 @@ static int LanguageArrayIndex( char **ppsz_langs, const char *psz_lang );
static char *EsOutProgramGetMetaName( es_out_pgrm_t *p_pgrm );
static char *EsInfoCategoryName( es_out_id_t* es );
static const vlc_fourcc_t EsOutFourccClosedCaptions[4] = {
VLC_CODEC_EIA608_1,
VLC_CODEC_EIA608_2,
VLC_CODEC_EIA608_3,
VLC_CODEC_EIA608_4,
};
static inline int EsOutGetClosedCaptionsChannel( vlc_fourcc_t fcc )
static inline int EsOutGetClosedCaptionsChannel( const es_format_t *p_fmt )
{
int i;
for( i = 0; i < 4; i++ )
{
if( fcc == EsOutFourccClosedCaptions[i] )
return i;
}
return -1;
int i_channel;
if( p_fmt->i_codec == VLC_CODEC_CEA608 && p_fmt->subs.cc.i_channel < 4 )
i_channel = p_fmt->subs.cc.i_channel;
else
i_channel = -1;
return i_channel;
}
static inline bool EsFmtIsTeletext( const es_format_t *p_fmt )
{
......@@ -1666,7 +1659,7 @@ static bool EsIsSelected( es_out_id_t *es )
bool b_decode = false;
if( es->p_master->p_dec )
{
int i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_original_fourcc );
int i_channel = EsOutGetClosedCaptionsChannel( &es->fmt );
if( i_channel != -1 )
input_DecoderGetCcState( es->p_master->p_dec, &b_decode, i_channel );
}
......@@ -1732,7 +1725,8 @@ static void EsSelect( es_out_t *out, es_out_id_t *es )
if( !es->p_master->p_dec )
return;
i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_original_fourcc );
i_channel = EsOutGetClosedCaptionsChannel( &es->fmt );
if( i_channel == -1 || input_DecoderSetCcState( es->p_master->p_dec, true, i_channel ) )
return;
}
......@@ -1793,7 +1787,7 @@ static void EsUnselect( es_out_t *out, es_out_id_t *es, bool b_update )
{
if( es->p_master->p_dec )
{
int i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_original_fourcc );
int i_channel = EsOutGetClosedCaptionsChannel( &es->fmt );
if( i_channel != -1 )
input_DecoderSetCcState( es->p_master->p_dec, false, i_channel );
}
......@@ -2077,7 +2071,8 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
continue;
msg_Dbg( p_input, "Adding CC track %d for es[%d]", 1+i, es->i_id );
es_format_Init( &fmt, SPU_ES, EsOutFourccClosedCaptions[i] );
es_format_Init( &fmt, SPU_ES, VLC_CODEC_CEA608 );
fmt.subs.cc.i_channel = i;
fmt.i_group = es->fmt.i_group;
if( asprintf( &fmt.psz_description,
_("Closed captions %u"), 1 + i ) == -1 )
......
......@@ -1602,11 +1602,7 @@ static const staticentry_t p_list_spu[] = {
B(VLC_CODEC_SCTE_27, "SCTE-27 subtitles"),
A("SC27"),
B(VLC_CODEC_EIA608_1, "EIA-608 subtitles"),
A("cc1 "),
A("cc2 "),
A("cc3 "),
A("cc4 "),
B(VLC_CODEC_CEA608, "EIA-608 subtitles"),
B(VLC_CODEC_TTML, "TTML subtitles"),
A("ttml"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment