From 41e04522af62fe0140da71d4fac9088c052c4d87 Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 8 Nov 2010 19:30:52 +0000 Subject: sub_cc: Allow selecting the Close Captioning channel git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32607 b3059339-0415-0410-9bf9-f77b7e298cf2 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32608 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/man/en/mplayer.1 | 4 ++-- cfg-common.h | 2 +- sub_cc.c | 26 ++++++++++++++++---------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 4f26e0e173..29c1ba9eba 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -2502,8 +2502,8 @@ Align subtitle bottom edge (default). .PD 1 . .TP -.B "\-subcc \ " -Display DVD Closed Caption (CC) subtitles. +.B "\-subcc <1\-4>\ " +Display DVD Closed Caption (CC) subtitles from the specified channel. These are .B not the VOB subtitles, these are special ASCII subtitles for the diff --git a/cfg-common.h b/cfg-common.h index 02c610d0a7..7657864f02 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -658,7 +658,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}, diff --git a/sub_cc.c b/sub_cc.c index c447dd0bd3..a83ac6944d 100644 --- a/sub_cc.c +++ b/sub_cc.c @@ -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 short int data) 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 *inputbuffer, unsigned int inputlength) 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 *inputbuffer, unsigned int inputlength) 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 *inputbuffer, unsigned int inputlength) 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 *inputbuffer, unsigned int inputlength) 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 *inputbuffer, unsigned int inputlength) //#endif break; } - current += skip; - curbytes += skip; } } -- cgit v1.2.3