annotate dvbsub.c @ 10934:9b31065f013d libavcodec

Dont waste time initializing stuff for deblocking intra mbs, none of it is used.
author michael
date Tue, 19 Jan 2010 03:14:45 +0000
parents 04423b2f6e0b
children 8a4984c5cacc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
1 /*
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
2 * DVB subtitle encoding for ffmpeg
8629
04423b2f6e0b cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 8516
diff changeset
3 * Copyright (c) 2005 Fabrice Bellard
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
15 * Lesser General Public License for more details.
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
16 *
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
20 */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
21 #include "avcodec.h"
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
22 #include "bytestream.h"
5354
dfa6e7fa2bac create colorspace.h and use it where appropriate
benoit
parents: 5067
diff changeset
23 #include "colorspace.h"
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
24
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
25 typedef struct DVBSubtitleContext {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
26 int hide_state;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
27 int object_version;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
28 } DVBSubtitleContext;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
29
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
30 #define PUTBITS2(val)\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
31 {\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
32 bitbuf |= (val) << bitcnt;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
33 bitcnt -= 2;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
34 if (bitcnt < 0) {\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
35 bitcnt = 6;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
36 *q++ = bitbuf;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
37 bitbuf = 0;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
38 }\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
39 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
40
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
41 static void dvb_encode_rle2(uint8_t **pq,
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
42 const uint8_t *bitmap, int linesize,
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
43 int w, int h)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
44 {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
45 uint8_t *q;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
46 unsigned int bitbuf;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
47 int bitcnt;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
48 int x, y, len, x1, v, color;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
49
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
50 q = *pq;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2946
diff changeset
51
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
52 for(y = 0; y < h; y++) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
53 *q++ = 0x10;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
54 bitbuf = 0;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
55 bitcnt = 6;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2946
diff changeset
56
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
57 x = 0;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
58 while (x < w) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
59 x1 = x;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
60 color = bitmap[x1++];
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
61 while (x1 < w && bitmap[x1] == color)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
62 x1++;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
63 len = x1 - x;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
64 if (color == 0 && len == 2) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
65 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
66 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
67 PUTBITS2(1);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
68 } else if (len >= 3 && len <= 10) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
69 v = len - 3;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
70 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
71 PUTBITS2((v >> 2) | 2);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
72 PUTBITS2(v & 3);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
73 PUTBITS2(color);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
74 } else if (len >= 12 && len <= 27) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
75 v = len - 12;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
76 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
77 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
78 PUTBITS2(2);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
79 PUTBITS2(v >> 2);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
80 PUTBITS2(v & 3);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
81 PUTBITS2(color);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
82 } else if (len >= 29) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
83 /* length = 29 ... 284 */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
84 if (len > 284)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
85 len = 284;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
86 v = len - 29;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
87 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
88 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
89 PUTBITS2(3);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
90 PUTBITS2((v >> 6));
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
91 PUTBITS2((v >> 4) & 3);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
92 PUTBITS2((v >> 2) & 3);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
93 PUTBITS2(v & 3);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
94 PUTBITS2(color);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
95 } else {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
96 PUTBITS2(color);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
97 if (color == 0) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
98 PUTBITS2(1);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
99 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
100 len = 1;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
101 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
102 x += len;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
103 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
104 /* end of line */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
105 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
106 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
107 PUTBITS2(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
108 if (bitcnt != 6) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
109 *q++ = bitbuf;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
110 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
111 *q++ = 0xf0;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
112 bitmap += linesize;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
113 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
114 *pq = q;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
115 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
116
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
117 #define PUTBITS4(val)\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
118 {\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
119 bitbuf |= (val) << bitcnt;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
120 bitcnt -= 4;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
121 if (bitcnt < 0) {\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
122 bitcnt = 4;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
123 *q++ = bitbuf;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
124 bitbuf = 0;\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
125 }\
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
126 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
127
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
128 /* some DVB decoders only implement 4 bits/pixel */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
129 static void dvb_encode_rle4(uint8_t **pq,
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
130 const uint8_t *bitmap, int linesize,
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
131 int w, int h)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
132 {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
133 uint8_t *q;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
134 unsigned int bitbuf;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
135 int bitcnt;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
136 int x, y, len, x1, v, color;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
137
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
138 q = *pq;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2946
diff changeset
139
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
140 for(y = 0; y < h; y++) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
141 *q++ = 0x11;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
142 bitbuf = 0;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
143 bitcnt = 4;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2946
diff changeset
144
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
145 x = 0;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
146 while (x < w) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
147 x1 = x;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
148 color = bitmap[x1++];
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
149 while (x1 < w && bitmap[x1] == color)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
150 x1++;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
151 len = x1 - x;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
152 if (color == 0 && len == 2) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
153 PUTBITS4(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
154 PUTBITS4(0xd);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
155 } else if (color == 0 && (len >= 3 && len <= 9)) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
156 PUTBITS4(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
157 PUTBITS4(len - 2);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
158 } else if (len >= 4 && len <= 7) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
159 PUTBITS4(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
160 PUTBITS4(8 + len - 4);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
161 PUTBITS4(color);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
162 } else if (len >= 9 && len <= 24) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
163 PUTBITS4(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
164 PUTBITS4(0xe);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
165 PUTBITS4(len - 9);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
166 PUTBITS4(color);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
167 } else if (len >= 25) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
168 if (len > 280)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
169 len = 280;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
170 v = len - 25;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
171 PUTBITS4(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
172 PUTBITS4(0xf);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
173 PUTBITS4(v >> 4);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
174 PUTBITS4(v & 0xf);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
175 PUTBITS4(color);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
176 } else {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
177 PUTBITS4(color);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
178 if (color == 0) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
179 PUTBITS4(0xc);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
180 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
181 len = 1;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
182 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
183 x += len;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
184 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
185 /* end of line */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
186 PUTBITS4(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
187 PUTBITS4(0);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
188 if (bitcnt != 4) {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
189 *q++ = bitbuf;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
190 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
191 *q++ = 0xf0;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
192 bitmap += linesize;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
193 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
194 *pq = q;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
195 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
196
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2946
diff changeset
197 static int encode_dvb_subtitles(DVBSubtitleContext *s,
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
198 uint8_t *outbuf, AVSubtitle *h)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
199 {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
200 uint8_t *q, *pseg_len;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
201 int page_id, region_id, clut_id, object_id, i, bpp_index, page_state;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
202
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
203
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
204 q = outbuf;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
205
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
206 page_id = 1;
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
207
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
208 if (h->num_rects == 0 || h->rects == NULL)
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
209 return -1;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
210
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
211 *q++ = 0x00; /* subtitle_stream_id */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
212
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
213 /* page composition segment */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
214
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
215 *q++ = 0x0f; /* sync_byte */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
216 *q++ = 0x10; /* segment_type */
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
217 bytestream_put_be16(&q, page_id);
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
218 pseg_len = q;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
219 q += 2; /* segment length */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
220 *q++ = 30; /* page_timeout (seconds) */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
221 if (s->hide_state)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
222 page_state = 0; /* normal case */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
223 else
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
224 page_state = 2; /* mode change */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
225 /* page_version = 0 + page_state */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2946
diff changeset
226 *q++ = s->object_version | (page_state << 2) | 3;
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
227
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
228 for (region_id = 0; region_id < h->num_rects; region_id++) {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
229 *q++ = region_id;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
230 *q++ = 0xff; /* reserved */
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
231 bytestream_put_be16(&q, h->rects[region_id]->x); /* left pos */
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
232 bytestream_put_be16(&q, h->rects[region_id]->y); /* top pos */
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
233 }
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
234
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
235 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
236
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
237 if (!s->hide_state) {
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
238 for (clut_id = 0; clut_id < h->num_rects; clut_id++) {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
239
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
240 /* CLUT segment */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
241
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
242 if (h->rects[clut_id]->nb_colors <= 4) {
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
243 /* 2 bpp, some decoders do not support it correctly */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
244 bpp_index = 0;
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
245 } else if (h->rects[clut_id]->nb_colors <= 16) {
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
246 /* 4 bpp, standard encoding */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
247 bpp_index = 1;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
248 } else {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
249 return -1;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
250 }
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
251
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
252 *q++ = 0x0f; /* sync byte */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
253 *q++ = 0x12; /* CLUT definition segment */
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
254 bytestream_put_be16(&q, page_id);
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
255 pseg_len = q;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
256 q += 2; /* segment length */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
257 *q++ = clut_id;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
258 *q++ = (0 << 4) | 0xf; /* version = 0 */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
259
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
260 for(i = 0; i < h->rects[clut_id]->nb_colors; i++) {
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
261 *q++ = i; /* clut_entry_id */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
262 *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1; /* 2 bits/pixel full range */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
263 {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
264 int a, r, g, b;
8516
315b302fcd1d Replace AVSubtitleRect.rgba_palette and bitmap by AVPicture.
michael
parents: 8512
diff changeset
265 uint32_t x= ((uint32_t*)h->rects[clut_id]->pict.data[1])[i];
315b302fcd1d Replace AVSubtitleRect.rgba_palette and bitmap by AVPicture.
michael
parents: 8512
diff changeset
266 a = (x >> 24) & 0xff;
315b302fcd1d Replace AVSubtitleRect.rgba_palette and bitmap by AVPicture.
michael
parents: 8512
diff changeset
267 r = (x >> 16) & 0xff;
315b302fcd1d Replace AVSubtitleRect.rgba_palette and bitmap by AVPicture.
michael
parents: 8512
diff changeset
268 g = (x >> 8) & 0xff;
315b302fcd1d Replace AVSubtitleRect.rgba_palette and bitmap by AVPicture.
michael
parents: 8512
diff changeset
269 b = (x >> 0) & 0xff;
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
270
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
271 *q++ = RGB_TO_Y_CCIR(r, g, b);
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
272 *q++ = RGB_TO_V_CCIR(r, g, b, 0);
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
273 *q++ = RGB_TO_U_CCIR(r, g, b, 0);
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
274 *q++ = 255 - a;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
275 }
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
276 }
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
277
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
278 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
279 }
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
280 }
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
281
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
282 for (region_id = 0; region_id < h->num_rects; region_id++) {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
283
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
284 /* region composition segment */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2946
diff changeset
285
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
286 if (h->rects[region_id]->nb_colors <= 4) {
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
287 /* 2 bpp, some decoders do not support it correctly */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
288 bpp_index = 0;
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
289 } else if (h->rects[region_id]->nb_colors <= 16) {
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
290 /* 4 bpp, standard encoding */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
291 bpp_index = 1;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
292 } else {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
293 return -1;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
294 }
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
295
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
296 *q++ = 0x0f; /* sync_byte */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
297 *q++ = 0x11; /* segment_type */
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
298 bytestream_put_be16(&q, page_id);
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
299 pseg_len = q;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
300 q += 2; /* segment length */
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
301 *q++ = region_id;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
302 *q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no fill */
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
303 bytestream_put_be16(&q, h->rects[region_id]->w); /* region width */
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
304 bytestream_put_be16(&q, h->rects[region_id]->h); /* region height */
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
305 *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
306 *q++ = region_id; /* clut_id == region_id */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
307 *q++ = 0; /* 8 bit fill colors */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
308 *q++ = 0x03; /* 4 bit and 2 bit fill colors */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
309
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
310 if (!s->hide_state) {
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
311 bytestream_put_be16(&q, region_id); /* object_id == region_id */
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
312 *q++ = (0 << 6) | (0 << 4);
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
313 *q++ = 0;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
314 *q++ = 0xf0;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
315 *q++ = 0;
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
316 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
317
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
318 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
319 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
320
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
321 if (!s->hide_state) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2946
diff changeset
322
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
323 for (object_id = 0; object_id < h->num_rects; object_id++) {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
324 /* Object Data segment */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
325
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
326 if (h->rects[object_id]->nb_colors <= 4) {
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
327 /* 2 bpp, some decoders do not support it correctly */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
328 bpp_index = 0;
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
329 } else if (h->rects[object_id]->nb_colors <= 16) {
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
330 /* 4 bpp, standard encoding */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
331 bpp_index = 1;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
332 } else {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
333 return -1;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
334 }
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
335
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
336 *q++ = 0x0f; /* sync byte */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
337 *q++ = 0x13;
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
338 bytestream_put_be16(&q, page_id);
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
339 pseg_len = q;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
340 q += 2; /* segment length */
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
341
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
342 bytestream_put_be16(&q, object_id);
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
343 *q++ = (s->object_version << 4) | (0 << 2) | (0 << 1) | 1; /* version = 0,
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
344 onject_coding_method,
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
345 non_modifying_color_flag */
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
346 {
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
347 uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
348 void (*dvb_encode_rle)(uint8_t **pq,
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
349 const uint8_t *bitmap, int linesize,
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
350 int w, int h);
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
351 ptop_field_len = q;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
352 q += 2;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
353 pbottom_field_len = q;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
354 q += 2;
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
355
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
356 if (bpp_index == 0)
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
357 dvb_encode_rle = dvb_encode_rle2;
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
358 else
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
359 dvb_encode_rle = dvb_encode_rle4;
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
360
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
361 top_ptr = q;
8516
315b302fcd1d Replace AVSubtitleRect.rgba_palette and bitmap by AVPicture.
michael
parents: 8512
diff changeset
362 dvb_encode_rle(&q, h->rects[object_id]->pict.data[0], h->rects[object_id]->w * 2,
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
363 h->rects[object_id]->w, h->rects[object_id]->h >> 1);
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
364 bottom_ptr = q;
8516
315b302fcd1d Replace AVSubtitleRect.rgba_palette and bitmap by AVPicture.
michael
parents: 8512
diff changeset
365 dvb_encode_rle(&q, h->rects[object_id]->pict.data[0] + h->rects[object_id]->w,
8512
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
366 h->rects[object_id]->w * 2, h->rects[object_id]->w,
aa45029f5cd7 Change AVSubtitle.rects to an array of pointers so ABI does not break
michael
parents: 7040
diff changeset
367 h->rects[object_id]->h >> 1);
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
368
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
369 bytestream_put_be16(&ptop_field_len, bottom_ptr - top_ptr);
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
370 bytestream_put_be16(&pbottom_field_len, q - bottom_ptr);
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
371 }
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
372
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
373 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
2796
95c35706acbb DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 2756
diff changeset
374 }
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
375 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
376
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
377 /* end of display set segment */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
378
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
379 *q++ = 0x0f; /* sync_byte */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
380 *q++ = 0x80; /* segment_type */
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
381 bytestream_put_be16(&q, page_id);
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
382 pseg_len = q;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
383 q += 2; /* segment length */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
384
5067
6166fbf375cc Remove duplicate bytestream functions
ramiro
parents: 3947
diff changeset
385 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
386
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
387 *q++ = 0xff; /* end of PES data */
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
388
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
389 s->object_version = (s->object_version + 1) & 0xf;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
390 s->hide_state = !s->hide_state;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
391 return q - outbuf;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
392 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
393
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
394 static int dvbsub_encode(AVCodecContext *avctx,
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
395 unsigned char *buf, int buf_size, void *data)
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
396 {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
397 DVBSubtitleContext *s = avctx->priv_data;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
398 AVSubtitle *sub = data;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
399 int ret;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
400
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
401 ret = encode_dvb_subtitles(s, buf, sub);
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
402 return ret;
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
403 }
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
404
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
405 AVCodec dvbsub_encoder = {
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
406 "dvbsub",
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
407 CODEC_TYPE_SUBTITLE,
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
408 CODEC_ID_DVB_SUBTITLE,
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
409 sizeof(DVBSubtitleContext),
5941
d030978bcd93 remove some empty close/init functions in avcodec
aurel
parents: 5354
diff changeset
410 NULL,
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
411 dvbsub_encode,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6712
diff changeset
412 .long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"),
2756
d8874c8749ec subtitle codec type support
bellard
parents:
diff changeset
413 };