diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-07-07 13:06:07 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-07-07 13:06:07 +0200 |
commit | 50b883c47561d33318e503e70a2fd88b349dbc17 (patch) | |
tree | 6640f4e92ebd5505dd13889a48a09de75e85b8e3 | |
parent | 735ff8d533278f00a5273e60d6aa4318fc794e0d (diff) |
Make streaming work again in new SpiceImage worldqxl-image
-rw-r--r-- | server/red_worker.c | 118 |
1 files changed, 46 insertions, 72 deletions
diff --git a/server/red_worker.c b/server/red_worker.c index 1a616a3..4dabff2 100644 --- a/server/red_worker.c +++ b/server/red_worker.c @@ -8012,31 +8012,28 @@ static inline void red_unref_channel(RedChannel *channel) } } -static inline uint8_t *red_get_image_line(RedWorker *worker, QXLDataChunk **chunk, int *offset, - int stride, long phys_delta, int memslot_id, - uint32_t group_id) +static inline uint8_t *red_get_image_line(RedWorker *worker, SpiceChunks *chunks, size_t *offset, + int *chunk_nr, int stride) { uint8_t *ret; - uint32_t data_size; + SpiceChunk *chunk; - validate_virt(&worker->mem_slots, (unsigned long)*chunk, memslot_id, sizeof(QXLDataChunk), - group_id); - data_size = (*chunk)->data_size; - validate_virt(&worker->mem_slots, (unsigned long)(*chunk)->data, memslot_id, data_size, group_id); + chunk = &chunks->chunk[*chunk_nr]; - if (data_size == *offset) { - if ((*chunk)->next_chunk == 0) { - return NULL; + if (*offset == chunk->len) { + if (*chunk_nr == chunks->num_chunks - 1) { + return NULL; /* Last chunk */ } *offset = 0; - *chunk = (QXLDataChunk *)((*chunk)->next_chunk + phys_delta); + (*chunk_nr)++; + chunk = &chunks->chunk[*chunk_nr]; } - if (data_size - *offset < stride) { + if (chunk->len - *offset < stride) { red_printf("bad chunk alignment"); return NULL; } - ret = (*chunk)->data + *offset; + ret = chunk->data + *offset; *offset += stride; return ret; } @@ -8049,35 +8046,32 @@ static void red_display_unshare_stream_buf(DisplayChannel *display_channel) { } -#if 0 static int red_rgb32bpp_to_24 (RedWorker *worker, const SpiceRect *src, const SpiceBitmap *image, uint8_t *frame, size_t frame_stride, - long phys_delta, int memslot_id, int id, - Stream *stream, uint32_t group_id) + int id, Stream *stream) { - QXLDataChunk *chunk; + SpiceChunks *chunks; uint32_t image_stride; uint8_t *frame_row; - int offset; - int i, x; + size_t offset; + int i, x, chunk; + chunks = image->data; offset = 0; - chunk = (QXLDataChunk *)(image->data + phys_delta); + chunk = 0; image_stride = image->stride; const int skip_lines = stream->top_down ? src->top : image->y - (src->bottom - 0); for (i = 0; i < skip_lines; i++) { - red_get_image_line(worker, &chunk, &offset, image_stride, phys_delta, memslot_id, - group_id); + red_get_image_line(worker, chunks, &offset, &chunk, image_stride); } const int image_height = src->bottom - src->top; const int image_width = src->right - src->left; for (i = 0; i < image_height; i++) { uint32_t *src_line = - (uint32_t *)red_get_image_line(worker, &chunk, &offset, image_stride, phys_delta, - memslot_id, group_id); + (uint32_t *)red_get_image_line(worker, chunks, &offset, &chunk, image_stride); if (!src_line) { return FALSE; @@ -8102,31 +8096,29 @@ static int red_rgb32bpp_to_24 (RedWorker *worker, const SpiceRect *src, static int red_rgb24bpp_to_24 (RedWorker *worker, const SpiceRect *src, const SpiceBitmap *image, uint8_t *frame, size_t frame_stride, - long phys_delta, int memslot_id, int id, - Stream *stream, uint32_t group_id) + int id, Stream *stream) { - QXLDataChunk *chunk; + SpiceChunks *chunks; uint32_t image_stride; uint8_t *frame_row; - int offset; - int i; + size_t offset; + int i, chunk; + chunks = image->data; offset = 0; - chunk = (QXLDataChunk *)(image->data + phys_delta); + chunk = 0; image_stride = image->stride; const int skip_lines = stream->top_down ? src->top : image->y - (src->bottom - 0); for (i = 0; i < skip_lines; i++) { - red_get_image_line(worker, &chunk, &offset, image_stride, phys_delta, memslot_id, - group_id); + red_get_image_line(worker, chunks, &offset, &chunk, image_stride); } const int image_height = src->bottom - src->top; const int image_width = src->right - src->left; for (i = 0; i < image_height; i++) { uint8_t *src_line = - (uint8_t *)red_get_image_line(worker, &chunk, &offset, image_stride, phys_delta, - memslot_id, group_id); + (uint8_t *)red_get_image_line(worker, chunks, &offset, &chunk, image_stride); if (!src_line) { return FALSE; @@ -8145,31 +8137,29 @@ static int red_rgb24bpp_to_24 (RedWorker *worker, const SpiceRect *src, static int red_rgb16bpp_to_24 (RedWorker *worker, const SpiceRect *src, const SpiceBitmap *image, uint8_t *frame, size_t frame_stride, - long phys_delta, int memslot_id, int id, - Stream *stream, uint32_t group_id) + int id, Stream *stream) { - QXLDataChunk *chunk; + SpiceChunks *chunks; uint32_t image_stride; uint8_t *frame_row; - int offset; - int i, x; + size_t offset; + int i, x, chunk; + chunks = image->data; offset = 0; - chunk = (QXLDataChunk *)(image->data + phys_delta); + chunk = 0; image_stride = image->stride; const int skip_lines = stream->top_down ? src->top : image->y - (src->bottom - 0); for (i = 0; i < skip_lines; i++) { - red_get_image_line(worker, &chunk, &offset, image_stride, phys_delta, memslot_id, - group_id); + red_get_image_line(worker, chunks, &offset, &chunk, image_stride); } const int image_height = src->bottom - src->top; const int image_width = src->right - src->left; for (i = 0; i < image_height; i++) { uint16_t *src_line = - (uint16_t *)red_get_image_line(worker, &chunk, &offset, image_stride, phys_delta, - memslot_id, group_id); + (uint16_t *)red_get_image_line(worker, chunks, &offset, &chunk, image_stride); if (!src_line) { return FALSE; @@ -8190,21 +8180,15 @@ static int red_rgb16bpp_to_24 (RedWorker *worker, const SpiceRect *src, return TRUE; } -#endif #define PADDING 8 /* old ffmpeg padding */ static inline int red_send_stream_data(DisplayChannel *display_channel, Drawable *drawable) { - fprintf(stderr, "%s:\n", __FUNCTION__); - abort(); - -#if 0 Stream *stream = drawable->stream; - QXLImage *qxl_image; + SpiceImage *image; RedChannel *channel; RedWorker* worker; - unsigned long data; uint8_t *frame; size_t frame_stride; int n; @@ -8214,11 +8198,9 @@ static inline int red_send_stream_data(DisplayChannel *display_channel, Drawable channel = &display_channel->base; worker = channel->worker; - qxl_image = (QXLImage *)get_virt(&worker->mem_slots, drawable->red_drawable->u.copy.src_bitmap, - sizeof(QXLImage), drawable->group_id); + image = drawable->red_drawable->u.copy.src_bitmap; - if (qxl_image->descriptor.type != SPICE_IMAGE_TYPE_BITMAP || - (qxl_image->bitmap.flags & QXL_BITMAP_DIRECT)) { + if (image->descriptor.type != SPICE_IMAGE_TYPE_BITMAP) { return FALSE; } @@ -8229,40 +8211,33 @@ static inline int red_send_stream_data(DisplayChannel *display_channel, Drawable return TRUE; } - data = qxl_image->bitmap.data; frame = mjpeg_encoder_get_frame(stream->mjpeg_encoder); frame_stride = mjpeg_encoder_get_frame_stride(stream->mjpeg_encoder); - switch (qxl_image->bitmap.format) { + switch (image->u.bitmap.format) { case SPICE_BITMAP_FMT_32BIT: if (!red_rgb32bpp_to_24(worker, &drawable->red_drawable->u.copy.src_area, - &qxl_image->bitmap, frame, frame_stride, - get_virt_delta(&worker->mem_slots, data, drawable->group_id), - get_memslot_id(&worker->mem_slots, data), - stream - worker->streams_buf, stream, drawable->group_id)) { + &image->u.bitmap, frame, frame_stride, + stream - worker->streams_buf, stream)) { return FALSE; } break; case SPICE_BITMAP_FMT_16BIT: if (!red_rgb16bpp_to_24(worker, &drawable->red_drawable->u.copy.src_area, - &qxl_image->bitmap, frame, frame_stride, - get_virt_delta(&worker->mem_slots, data, drawable->group_id), - get_memslot_id(&worker->mem_slots, data), - stream - worker->streams_buf, stream, drawable->group_id)) { + &image->u.bitmap, frame, frame_stride, + stream - worker->streams_buf, stream)) { return FALSE; } break; case SPICE_BITMAP_FMT_24BIT: if (!red_rgb24bpp_to_24(worker, &drawable->red_drawable->u.copy.src_area, - &qxl_image->bitmap, frame, frame_stride, - get_virt_delta(&worker->mem_slots, data, drawable->group_id), - get_memslot_id(&worker->mem_slots, data), - stream - worker->streams_buf, stream, drawable->group_id)) { + &image->u.bitmap, frame, frame_stride, + stream - worker->streams_buf, stream)) { return FALSE; } break; default: - red_printf_some(1000, "unsupported format %d", qxl_image->bitmap.format); + red_printf_some(1000, "unsupported format %d", image->u.bitmap.format); return FALSE; } @@ -8297,7 +8272,6 @@ static inline int red_send_stream_data(DisplayChannel *display_channel, Drawable display_begin_send_massage(display_channel, NULL); agent->lats_send_time = time_now; return TRUE; -#endif } static inline void send_qxl_drawable(DisplayChannel *display_channel, Drawable *item) |