another try to feet scaled subs to user-defined screen edges

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@218 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Branch: ni/coolstream
Commit: 1a8ea714b9
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2010-01-29 (Fri, 29 Jan 2010)



------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2010-01-29 13:57:54 +00:00
parent 522f0e8773
commit b41ed62ef5

View File

@@ -72,30 +72,30 @@ cDvbSubtitleBitmaps::~cDvbSubtitleBitmaps()
memset(&sub, 0, sizeof(AVSubtitle)); memset(&sub, 0, sizeof(AVSubtitle));
} }
fb_pixel_t * simple_resize32(fb_pixel_t * orgin, int ox, int oy, int dx, int dy) fb_pixel_t * simple_resize32(uint8_t * orgin, uint32_t * colors, int nb_colors, int ox, int oy, int dx, int dy)
{ {
fb_pixel_t *cr,*p,*l; fb_pixel_t *cr,*l;
int i,j,k,ip; int i,j,k,ip;
cr = (fb_pixel_t *) malloc(dx*dy*sizeof(fb_pixel_t)); cr = (fb_pixel_t *) malloc(dx*dy*sizeof(fb_pixel_t));
if(cr == NULL) { if(cr == NULL) {
printf("Error: malloc\n"); printf("Error: malloc\n");
return(orgin); return NULL;
} }
l = cr; l = cr;
for(j = 0; j < dy; j++, l += dx) for(j = 0; j < dy; j++, l += dx)
{ {
p = orgin + (j*oy/dy*ox); uint8_t * p = orgin + (j*oy/dy*ox);
for(i = 0, k = 0; i < dx; i++, k++) {
for(i = 0, k = 0; i < dx; i++, k++) { ip = i*ox/dx;
ip = i*ox/dx; int idx = p[ip];
l[k] = p[ip]; if(idx < nb_colors)
} l[k] = colors[idx];
} }
free(orgin); }
return(cr); return(cr);
} }
void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y) void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y)
@@ -110,55 +110,39 @@ void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y)
dbgconverter("cDvbSubtitleBitmaps::Draw: %d bitmaps, x= %d, width= %d yend=%d stride %d\n", Count(), xstart, wd, yend, stride); dbgconverter("cDvbSubtitleBitmaps::Draw: %d bitmaps, x= %d, width= %d yend=%d stride %d\n", Count(), xstart, wd, yend, stride);
for (i = 0; i < Count(); i++) { double xc = (double) CFrameBuffer::getInstance()->getScreenWidth(true)/(double) 720;
/* center on screen */ double yc = (double) CFrameBuffer::getInstance()->getScreenHeight(true)/(double) 576;
/* int xoff = xstart + (wd - sub.rects[i]->w) / 2;*/ xc = yc; //FIXME should we scale also to full width ?
int xdiff = (wd > 720) ? ((wd - 720) / 2) : 0; int xf = xc * (double) 720;
int xoff = sub.rects[i]->x + xstart + xdiff;
for (i = 0; i < Count(); i++) {
uint32_t * colors = (uint32_t *) sub.rects[i]->pict.data[1]; uint32_t * colors = (uint32_t *) sub.rects[i]->pict.data[1];
int width = sub.rects[i]->w; int width = sub.rects[i]->w;
int height = sub.rects[i]->h; int height = sub.rects[i]->h;
int xoff, yoff;
int ys = yend - (576 - sub.rects[i]->y + height);
double xc = (double) CFrameBuffer::getInstance()->getScreenWidth(true)/(double) 720;
double yc = (double) CFrameBuffer::getInstance()->getScreenHeight(true)/(double) 576;
int nw = (double) width * xc; int nw = (double) width * xc;
int nh = (double) height * yc; int nh = (double) height * yc;
xoff = (double) xoff / (xc > 0 ? xc : 1); int xdiff = (wd > xf) ? ((wd - xf) / 2) : 0;
ys = (double) ys*yc - nh; xoff = sub.rects[i]->x*xc + xstart + xdiff;
if(ys < 0)
ys = ystart;
dbgconverter("cDvbSubtitleBitmaps::Draw: #%d at %d,%d size %dx%d colors %d (x=%d y=%d w=%d h=%d) \n", i+1, if(sub.rects[i]->y < 576/2) {
sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h, sub.rects[i]->nb_colors, xoff, ys, nw, nh); yoff = ystart + sub.rects[i]->y*yc;
} else {
yoff = yend - (576 - (double) (sub.rects[i]->y + height))*yc - nh;
int yoff = ys * stride; if(yoff < ystart)
yoff = ystart;
fb_pixel_t * data = (fb_pixel_t*) malloc(width*height*sizeof(fb_pixel_t));
fb_pixel_t * ptr = data;
for (int y2 = 0; y2 < sub.rects[i]->h; y2++) {
for (int x2 = 0; x2 < sub.rects[i]->w; x2++)
{
int idx = sub.rects[i]->pict.data[0][y2*sub.rects[i]->w+x2];
if(idx > sub.rects[i]->nb_colors) {
dbgconverter("cDvbSubtitleBitmaps::Draw pixel at %d x %d is %d!\n", x2, y2, idx);
} else {
*ptr++ = colors[idx];
}
}
} }
fb_pixel_t * newdata = simple_resize32 (data, width, height, nw, nh); 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);
ptr = newdata; 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++) { for (int y2 = 0; y2 < nh; y2++) {
int y = y2*stride + yoff; int y = (yoff + y2) * stride;
for (int x2 = 0; x2 < nw; x2++) for (int x2 = 0; x2 < nw; x2++)
*(sublfb + xoff + x2 + y) = *ptr++; *(sublfb + xoff + x2 + y) = *ptr++;
} }
@@ -166,12 +150,12 @@ void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y)
if(min_x > xoff) if(min_x > xoff)
min_x = xoff; min_x = xoff;
if(min_y > ys) if(min_y > yoff)
min_y = ys; min_y = yoff;
if(max_x < (xoff + nw)) if(max_x < (xoff + nw))
max_x = xoff + nw; max_x = xoff + nw;
if(max_y < (ys + nh)) if(max_y < (yoff + nh))
max_y = ys + nh; max_y = yoff + nh;
} }
if(Count()) 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("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);