[vlc-commits] fourcc/es: unify EIA/CEA fourcc with channel in fmt

Francois Cartegnie git at videolan.org
Tue Sep 19 22:35:59 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep  8 18:05:14 2017 +0200| [1c36cd786a34308e448ca0d292ba090637f179a2] | committer: Francois Cartegnie

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1c36cd786a34308e448ca0d292ba090637f179a2
---

 include/vlc_es.h            |  1 +
 include/vlc_fourcc.h        |  7 ++-----
 modules/access/decklink.cpp |  2 +-
 modules/codec/cc.c          | 29 ++++++++++-------------------
 modules/demux/mp4/essetup.c |  2 +-
 modules/demux/mp4/mp4.c     |  2 +-
 modules/demux/subtitle.c    |  2 +-
 modules/demux/ty.c          |  9 ++-------
 src/input/decoder.c         |  9 ++-------
 src/input/es_out.c          | 31 +++++++++++++------------------
 src/misc/fourcc_list.h      |  6 +-----
 11 files changed, 35 insertions(+), 65 deletions(-)

diff --git a/include/vlc_es.h b/include/vlc_es.h
index 0617bb72fe..f15c9dae2b 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -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;
 
diff --git a/include/vlc_fourcc.h b/include/vlc_fourcc.h
index ea96d50591..26dd46a63f 100644
--- a/include/vlc_fourcc.h
+++ b/include/vlc_fourcc.h
@@ -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| */
diff --git a/modules/access/decklink.cpp b/modules/access/decklink.cpp
index ec11470e79..3c66544e77 100644
--- a/modules/access/decklink.cpp
+++ b/modules/access/decklink.cpp
@@ -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);
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index ae1ed13997..ee35007291 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -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;
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 05e910ab89..a085289d58 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -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' ) ):
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index f8b8d242bf..4a7561cd40 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -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:
diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 578d2dab79..c532d3fcfe 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -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 );
diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index 0273125693..86115504ea 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -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 );
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 109d5a2205..54eec0f342 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -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 );
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 777fe3611a..b19c500068 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -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 )
diff --git a/src/misc/fourcc_list.h b/src/misc/fourcc_list.h
index 3a5914fd63..b6916b9ff4 100644
--- a/src/misc/fourcc_list.h
+++ b/src/misc/fourcc_list.h
@@ -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"),



More information about the vlc-commits mailing list