⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cc.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
        return false;    /* Row */    if( h->mode != EIA608_MODE_TEXT )        h->cursor.i_row = pi_row[i_row_index] - 1;    h->i_row_rollup = pi_row[i_row_index] - 1;    /* Column */    if( d2 >= 0x60 )        d2 -= 0x60;    else if( d2 >= 0x40 )        d2 -= 0x40;    h->cursor.i_column = pac2_attribs[d2].i_column;    return false;}static bool Eia608ParseData( eia608_t *h, uint8_t d1, uint8_t d2 ){    bool b_changed = false;    if( d1 >= 0x18 && d1 <= 0x1f )        d1 -= 8;#define ON( d2min, d2max, cmd ) do { if( d2 >= d2min && d2 <= d2max ) b_changed = cmd; } while(0)    switch( d1 )    {    case 0x11:        ON( 0x20, 0x2f, Eia608ParseTextAttribute( h, d2 ) );        ON( 0x30, 0x3f, Eia608ParseDouble( h, d2 ) );        break;    case 0x12: case 0x13:        ON( 0x20, 0x3f, Eia608ParseExtended( h, d1, d2 ) );        break;    case 0x14: case 0x15:        ON( 0x20, 0x2f, Eia608ParseCommand0x14( h, d2 ) );        break;    case 0x17:        ON( 0x21, 0x22, Eia608ParseCommand0x17( h, d2 ) );        ON( 0x2e, 0x2f, Eia608ParseTextAttribute( h, d2 ) );        break;    }    if( d1 == 0x10 )        ON( 0x40, 0x5f, Eia608ParsePac( h, d1, d2 ) );    else if( d1 >= 0x11 && d1 <= 0x17 )        ON( 0x40, 0x7f, Eia608ParsePac( h, d1, d2 ) );#undef ON    if( d1 >= 0x20 )    {        b_changed = Eia608ParseSingle( h, d1 );        if( d2 >= 0x20 )            b_changed |= Eia608ParseSingle( h, d2 );    }    return b_changed;}static void Eia608TextUtf8( char *psz_utf8, uint8_t c ) // Returns number of bytes used{#define E1(c,u) { c, { u, '\0' } }#define E2(c,u1,u2) { c, { u1, u2, '\0' } }#define E3(c,u1,u2,u3) { c, { u1, u2, u3, '\0' } }    static const struct {        uint8_t c;        char utf8[3+1];    } c2utf8[] = {        // Regular line-21 character set, mostly ASCII except these exceptions        E2( 0x2a, 0xc3,0xa1), // lowercase a, acute accent        E2( 0x5c, 0xc3,0xa9), // lowercase e, acute accent        E2( 0x5e, 0xc3,0xad), // lowercase i, acute accent        E2( 0x5f, 0xc3,0xb3), // lowercase o, acute accent        E2( 0x60, 0xc3,0xba), // lowercase u, acute accent        E2( 0x7b, 0xc3,0xa7), // lowercase c with cedilla        E2( 0x7c, 0xc3,0xb7), // division symbol        E2( 0x7d, 0xc3,0x91), // uppercase N tilde        E2( 0x7e, 0xc3,0xb1), // lowercase n tilde        // THIS BLOCK INCLUDES THE 16 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS        // THAT COME FROM HI BYTE=0x11 AND LOW BETWEEN 0x30 AND 0x3F        E2( 0x80, 0xc2,0xae), // Registered symbol (R)        E2( 0x81, 0xc2,0xb0), // degree sign        E2( 0x82, 0xc2,0xbd), // 1/2 symbol        E2( 0x83, 0xc2,0xbf), // Inverted (open) question mark        E3( 0x84, 0xe2,0x84,0xa2), // Trademark symbol (TM)        E2( 0x85, 0xc2,0xa2), // Cents symbol        E2( 0x86, 0xc2,0xa3), // Pounds sterling        E3( 0x87, 0xe2,0x99,0xaa), // Music note        E2( 0x88, 0xc3,0xa0), // lowercase a, grave accent        E1( 0x89, 0x20), // transparent space, we make it regular        E2( 0x8a, 0xc3,0xa8), // lowercase e, grave accent        E2( 0x8b, 0xc3,0xa2), // lowercase a, circumflex accent        E2( 0x8c, 0xc3,0xaa), // lowercase e, circumflex accent        E2( 0x8d, 0xc3,0xae), // lowercase i, circumflex accent        E2( 0x8e, 0xc3,0xb4), // lowercase o, circumflex accent        E2( 0x8f, 0xc3,0xbb), // lowercase u, circumflex accent        // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS        // THAT COME FROM HI BYTE=0x12 AND LOW BETWEEN 0x20 AND 0x3F        E2( 0x90, 0xc3,0x81), // capital letter A with acute        E2( 0x91, 0xc3,0x89), // capital letter E with acute        E2( 0x92, 0xc3,0x93), // capital letter O with acute        E2( 0x93, 0xc3,0x9a), // capital letter U with acute        E2( 0x94, 0xc3,0x9c), // capital letter U with diaresis        E2( 0x95, 0xc3,0xbc), // lowercase letter U with diaeresis        E1( 0x96, 0x27), // apostrophe        E2( 0x97, 0xc1,0xa1), // inverted exclamation mark        E1( 0x98, 0x2a), // asterisk        E1( 0x99, 0x27), // apostrophe (yes, duped). See CCADI source code.        E1( 0x9a, 0x2d), // hyphen-minus        E2( 0x9b, 0xc2,0xa9), // copyright sign        E3( 0x9c, 0xe2,0x84,0xa0), // Service mark        E1( 0x9d, 0x2e), // Full stop (.)        E1( 0x9e, 0x22), // Quoatation mark        E1( 0x9f, 0x22), // Quoatation mark        E2( 0xa0, 0xc3,0x80), // uppercase A, grave accent        E2( 0xa1, 0xc3,0x82), // uppercase A, circumflex        E2( 0xa2, 0xc3,0x87), // uppercase C with cedilla        E2( 0xa3, 0xc3,0x88), // uppercase E, grave accent        E2( 0xa4, 0xc3,0x8a), // uppercase E, circumflex        E2( 0xa5, 0xc3,0x8b), // capital letter E with diaresis        E2( 0xa6, 0xc3,0xab), // lowercase letter e with diaresis        E2( 0xa7, 0xc3,0x8e), // uppercase I, circumflex        E2( 0xa8, 0xc3,0x8f), // uppercase I, with diaresis        E2( 0xa9, 0xc3,0xaf), // lowercase i, with diaresis        E2( 0xaa, 0xc3,0x94), // uppercase O, circumflex        E2( 0xab, 0xc3,0x99), // uppercase U, grave accent        E2( 0xac, 0xc3,0xb9), // lowercase u, grave accent        E2( 0xad, 0xc3,0x9b), // uppercase U, circumflex        E2( 0xae, 0xc2,0xab), // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK        E2( 0xaf, 0xc2,0xbb), // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK        // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS        // THAT COME FROM HI BYTE=0x13 AND LOW BETWEEN 0x20 AND 0x3F        E2( 0xb0, 0xc3,0x83), // Uppercase A, tilde        E2( 0xb1, 0xc3,0xa3), // Lowercase a, tilde        E2( 0xb2, 0xc3,0x8d), // Uppercase I, acute accent        E2( 0xb3, 0xc3,0x8c), // Uppercase I, grave accent        E2( 0xb4, 0xc3,0xac), // Lowercase i, grave accent        E2( 0xb5, 0xc3,0x92), // Uppercase O, grave accent        E2( 0xb6, 0xc3,0xb2), // Lowercase o, grave accent        E2( 0xb7, 0xc3,0x95), // Uppercase O, tilde        E2( 0xb8, 0xc3,0xb5), // Lowercase o, tilde        E1( 0xb9, 0x7b), // Open curly brace        E1( 0xba, 0x7d), // Closing curly brace        E1( 0xbb, 0x5c), // Backslash        E1( 0xbc, 0x5e), // Caret        E1( 0xbd, 0x5f), // Underscore        E2( 0xbe, 0xc2,0xa6), // Pipe (broken bar)        E1( 0xbf, 0x7e), // Tilde (utf8 code unsure)        E2( 0xc0, 0xc3,0x84), // Uppercase A, umlaut        E2( 0xc1, 0xc3,0xa4), // Lowercase A, umlaut        E2( 0xc2, 0xc3,0x96), // Uppercase O, umlaut        E2( 0xc3, 0xc3,0xb6), // Lowercase o, umlaut        E2( 0xc4, 0xc3,0x9f), // Esszett (sharp S)        E2( 0xc5, 0xc2,0xa5), // Yen symbol        E2( 0xc6, 0xc2,0xa4), // Currency symbol        E1( 0xc7, 0x7c), // Vertical bar        E2( 0xc8, 0xc3,0x85), // Uppercase A, ring        E2( 0xc9, 0xc3,0xa5), // Lowercase A, ring        E2( 0xca, 0xc3,0x98), // Uppercase O, slash        E2( 0xcb, 0xc3,0xb8), // Lowercase o, slash        E3( 0xcc, 0xe2,0x8c,0x9c), // Upper left corner        E3( 0xcd, 0xe2,0x8c,0x9d), // Upper right corner        E3( 0xce, 0xe2,0x8c,0x9e), // Lower left corner        E3( 0xcf, 0xe2,0x8c,0x9f), // Lower right corner        E1(0,0)    };#undef E3#undef E2#undef E1    static const int i_c2utf8 = sizeof(c2utf8)/sizeof(*c2utf8);    int i;    for( i = 0; i < i_c2utf8; i++ )    {        if( c2utf8[i].c == c )            break;    }    if( i >= i_c2utf8 )    {        psz_utf8[0] = c < 0x80 ? c : '?';   /* Normal : Unsupported */        psz_utf8[1] = '\0';    }    else    {        strcpy( psz_utf8, c2utf8[i].utf8 );    }}static void Eia608Strlcat( char *d, const char *s, int i_max ){    if( i_max > 1 )        strncat( d, s, i_max-1 - strnlen(d, i_max-1));    if( i_max > 0 )        d[i_max-1] = '\0';}static void Eia608TextLine( struct eia608_screen *screen, char *psz_text, int i_text_max, int i_row, bool b_html ){    const uint8_t *p_char = screen->characters[i_row];    const eia608_color_t *p_color = screen->colors[i_row];    const eia608_font_t *p_font = screen->fonts[i_row];    int i_start;    int i_end;    int x;    eia608_color_t last_color = EIA608_COLOR_DEFAULT;    bool     b_last_italics = false;    bool     b_last_underline = false;    /* Search the start */    i_start = 0;    while( i_start < EIA608_SCREEN_COLUMNS-1 && p_char[i_start] == ' ' )        i_start++;    /* Search the end */    i_end = EIA608_SCREEN_COLUMNS-1;    while( i_end > i_start && p_char[i_end] == ' ' )        i_end--;    /* */#define CAT(t) Eia608Strlcat( psz_text, t, i_text_max )    for( x = i_start; x <= i_end; x++ )    {        eia608_color_t color = p_color[x];        bool b_italics = p_font[x] & EIA608_FONT_ITALICS;        bool b_underline = p_font[x] & EIA608_FONT_UNDERLINE;        char utf8[4];        /* */        if( b_html )        {            bool b_close_color, b_close_italics, b_close_underline;            /* We create the tags font / i / u in that orders */            b_close_color = color != last_color && last_color != EIA608_COLOR_DEFAULT;            b_close_italics = !b_italics && b_last_italics;            b_close_underline = !b_underline && b_last_underline;            /* Be sure to create valid html */            b_close_italics |= b_last_italics && b_close_color;            b_close_underline = b_last_underline && ( b_close_italics || b_close_color );            if( b_close_underline )                CAT( "</u>" );            if( b_close_italics )                CAT( "</i>" );            if( b_close_color )                CAT( "</font>" );            if( color != EIA608_COLOR_DEFAULT && color != last_color)            {                static const char *ppsz_color[] = {                    "#ffffff",  // white                    "#00ff00",  // green                    "#0000ff",  // blue                    "#00ffff",  // cyan                    "#ff0000",  // red                    "#ffff00",  // yellow                    "#ff00ff",  // magenta                    "#ffffff",  // user defined XXX we use white                };                CAT( "<font color=" );                CAT( ppsz_color[color] );                CAT( ">" );            }            if( ( b_close_italics && b_italics ) || ( b_italics && !b_last_italics ) )                CAT( "<i>" );            if( ( b_close_underline && b_underline ) || ( b_underline && !b_last_underline ) )                CAT( "<u>" );        }        /* */         Eia608TextUtf8( utf8, p_char[x] );        CAT( utf8 );        /* */        b_last_underline = b_underline;        b_last_italics = b_italics;        last_color = color;    }    if( b_html )    {        if( b_last_underline )            CAT( "</u>" );        if( b_last_italics )            CAT( "</i>" );        if( last_color != EIA608_COLOR_DEFAULT )            CAT( "</font>" );    }#undef CAT}/* */static void Eia608Init( eia608_t *h ){    memset( h, 0, sizeof(*h) );    /* */    h->i_channel = -1;    h->i_screen = 0;    Eia608ClearScreen( h, 0 );    Eia608ClearScreen( h, 1 );    /* Cursor for writing text */    h->cursor.i_column = 0;    h->cursor.i_row = 0;    h->last.d1 = 0x00;    h->last.d2 = 0x00;    h->mode = EIA608_MODE_POPUP;    h->color = EIA608_COLOR_DEFAULT;    h->font = EIA608_FONT_REGULAR;    h->i_row_rollup = EIA608_SCREEN_ROWS-1;}static bool Eia608Parse( eia608_t *h, int i_channel_selected, const uint8_t data[2] ){    const uint8_t d1 = data[0] & 0x7f; /* Removed parity bit TODO we might want to check them */    const uint8_t d2 = data[1] & 0x7f;    bool b_screen_changed = false;    if( d1 == 0 && d2 == 0 )        return false;   /* Ignore padding */    Eia608ParseChannel( h, d1 );    if( h->i_channel != i_channel_selected )        return false;    //fprintf( stderr, "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC %x %x\n", data[0], data[1] );    if( d1 >= 0x10 )    {        if( d1 >= 0x20 ||            d1 != h->last.d1 || d2 != h->last.d2 ) /* Command codes can be repeated */            b_screen_changed = Eia608ParseData( h, d1,d2 );        h->last.d1 = d1;        h->last.d2 = d2;    }    else if( ( d1 >= 0x01 && d1 <= 0x0E ) || d1 == 0x0F )    {        /* XDS block / End of XDS block */    }    return b_screen_changed;}static char *Eia608Text( eia608_t *h, bool b_html ){    const int i_size = EIA608_SCREEN_ROWS * 3 * EIA608_SCREEN_COLUMNS+1;    struct eia608_screen *screen = &h->screen[h->i_screen];    bool b_first = true;    char *psz;    int i;    /* We allocate a buffer big enough for normal case */    psz = malloc( i_size );    if( !psz )        return NULL;    *psz = '\0';    if( b_html )        Eia608Strlcat( psz, "<text>", i_size );    for( i = 0; i < EIA608_SCREEN_ROWS; i++ )    {        if( !screen->row_used[i] )            continue;        if( !b_first )            Eia608Strlcat( psz, b_html ? "<br />" : "\n", i_size );        b_first = false;        Eia608TextLine( screen, psz, i_size, i, b_html );    }    if( b_html )        Eia608Strlcat( psz, "</text>", i_size );    return psz;}static void Eia608Exit( eia608_t *h ){}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -