30 #define PUTBITS2(val)\
32 bitbuf |= (val) << bitcnt;\
42 const uint8_t *bitmap,
int linesize,
45 uint8_t *q, *line_begin;
52 for(y = 0; y <
h; y++) {
54 if (buf_size * 8 <
w * 3 + 32)
65 while (x1 <
w && bitmap[x1] ==
color)
72 }
else if (
len >= 3 &&
len <= 10) {
78 }
else if (
len >= 12 &&
len <= 27) {
86 }
else if (
len >= 29) {
117 buf_size -= q - line_begin;
124 #define PUTBITS4(val)\
126 bitbuf |= (val) << bitcnt;\
137 const uint8_t *bitmap,
int linesize,
140 uint8_t *q, *line_begin;
147 for(y = 0; y <
h; y++) {
149 if (buf_size * 8 <
w * 6 + 32)
159 color = bitmap[x1++];
160 while (x1 <
w && bitmap[x1] ==
color)
169 }
else if (
len >= 4 &&
len <= 7) {
173 }
else if (
len >= 9 &&
len <= 24) {
178 }
else if (
len >= 25) {
204 buf_size -= q - line_begin;
212 const uint8_t *bitmap,
int linesize,
215 uint8_t *q, *line_begin;
220 for (y = 0; y <
h; y++) {
222 if (buf_size * 8 <
w * 12 + 24)
230 color = bitmap[x1++];
231 while (x1 <
w && bitmap[x1] ==
color)
243 }
else if (
len > 2) {
265 buf_size -= q - line_begin;
276 uint8_t *q, *pseg_len;
277 int page_id, region_id, clut_id, object_id,
i, bpp_index, page_state;
284 if (
h->num_rects && !
h->rects)
287 if (
h->num_rects >= 256)
296 bytestream_put_be16(&q, page_id);
300 bytestream_put_be16(&q, avctx->
width - 1);
301 bytestream_put_be16(&q, avctx->
height - 1);
302 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
308 if (buf_size < 8 + h->num_rects * 6)
312 bytestream_put_be16(&q, page_id);
318 *q++ = (
s->object_version << 4) | (page_state << 2) | 3;
320 for (region_id = 0; region_id <
h->num_rects; region_id++) {
323 bytestream_put_be16(&q,
h->rects[region_id]->x);
324 bytestream_put_be16(&q,
h->rects[region_id]->y);
327 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
328 buf_size -= 8 +
h->num_rects * 6;
331 for (clut_id = 0; clut_id <
h->num_rects; clut_id++) {
334 if (
h->rects[clut_id]->nb_colors <= 4
U) {
337 }
else if (
h->rects[clut_id]->nb_colors <= 16
U) {
340 }
else if (
h->rects[clut_id]->nb_colors <= 256
U) {
347 if (buf_size < 6 + h->rects[clut_id]->nb_colors * 6)
353 bytestream_put_be16(&q, page_id);
357 *q++ = (0 << 4) | 0
xf;
359 for(
i = 0;
i <
h->rects[clut_id]->nb_colors;
i++) {
361 *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1;
364 uint32_t x= ((uint32_t*)
h->rects[clut_id]->data[1])[
i];
365 a = (x >> 24) & 0xff;
366 r = (x >> 16) & 0xff;
377 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
378 buf_size -= 6 +
h->rects[clut_id]->nb_colors * 6;
381 if (buf_size < h->num_rects * 22)
383 for (region_id = 0; region_id <
h->num_rects; region_id++) {
387 if (
h->rects[region_id]->nb_colors <= 4) {
390 }
else if (
h->rects[region_id]->nb_colors <= 16) {
393 }
else if (
h->rects[region_id]->nb_colors <= 256) {
402 bytestream_put_be16(&q, page_id);
406 *q++ = (
s->object_version << 4) | (0 << 3) | 0x07;
407 bytestream_put_be16(&q,
h->rects[region_id]->w);
408 bytestream_put_be16(&q,
h->rects[region_id]->h);
409 *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
414 bytestream_put_be16(&q, region_id);
415 *q++ = (0 << 6) | (0 << 4);
420 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
422 buf_size -=
h->num_rects * 22;
424 for (object_id = 0; object_id <
h->num_rects; object_id++) {
425 int (*dvb_encode_rle)(uint8_t **pq,
int buf_size,
426 const uint8_t *bitmap,
int linesize,
433 if (
h->rects[object_id]->nb_colors <= 4) {
436 }
else if (
h->rects[object_id]->nb_colors <= 16) {
439 }
else if (
h->rects[object_id]->nb_colors <= 256) {
449 bytestream_put_be16(&q, page_id);
453 bytestream_put_be16(&q, object_id);
454 *q++ = (
s->object_version << 4) | (0 << 2) | (0 << 1) | 1;
458 uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr;
463 pbottom_field_len = q;
468 ret = dvb_encode_rle(&q, buf_size,
469 h->rects[object_id]->data[0],
470 h->rects[object_id]->w * 2,
471 h->rects[object_id]->w,
472 h->rects[object_id]->h >> 1);
477 ret = dvb_encode_rle(&q, buf_size,
478 h->rects[object_id]->data[0] +
h->rects[object_id]->w,
479 h->rects[object_id]->w * 2,
480 h->rects[object_id]->w,
481 h->rects[object_id]->h >> 1);
486 bytestream_put_be16(&ptop_field_len, bottom_ptr - top_ptr);
487 bytestream_put_be16(&pbottom_field_len, q - bottom_ptr);
490 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
500 bytestream_put_be16(&q, page_id);
504 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
507 s->object_version = (
s->object_version + 1) & 0
xf;