[MPlayer-cvslog] r32607 - in trunk: cfg-common.h sub/sub_cc.c

reimar subversion at mplayerhq.hu
Mon Nov 8 20:30:53 CET 2010


Author: reimar
Date: Mon Nov  8 20:30:52 2010
New Revision: 32607

Log:
Add code to allow selecting the Close Captioning channel.

Modified:
   trunk/cfg-common.h
   trunk/sub/sub_cc.c

Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h	Mon Nov  8 08:47:16 2010	(r32606)
+++ trunk/cfg-common.h	Mon Nov  8 20:30:52 2010	(r32607)
@@ -590,7 +590,7 @@ const m_option_t common_opts[] = {
     // 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},

Modified: trunk/sub/sub_cc.c
==============================================================================
--- trunk/sub/sub_cc.c	Mon Nov  8 08:47:16 2010	(r32606)
+++ trunk/sub/sub_cc.c	Mon Nov  8 20:30:52 2010	(r32607)
@@ -107,6 +107,7 @@ static void scroll_buffer(subtitle* buf)
 	}
 }
 
+static int channel;
 
 void subcc_init(void)
 {
@@ -117,6 +118,7 @@ void subcc_init(void)
 	buf1.lines=buf2.lines=0;
 	fb=&buf1;
 	bb=&buf2;
+	channel = -1;
 
 	initialized=1;
 }
@@ -171,6 +173,10 @@ static void swap_buffers(void)
 	bb=foo;
 }
 
+static int selected_channel(void)
+{
+    return subcc_enabled - 1;
+}
 
 static void cc_decode_EIA608(unsigned short int data)
 {
@@ -180,13 +186,17 @@ static void cc_decode_EIA608(unsigned sh
   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 @@ static void subcc_decode(unsigned char *
   int odd_offset = 1;
 
   while (curbytes < inputlength) {
-    int skip = 2;
-
     cc_code = current[0];
 
     if (inputlength - curbytes < 2) {
@@ -296,7 +304,7 @@ static void subcc_decode(unsigned char *
 
     data1 = current[1];
     data2 = current[2];
-    current++; curbytes++;
+    current += 3; curbytes += 3;
 
     switch (cc_code) {
     case 0xfe:
@@ -305,12 +313,14 @@ static void subcc_decode(unsigned char *
       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 @@ static void subcc_decode(unsigned char *
       break;
 
     case 0x01:
-      odd_offset = data2 & 0x80;
-      if (!odd_offset)
-	skip = 5;
+      odd_offset = data2 >> 7;
       break;
 
     default:
@@ -329,8 +337,6 @@ static void subcc_decode(unsigned char *
 //#endif
       break;
     }
-    current += skip;
-    curbytes += skip;
   }
 }
 


More information about the MPlayer-cvslog mailing list