280 uint8_t *q, *pseg_len;
281 int page_id, region_id, clut_id, object_id,
i, bpp_index, page_state, min_colors;
292 min_colors = 1 <<
s->min_bpp;
299 if (
h->num_rects && !
h->rects)
302 if (
h->num_rects >= 256)
311 bytestream_put_be16(&q, page_id);
315 bytestream_put_be16(&q, avctx->
width - 1);
316 bytestream_put_be16(&q, avctx->
height - 1);
317 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
323 if (buf_size < 8 + h->num_rects * 6)
327 bytestream_put_be16(&q, page_id);
333 *q++ = (
s->object_version << 4) | (page_state << 2) | 3;
335 for (region_id = 0; region_id <
h->num_rects; region_id++) {
338 bytestream_put_be16(&q,
h->rects[region_id]->x);
339 bytestream_put_be16(&q,
h->rects[region_id]->y);
342 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
343 buf_size -= 8 +
h->num_rects * 6;
346 for (clut_id = 0; clut_id <
h->num_rects; clut_id++) {
348 int nb_colors =
FFMAX(min_colors,
h->rects[clut_id]->nb_colors);
350 if (nb_colors <= 4U) {
353 }
else if (nb_colors <= 16U) {
356 }
else if (nb_colors <= 256U) {
363 if (buf_size < 6 + h->rects[clut_id]->nb_colors * 6)
369 bytestream_put_be16(&q, page_id);
373 *q++ = (0 << 4) | 0xf;
375 for(
i = 0;
i <
h->rects[clut_id]->nb_colors;
i++) {
377 *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1;
380 uint32_t x= ((uint32_t*)
h->rects[clut_id]->data[1])[
i];
381 a = (x >> 24) & 0xff;
382 r = (x >> 16) & 0xff;
393 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
394 buf_size -= 6 +
h->rects[clut_id]->nb_colors * 6;
397 if (buf_size < h->num_rects * 22)
399 for (region_id = 0; region_id <
h->num_rects; region_id++) {
402 int nb_colors =
FFMAX(min_colors,
h->rects[region_id]->nb_colors);
404 if (nb_colors <= 4) {
407 }
else if (nb_colors <= 16) {
410 }
else if (nb_colors <= 256) {
419 bytestream_put_be16(&q, page_id);
423 *q++ = (
s->object_version << 4) | (0 << 3) | 0x07;
424 bytestream_put_be16(&q,
h->rects[region_id]->w);
425 bytestream_put_be16(&q,
h->rects[region_id]->h);
426 *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03;
431 bytestream_put_be16(&q, region_id);
432 *q++ = (0 << 6) | (0 << 4);
437 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
439 buf_size -=
h->num_rects * 22;
441 for (object_id = 0; object_id <
h->num_rects; object_id++) {
442 int (*dvb_encode_rle)(uint8_t **pq,
int buf_size,
443 const uint8_t *bitmap,
int linesize,
446 int nb_colors =
FFMAX(min_colors,
h->rects[object_id]->nb_colors);
452 if (nb_colors <= 4) {
455 }
else if (nb_colors <= 16) {
458 }
else if (nb_colors <= 256) {
468 bytestream_put_be16(&q, page_id);
472 bytestream_put_be16(&q, object_id);
473 *q++ = (
s->object_version << 4) | (0 << 2) | (0 << 1) | 1;
477 uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr;
482 pbottom_field_len = q;
487 ret = dvb_encode_rle(&q, buf_size,
488 h->rects[object_id]->data[0],
489 h->rects[object_id]->w * 2,
490 h->rects[object_id]->w,
491 h->rects[object_id]->h >> 1);
496 ret = dvb_encode_rle(&q, buf_size,
497 h->rects[object_id]->data[0] +
h->rects[object_id]->w,
498 h->rects[object_id]->w * 2,
499 h->rects[object_id]->w,
500 h->rects[object_id]->h >> 1);
505 bytestream_put_be16(&ptop_field_len, bottom_ptr - top_ptr);
506 bytestream_put_be16(&pbottom_field_len, q - bottom_ptr);
509 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
519 bytestream_put_be16(&q, page_id);
523 bytestream_put_be16(&pseg_len, q - pseg_len - 2);
526 s->object_version = (
s->object_version + 1) & 0xf;
main external API structure.