Ejemplo n.º 1
0
int BC_Bitmap::allocate_data()
{
	int count = 1;
	max_buffer_count = MAX_BITMAP_BUFFERS;
	if(use_shm) { // Use shared memory.
		int bsz = best_buffer_size();
		if( bsz >= 0x800000 ) max_buffer_count = 2;
		else if( bsz >= 0x400000 ) max_buffer_count /= 8;
		else if( bsz >= 0x100000 ) max_buffer_count /= 4;
		else if( bsz >= 0x10000 ) max_buffer_count /= 2;
		type = hardware_scaling() ? bmXvShmImage : bmXShmImage;
		count = MIN_BITMAP_BUFFERS;
	}
	else // use unshared memory.
		type = hardware_scaling() ? bmXvImage : bmXImage;
	update_buffers(count);
	return 0;
}
Ejemplo n.º 2
0
int BC_Bitmap::read_frame(VFrame *frame, 
	int in_x, int in_y, int in_w, int in_h,
	int out_x, int out_y, int out_w, int out_h)
{
	BC_BitmapImage *bfr = cur_bfr();
	if( hardware_scaling() && frame->get_color_model() == color_model ) {
// Hardware accelerated bitmap
		switch(color_model) {
		case BC_YUV420P:
			memcpy(bfr->get_y_data(), frame->get_y(), w * h);
			memcpy(bfr->get_u_data(), frame->get_u(), w * h / 4);
			memcpy(bfr->get_v_data(), frame->get_v(), w * h / 4);
			break;
		case BC_YUV422P:
			memcpy(bfr->get_y_data(), frame->get_y(), w * h);
			memcpy(bfr->get_u_data(), frame->get_u(), w * h / 2);
			memcpy(bfr->get_v_data(), frame->get_v(), w * h / 2);
			break;
		default:
		case BC_YUV422:
			memcpy(get_data(), frame->get_data(), w * h + w * h);
			break;
		}
	}
	else {
// Software only

//printf("BC_Bitmap::read_frame %d -> %d %d %d %d %d -> %d %d %d %d\n",
//  frame->get_color_model(), color_model,
//  in_x, in_y, in_w, in_h, out_x, out_y, out_w, out_h);
//if(color_model == 6 && frame->get_color_model() == 19)
//printf("BC_Bitmap::read_frame 1 %d %d %d %d\n", frame->get_w(), frame->get_h(), get_w(), get_h());
		BC_CModels::transfer(
			bfr->get_row_data(), frame->get_rows(),
			bfr->get_y_data(), bfr->get_u_data(), bfr->get_v_data(),
			frame->get_y(), frame->get_u(), frame->get_v(),
			in_x, in_y, in_w, in_h,
			out_x, out_y, out_w, out_h,
			frame->get_color_model(), color_model,
			bg_color, frame->get_w(), w);

		if( color_model == BC_TRANSPARENCY && !top_level->server_byte_order )
			transparency_bitswap(frame->get_data(), w, h);
//if(color_model == 6 && frame->get_color_model() == 19)
//printf("BC_Bitmap::read_frame 2\n");
	}

	return 0;
}
Ejemplo n.º 3
0
int BC_Bitmap::write_drawable(Drawable &pixmap,
                              GC &gc,
                              int source_x,
                              int source_y,
                              int source_w,
                              int source_h,
                              int dest_x,
                              int dest_y,
                              int dest_w,
                              int dest_h,
                              int dont_wait)
{
//printf("BC_Bitmap::write_drawable 1 %p %d\n", this, current_ringbuffer);fflush(stdout);
    if(use_shm)
    {
        if(dont_wait) XSync(top_level->display, False);

        if(hardware_scaling())
        {
// printf("BC_Bitmap::write_drawable %d %d %d %d -> %d %d %d %d\n", source_x,
// 				source_y,
// 				source_w,
// 				source_h,
// 				dest_x,
// 				dest_y,
// 				dest_w,
// 				dest_h);
//for(int i = 0; i < 1000; i++) xv_image[current_ringbuffer]->data[i] = 255;
//printf("BC_Bitmap::write_drawable 2 %d %d %p %p\n", xv_portid,
//	pixmap,
//	gc,
//	xv_image[current_ringbuffer]);
            XvShmPutImage(top_level->display,
                          xv_portid,
                          pixmap,
                          gc,
                          xv_image[current_ringbuffer],
                          source_x,
                          source_y,
                          source_w,
                          source_h,
                          dest_x,
                          dest_y,
                          dest_w,
                          dest_h,
                          False);
// Need to pass these to the XvStopVideo
            last_pixmap = pixmap;
            last_pixmap_used = 1;
        }
        else
        {
// printf("BC_Bitmap::write_drawable %d %d %d %d -> %d %d %d %d\n", source_x,
// 				source_y,
// 				source_w,
// 				source_h,
// 				dest_x,
// 				dest_y,
// 				dest_w,
// 				dest_h);
            XShmPutImage(top_level->display,
                         pixmap,
                         gc,
                         ximage[current_ringbuffer],
                         source_x,
                         source_y,
                         dest_x,
                         dest_y,
                         dest_w,
                         dest_h,
                         False);
        }

// Force the X server into processing all requests.
// This allows the shared memory to be written to again.
        if(!dont_wait) XSync(top_level->display, False);
//TRACE("BC_Bitmap::write_drawable 5");
    }
    else
    {
        XPutImage(top_level->display,
                  pixmap,
                  gc,
                  ximage[current_ringbuffer],
                  source_x,
                  source_y,
                  dest_x,
                  dest_y,
                  dest_w,
                  dest_h);
    }

//printf("BC_Bitmap %d\n", current_ringbuffer);
    current_ringbuffer++;
    if(current_ringbuffer >= ring_buffers) current_ringbuffer = 0;
//printf("BC_Bitmap::write_drawable 2\n");fflush(stdout);
    return 0;
}