changeset 32520:5e062dc4a04d

Add code to allow selecting the Close Captioning channel.
author reimar
date Mon, 08 Nov 2010 19:30:52 +0000
parents 68f26b2ca07e
children b2546300b48b
files cfg-common.h sub/sub_cc.c
diffstat 2 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Mon Nov 08 07:47:16 2010 +0000
+++ b/cfg-common.h	Mon Nov 08 19:30:52 2010 +0000
@@ -590,7 +590,7 @@
     // specify IFO file for VOBSUB subtitle
     {"ifo", &spudec_ifo, CONF_TYPE_STRING, 0, 0, 0, NULL},
     // enable Closed Captioning display
-    {"subcc", &subcc_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+    {"subcc", &subcc_enabled, CONF_TYPE_INT, CONF_RANGE, 0, 4, NULL},
     {"nosubcc", &subcc_enabled, CONF_TYPE_FLAG, 0, 1, 0, NULL},
     {"overlapsub", &suboverlap_enabled, CONF_TYPE_FLAG, 0, 0, 2, NULL},
     {"nooverlapsub", &suboverlap_enabled, CONF_TYPE_FLAG, 0, 0, 0, NULL},
--- a/sub/sub_cc.c	Mon Nov 08 07:47:16 2010 +0000
+++ b/sub/sub_cc.c	Mon Nov 08 19:30:52 2010 +0000
@@ -107,6 +107,7 @@
 	}
 }
 
+static int channel;
 
 void subcc_init(void)
 {
@@ -117,6 +118,7 @@
 	buf1.lines=buf2.lines=0;
 	fb=&buf1;
 	bb=&buf2;
+	channel = -1;
 
 	initialized=1;
 }
@@ -171,6 +173,10 @@
 	bb=foo;
 }
 
+static int selected_channel(void)
+{
+    return subcc_enabled - 1;
+}
 
 static void cc_decode_EIA608(unsigned short int data)
 {
@@ -180,13 +186,17 @@
   unsigned char c2 = (data >> 8) & 0x7f;
 
   if (c1 & 0x60) {		/* normal character, 0x20 <= c1 <= 0x7f */
+	   if (channel != (selected_channel() & 1))
+		   return;
 	   append_char(chartbl[c1]);
 	   if(c2 & 0x60)	/*c2 might not be a normal char even if c1 is*/
 		   append_char(chartbl[c2]);
   }
   else if (c1 & 0x10)		// control code / special char
   {
-//	  int channel= (c1 & 0x08) >> 3;
+	  channel = (c1 & 0x08) >> 3;
+	  if (channel != (selected_channel() & 1))
+		return;
 	  c1&=~0x08;
 	  if(data!=lastcode)
 	  {
@@ -283,8 +293,6 @@
   int odd_offset = 1;
 
   while (curbytes < inputlength) {
-    int skip = 2;
-
     cc_code = current[0];
 
     if (inputlength - curbytes < 2) {
@@ -296,7 +304,7 @@
 
     data1 = current[1];
     data2 = current[2];
-    current++; curbytes++;
+    current += 3; curbytes += 3;
 
     switch (cc_code) {
     case 0xfe:
@@ -305,12 +313,14 @@
       break;
 
     case 0xff:
+      odd_offset ^= 1;
+      if (odd_offset != selected_channel() >> 1)
+          break;
       /* expect EIA-608 CC1/CC2 encoding */
       // FIXME check parity!
       // Parity check omitted assuming we are reading from a DVD and therefore
       // we should encounter no "transmission errors".
       cc_decode_EIA608(data1 | (data2 << 8));
-      skip = 5;
       break;
 
     case 0x00:
@@ -318,9 +328,7 @@
       break;
 
     case 0x01:
-      odd_offset = data2 & 0x80;
-      if (!odd_offset)
-	skip = 5;
+      odd_offset = data2 >> 7;
       break;
 
     default:
@@ -329,8 +337,6 @@
 //#endif
       break;
     }
-    current += skip;
-    curbytes += skip;
   }
 }