29 #define PUTBITS2(val)\
31 bitbuf |= (val) << bitcnt;\
41 const uint8_t *bitmap,
int linesize,
51 for(y = 0; y <
h; y++) {
60 while (x1 <
w && bitmap[x1] ==
color)
67 }
else if (
len >= 3 &&
len <= 10) {
73 }
else if (
len >= 12 &&
len <= 27) {
81 }
else if (
len >= 29) {
116 #define PUTBITS4(val)\
118 bitbuf |= (val) << bitcnt;\
129 const uint8_t *bitmap,
int linesize,
139 for(y = 0; y <
h; y++) {
147 color = bitmap[x1++];
148 while (x1 <
w && bitmap[x1] ==
color)
157 }
else if (
len >= 4 &&
len <= 7) {
161 }
else if (
len >= 9 &&
len <= 24) {
166 }
else if (
len >= 25) {
197 const uint8_t *bitmap,
int linesize,
205 for (y = 0; y <
h; y++) {
211 color = bitmap[x1++];
212 while (x1 <
w && bitmap[x1] ==
color)
224 }
else if (
len > 2) {
255 int page_id, region_id, clut_id, object_id,
i, bpp_index, page_state;
262 if (
h->num_rects && !
h->rects)
269 bytestream_put_be16(&q, page_id);
273 bytestream_put_be16(&q, avctx->
width - 1);
274 bytestream_put_be16(&q, avctx->
height - 1);
275 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
282 bytestream_put_be16(&q, page_id);
288 *q++ = (
s->object_version << 4) | (page_state << 2) | 3;
290 for (region_id = 0; region_id <
h->num_rects; region_id++) {
293 bytestream_put_be16(&q,
h->rects[region_id]->x);
294 bytestream_put_be16(&q,
h->rects[region_id]->y);
297 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
300 for (clut_id = 0; clut_id <
h->num_rects; clut_id++) {
304 if (
h->rects[clut_id]->nb_colors <= 4) {
307 }
else if (
h->rects[clut_id]->nb_colors <= 16) {
310 }
else if (
h->rects[clut_id]->nb_colors <= 256) {
321 bytestream_put_be16(&q, page_id);
325 *q++ = (0 << 4) | 0
xf;
327 for(
i = 0;
i <
h->rects[clut_id]->nb_colors;
i++) {
329 *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1;
332 uint32_t x= ((uint32_t*)
h->rects[clut_id]->data[1])[
i];
333 a = (x >> 24) & 0xff;
334 r = (x >> 16) & 0xff;
345 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
349 for (region_id = 0; region_id <
h->num_rects; region_id++) {
353 if (
h->rects[region_id]->nb_colors <= 4) {
356 }
else if (
h->rects[region_id]->nb_colors <= 16) {
359 }
else if (
h->rects[region_id]->nb_colors <= 256) {
368 bytestream_put_be16(&q, page_id);
372 *q++ = (
s->object_version << 4) | (0 << 3) | 0x07;
373 bytestream_put_be16(&q,
h->rects[region_id]->w);
374 bytestream_put_be16(&q,
h->rects[region_id]->h);
375 *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
380 bytestream_put_be16(&q, region_id);
381 *q++ = (0 << 6) | (0 << 4);
386 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
391 for (object_id = 0; object_id <
h->num_rects; object_id++) {
392 void (*dvb_encode_rle)(
uint8_t **pq,
393 const uint8_t *bitmap,
int linesize,
397 if (
h->rects[object_id]->nb_colors <= 4) {
400 }
else if (
h->rects[object_id]->nb_colors <= 16) {
403 }
else if (
h->rects[object_id]->nb_colors <= 256) {
413 bytestream_put_be16(&q, page_id);
417 bytestream_put_be16(&q, object_id);
418 *q++ = (
s->object_version << 4) | (0 << 2) | (0 << 1) | 1;
422 uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr;
426 pbottom_field_len = q;
430 dvb_encode_rle(&q,
h->rects[object_id]->data[0],
h->rects[object_id]->w * 2,
431 h->rects[object_id]->w,
h->rects[object_id]->h >> 1);
433 dvb_encode_rle(&q,
h->rects[object_id]->data[0] +
h->rects[object_id]->w,
434 h->rects[object_id]->w * 2,
h->rects[object_id]->w,
435 h->rects[object_id]->h >> 1);
437 bytestream_put_be16(&ptop_field_len, bottom_ptr - top_ptr);
438 bytestream_put_be16(&pbottom_field_len, q - bottom_ptr);
441 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
449 bytestream_put_be16(&q, page_id);
453 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
455 s->object_version = (
s->object_version + 1) & 0
xf;
460 unsigned char *
buf,
int buf_size,