[vlc-commits] codec: cc: always create header bits on byte 0

Francois Cartegnie git at videolan.org
Fri Sep 23 10:52:02 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep 23 10:48:25 2016 +0200| [aeb5eea9c7992ccb0320027f2f4b42a79ba84f95] | committer: Francois Cartegnie

codec: cc: always create header bits on byte 0

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

 modules/codec/cc.h      | 8 +++++---
 modules/demux/mp4/mp4.c | 4 ++--
 modules/demux/ty.c      | 2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/codec/cc.h b/modules/codec/cc.h
index c6fd7bb..d206455 100644
--- a/modules/codec/cc.h
+++ b/modules/codec/cc.h
@@ -28,6 +28,8 @@
 
 #define BLOCK_FLAG_ORDERED_CAPTIONS (0x01 << BLOCK_FLAG_PRIVATE_SHIFT)
 
+#define CC_PKT_BYTE0(field) (0xFC | (0x03 & field))
+
 /* CC have a maximum rate of 9600 bit/s (per field?) */
 #define CC_MAX_DATA_SIZE (2 * 3*600)
 enum
@@ -235,7 +237,7 @@ static inline void cc_Extract( cc_data_t *c, bool b_top_field_first, const uint8
                 if( c->i_data + 3 > CC_MAX_DATA_SIZE )
                     continue;
 
-                cc_AppendData( c, i_field, &cc[1] );
+                cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[1] );
             }
         }
         c->b_reorder = false;
@@ -251,7 +253,7 @@ static inline void cc_Extract( cc_data_t *c, bool b_top_field_first, const uint8
         {
             const int i_field = i == 0 ? 1 : 0;
 
-            cc_AppendData( c, i_field, &cc[2] );
+            cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[2] );
         }
         c->b_reorder = false;
     }
@@ -284,7 +286,7 @@ static inline void cc_Extract( cc_data_t *c, bool b_top_field_first, const uint8
             if (!b_top_field_first)
                 i_field ^= 1;
 
-            cc_AppendData( c, i_field, &cc[0] );
+            cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[0] );
         }
         c->b_reorder = true;
     }
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index bc1694d..3c7817f 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -368,7 +368,7 @@ static block_t * MP4_EIA608_Convert( block_t * p_block )
 
     do
     {
-        p_write[i_copied++] = 0; /* cc1 == field 0 */
+        p_write[i_copied++] = CC_PKT_BYTE0(0); /* cc1 == field 0 */
         p_write[i_copied++] = p_read[0];
         p_write[i_copied++] = p_read[1];
         p_read += 2;
@@ -387,7 +387,7 @@ static block_t * MP4_EIA608_Convert( block_t * p_block )
         i_remaining -= 8;
         do
         {
-            p_write[i_copied++] = 0; /* cc1 == field 0 */
+            p_write[i_copied++] = CC_PKT_BYTE0(0); /* cc1 == field 0 */
             p_write[i_copied++] = p_read[0];
             p_write[i_copied++] = p_read[1];
             p_read += 2;
diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index 24648a2..2079d1d 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -1042,7 +1042,7 @@ static int DemuxRecCc( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_block
     if( p_sys->cc.i_data + 3 > CC_MAX_DATA_SIZE )
         return 0;
 
-    cc_AppendData( &p_sys->cc, i_field, rec_hdr->ex );
+    cc_AppendData( &p_sys->cc, CC_PKT_BYTE0(i_field), rec_hdr->ex );
     return 0;
 }
 



More information about the vlc-commits mailing list