29 #define PUTBITS2(val)\
31 bitbuf |= (val) << bitcnt;\
41 const uint8_t *bitmap,
int linesize,
44 uint8_t *q, *line_begin;
51 for(y = 0; y <
h; y++) {
53 if (buf_size * 8 <
w * 3 + 32)
64 while (x1 <
w && bitmap[x1] ==
color)
71 }
else if (
len >= 3 &&
len <= 10) {
77 }
else if (
len >= 12 &&
len <= 27) {
85 }
else if (
len >= 29) {
116 buf_size -= q - line_begin;
123 #define PUTBITS4(val)\
125 bitbuf |= (val) << bitcnt;\
136 const uint8_t *bitmap,
int linesize,
139 uint8_t *q, *line_begin;
146 for(y = 0; y <
h; y++) {
148 if (buf_size * 8 <
w * 6 + 32)
158 color = bitmap[x1++];
159 while (x1 <
w && bitmap[x1] ==
color)
168 }
else if (
len >= 4 &&
len <= 7) {
172 }
else if (
len >= 9 &&
len <= 24) {
177 }
else if (
len >= 25) {
203 buf_size -= q - line_begin;
211 const uint8_t *bitmap,
int linesize,
214 uint8_t *q, *line_begin;
219 for (y = 0; y <
h; y++) {
221 if (buf_size * 8 <
w * 12 + 24)
229 color = bitmap[x1++];
230 while (x1 <
w && bitmap[x1] ==
color)
242 }
else if (
len > 2) {
264 buf_size -= q - line_begin;
275 uint8_t *q, *pseg_len;
276 int page_id, region_id, clut_id, object_id,
i, bpp_index, page_state;
283 if (
h->num_rects && !
h->rects)
292 bytestream_put_be16(&q, page_id);
296 bytestream_put_be16(&q, avctx->
width - 1);
297 bytestream_put_be16(&q, avctx->
height - 1);
298 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
304 if (buf_size < 8 + h->num_rects * 6)
308 bytestream_put_be16(&q, page_id);
314 *q++ = (
s->object_version << 4) | (page_state << 2) | 3;
316 for (region_id = 0; region_id <
h->num_rects; region_id++) {
319 bytestream_put_be16(&q,
h->rects[region_id]->x);
320 bytestream_put_be16(&q,
h->rects[region_id]->y);
323 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
324 buf_size -= 8 +
h->num_rects * 6;
327 for (clut_id = 0; clut_id <
h->num_rects; clut_id++) {
328 if (buf_size < 6 + h->rects[clut_id]->nb_colors * 6)
333 if (
h->rects[clut_id]->nb_colors <= 4) {
336 }
else if (
h->rects[clut_id]->nb_colors <= 16) {
339 }
else if (
h->rects[clut_id]->nb_colors <= 256) {
350 bytestream_put_be16(&q, page_id);
354 *q++ = (0 << 4) | 0
xf;
356 for(
i = 0;
i <
h->rects[clut_id]->nb_colors;
i++) {
358 *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1;
361 uint32_t x= ((uint32_t*)
h->rects[clut_id]->data[1])[
i];
362 a = (x >> 24) & 0xff;
363 r = (x >> 16) & 0xff;
374 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
375 buf_size -= 6 +
h->rects[clut_id]->nb_colors * 6;
378 if (buf_size < h->num_rects * 22)
380 for (region_id = 0; region_id <
h->num_rects; region_id++) {
384 if (
h->rects[region_id]->nb_colors <= 4) {
387 }
else if (
h->rects[region_id]->nb_colors <= 16) {
390 }
else if (
h->rects[region_id]->nb_colors <= 256) {
399 bytestream_put_be16(&q, page_id);
403 *q++ = (
s->object_version << 4) | (0 << 3) | 0x07;
404 bytestream_put_be16(&q,
h->rects[region_id]->w);
405 bytestream_put_be16(&q,
h->rects[region_id]->h);
406 *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
411 bytestream_put_be16(&q, region_id);
412 *q++ = (0 << 6) | (0 << 4);
417 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
419 buf_size -=
h->num_rects * 22;
421 for (object_id = 0; object_id <
h->num_rects; object_id++) {
422 int (*dvb_encode_rle)(uint8_t **pq,
int buf_size,
423 const uint8_t *bitmap,
int linesize,
430 if (
h->rects[object_id]->nb_colors <= 4) {
433 }
else if (
h->rects[object_id]->nb_colors <= 16) {
436 }
else if (
h->rects[object_id]->nb_colors <= 256) {
446 bytestream_put_be16(&q, page_id);
450 bytestream_put_be16(&q, object_id);
451 *q++ = (
s->object_version << 4) | (0 << 2) | (0 << 1) | 1;
455 uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr;
460 pbottom_field_len = q;
465 ret = dvb_encode_rle(&q, buf_size,
466 h->rects[object_id]->data[0],
467 h->rects[object_id]->w * 2,
468 h->rects[object_id]->w,
469 h->rects[object_id]->h >> 1);
474 ret = dvb_encode_rle(&q, buf_size,
475 h->rects[object_id]->data[0] +
h->rects[object_id]->w,
476 h->rects[object_id]->w * 2,
477 h->rects[object_id]->w,
478 h->rects[object_id]->h >> 1);
483 bytestream_put_be16(&ptop_field_len, bottom_ptr - top_ptr);
484 bytestream_put_be16(&pbottom_field_len, q - bottom_ptr);
487 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
497 bytestream_put_be16(&q, page_id);
501 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
504 s->object_version = (
s->object_version + 1) & 0
xf;