annotate sub_cc.c @ 23510:a6c619ee9d30

Teletext support for tv:// (v4l and v4l2 only) modified patch from Otvos Attila oattila at chello dot hu Module uses zvbi library for all low-level VBI operations (like I/O with vbi device, converting vbi pages into usefull vbi_page stuctures, rendering them into RGB32 images). All teletext related stuff (except properties, slave commands and rendering osd in text mode or RGB32 rendered teletext pages in spu mode) is implemented in tvi_vbi.c New properties: teletext_page - switching between pages teletext_mode - switch between on/off/opaque/transparent modes teletext_format - (currently read-only) allows to get format info (black/white,gray,text) teletext_half_page - trivial zooming (displaying top/bottom half of teletext page) New slave commands: teletext_add_dec - user interface for jumping to any page by editing page number interactively teletext_go_link - goes though links, specified on current page
author voroshil
date Sun, 10 Jun 2007 00:06:12 +0000
parents 530b31f3e60a
children 31efcf6a10d0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
1 /*
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
2 * sub_cc.c - Decoder for Closed Captions
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
3 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
4 * This decoder relies on MPlayer's OSD to display subtitles.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
5 * Be warned that the decoding is somewhat preliminary, though it basically works.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
6 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
7 * Most notably, only the text information is decoded as of now, discarding color,
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
8 * background and position info (see source below).
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
9 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
10 * by Matteo Giani
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
11 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
12 * uses source from the xine closed captions decoder
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
13 */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
14
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
15
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
16 #include <stdio.h>
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
17 #include <stdlib.h>
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7472
diff changeset
18 #include <string.h>
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
19
17630
7c4eef408b6b include config.h before includes that need it
iive
parents: 17566
diff changeset
20 #include "config.h"
6791
a3b2f80f3a26 codmetics :)
arpi
parents: 6784
diff changeset
21 #include "sub_cc.h"
a3b2f80f3a26 codmetics :)
arpi
parents: 6784
diff changeset
22
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
23 #include "subreader.h"
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
24
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
25 #include "libvo/video_out.h"
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
26 #include "libvo/sub.h"
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
27
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
28
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
29 #define CC_MAX_LINE_LENGTH 64
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
30
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
31 static char chartbl[128];
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
32
6791
a3b2f80f3a26 codmetics :)
arpi
parents: 6784
diff changeset
33 static subtitle buf1,buf2;
a3b2f80f3a26 codmetics :)
arpi
parents: 6784
diff changeset
34 static subtitle *fb,*bb;
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
35
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
36 static unsigned int cursor_pos=0;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
37
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
38 static int inited=0;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
39
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
40 static void build_char_table(void)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
41 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
42 int i;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
43 /* first the normal ASCII codes */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
44 for (i = 0; i < 128; i++)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
45 chartbl[i] = (char) i;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
46 /* now the special codes */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
47 chartbl[0x2a] = 'á';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
48 chartbl[0x5c] = 'é';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
49 chartbl[0x5e] = 'í';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
50 chartbl[0x5f] = 'ó';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
51 chartbl[0x60] = 'ú';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
52 chartbl[0x7b] = 'ç';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
53 chartbl[0x7c] = '÷';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
54 chartbl[0x7d] = 'Ñ';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
55 chartbl[0x7e] = 'ñ';
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
56 chartbl[0x7f] = '¤'; /* FIXME: this should be a solid block */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
57 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
58
6791
a3b2f80f3a26 codmetics :)
arpi
parents: 6784
diff changeset
59 static void clear_buffer(subtitle *buf)
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
60 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
61 int i;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
62 buf->lines=0;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
63 for(i=0;i<SUB_MAX_TEXT;i++) if(buf->text[i]) {free(buf->text[i]);buf->text[i]=NULL;}
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
64 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
65
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
66
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 8123
diff changeset
67 void subcc_init(void)
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
68 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
69 int i;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
70 //printf("subcc_init(): initing...\n");
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
71 build_char_table();
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
72 for(i=0;i<SUB_MAX_TEXT;i++) {buf1.text[i]=buf2.text[i]=NULL;}
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
73 buf1.lines=buf2.lines=0;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
74 fb=&buf1;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
75 bb=&buf2;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
76
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
77 inited=1;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
78 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
79
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
80 static void append_char(char c)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
81 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
82 if(!bb->lines) {bb->lines++; cursor_pos=0;}
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
83 if(bb->text[bb->lines - 1]==NULL)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
84 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
85 bb->text[bb->lines - 1]=malloc(CC_MAX_LINE_LENGTH);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
86 memset(bb->text[bb->lines - 1],0,CC_MAX_LINE_LENGTH);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
87 cursor_pos=0;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
88 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
89
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
90 if(c=='\n')
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
91 {
21237
530b31f3e60a Sanity-check number of lines in CC subtitle
reimar
parents: 21236
diff changeset
92 if(cursor_pos>0 && bb->lines < SUB_MAX_TEXT)
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
93 bb->lines++;cursor_pos=0;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
94 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
95 else
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
96 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
97 if(cursor_pos==CC_MAX_LINE_LENGTH-1)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
98 {
17971
fd0d4b94b5ec Change some printf calls to fprintf.
diego
parents: 17630
diff changeset
99 fprintf(stderr,"sub_cc.c: append_char() reached CC_MAX_LINE_LENGTH!\n");
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
100 return;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
101 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
102 bb->text[bb->lines - 1][cursor_pos++]=c;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
103 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
104 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
105
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
106
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 8123
diff changeset
107 static void swap_buffers(void)
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
108 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
109 subtitle *foo;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
110 foo=fb;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
111 fb=bb;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
112 bb=foo;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
113 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
114
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
115 static void display_buffer(subtitle * buf)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
116 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
117 vo_sub=buf;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
118 vo_osd_changed(OSDTYPE_SUBTITLE);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
119 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
120
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
121
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
122 static void cc_decode_EIA608(unsigned short int data)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
123 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
124
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
125 static unsigned short int lastcode=0x0000;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
126 unsigned char c1 = data & 0x7f;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
127 unsigned char c2 = (data >> 8) & 0x7f;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
128
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
129 if (c1 & 0x60) { /* normal character, 0x20 <= c1 <= 0x7f */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
130 append_char(chartbl[c1]);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
131 if(c2 & 0x60) /*c2 might not be a normal char even if c1 is*/
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
132 append_char(chartbl[c2]);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
133 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
134 else if (c1 & 0x10) // control code / special char
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
135 {
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 6791
diff changeset
136 // int channel= (c1 & 0x08) >> 3;
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
137 c1&=~0x08;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
138 if(data!=lastcode)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
139 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
140 if(c2 & 0x40) { /*PAC, Preamble Address Code */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
141 append_char('\n'); /*FIXME properly interpret PACs*/
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
142 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
143 else
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
144 switch(c1)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
145 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
146 case 0x10: break; // ext attribute
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
147 case 0x11:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
148 if((c2 & 0x30)==0x30)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
149 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
150 //printf("[debug]:Special char (ignored)\n");
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
151 /*cc_decode_special_char()*/;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
152 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
153 else if (c2 & 0x20)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
154 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
155 //printf("[debug]: midrow_attr (ignored)\n");
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
156 /*cc_decode_midrow_attr()*/;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
157 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
158 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
159 case 0x14:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
160 switch(c2)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
161 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
162 case 0x2C: display_buffer(NULL); //EDM
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
163 clear_buffer(fb); break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
164 case 0x2d: append_char('\n'); //carriage return
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
165 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
166 case 0x2e: clear_buffer(bb); //ENM
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
167 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
168 case 0x2f: swap_buffers(); //Swap buffers
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
169 display_buffer(fb);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
170 clear_buffer(bb);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
171 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
172 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
173 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
174 case 0x17:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
175 if( c2>=0x21 && c2<=0x23) //TAB
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
176 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
177 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
178 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
179 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
180 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
181 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
182 lastcode=data;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
183 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
184
21236
3ec5917cdae2 Cleanup for uselessly complicated closed-caption subtitle handling
reimar
parents: 21234
diff changeset
185 static void subcc_decode(unsigned char *inputbuffer, unsigned int inputlength)
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
186 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
187 /* The first number may denote a channel number. I don't have the
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
188 * EIA-708 standard, so it is hard to say.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
189 * From what I could figure out so far, the general format seems to be:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
190 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
191 * repeat
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
192 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
193 * 0xfe starts 2 byte sequence of unknown purpose. It might denote
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
194 * field #2 in line 21 of the VBI. We'll ignore it for the
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
195 * time being.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
196 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
197 * 0xff starts 2 byte EIA-608 sequence, field #1 in line 21 of the VBI.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
198 * Followed by a 3-code triplet that starts either with 0xff or
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
199 * 0xfe. In either case, the following triplet needs to be ignored
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
200 * for line 21, field 1.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
201 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
202 * 0x00 is padding, followed by 2 more 0x00.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
203 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
204 * 0x01 always seems to appear at the beginning, always seems to
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
205 * be followed by 0xf8, 8-bit number.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
206 * The lower 7 bits of this 8-bit number seem to denote the
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
207 * number of code triplets that follow.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
208 * The most significant bit denotes whether the Line 21 field 1
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
209 * captioning information is at odd or even triplet offsets from this
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
210 * beginning triplet. 1 denotes odd offsets, 0 denotes even offsets.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
211 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
212 * Most captions are encoded with odd offsets, so this is what we
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
213 * will assume.
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
214 *
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
215 * until end of packet
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
216 */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
217 unsigned char *current = inputbuffer;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
218 unsigned int curbytes = 0;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
219 unsigned char data1, data2;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
220 unsigned char cc_code;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
221 int odd_offset = 1;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
222
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
223 while (curbytes < inputlength) {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
224 int skip = 2;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
225
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
226 cc_code = *(current);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
227
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
228 if (inputlength - curbytes < 2) {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
229 #ifdef LOG_DEBUG
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
230 fprintf(stderr, "Not enough data for 2-byte CC encoding\n");
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
231 #endif
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
232 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
233 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
234
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
235 data1 = *(current+1);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
236 data2 = *(current + 2);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
237 current++; curbytes++;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
238
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
239 switch (cc_code) {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
240 case 0xfe:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
241 /* expect 2 byte encoding (perhaps CC3, CC4?) */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
242 /* ignore for time being */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
243 skip = 2;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
244 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
245
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
246 case 0xff:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
247 /* expect EIA-608 CC1/CC2 encoding */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
248 // FIXME check parity!
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
249 // Parity check omitted assuming we are reading from a DVD and therefore
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
250 // we should encounter no "transmission errors".
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
251 cc_decode_EIA608(data1 | (data2 << 8));
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
252 skip = 5;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
253 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
254
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
255 case 0x00:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
256 /* This seems to be just padding */
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
257 skip = 2;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
258 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
259
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
260 case 0x01:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
261 odd_offset = data2 & 0x80;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
262 if (odd_offset)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
263 skip = 2;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
264 else
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
265 skip = 5;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
266 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
267
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
268 default:
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
269 //#ifdef LOG_DEBUG
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
270 fprintf(stderr, "Unknown CC encoding: %x\n", cc_code);
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
271 //#endif
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
272 skip = 2;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
273 break;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
274 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
275 current += skip;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
276 curbytes += skip;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
277 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
278 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
279
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
280
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
281 void subcc_process_data(unsigned char *inputdata,unsigned int len)
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
282 {
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
283 if(!subcc_enabled) return;
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
284 if(!inited) subcc_init();
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
285
21236
3ec5917cdae2 Cleanup for uselessly complicated closed-caption subtitle handling
reimar
parents: 21234
diff changeset
286 subcc_decode(inputdata, len);
6784
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
287 }
b38e38b6f88f DVD Closed Captioning support, patch by Matteo Giani <matgiani@ctonet.it>, small changes by me.
atmos4
parents:
diff changeset
288