Example #1
0
void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y)
{
	int i;
	
	int stride = CFrameBuffer::getInstance()->getScreenWidth(true);
	int wd = CFrameBuffer::getInstance()->getScreenWidth();
	int xstart = CFrameBuffer::getInstance()->getScreenX();
	int yend = CFrameBuffer::getInstance()->getScreenY() + CFrameBuffer::getInstance()->getScreenHeight();
	//int ystart = CFrameBuffer::getInstance()->getScreenY();
	//uint32_t *sublfb = CFrameBuffer::getInstance()->getFrameBufferPointer();

	dbgconverter("cDvbSubtitleBitmaps::Draw: %d bitmaps, x= %d, width= %d yend=%d stride %d\n", Count(), xstart, wd, yend, stride);

	int sw = CFrameBuffer::getInstance()->getScreenWidth(true);
	int sh = CFrameBuffer::getInstance()->getScreenHeight(true);

	for (i = 0; i < Count(); i++) 
	{
		//NOTE remove me
		//printf("color:%d width:%d height:%d at x:%d y:%d\n", sub.rects[i]->nb_colors, sub.rects[i]->w, sub.rects[i]->h, sub.rects[i]->x, sub.rects[i]->y);
		
		uint32_t * colors = (uint32_t *) sub.rects[i]->pict.data[1];
		int width = sub.rects[i]->w;
		int height = sub.rects[i]->h;

		int h2 = (width == 1280) ? 720 : 576;
		
		int xoff = sub.rects[i]->x * sw / width;
		int yoff = sub.rects[i]->y * sh / h2;
		int nw = width * sw / width;
		int nh = height * sh / h2;

		dbgconverter("cDvbSubtitleBitmaps::Draw: #%d at %d,%d size %dx%d colors %d (x=%d y=%d w=%d h=%d) \n", i+1, sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h, sub.rects[i]->nb_colors, xoff, yoff, nw, nh);

		// resize color to 32 bit
		fb_pixel_t * newdata = simple_resize32(sub.rects[i]->pict.data[0], colors, sub.rects[i]->nb_colors, width, height, nw, nh);
		
		// blit2fb
		CFrameBuffer::getInstance()->blit2FB(newdata, nw, nh, xoff, yoff, 0, 0, true);

		free(newdata);

		// recalculate min_x min_y max_x max_y
		if(min_x > xoff)
			min_x = xoff;

		if(min_y > yoff)
			min_y = yoff;

		if(max_x < (xoff + nw))
			max_x = xoff + nw;

		if(max_y < (yoff + nh))
			max_y = yoff + nh;
	}

	if(Count())
		dbgconverter("cDvbSubtitleBitmaps::Draw: finish, min/max screen: x=% d y= %d, w= %d, h= %d\n", min_x, min_y, max_x-min_x, max_y-min_y);
	dbgconverter("\n");
}
void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y)
{
	int i;
	int stride = CFrameBuffer::getInstance()->getScreenWidth(true);
	int wd = CFrameBuffer::getInstance()->getScreenWidth();
	int xstart = CFrameBuffer::getInstance()->getScreenX();
	int yend = CFrameBuffer::getInstance()->getScreenY() + CFrameBuffer::getInstance()->getScreenHeight();
	int ystart = CFrameBuffer::getInstance()->getScreenY();
	uint32_t *sublfb = CFrameBuffer::getInstance()->getFrameBufferPointer();

	dbgconverter("cDvbSubtitleBitmaps::Draw: %d bitmaps, x= %d, width= %d yend=%d stride %d\n", Count(), xstart, wd, yend, stride);

	double xc = (double) CFrameBuffer::getInstance()->getScreenWidth(true)/(double) 720;
	double yc = (double) CFrameBuffer::getInstance()->getScreenHeight(true)/(double) 576;
	xc = yc; //FIXME should we scale also to full width ?
	int xf = xc * (double) 720;

	for (i = 0; i < Count(); i++) {
		uint32_t * colors = (uint32_t *) sub.rects[i]->pict.data[1];
		int width = sub.rects[i]->w;
		int height = sub.rects[i]->h;
		int xoff, yoff;

		int nw = (double) width * xc;
		int nh = (double) height * yc;

		int xdiff = (wd > xf) ? ((wd - xf) / 2) : 0;
		xoff = sub.rects[i]->x*xc + xstart + xdiff;

		if(sub.rects[i]->y < 576/2) {
			yoff = ystart + sub.rects[i]->y*yc;
		} else {
			yoff = yend - (576 - (double) (sub.rects[i]->y + height))*yc - nh;
			if(yoff < ystart)
				yoff = ystart;
		}

		dbgconverter("cDvbSubtitleBitmaps::Draw: #%d at %d,%d size %dx%d colors %d (x=%d y=%d w=%d h=%d) \n", i+1, 
				sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h, sub.rects[i]->nb_colors, xoff, yoff, nw, nh);

		fb_pixel_t * newdata = simple_resize32 (sub.rects[i]->pict.data[0], colors, sub.rects[i]->nb_colors, width, height, nw, nh);

		fb_pixel_t * ptr = newdata;
		for (int y2 = 0; y2 < nh; y2++) {
			int y = (yoff + y2) * stride;
			for (int x2 = 0; x2 < nw; x2++)
				*(sublfb + xoff + x2 + y) = *ptr++;
		}
		free(newdata);

		if(min_x > xoff)
			min_x = xoff;
		if(min_y > yoff)
			min_y = yoff;
		if(max_x < (xoff + nw))
			max_x = xoff + nw;
		if(max_y < (yoff + nh))
			max_y = yoff + nh;
	}
	if(Count())
		dbgconverter("cDvbSubtitleBitmaps::Draw: finish, min/max screen: x=% d y= %d, w= %d, h= %d\n", min_x, min_y, max_x-min_x, max_y-min_y);
	dbgconverter("\n");
}
void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y)
{
#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
#define DEFAULT_XRES 1280	// backbuffer width
#define DEFAULT_YRES 720	// backbuffer height

	if (!Count())
		return;

	dbgconverter("cDvbSubtitleBitmaps::%s: start\n", __func__);

	CFrameBuffer* fb = CFrameBuffer::getInstance();
	fb_pixel_t *b = fb->getBackBufferPointer();

	// HACK. When having just switched channels we may not yet have yet
	// received valid authoring data. This check triggers for the most
	// common HD subtitle format and sets our authoring display format
	// accordingly. Plus, me may not get the authoring data at all, e.g. for
	// blu-ray playback.
	if (max_x == 720 && max_y == 576)
		switch (sub.rects[0]->w) {
		case 1280:
			min_x = min_y = 0, max_x = 1280, max_y = 720;
			break;
		case 1920:
			min_x = min_y = 0, max_x = 1920, max_y = 1080;
			break;
		}

	for (int i = 0; i < Count(); i++) {
		uint32_t * colors = (uint32_t *) sub.rects[i]->pict.data[1];
		int width = sub.rects[i]->w;
		int height = sub.rects[i]->h;
		uint8_t *origin = sub.rects[i]->pict.data[0];
		int nb_colors = sub.rects[i]->nb_colors;

		size_t bs = width * height;
		for (unsigned int j = 0; j < bs; j++)
			if (origin[j] < nb_colors)
				b[j] = colors[origin[j]];

		int width_new = (width * DEFAULT_XRES) / max_x;
		int height_new = (height * DEFAULT_YRES) / max_y;
		int x_new = (sub.rects[i]->x * DEFAULT_XRES) / max_x;
		int y_new = (sub.rects[i]->y * DEFAULT_YRES) / max_y;

		dbgconverter("cDvbSubtitleBitmaps::Draw: original bitmap=%d x=%d y=%d, w=%d, h=%d col=%d\n",
			i, sub.rects[i]->x, sub.rects[i]->y, width, height, sub.rects[i]->nb_colors);
		dbgconverter("cDvbSubtitleBitmaps::Draw: scaled bitmap=%d x_new=%d y_new=%d, w_new=%d, h_new=%d\n",
			i, x_new, y_new, width_new, height_new);
		fb->blitArea(width, height, x_new, y_new, width_new, height_new);
	}
	if (Count())
		fb->blit();

	dbgconverter("cDvbSubtitleBitmaps::%s: done\n", __func__);
#else
	int i;
	int stride = CFrameBuffer::getInstance()->getScreenWidth(true);
	int wd = CFrameBuffer::getInstance()->getScreenWidth();
	int xstart = CFrameBuffer::getInstance()->getScreenX();
	int yend = CFrameBuffer::getInstance()->getScreenY() + CFrameBuffer::getInstance()->getScreenHeight();
	int ystart = CFrameBuffer::getInstance()->getScreenY();
	uint32_t *sublfb = CFrameBuffer::getInstance()->getFrameBufferPointer();

	dbgconverter("cDvbSubtitleBitmaps::Draw: %d bitmaps, x= %d, width= %d yend=%d stride %d\n", Count(), xstart, wd, yend, stride);

	double xc = (double) CFrameBuffer::getInstance()->getScreenWidth(true)/(double) 720;
	double yc = (double) CFrameBuffer::getInstance()->getScreenHeight(true)/(double) 576;
	xc = yc; //FIXME should we scale also to full width ?
	int xf = int(xc * (double) 720);

	for (i = 0; i < Count(); i++) {
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 5, 0)
		uint32_t * colors = (uint32_t *) sub.rects[i]->pict.data[1];
#else
		uint32_t * colors = (uint32_t *) sub.rects[i]->data[1];
#endif
		int width = sub.rects[i]->w;
		int height = sub.rects[i]->h;
		int xoff, yoff;

		int nw = int(width == 1280 ? ((double) width / xc) : ((double) width * xc));
		int nh = int((double) height * yc);

		int xdiff = (wd > xf) ? ((wd - xf) / 2) : 0;
		xoff = int(sub.rects[i]->x*xc + xstart + xdiff);
		if(sub.rects[i]->y < 576/2) {
			yoff = int(ystart + sub.rects[i]->y*yc);
		} else {
			yoff = int(yend - ((width == 1280 ? 704:576) - (double) (sub.rects[i]->y + height))*yc - nh);
			if(yoff < ystart)
				yoff = ystart;
		}

		dbgconverter("cDvbSubtitleBitmaps::Draw: #%d at %d,%d size %dx%d colors %d (x=%d y=%d w=%d h=%d) \n", i+1, 
				sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h, sub.rects[i]->nb_colors, xoff, yoff, nw, nh);
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 5, 0)
		fb_pixel_t * newdata = simple_resize32 (sub.rects[i]->pict.data[0], colors, sub.rects[i]->nb_colors, width, height, nw, nh);
#else
		fb_pixel_t * newdata = simple_resize32 (sub.rects[i]->data[0], colors, sub.rects[i]->nb_colors, width, height, nw, nh);
#endif
		fb_pixel_t * ptr = newdata;
		for (int y2 = 0; y2 < nh; y2++) {
			int y = (yoff + y2) * stride;
			for (int x2 = 0; x2 < nw; x2++)
				*(sublfb + xoff + x2 + y) = *ptr++;
		}
		free(newdata);

		if(min_x > xoff)
			min_x = xoff;
		if(min_y > yoff)
			min_y = yoff;
		if(max_x < (xoff + nw))
			max_x = xoff + nw;
		if(max_y < (yoff + nh))
			max_y = yoff + nh;
	}
	if(Count())
		dbgconverter("cDvbSubtitleBitmaps::Draw: finish, min/max screen: x=% d y= %d, w= %d, h= %d\n", min_x, min_y, max_x-min_x, max_y-min_y);
	dbgconverter("\n");
#endif
}
Example #4
0
void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y)
{
	int i;
#if !HAVE_SPARK_HARDWARE && !HAVE_DUCKBOX_HARDWARE
	int stride = CFrameBuffer::getInstance()->getScreenWidth(true);
#if 0
	int wd = CFrameBuffer::getInstance()->getScreenWidth();
	int xstart = CFrameBuffer::getInstance()->getScreenX();
	int yend = CFrameBuffer::getInstance()->getScreenY() + CFrameBuffer::getInstance()->getScreenHeight();
	int ystart = CFrameBuffer::getInstance()->getScreenY();
#endif
	uint32_t *sublfb = CFrameBuffer::getInstance()->getFrameBufferPointer();
#endif

//	dbgconverter("cDvbSubtitleBitmaps::Draw: %d bitmaps, x= %d, width= %d yend=%d stride %d\n", Count(), xstart, wd, yend, stride);

	int sw = CFrameBuffer::getInstance()->getScreenWidth(true);
	int sh = CFrameBuffer::getInstance()->getScreenHeight(true);
#if 0
	double xc = (double) CFrameBuffer::getInstance()->getScreenWidth(true)/(double) 720;
	double yc = (double) CFrameBuffer::getInstance()->getScreenHeight(true)/(double) 576;
	xc = yc; //FIXME should we scale also to full width ?
	int xf = xc * (double) 720;
#endif

	for (i = 0; i < Count(); i++) {
		uint32_t * colors = (uint32_t *) sub.rects[i]->pict.data[1];
		int width = sub.rects[i]->w;
		int height = sub.rects[i]->h;
		int xoff, yoff;

#if 0
		int nw = width == 1280 ? ((double) width / xc) : ((double) width * xc);
		int nh = (double) height * yc;

		int xdiff = (wd > xf) ? ((wd - xf) / 2) : 0;
		xoff = sub.rects[i]->x*xc + xstart + xdiff;
		if(sub.rects[i]->y < 576/2) {
			yoff = ystart + sub.rects[i]->y*yc;
		} else {
			yoff = yend - ((width == 1280 ? 704:576) - (double) (sub.rects[i]->y + height))*yc - nh;
			if(yoff < ystart)
				yoff = ystart;
		}
#endif
		int h2 = (width == 1280) ? 720 : 576;
		xoff = sub.rects[i]->x * sw / width;
		yoff = sub.rects[i]->y * sh / h2;
		int nw = width * sw / width;
		int nh = height * sh / h2;

//		dbgconverter("cDvbSubtitleBitmaps::Draw: #%d at %d,%d size %dx%d colors %d (x=%d y=%d w=%d h=%d) \n", i+1, 
//				sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h, sub.rects[i]->nb_colors, xoff, yoff, nw, nh);

		fb_pixel_t * newdata = simple_resize32 (sub.rects[i]->pict.data[0], colors, sub.rects[i]->nb_colors, width, height, nw, nh);

#if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE
		CFrameBuffer::getInstance()->blit2FB(newdata, nw, nh, xoff, yoff, 0, 0);
#else
		fb_pixel_t * ptr = newdata;
		for (int y2 = 0; y2 < nh; y2++) {
			int y = (yoff + y2) * stride;
			for (int x2 = 0; x2 < nw; x2++)
				*(sublfb + xoff + x2 + y) = *ptr++;
		}
		free(newdata);
#endif

		if(min_x > xoff)
			min_x = xoff;
		if(min_y > yoff)
			min_y = yoff;
		if(max_x < (xoff + nw))
			max_x = xoff + nw;
		if(max_y < (yoff + nh))
			max_y = yoff + nh;
	}

	if (Count())	/* sync framebuffer */
		CFrameBuffer::getInstance()->blit();

//	if(Count())
//		dbgconverter("cDvbSubtitleBitmaps::Draw: finish, min/max screen: x=% d y= %d, w= %d, h= %d\n", min_x, min_y, max_x-min_x, max_y-min_y);
//	dbgconverter("\n");
}